Click to See Complete Forum and Search --> : Raw sockets problem


squall_lion_heart
December 21st, 2004, 02:04 PM
well, i learning from mixter's text, you can find it here:

http://mixter.void.ru/rawip.html

mixter programmed this struct of ip header:

struct ipheader {
unsigned char ip_hl:4, ip_v:4; /* this means that each member is 4 bits */
unsigned char ip_tos;
unsigned short int ip_len;
unsigned short int ip_id;
unsigned short int ip_off;
unsigned char ip_ttl;
unsigned char ip_p;
unsigned short int ip_sum;
unsigned int ip_src;
unsigned int ip_dst;
}; /* total ip header length: 20 bytes (=160 bits) */


and i have one question,
what does the field ip_off supposed to indicate?
the writer said that the field used for reassembly of fragmented datagrams and somthing about flags i didn't understand it, someone can explain me please?

thanks for the help

squall!

j0nas
December 22nd, 2004, 04:13 AM
Read the IP RFC 791: http://www.faqs.org/rfcs/rfc791.html

Search on "Fragment Offset" in the RFC. In the end of the RFC, there are examples (#2 deals with fragmentation).

The frag ofs is specified in 8 bytes block. You'll understand after you've read the RFC.

Good luck.

Mathew Joy
December 22nd, 2004, 01:19 PM
If the packet is fragmented, then the fragmented packets are reassembeled checking at the value of that field. Fragmented packets will have the same id. The the ordering will be possible only looking at the offset.

squall_lion_heart
December 23rd, 2004, 06:56 AM
thank you for the help!

and i have one more little question, in the packet structure i didn't see any field that can contain the data.
if i want to send packet with data should i add one more field and put the data there?

Mathew Joy
December 30th, 2004, 01:25 PM
Well, there is a field 'Total Length', that indicates the total length of the packet including the headers and data. Any chars that follow the IP header is considered to be the data.