If app A listens to the same private port previously used by app B, will app A get app B's public port number? - udp

If one application listens to the same private port number previously used by another application on that computer, will the more recent app get the same public port number as the less recent app?
Application A and Application B both use non-multicast UDP. They both run on a computer that is behind a residential router that does not have port forwarding set up. If application A listens to the same private port number (behind NAT) that application B just finished listening to, will application A receive the same public port number that application B had when application B was using that port? Will application A get all the UDP packets meant for application B?
Another closely related question:
Imagine that computer A and computer B share a residential router. Computer A and computer B both run an application that sends a UDP packet/datagram to server C at public IP 123.456.789 and public port number 12345. Server C responds by sending a packet/datagram back to the senders. The application that computer A and computer B used, in addition to specifying that it wanted to send on port 12345, also listens on port 12345 for the reply. Computer A and computer B get the reply packet, but the public port number that the server, C, was sending its reply to might not match the number 12345 specified by the application that computer A and computer B are running (correct me if I am mistaken, please).
Now, for some reason, server C decides that it wants to kill the application that was sending and receiving udp packets to computers A and B and open up a completely different application that will send udp packets to the public IP's and public port numbers that the previous application used to communicate with computers A and B. Will the packets generated by this new server side application go through to computers A and B? Or will the death of the old application and the pause between killing the old application and running the new one cause the packets sent by the new server side application to be blocked or rejected by the clients? Will the packets make it through the router/NAT?
What if it was the other way around and computer B killed the application that it used to communicate with server C and then opened up a new, different application that internally also listens to udp port 12345. If server C sends another UDP response packet to computer B after computer B kills its old application, will this new, different application get the packets sent by server C that were meant to be a reply to the packets sent by the previous application run by computer B?
Does the answer differ depending on the type of NAT and the amount of time between one application finishing using the port and another application starting to use the same port that the other application used previously? If so, how?

The public port number belongs to the router, not to App A or App B, and, if it is mapped to a private port number, that mapping also persists beyond any specific application's lifetime.

Related

How To Use Serial Port Monitor

Hi I created a program let's say using ABAP and I want to monitor the data sent to my serial port (COM port)
Now there are a lot of software out there that can help me monitor this transaction.
But the problem is that the software only built to monitor data send from outside the computer.
For example some device sending data through com port to your pc.
BUT when you send the data from your PC to serial port it will raise an error on PORT is already open.
The way the port monitor software works is first opening the port and the read the data send to the serial port.
The problem happens when my own custom program try to send data to serial port, where I also need to open the port first.
So in order for my program to work then I have to shutdown the serial monitor software (this way I cannot use the monitor program).
But If I turn on the monitor software, then it will open a port that will make my program to become error and cannot open a port (I cannot send any data to serial port).
If I send data using my program without opening a port then it will send nothing.
You need to use com port emulator software. Generally these programs create virtual comport for listening. You application must connect to this virtual port.
Some of these emulator programs can connect virtual port to the real port. So you can get inbound and outbound data.

VB.NET Server Does Not Receive Connection Requests from Remote Clients

VB.NET Server Does Not Receive Connection Requests from Remote Clients
A VB.NET server application does not see connection requests from another client on the network (i.e. with a different IP address). However, it does see connection requests from the client application running on the same computer as the server.
The listening socket is created with the following parameters
System.Net.Sockets.AddressFamily.InterNetwork
System.Net.Sockets.SocketType.Stream
System.Net.Sockets.ProtocolType.IP
We have experimented with the preceding without success.
The endpoint to which the listening socket is bound specifies the local IP address and a specific port number.
The wait-for-connection code is textbook asynchronous:
thelistener.Listen(10)
thelistener.BeginAccept(New System.AsyncCallback(AddressOf targetofaccept), thelistener)
If the client that attempts connection is on the same computer as the listener, then targetofaccept is run successfully. If the client that attempts connection is on some other computer on the network, then targetofaccept is not run.
The behavior occurs for any other client on the network (i.e., not just one).
Thinking that there was some firewall issue, we created VB6 servers and clients using the same addresses and ports. The VB6 server will receive connection requests regardless of the client system.
There is no other issue with communication between clients and the server, as far as we can see. The network architecture has not been modified for a number of years.
We are debugging the code as a VB.NET console application.
Any tips on how to diagnose appreciated.
Before calling Listen() you need to bind your listener socket to the address 0.0.0.0 (in .NET IPAddress.Any) so that it listens to connections from any IP address.
This can be done using the Socket.Bind() method:
Dim listenerEndpoint As New IPEndPoint(IPAddress.Any, <your port>)
thelistener.Bind(listenerEndpoint)
thelistener.Listen(10)
Thank you.
Issue WAS firewall. Fixed by finding exact location of the IDE (devenv.exe), opening "Windows Firewall" in the control panel, selecting "Allow a program or feature through firewall", selecting "Allow another program...", browsing to the exact location and selecting the executable, then ensuring "Home/Work (Private)" column is checked for that "Name".

No SIP packets from virtual client machine

Implementing a SIP call using asterisk server, but every time I have one client call another (virtual machines), Wireshark doesn't show any SIP packet requests even though the call is being placed?
1) check firewalls on both machine, try turn firewall off
2) check sip nat settings or assign public ips to hosts.
3) check network availible inside your virtulization environment(each host can ping other one).

Copy UDP packets to another destination

I have application A sending UDP packets to application B on port 10002.
They both run on the same PC and communicate through the local IP 127.0.01
What I need is a way to copy UDP packets and send them also to application C (also running locally) ; so that UDP packets go to both applications B and C.
Applications A is ready made application, I do not have its source code otherwise I would update it to send UDP packets to multiple destinations.
Operating system is Windows 8
I searched a lot and could not find a software to do that.
Should I write my own code for this ? To snif for the UDP packets I am interested in, take copy and send them to application C.
Thanks

Visual Basic Server

I want to create a Console Application in VB that broadcasts to all IPs on Local Area Network his own Ip.
So a Timer that broadcasts the IP of the server every second. Every client that connects, receives the IP of the Server.
Then, a client logs in to the Application and sends 2 strings to the Servers IP:
Username
Password
The server checks the validity of the 2 strings, and either allows or restricts access to the Server.
How should I proceed?
I have found TcpClient and TcpListener, but I am unable to broadcast an IP to 255.255.255.255...
Mainly, what I want to achieve, is broadcast (255.255.255.255) my Local Ip (192.168.1.1), so I would broadcast the String "192.168.1.1"
You should take a look at the UDP classes instead of the TCP classes. UDP will allow you to broadcast small messages on your LAN. One the IP address is received, then you can use TCP to connect to the server.