This is a low-level network debugging utility that utilizes raw packet i/o to construct and deconstruct tcp, udp, ipv4, arp, and icmp packets over ethernet.

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

IP_PacketHeader Struct Reference

IP_PacketHeader Struct Reference

IP Packet memory map. More...

#include <ip.h>

Data Fields

unsigned version:4
 4 bits that contain the version, that specifies if it's an IPv4 or IPv6 packet,
unsigned header_bytes_div4:4
 4 bits that contain the Internet Header Length which is the length of the header in multiples of 4 bytes (eg. 5 means 20 bytes).
unsigned tos:8
 8 bits that contain the Type of Service, also referred to as Quality of Service (QoS), which describes what priority the packet should have,
u16 packet_bytes
 16 bits that contain the total length of the IP packet (datagram) in bytes,
u16 fragment_id
 16 bits that contain an identification tag to help reconstruct the packet from several fragments,
unsigned unused_0:1
 3 bits that contain a zero, 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)
unsigned fragment_offset:13
 13 bits that contain the fragment offset, a field to identify position of fragment within original packet
unsigned ttl:8
 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),
unsigned protocol:8
 8 bits that contain the protocol (TCP, UDP, ICMP, etc...) 0x01 ICMP 0x06 TCP 0x11 UDP
u16 header_checksum
 16 bits that contain the Header Checksum, a number used in error detection,
IP_Address source
 32 bits that contain the source IP address,
IP_Address destination
 32 bits that contain the destination address.
unsigned char data []
 Zero-length field for memory mapping the packet data.

Detailed Description

IP Packet memory map.

Definition at line 23 of file ip.h.


Field Documentation

unsigned char data[]

Zero-length field for memory mapping the packet data.

Definition at line 54 of file ip.h.

32 bits that contain the destination address.

Definition at line 52 of file ip.h.

16 bits that contain an identification tag to help reconstruct the packet from several fragments,

Definition at line 33 of file ip.h.

unsigned fragment_offset

13 bits that contain the fragment offset, a field to identify position of fragment within original packet

This and the ones above may not work properly due to endianness

Definition at line 39 of file ip.h.

4 bits that contain the Internet Header Length which is the length of the header in multiples of 4 bytes (eg. 5 means 20 bytes).

Definition at line 27 of file ip.h.

16 bits that contain the Header Checksum, a number used in error detection,

Definition at line 48 of file ip.h.

16 bits that contain the total length of the IP packet (datagram) in bytes,

Definition at line 31 of file ip.h.

unsigned protocol

8 bits that contain the protocol (TCP, UDP, ICMP, etc...) 0x01 ICMP 0x06 TCP 0x11 UDP

Definition at line 46 of file ip.h.

32 bits that contain the source IP address,

Definition at line 50 of file ip.h.

unsigned tos

8 bits that contain the Type of Service, also referred to as Quality of Service (QoS), which describes what priority the packet should have,

Definition at line 29 of file ip.h.

unsigned ttl

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),

Definition at line 41 of file ip.h.

unsigned unused_0

3 bits that contain a zero, 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)

Definition at line 35 of file ip.h.

unsigned version

4 bits that contain the version, that specifies if it's an IPv4 or IPv6 packet,

Definition at line 25 of file ip.h.