I've two pc using VRRP for redundancy. So every PC (Linux) has a physical and a Virtual IP address.
I've a software (C++) with a client/server architecture with UDP protocol. The software bind the listen socket on "0.0.0.0" and use a new socket every time it needs to send some data to the other party. With wireshark I saw that when it sends data the source IP is the phisycal one... How can I set the source address of the sending socket to the Virtual one??
NOTE: Whit ifconfig I see only eth0 with the physical address...
It's true that neither UDP or TCP headers include a source address, but that's because they don't have to: source address is already included in the header of the encapsulating transport protocol, which in this case would be the IP header.
UDP Broadcast is an automatic method that can be used without manually entering the IP address of all Audia/Nexia devices. TCP can be used only if the exact IP addresses are known and can be entered manually.
Datagram (UDP) sockets. The CONNECT command enables an application to associate a socket with the socket name of a peer. The socket then is considered to be a connected UDP socket. You can call the CONNECT command multiple times with different peer names to change the socket association.
TCP vs UDP Once connected, a TCP socket can only send and receive to/from the remote machine. This means that you'll need one TCP socket for each client in your application. UDP is not connection-based, you can send and receive to/from anyone at any time with the same socket.
When the kernel needs to send something through a socket it performs these steps
So you need to bind(2)
your socket to your desired address. For more information: "Source Address Selection" in chapter "IP Routing" of "Guide to IP Layer Network Administration with Linux".
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With