当前位置:网站首页>Hub, switch, router

Hub, switch, router

2022-06-21 06:56:00 ZDB

A hub 、 Switch 、 Router

1. A hub : Broadcast the input signal to all ports , If multiple signals are input at the same time, collision will occur , Multiple signals cannot be transmitted at the same time . Working on the physical level .

2. Switch : It is a layer-2 network device designed based on Ethernet , The port of the switch does not have MAC Address . Forward packets only to those with a specific MAC Address of the connected device , Multiple packets can be forwarded at the same time . Working at the data link layer .

3. Router : Is based on IP The design of the , It's a three-tier network device , Each port of the router has one MAC Address and IP Address .
It mainly completes two functions : Complete routing ( Determine which path ) And packet forwarding ( The action taken when a packet arrives ). The former constructs a routing table according to a specific routing protocol , At the same time, we often or regularly exchange routing information with neighboring routers and constantly update and maintain the routing table . The latter handles the data flow through the router , The key operation is to post the query 、 Forwarding and related queue management and task scheduling .


The basic principle of router : The router's port has MAC Address , Therefore, it can become the sender and receiver of Ethernet packets ; It also has IP Address , In that sense , It's the same as the computer's network card . When forwarding packets , First, the router port receives the Ethernet packets sent to it , Then the router queries the forwarding target , Ethernet packets are then sent out using the corresponding port as the sender .


Packet receiving operation of router 1. First , The electrical signal reaches the network cable interface part , The modules in the router will convert electrical signals into digital signals , Then pass through the end of the package FCS Error checking . 2. If there is no problem, check MAC Receiver in header MAC Address , Let's see if it's a bag for you , If so, put it in the receive buffer , Otherwise, discard the package .

in general , The router's ports all have them MAC Address , Accept only packets that match its address , Mismatched packages are discarded .

 

1、 Routing table

Routing tables are used to determine how packets are transferred from one subnet to another , In other words, it is used to determine which network card the packets received from a network card should be sent to . stay Linux It can be used route add default gw < Default route IP> Configure a default route .

Each row of the routing table has at least the target network number 、netmask、 And the network card that should be used to connect to this subnet . When the router receives a packet from a network card , It scans every row of the routing table , Use the inside netmask And the goals in the bag IP Addresses do logic and operations , Find the target network number , If the network number is the same as the network number in this line, keep this router as a backup route , If there are already backup routes, the longest network number will be left in the two routes , Another discard , Then scan the next line until the end . If no route is found after the scan , Just use the default route . After routing , Send the package directly to the corresponding network card . In the concrete realization , The routing table may contain more information for the details of the routing algorithm .

原网站

版权声明
本文为[ZDB]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/172/202206210641464639.html