Home  >  Article  >  Operation and Maintenance  >  How to realize one-to-one communication in LAN

How to realize one-to-one communication in LAN

齐天大圣
齐天大圣Original
2020-12-09 12:01:143044browse

We know that LAN uses broadcast channels for transmission, and broadcast channels can achieve one-to-many communication. But in reality, one-to-many communication is not always required, so how to perform one-to-one communication between two hosts? This problem is not that simple. We need to consider multiple aspects:

  • How the host transmits the generated information to the channel

  • Multiple hosts share the channel, so how to prevent collisions between messages

  • How to send messages to a specific host

The role of the network adapter (network card)

The network adapter is what we usually call the network card. When the host communicates with the external LAN, it is adapted through the network card. Because the host and network card use parallel transmission, while the network card and LAN home use serial transmission, the network card needs to adapt between the two.

In the ROM (read-only memory) of the network card, write the computer’s hardware address, that is, the MAC address. This MAC address is very important, it is the key to achieving one-to-one communication. We will talk about it later.

CSMA/CD protocol

Because the LAN uses a shared channel, since it is a shared channel, we need to control the first and second sending of the host. A later problem. Because if multiple hosts send information at the same time, confusion will occur. There is a well-known LAN protocol CSMA/CD (Carrier Sense Multiple Access/Collision Detection) that solves this problem.

The protocol is very easy to understand. Let's use an example to illustrate: In a venue, there are some people attending the meeting. There is no moderator at the meeting and everyone can speak freely. However, you can only speak after others have finished speaking and the venue is quiet. If multiple people are speaking at the same time, everyone who speaks at the same time will finish speaking, and then wait for a random time before speaking again if the venue is quiet. It is easy to understand why it is a random time here. If it is a fixed time, people who speak at the same time will still speak at the same time after a while.

One-to-one communication through MAC address

After solving the above problem, let’s look at how one-to-one communication is performed between hosts. As mentioned above, there is a MAC address on the network card. The following is a MAC address

A0-A4-C2-4B-9F-56

It is composed of 48 bits ( 6 bytes), the MAC address of each network card is globally unique. Since it is unique, it can be used for one-to-one communication between hosts.

The basic unit of communication in the local area network is the data frame. When host A in the LAN wants to communicate with another host B in the same LAN, the destination address (B's MAC address) must be written in the header of the data frame sent by A, and then the data frame will be broadcast to the LAN. All hosts, when the network cards of other hosts accept this data frame, check whether its destination address is consistent with its own MAC address, and discard it if it is inconsistent. In this way, a LAN with broadcast characteristics realizes one-to-one communication.

The above is the detailed content of How to realize one-to-one communication in LAN. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn