Friday, July 23, 2010

A sneak peak in to the IP Packet.


Though Most of us know about the IP packet..here is an attempt to explain the IP packet detailing each and every field it has.

Ok..now let's sneak in to a IP packet ..



Version
:Version identifies which version of the IP (Either IPv4 or IPV6) This packet belongs to.And this is a four bit field usually set to binary 0100.


Header Length:Header length is also a 4 bit field in an IP Packet and as the name implies its tells about the length of the IP header.
The minimum length of a IP header is 20 octets and can scale up to 24 octets.
TOS (Type of Service):Its a 8 bit field which can be broken down in to two parts .a)precedence :Which talks about the priority Very urgent,urgent or normal delivery of the packet and b)TOS :and this deciding on the priority of delivery will be based on throughput,delay,reliability and monetary cost factors.

And yep!!.this precedence will be used in QoS (Quality of Service) applications.

Total Length: It talks about the total length of the IP Packet including the header in octets ranging from 16 to 65,535 octets . This field consist of 16 bit.

Identifier:Imagine you are sending a 5000 byte packets in the network and it encounters a data link whose MTU is set 1500 bytes and that means that link can handle only 1500 bytes at a time. in that case the entire packet will be fragmented in to the chuncks of not more than 1500 bytes and then router marks each fragment with the same number in the identifier field so that a receiving device can identify the fragments and that go together in the end . This field consists of 16 bits .

Flags: Its a three bit field ..where first bit will be unused . second one is don't fragment(DF) bit .When this bit is set to on (1), the device which handling the packet cann't fragment the incoming packet .

If the incoming packet is of size which is larger than it can handle and if its not allowed to fragment than it will drop the packet and sends an error message to the source of the packet and this DF option will be set to determine the MTU on a network .

The third bit is MF(More fragments) bit..when a device fragments a packet , it sets MF bit to one and on the last packet where there is no more packets need to be fragmented it will set the MF bit to zero .

Fragment Offset :Its specifies offsets and responsible for fragments packets to re-assembled in the correct order in the end .

TTL(Time To Leave):You know it ..when a packet starts it journey towards its destination in a network ...as it passes through each hops (routers) the initially set value of TTL is decremented by one so that it prevents lost packets from wandering endlessly through an inter network and when the TTL value reaches zero packet will be discarded and the error message will be sent to the source.

Protocol:It talks about which transport layer protocol like this packet is destined for .( Example :1 is for ICMP.6 for TCP and 17 for UDP).

Header checksum :Its used for error-correction and its not used for encapsulated data.Its a 16 bit field field where the checksum will calculated at the source and once its received at the destination the checksum will be again calculated and if the checksums are exactly matching ( all one's) than it proves that packet is recieved without any errors and received intact .

Source and Destination Address: We all know abt this ! ..its 32 bit IP address . Identifies the source and destination.

Options : Its Optional!!..only used when it need contains any source generated information or for other routers to enter information like timestamp and strict source routing where its strictly defined how the packets should be routed via which routers interfaces .

Padding ensures that header ends on a 32 bit boundaryby adding extra zeroes after the option field until a multiple of 32 is reached .

Wireshark capture of an IP packet as below;







No comments: