User:KemyLand
My editing room :)
Internet Protocol
This article talks about the IPv4 (Internet Protocol, version 4). IPv4, as defined in RFC 791 in September 1981, is used to communicate devices through the Internet, i.e: the world-wide computer network you're using right now. This is done with the concept of an IP address, that is, a 32-bit number uniquely identifying a device or network in the Internet. ARP runs on the link-layer, so it's irrelevant for this article.
Relation to other protocols
The IP is designed to be used in a protocol-stack manner. In the first layer you'll find ARP and lots of strange stuffs. On the second layer you'll find IPv4 and ICMP. On the third layer you find either TCP or UDP, and the list goes on.
Each stack layer uses the abstractions provided by lower-layers, to provide abstractions for higher-layers.
The IPv4 Header
The IP Header is actually the unique data-structure defined by the IP protocol. It appears like follows. Note that bit-fields smaller than 8-bits may be used (not available in C), as well as non-2-power fields:
typedef UInt32 IPAddr;
struct IPv4Header {
UInt4 version;
UInt4 headerLen;
UInt8 service;
UInt16 datagramLen;
UInt16 id;
UInt3 flags;
UInt13 fragmentOff;
UInt8 lifeTime;
UInt8 protocol;
UInt16 checksum;
IPAddr srcAddr;
IPAddr destAddr;
UInt8 options[?];
UInt8 padding[?];
};