Recall the main function of the network layer: The network map is drawn by TCP or UDP protocol, and the packet is selected by the appropriate path (Network layer basic unit: Packet package)
(1) Addressing (the IP address of the target end), the process of data transmission must indicate the destination IP address to be sent;
(2) routing : Select one of the fastest paths for packet transmission;
(3) congestion control : Prevent congestion in the process of packet transmission, resulting in packet loss and delay.
(a) The functions of the IP protocol:
(1) Addressing and routing, (according to the other's IP address, to find the best path to transmit information);
(2) Delivery service: ① unreliable (IP protocol is to do its best to transmit packets), reliability is provided by the upper layer Protocol (TCP protocol); ② is not connected; (no prior session established);
(3) Fragmentation and reassembly of packets.
(ii) IP packet detailed:
(1)0100 = Version : 4 (indicates the IPV4 protocol used), the same IP protocol (IPV4 protocol) is used between peers;
(2)0101 = header Length: 20Bytes (5) The header is 4 bit long and can represent a maximum value of 15 units (1111), a unit one byte, and a maximum of 60 bytes;
(3) service type -----accounted for 8 bit, (differentiatedservices field) field to differentiate service, delay = 1 delay small, throughput = 1 throughput Large, Reliability = 1 high quality, cost = 1 minimum price. At the same time only one is 1;
(4) total length bit:2^16-1 = 65535 bytes, value header and data sum of length, in bytes, so the maximum length of the datagram is 65535 bytes (MTU Maximum transmission unit);
(5) mark (identification) occupies a bit, it is a counter, used to generate the identity of the packet;
(6) flag: Packet in the process of transmission, the Flag field MF (more fregment), MF = 1 indicates that there is also a shard, mf = 0 means the last shard;
(7) chip offset : Each piece of data is not transmitted simultaneously, marking the plot in the original packet relative offset position, with 8 bytes as the offset unit;
Note: The sending of datagrams is too large, it is necessary to fragment processing of its datagram, each shard will contain an identity (IP address + identity), to the destination to be all of its shards to reassemble;
Focus: chip migration calculation process; The first part of the big question is the same, because all belong to the same number of data messages.
(8) lifetime (time to Live) occupies 8bit, using "hop count" as the unit of the TTL. Datagrams are reduced by 1 for each router experience, and the datagram is prevented from looping in the router because the datagram consumes a certain amount of bandwidth during transmission (the TTL value is 0 automatically discarded);
(9) The protocol (8bit) field indicates whether the TCP protocol used by this datagram to carry the upper-layer data or the UDP protocol, so that the peer receives the datagram to the upper layer corresponding protocol (TCP or UDP protocol) for processing;
(Ten) The first test and (header checksum 16bit) field only verifies the header of the datagram, does not contain the data part; see if the IP datagram header is damaged, tampered with, lost, etc.
(one) Source address : Data sent outward, sending the IP address of the machine itself, also become a logical address;
Destination address : Data specifically to send the destination and its IP address.
(corresponding IP datagram Wireshark packet capture plot)
(iii) logical address and Physical address interpretation:
(1) logical address : (Work in the network layer, network level) also known as IP address, with the characteristics of ① global uniqueness; ② use software to achieve address management in the network; ③ is 32 bits, 4 bytes;
(2) Physical Address : Also known as hardware address, link address or MAC address, (working at the network interface layer) has characteristics: ① local scope uniqueness; ② uses hardware implementations (routers, computers have a location to set MAC addresses), ③ is 48 bits, 12 bytes, and 16 binary representations. For example: 74-e5-0b-35-60-16:0111 0100-1110 0101-0000 1011-0011 0101-0110 0000-0001 0110.
(d) Why you have an IP address and use a MAC address:
①ip address is generally easy to modify and change, with randomness, can not be fixed on the network to identify a device;
②mac address the general situation factory burned to the network card, not easy to modify, in the local area within easy to locate a single device.
③ from the topology and layered analysis, IP address belongs to the network layer, the main function of the WAN range of routing addressing, select the best route, and the MAC address in the network interface layer to form a suitable for the transmission of network media data frame.
Note: Three ways to identify a device: ① Domain Access (www.baidu.com, Application layer), ② device IP address access (network layer), ③ device's MAC address (the device is uniquely identified in the LAN, it is not actually accessed, in the network interface layer, has a fixed feature, Not prone to disturbances).