Five layer network model

Application layer: data format and content of application program.

Transport layer: UDP /TCP, system port, and application port.

Network layer: IP protocol, ASSIGN IP addresses, determine subnetworks.

Link layer: Ethernet protocol, MAC address, subnet broadcast.

Physical layer: also the physical layer, signal transmission medium, such as cable.

Network packet structure

Headers, data

The following simplified steps reflect the basic principles of Internet communication

(1) DHCP protocol – networking

Broadcast through DHCP, obtain the internal dynamic Ip address, subnet mask, gateway Ip address, and DNS Ip address from the Intranet, and then connect to the Internet

Whether it is a dynamic IP address or a static IP address, the following parameters must be set if you want to connect to the Internet. (The actual parameter values prevail.)

* IP address of the local server: 192.168.1.100 * Subnet mask: 255.255.255.0 * GATEWAY IP address: 192.168.1.1 * DNS IP address: 8.8.8.8Copy the code

(2) DNS protocol – domain name resolution to IP

The DNS protocol can help us convert this url www.google.com into an IP address. Given that the DNS server is 8.8.8.8, we send a DNS packet (port 53) to this address. The DNS server then responds, telling us that Google’s IP address is 172.194.72.105. So we know each other’s IP addresses.

(3) subnet mask – calculate whether the communication target is in the same subnet

1. After the local IP address AND subnet mask are AND, A is obtained. After the target IP address AND subnet mask are AND, B is obtained.

2. The IP address of the gateway, combined with its own subnet mask, can be used to determine whether the destination IP address and the gateway are in the same subnetwork. If they are not on the same subnet, the packets are forwarded to the upper-layer gateway, and so on.

3.DNS IP address, used to resolve the target domain name into an IP address.

(4)ARP protocol – if in the same subnet, obtain the MAC address of the other party, you can communicate

Obtain MAC addresses of computers on the same subnet through ARP

If two hosts are in the same subnetwork, we can use ARP to obtain the MAC address of each other. ARP also sends a packet (contained in an Ethernet packet) that contains the IP address of the host to be queried. In the MAC address field, the packet is FF:FF:FF:FF:FF. Each host in its subnetwork receives the packet, extracts its IP address, and compares it with its own IP address. If they are the same, both reply with their MAC addresses. Otherwise, the packet is discarded.

In short, with THE ARP protocol, we can get the MAC address of the host in the same subnetwork, and can send packets to any host.

Refer to Internet Protocol 1 Internet Protocol 2