A computer network (iv): The network layer

Network layer to solve the problem

  • The network layer is responsible for forwarding data packets between different networks, packet-based IP address of the Forwarding
  • If a packet is lost, the network layer is not responsible for lost retransmission.
  • The network layer is not responsible for the arrival order of the packets.

IP address and subnet mask

  • IP address consists of 32-bit binary composition, divided by four. Separated, e.g. 192.168.0.1.
  • IP addresses into network addresses and host addresses two parts, the segment number indicating the network address, the same IP address of the computer network address part of the same network segment, in different host number. (The forwarding is a network address part of the IP address of the router broadcast packets)

Classification of IP addresses

  • Class A network address part of 8 bits, the address can have a 256 * 256 * 256 host addresses
  • Class B network address portion comprises 16 bits, the address can have a 256 * 256 host addresses
  • Class C network address representing portion 24, the address may be a host address 256
    Here Insert Picture Description

Kinds of commonly used IP address
so it can be determined by the class of the IP address prior to the IP address of the digital first.
Here Insert Picture DescriptionSome special address

  • Local loopback address: 127.0.0.1 points to retain its own address (localhost);
  • 169.254.0.0: dhcp acquiring the address fails, it will obtain a random address in the Class B addresses;
  • Reserved private address (the public address the world's only, you can visit. Private network addresses to addresses within the LAN. Private IP address when accessing the Internet will go through NAT technology into the public network address and then access the Internet. So do not see the public online these private address)
    10.0.0.0 - 10.255.255.255
    172.16.0.0 - 172.31.255.255
    192.168.0.0 - 192.168.255.255

Subnet Mask

Is used to indicate the network number and host number of the dividing position, indicated as part of a network number and host number part is 0.
For example 16.16.16.16 255.0.0.0 16.16.16.16/8 expressed or before eight network number, back to the host number

Subnetting and super-network consolidation

Subnetting

The network is divided into a plurality of segments, increased (point 252 Best subnet mask) in accordance with the number of the host address of the subnet, a subnet mask is set

Here Insert Picture Description
Host address of all 0: represents the network segment
host address of all 1: represents the broadcast
host address 1: usually represents a gateway (the first data to the gateway of the network segment to send data to other networks)

Supernetting merger

Supernetting combined with subnetting contrast, the plurality of segments into one segment, reducing the number of hosts in accordance with the subnet address, a subnet mask is set

router

  • A router is a three-tier device, you can see the target IP address of the packet.
  • The router receives the packet destination address and its routing table, forwards the packet.
  • Sent to the routing table to record which ports of different network data packets to be sent, is provided by the network administrator may be automatically updated through learning.

Network layer protocol

ARP–IP–ICMP–IGMP
Here Insert Picture Description

ARP protocol

  • In the same segment, parsing its MAC address broadcast destination IP address.

The target IP address by broadcasting (in the network segment to the destination MAC address is all send F, subnet will be sent to each computer) find each other's MAC address to ask yourself the target computer receives the packet, his MAC address is sent to the other party.

相关命令 
arp -a 							查看arpIP地址绑定MAC地址  
arp -s 	IP地址 MAC地址			手动添加静态绑定MAC地址  
arp -d 							清空arp缓存 ```

ICMP protocol

  • ICMP protocol for testing the network layer is smooth, the control message is transmitted. Refers to the network control messages through the operation fails, the host is reachable, a message such as whether the available route network itself.
相关命令  
ping ip地址 					估算网络是否畅通 
trancert ip地址					跟踪数据包路径
pathping ip地址					跟踪数据包路径,并计算丢包情况

IGMP protocol

  • IGMP protocol is a multicast protocol

communication method

  • Point- : the only destination address
  • Broadcast : sending to all the computer network segment
    destination IP address is 255.255.255.255, the destination MAC address is all F (broadcast can not cross routers)
  • Multicast / multicast : send data to the part of the computer network segment
    using the multicast address allows a group of computers accept data (multicast insurmountable router)

IP protocol

IP protocol is a general term that allows the router to learn the routing table protocol called IP protocol.

  • Static Routing: manually configured by the administrator, all tell the router not directly connected to the network, next to whom.
  • Dynamic routing: router through some kind of protocol routing learning table.
    RIP protocol : first dynamic routing protocol, routers periodically broadcasts its neighbor routers to reach the subnet, period of 30 seconds. After reaching the target segment, the less number of routers (hops), is considered the more superior path.
    OSPF protocol : dynamic routing protocol, updated routing table triggered, determining the path bandwidth merits.
    BGP protocol : connecting different autonomous system (using a different IP protocol network system) routing protocol.

VPN technology

Establish a dial-up connection through the public network access to the computer can achieve the effect of the private network, the private network to access resources in the art.

NAT and PAT technology Technology

NAT address mapping : When you access the public network, will be replaced with a public address technical network address within the network, enabling the network can access the public Internet computers, but the public can not take the initiative to access the internal network computer network addresses and public network address correspondence.

PAT port mapping : public access network, the network address is replaced with the same public IP address, port mapping implemented by the mapping target different computers. To achieve public access to internal network resources.

Released eight original articles · won praise 14 · views 464

Guess you like

Origin blog.csdn.net/qq_39304851/article/details/104764448