Skip to content

Instantly share code, notes, and snippets.

@mdang
Last active August 29, 2015 14:21
Show Gist options
  • Save mdang/40f64458b702f0060d26 to your computer and use it in GitHub Desktop.
Save mdang/40f64458b702f0060d26 to your computer and use it in GitHub Desktop.
IP Packets

IP Packets

IP packets are composed of a header and payload. The IPv4 packet header consists of:

  • 4 bits that contain the version, that specifies if it's an IPv4 or IPv6 packet,
  • 4 bits that contain the Internet Header Length, which is the length of the header in multiples of 4 bytes (e.g., 5 means 20 bytes).
  • 8 bits that contain the Type of Service, also referred to as Quality of Service (QoS), which describes what priority the packet should have,
  • 16 bits that contain the length of the packet in bytes,
  • 16 bits that contain an identification tag to help reconstruct the packet from several fragments,
  • 3 bits. The first contains a zero, followed by a flag that says whether the packet is allowed to be fragmented or not (DF: Don't fragment), and a flag to state whether more fragments of a packet follow (MF: More Fragments)
  • 13 bits that contain the fragment offset, a field to identify position of fragment within original packet
  • 8 bits that contain the Time to live (TTL), which is the number of hops (router, computer or device along a network) the packet is allowed to pass before it dies (for example, a packet with a TTL of 16 will be allowed to go across 16 routers to get to its destination before it is discarded),
  • 8 bits that contain the protocol (TCP, UDP, ICMP, etc.)
  • 16 bits that contain the Header Checksum, a number used in error detection,
  • 32 bits that contain the source IP address,
  • 32 bits that contain the destination address.

Source: http://en.wikipedia.org/wiki/Network_packet

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment