I'm currently writing a program to exchange packet between two machines via multiple connection between them. The main scenario is I have two machines: Mobile Host (MH) and Home Agent machine (HA). The MH has several interfaces so it can simultaneously connect to the HA via multiple links. Each application on MH initiates a TCP connection to HA so we have a address/port pair of this end-to-end connection. But I wish the HA can send packets to MH via different connections using tunnel mechanism.
Suppose that MH uses address 192.168.1.2 for above TCP connection. So we receive a packet on interface 192.168.1.3 with destination address of outer header of the packet (header of the tunnel - IP in IP packet), then we decapsulate the IP-in-IP packet to get the original packet with the destination address is 192.168.1.2. To send this packet to the application on upper layer, we must to put it on the interface 192.168.1.2 => HOW can I do it?
(I'm doing it using libpcap)
Many thanks and kind regards!