c++ - udp packet fragmentation for raw sockets -
follow-up of question packet fragmentation raw sockets
if have raw socket implemented such:
if ((sip_socket = socket(af_inet, sock_raw, ipproto_raw)) < 0) { cout << "unable create sip sockets."<< sip_socket<<" \n"; return -3; } if ( setsockopt(sip_socket, ipproto_ip, ip_hdrincl, &one, sizeof(one)) == -1) { cerr << "unable set option raw socket.\n"; return -4; };
how can set iphdr->fragment_offset (16 bits including 3 bit flags) if have packet of size 1756 (not including ip header)?
need prepare 2 packets-one of size 1480 , of size 276, , slap ip headers on both packets?
can point example code this?
yes, need prepare 2 packets, each own ip header.
if put 1480 bytes of data in first packet , 276 in second, ip headers should identical, except these fields:
fragment offset
: set0
in first packet, ,1480
in second;total length
: set 1480 plus header length in first packet, , 276 plus header length in second packet;mf
flag: set1
in first packet ,0
in second;header checksum
: recalculated on different headers appropriate.
Comments
Post a Comment