IP Headers - jibingl/CCNA-CCNP GitHub Wiki

Internet Protocol Headers

                          IPv4                                                                        IPv6

 0                   1                   2                   3             0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1           0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+         +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|Version|  IHL  |Type of Service|          Total Length         |         |Version| Traffic Class |           Flow Label                  |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+         +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|         Identification        |Flags|      Fragment Offset    |         |         Payload Length        |  Next Header  |   Hop Limit   |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+         +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|  Time to Live |    Protocol   |         Header Checksum       |         |                                                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+         +                                                               +
|                       Source Address                          |         |                                                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+         +                        Source Address                         +
|                    Destination Address                        |         |                                                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+         +                                                               +
|                    Options                    |    Padding    |         |                                                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+         +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
                       (rfc791- figure 4)                                 |                                                               |
                  20 - 60 Bytes (depends on options)                      +                                                               +
                                                                          |                                                               |
                                                                          +                      Destination Address                      +
                                                                          |                                                               |
                                                                          +                                                               +
                                                                          |                                                               |
                                                                          +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
                                                                                                     (rfc2460)   Fixed 40 Bytes

Fields           Bits  Explanations                                       Fields           Bits  Explanations
------           ----  ------------------------------------------         ------           ----  ------------------------------------------
Version          4     0x04 - 0100 - version 4                            Version           4    0x06 - 0110 - version 6
IHL              4     Internet Header Length 
                       The value range 5-15 (20-60bytes)
                       Example: IHL(5) = 5 * 4bytes =20bytes 
Type of Service  8      0   1   2   3   4   5   6   7                     Traffic Class     8    QoS
                       +---+---+---+---+---+---+---+---+  
                       |    DSCP               |  ECN  |  
                       +---+---+---+---+---+---+---+---+ 
                       Differentiated Service Code Point - QoS
                       Explicit Congestion Notification
                       (Congested network without dropping data)
Total Length     16    Total length of a packet (L3 + L4)                 Payload Length    16
                       Minimum 20 bytes (= only L3 IPv4 header)
                       Maximum 65535 bytes
Identification   16    Which packet is a fragment belongs.                Flow Label        20
Flags            3         0   1   2     
                         +---+---+---+   
                         | 0 |DF |MF |   
                         +---+---+---+ 
                       Bit0: reserved, must be zero
                       Bit1(DF): 0=May Fragment,  1=Don't Fragment
                       Bit2(MF): 0=Last Fragment, 1=More Fragments
Fragment Offset  13    Where in the datagram this fragment belongs
                       (A fragment's position within the packet) 
Time to Live     8     Recommended default value is 64                     Hop Limit         8
Protocol         8     The next level protocol used                        Next Header       8
Header Checksum  16    Check error in the IP header only