1. Structure of the IP header
IP header 20 bytes, including 4-bit version number, 4-bit header, 8-bit service type, 16-bit total length, 16-bit Identification field, 3-bit flag field and 13-bit offset field, 8-bit TTL, 8-bit protocol, 16-bit header check, and 32-bit source ip,32-bit destination IP.
8-bit service type (TOS) This I always ignore, notice that the front 3 bits have been discarded, the back 4 bits represent the minimum delay, the maximum throughput, the highest reliability and the minimum cost, 4 can only choose one position of 1, if 4 bits are 0, then the General Service unexpectedly.
The TTL represents the maximum number of routers that can be passed, which is the lifetime of the datagram.
2. IP Routing
The most important nature of IP is to choose the road, choose the way to rely on what? The routing table.
First look at the composition of the routing table:
Target (note: The destination can be a host address, or it can be a subnet address, network address, or default route, and so on)
Gateway (the address of the next article)
Flag (whether it is available, whether it is a path, whether it is to the host, etc.)
Interface
Reference count (refcnt), number of active processes that are using routing
Number of groupings (number of packets sent through this route)
So what are the steps for IP routing?
1) First of all, we must select an exact match address (host address)
2) if 1) does not match, it will look for network address matching
3) 1) 2) are not found, search default table entries.
4) 1) 2) 3) are not found, reply to the host is not reached.
2016-04-09 Agreement