After the previous two blogs , We probably know switches and routers , Then summarize the difference between switch and router .
Switches and routers are network hardware , So what are the main differences ? As I understand , Switches are used to connect to local area networks , Routers are used to connect to the Internet ( You can also connect multiple LANs )
<> difference
* Router : addressing , forward ( rely on IP address ), Switch : filter , forward ( rely on MAC address )
* Switches are used to connect to local area networks , Data forwarding of data packet in LAN , Router is used to connect LAN and extranet , Packets can be forwarded on different LANs .
* The switch works in TCP/IP The last layer of the protocol is the data link layer ( physical layer ), The router works at the network layer
*
The switch is responsible for specific packet transmission , The router is not responsible for the actual transmission of packets , The router only encapsulates the data packets to be transmitted , Then give it to the switch for transmission ( Not necessarily a switch , It may be other transmission technologies ), use java The metaphor can be simply understood as that the router is an abstract class , Define the data packet format for transmission , The switch is a concrete implementation class , There can also be other implementation classes
* No switch MAC Address and IP address , Router has MAC Address and IP address ( Refers to pure broken switches and routers , Layer 3 switches can have IP Addressable , The router also has the function of built-in switch )
also , By the way :
The difference between hub and switch
Hubs and switches work in TCP/IP The last layer of the agreement , data link ( physical layer ), Are connected to multiple devices to form a local area network .
The hub will broadcast the received packets to all computers in the LAN every time , The switch is only available for the first time MAC The address table cannot find the record before broadcasting , Other times, it is sent directly to the corresponding MAC Address computer . The switch can be said to be an upgraded and improved version of the hub , On the basis of more hubs MAC Address table , Can split conflict domain , More intelligent .
The data transmission mode of hub is broadcast mode , The data transmission of the switch is purposeful , Data is only sent to the destination node , Just in your own MAC If the address cannot be found in the address table, it is sent by broadcast for the first time , Then because the switch has MAC Address learning function , After the second time, it is no longer broadcast , It is purposeful sending again . This benefit is to improve the efficiency of data transmission , There will be no broadcast storm , In terms of security, other nodes will not listen
Difference between bridge and switch
*
When the switch is working , In fact, channels between many groups of ports are allowed to work at the same time . therefore , The function of the switch reflects the function of more than just a bridge , It is a collection of multiple bridge functions . That is, the bridge is generally divided into two output and input ports , The switch has high-density ports . So the general switch , The bridge has the function of bridging .
* The bridge is mainly realized by software , The switch is mainly realized by hardware
A bridge can also be understood as a switch with only two ports , The switch can be understood as composed of multiple bridges
Connection mode of bridge :( The red dot is the hub )
Switch connection mode :
<> summary
Switches and routers , Understand the relationship between the two , The key point is that the computer sends network packets , Or when the router forwards network packets , All need to be preceded by MAC head . The previous explanations all said to add at the beginning
MAC head , If you look at the picture 3.16 You can find , The exact statement should be to IP Packed into the data part of the Ethernet package . in other words , Add to the bag MAC Header and send , In essence, it will
IP Packed into the data part of the Ethernet package , Entrust Ethernet to transmit these data .IP The protocol itself has no function of transmitting packets , Therefore, the actual transmission of packets should be entrusted to Ethernet . Router is based on IP
Designed , The switch is designed based on Ethernet , because this IP The relationship with Ethernet is the relationship between router and switch .
let me put it another way , The router entrusts the transmission of packets to the switch . of course , The content here is only applicable to the original implementation IP
Pure routers and switches with Ethernet mechanism , The actual router has the function of built-in switch , For example, home routers used to connect to the Internet belong to this kind , For this kind of router , The above may not apply . however , If you put this “ Not pure ” Split your router into “ pure ” Router and “ pure ” Switch for , Then they all apply to the above content .
The router entrusts the transmission of packets to the switch , In addition to using switches , Hubs can also be used , Or it can be directly connected to the router port with cross twisted pair . The key is , When delegating transmission , As long as packets can be transmitted according to Ethernet rules , No matter what kind of equipment it is
The delegation relationship between the router and the switch can also be seen from the packet forwarding target .IP Ethernet is not entrusted to transmit packets to the final destination , Instead, it is transmitted to the next router . Creating MAC Head time , Also from IP
Find the route of the next router in the routing table of IP address , And pass ARP Find out MAC address , Then MAC Address write MAC In the head , This means IP
The delegation of Ethernet is just to transfer the packet to the next router .
When the packet reaches the next router , The next router will re entrust Ethernet to transmit the packet to the next router . As this process is repeated , The package will eventually arrive IP
Destination , That is, the object of communication . Here we have combed the relationship between routers and switches . In short ,IP( Router ) Responsible for the overall process of sending packets to communication objects , The process of transmitting the packet to the next router is controlled by Ethernet ( Switch ) To be responsible .
of course , Ethernet is not the only network , And WLAN , And communication lines connected to the Internet , They and IP
What is the relationship between them ? In fact, just replace Ethernet with WLAN , Internet lines and other communication specifications are OK . in other words , If the connection with the next router is through WLAN , Then entrust WLAN to transmit the packet ; If it is connected through an Internet line , Then delegate it to transfer the packet . In addition to the examples listed here , There are many other types of communication technologies in the world , The relationship between them is the same , It is the communication technology used by the delegation to transmit the packet .
IP It is not responsible for the transmission of packets , Instead, it entrusts various communication technologies to transmit the packet to the next router , Such a design is of great significance , That is, various communication technologies can be flexibly used according to needs , This too IP
The biggest feature of .
IP( Router ) Responsible for the overall process of delivering the package to the communication object , The process of transmitting the packet to the next router is controlled by Ethernet ( Switch ) To be responsible .IP( Router ) Responsible for the overall process of delivering the package to the communication object , The process of transmitting the packet to the next router is controlled by Ethernet ( Switch ) To be responsible .
Technology
Daily Recommendation