RFC 791 http://www.cis.ohio-state.edu/htbin/rfc/rfc791.html
The Internet Protocol (IP), defined by IETF RFC791, is the routing layer datagram service of the TCP/IP suite. All other protocols within the TCP/IP suite, except ARP and RARP, use IP to route frames from host to host. The IP frame header contains routing information and control information associated with datagram delivery.
The IP header structure is as follows:
4
|
8
|
16
|
32 bits
|
||||
|
|
|
Total length | ||||
|
|
Fragment offset | |||||
|
Protocol |
|
|||||
|
|||||||
|
|||||||
|
|||||||
|
|||||||
IP
header structure
|
Version
Version field indicates the format of the
Internet header.
IHL
Internet header length is the length of
the Internet header in 32-bit words. Points to the beginning
of the data. The minimum value for a correct header is
5.
Type of service
Indicates the quality
of service desired. Networks may offer service precedence,
meaning that they accept traffic only above a certain
precedence at times of high load. There is a three-way
trade-off between low delay, high reliability and high
throughput.
Bits 0-2: Precedence | |
111 | Network control. |
110 | Internetwork control. |
101 | CRITIC/ECP. |
100 | Flash override. |
011 | Flash. |
010 | Immediate. |
001 | Priority. |
000 | Routine. |
Bit 3: Delay
0 | Normal delay. |
1 | Low delay. |
Bit 4: Throughput
0 | Normal throughput. |
1 | High throughput. |
Bit 5: Reliability
0 | Normal reliability. |
1 | High reliability. |
Bits 6-7: Reserved for future use.
Total length
Length of
the datagram measured in bytes, including the
Internet header and data. This field allows the
length of a datagram to be up to 65,535 bytes,
although such long datagrams are impractical for
most hosts and networks. All hosts must be prepared
to accept datagrams of up to 576 bytes, regardless
of whether they arrive whole or in fragments.
It is recommended that hosts send datagrams larger than
576 bytes only if the destination is prepared to accept
the larger datagrams.
Identification
Identifying
value assigned by the sender to aid in assembling
the fragments of a datagram.
Flags
3 bits.
Control flags:
Bit 0 is reserved and must be zero
Bit 1: Don’t fragment bit:
0 | May fragment. |
1 | Don’t fragment. |
Bit 2: More fragments bit:
0 | Last fragment. |
1 | More fragments. |
Fragment
offset
13 bits.
Indicates where this fragment belongs in the
datagram. The fragment offset is measured
in units of 8 bytes (64 bits). The first fragment
has offset zero.
Time to live
Indicates
the maximum time the datagram is allowed to
remain in the Internet system. If this field
contains the value zero, the datagram must
be destroyed. This field is modified in Internet
header processing. The time is measured in
units of seconds. However, since every module
that processes a datagram must decrease the
TTL by at least one (even if it processes
the datagram in less than 1 second), the TTL must
be thought of only as an upper limit on the time
a datagram may exist. The intention is to cause
undeliverable datagrams to be discarded and to bound
the maximum datagram lifetime.
Protocol
Indicates
the next level protocol used in the data portion
of the Internet datagram.
Header checksum
A checksum
on the header only. Since some header fields
change, e.g., Time To Live, this is recomputed
and verified at each point that the Internet
header is processed.
Source address
/ destination address
32 bits
each. A distinction is made between names,
addresses and routes. A name indicates
an object to be sought. An address
indicates the location of the object. A route
indicates how to arrive at the object.
The Internet protocol deals primarily with
addresses. It is the task of higher level protocols
(such as host-to-host or application) to make the
mapping from names to addresses. The Internet module
maps Internet addresses to local net addresses.
It is the task of lower level procedures (such
as local net or gateways) to make the mapping
from local net addresses to routes.
Options
Options
may or may not appear in datagrams. They must
be implemented by all IP modules (host and
gateways). What is optional is their transmission
in any particular datagram, not their implementation.
In some environments, the security option
may be required in all datagrams.
The option field is variable in length. There may be zero or more options. There are two possible formats for an option:
The length octet includes the option type octet and the actual option data octets.
The option type octet has 3 fields:
1 bit: Copied flag. Indicates that this option is copied into all fragments during fragmentation:
0 | Copied. |
1 | Not copied. |
2 bits: Option class
0 | Control. |
1 | Reserved for future use. |
2 | Debugging and measurement. |
3 | Reserved for future use. |
5 bits: Option number.
Data
IP
data or higher layer protocol header.