TCP/IP packets [Archive] - C Board

PDA

View Full Version : TCP/IP packets


xuftugulus
03-12-2008, 11:34 AM
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 (http://tools.ietf.org/html/rfc791)

brewbuck
03-12-2008, 01:04 PM
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.

xuftugulus
03-12-2008, 01:13 PM
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?

brewbuck
03-12-2008, 01:15 PM
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.

xuftugulus
03-12-2008, 05:52 PM
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 :( :(