Thread: TCP/IP packets

  1. #1
    uint64_t...think positive xuftugulus's Avatar
    Join Date
    Feb 2008
    Location
    Pacem
    Posts
    355

    TCP/IP packets

    I am doing a little researchon TCP/IP packets, and i am constructing a test packet that sends TCMP ECHO.

    Questions:
    1. The header checksum is calculated by me?
    2. When i have constructed a packet how do i send it to the network?
    3. Where will i find more digestable information regarding low/level networking communication protocols?

    My source of info is: rfc791
    Code:
    ...
        goto johny_walker_red_label;
    johny_walker_blue_label: exit(-149$);
    johny_walker_red_label : exit( -22$);
    A typical example of ...cheap programming practices.

  2. #2
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    Quote Originally Posted by xuftugulus View Post
    1. The header checksum is calculated by me?
    Yes, because you are forming a raw packet, it's all your responsibility. If the checksum is wrong, the network stack will drop the packet on the floor and not even send it out.

    2. When i have constructed a packet how do i send it to the network?
    You have to open a SOCK_RAW socket. You must be root.

    3. Where will i find more digestable information regarding low/level networking communication protocols?
    There are a huge series of TCP/IP books by W. Richard Stevens called "TCP/IP Illustrated." This is the gold standard for TCP/IP network programming texts. I spent over $200 to get the full set, then made the mistake of letting somebody borrow them "for the weekend" and never got them back. If you buy them, don't let them out of your sight.

  3. #3
    uint64_t...think positive xuftugulus's Avatar
    Join Date
    Feb 2008
    Location
    Pacem
    Posts
    355
    Thanx for the feedback. One thing i need cleared about the checksum...
    The checksum exists in the header, and the checksum is the checksum of the header right?
    Do i assume that the checksum before calculation is 0?
    Code:
    ...
        goto johny_walker_red_label;
    johny_walker_blue_label: exit(-149$);
    johny_walker_red_label : exit( -22$);
    A typical example of ...cheap programming practices.

  4. #4
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    Quote Originally Posted by xuftugulus View Post
    Thanx for the feedback. One thing i need cleared about the checksum...
    The checksum exists in the header, and the checksum is the checksum of the header right?
    Do i assume that the checksum before calculation is 0?
    This is the stuff that I used to look up in my fancy books My guess is, the checksum covers the entire packet, and it is calculated as if it was set to zero initially, but that's all it is, a guess. Googling for "IP compute checksum" might help.

  5. #5
    uint64_t...think positive xuftugulus's Avatar
    Join Date
    Feb 2008
    Location
    Pacem
    Posts
    355
    I am browsing the source of linux ping atm, about 2k lines and i believe it should answer a lot of my questions although it's not totally 'raw'
    "TCP/IP Illustrated" -> What a book! I browsed it a bit online, albeit i would like it hard-printed
    Code:
    ...
        goto johny_walker_red_label;
    johny_walker_blue_label: exit(-149$);
    johny_walker_red_label : exit( -22$);
    A typical example of ...cheap programming practices.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Accessing and editing packets of other applications
    By Inder in forum Linux Programming
    Replies: 1
    Last Post: 09-01-2006, 12:00 PM
  2. TCP/IP packets
    By Zairus in forum C++ Programming
    Replies: 1
    Last Post: 03-29-2006, 05:35 AM
  3. Recieve packets
    By valt in forum C++ Programming
    Replies: 9
    Last Post: 02-04-2006, 12:41 AM
  4. Adding delay to all packets (incoming and leaving)
    By ingtabby in forum Windows Programming
    Replies: 1
    Last Post: 01-31-2006, 10:33 AM
  5. establish a connection using TCP and capture the incoming packets
    By shraddha in forum Networking/Device Communication
    Replies: 12
    Last Post: 10-22-2005, 02:15 AM