Thread: Packet processing in Socket programming, please help

  1. #1
    Registered User
    Join Date
    Mar 2009
    Posts
    3

    Packet processing in Socket programming, please help

    Hi everybody,
    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!
    Edit/Delete Message

  2. #2
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    I have a hard time getting this straight because to me there appear to be some internal contradictions in what you are saying -- so if you don't get a helpful reply, consider clarifying:

    Quote Originally Posted by pumpkin View Post
    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.
    Which TCP connection? You just said there were several.

    So we receive a packet on interface 192.168.1.3
    How would you do that if you just said the connection was on .1.2? Or do you mean .1.2 is the HA, and the MH is .1.3, hence the MH "uses" .1.2 to reach the HA?

    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?
    The obvious answer would seem to be: send it there. There can only be one 192.168.1.2 on your network, if you want a packet to go there, send it.
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  3. #3
    Registered User
    Join Date
    Mar 2009
    Posts
    3
    Hi MK27, thanks for your reply and sorry for my bad English!

    In my application scenario, the MH has several interfaces, each of them was connected to the HA via different connections (because of my application aims to aggregate bandwidth of these connections).
    Which TCP connection? You just said there were several.
    How would you do that if you just said the connection was on .1.2? Or do you mean .1.2 is the HA, and the MH is .1.3, hence the MH "uses" .1.2 to reach the HA?
    As you know, TCP connection is a end-to-end connection, if MH has a TCP connection with HA and it uses its address 192.168.1.2 (on one interface of course). We want to increase bandwidth for this connection then we send packets of this connection from HA to other interfaces of MH, such as interfaces with addresses are 192.168.1.3, 192.168.1.4.

    The obvious answer would seem to be: send it there. There can only be one 192.168.1.2 on your network, if you want a packet to go there, send it.
    How to send packets from an interface to another on the same MH?

    Thanks again!

  4. #4
    Registered User slingerland3g's Avatar
    Join Date
    Jan 2008
    Location
    Seattle
    Posts
    603
    There is a lot more going on than simply trying to pass a packet down an available port. How are you handling the L2 MAC addresses for these trunked ports for aggregated bandwidth? Also there will be a need to assemble all these packets if they are being evenly distributed across all these ports. Are you doing synchronous transmissions as well? What you are asking is a bit open ended and will require lots more thought on this.

    Perhaps reviewing the RFC on SCTP may shed light on how TCP can be sent down mulitple host ports.

  5. #5
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    Why not create a helper program whose sole purpose is to listen on multiple interfaces and bind these together into a single "super" interface? This helper program then passes the reconstructed data stream to the true application through a pipe or UNIX domain socket.
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

  6. #6
    Registered User
    Join Date
    Mar 2009
    Posts
    3
    Quote Originally Posted by brewbuck View Post
    Why not create a helper program whose sole purpose is to listen on multiple interfaces and bind these together into a single "super" interface? This helper program then passes the reconstructed data stream to the true application through a pipe or UNIX domain socket.
    Hi brewbuck,
    I got your point but what's the "super" interface in Linux? I've never hear anything like that, can you help me to figure out this confusion?

    Many thanks!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. multi-thread socket program with packet fragmentation
    By thinkerchjf in forum Networking/Device Communication
    Replies: 2
    Last Post: 06-25-2009, 10:46 AM
  2. Global Variables
    By Taka in forum C Programming
    Replies: 34
    Last Post: 11-02-2007, 03:25 AM
  3. Problem while constructing IP packet and sending using socket() system call
    By cavestine in forum Networking/Device Communication
    Replies: 10
    Last Post: 10-15-2007, 05:49 AM
  4. sendto Socket packet size
    By bj00 in forum Networking/Device Communication
    Replies: 0
    Last Post: 07-27-2007, 11:05 AM
  5. Packet Filter using Unix Socket
    By doraiashok in forum Networking/Device Communication
    Replies: 2
    Last Post: 12-12-2003, 08:14 AM

Tags for this Thread