Data link layer: broadcast communication

Data link layer (3 messages) Computer network data link layer_Put on straw sandals to travel blog-CSDN blog

Table of contents

1. Data link layer of local area network

2. CSMA/CD Agreement

3. Ethernet channel utilization

4. MAC layer of Ethernet

        1.Hardware address of MAC layer

        2. There are three types of frames received by the adapter in the LAN:

        3.Frame format of MAC layer


The broadcast channel can carry out one-to-many communication, and the local area network uses the broadcast channel. Local area networks can be classified according to their topology.

1. Data link layer of local area network

        The main characteristics of a local area network: the network is owned by one unit, and the geographical scope and number of sites are limited. Advantages of LAN: 1. With broadcast function, the entire network can be easily accessed from one site. 2. Hosts on the LAN can share various hardware and software resources connected to the LAN. 3. Facilitate the expansion and gradual evolution of the system and improve the reliability, availability and survivability of the system. Ethernet is a type of local area network, and most local area networks are Ethernet. Twisted pair is the mainstream transmission media in local area networks.

        There are two ways to implement a shared channel:

        1. Static division of channels, such as frequency division multiplexing, time division multiplexing, code division multiplexing, etc., but is not suitable for local area networks.

        2. Dynamic media access control, also known as multi-point access. The characteristic is that the channel is not fixedly allocated to the user when the user communicates. Random access : The feature is that users can send messages randomly. If two users send at the same time, there will be a collision on the shared media and the sending will fail. At this time, the conflicting network protocol needs to be resolved, namely the CSMA/CD protocol. Controlled access : The characteristic is that users cannot send information randomly but must obey certain controls. The main application of Ethernet is random access . For historical reasons, the Ethernet layer is split into two sub-layers: Logical Link Control LLC and Media Access Control MAC. Now LLC has basically disappeared, mainly MAC protocol.

        The role of the adapter : The connection between the computer and the external LAN is through the adapter, which was also called the network card before. The communication between the adapter and the LAN is carried out in serial transmission through cables or twisted pairs, while the communication between the adapter and the computer is transmitted in parallel through the I/O bus, so an important function of the adapter is to carry out data serialization . Conversion between transmission and parallel transmission . The functions implemented by the adapter include functions at two levels: data link layer and physical layer. After the adapter receives the correct frame, it uses an interrupt to notify the computer and delivers the data to the network layer in the protocol stack. When the computer wants to send an IP datagram, the protocol stack hands the packet to the adapter, which assembles it into a frame and sends it to the LAN. ( Functions such as encapsulation, transparent transmission, error detection, etc. are all completed by the adapter ) The computer's hardware address is stored in the adapter, and the software address-IP address is stored in the computer.

2. CSMA/CD Agreement

        Computers on a local area network are often called workstations, sites, etc. In order to simplify communication, Ethernet has adopted the following two measures: 1. Adopt a more flexible connectionless working mode, that is, data can be sent directly without establishing a connection . The adapter does not number the data frames it sends, nor does it require the other party to send back an acknowledgment. What it provides is best-effort delivery, which is unreliable delivery. It is decided by the higher layer whether to retransmit the error frame. Only one computer can send data at the same time. If a conflict occurs, the CSMA/CD protocol is used to coordinate. 2. The data sent by Ethernet uses Manchester encoding .

        Key Points of the CSMA/CD Agreement

  1. Multi-point access: Multi-point access refers to a bus network, in which many computers are connected to a bus in a multi-point access manner. The essence of the protocol is carrier monitoring and collision detection.
  2. Carrier Sense: The use of electronic technology to detect whether other computers on the channel are also transmitting. Whether before sending or during sending, each station must constantly detect the channel.
  3. Collision detection: listening while sending. If several stations send data at the same time, the signal voltage change on the bus will increase, indicating a collision. At this time, the sending will be stopped immediately.

        When using the CSMA/CD protocol, you cannot send and receive at the same time, so Ethernet using the CSMA/CD protocol can only perform half-duplex communication (two-way alternating communication). The collision occurs because of the propagation delay. A sends the data but before it reaches B, B does not know that someone has sent the data. When A and B send data at the same time and a collision occurs, they both fail to send data and have to postpone it for a while and resend it. Because it is not known whether a collision will occur, there is transmission uncertainty in Ethernet. It takes up to 2θ time after A sends the data to know whether there is a collision. This 2θ time is called the contention period. If there is no collision after the contention period, the transmission is successful . If a collision occurs, Ethernet uses a truncated two-exponential backoff algorithm to determine when to retransmit after a collision. Ethernet stipulates the length of the contention period, which restricts the geographical scope of Ethernet to not be too large, otherwise the propagation delay will exceed the contention period limit. Ethernet stipulates that the shortest frame length is 64 bytes (the number of bytes that can be sent during a contention period) . If a collision occurs during the contention period, transmission will stop. Therefore, frames with a length less than 64 bytes on the channel are invalid frames. After the collision, in addition to immediately stopping sending data, an artificial interference signal is also continued to be sent to inform all users that a collision has now occurred. Ethernet also specifies a minimum interval of 96 bits between frames. This is to enable the stack that has just received the data frame to clear the cache and prepare to receive the next frame.

        Ethernet uses a truncated binary exponential backoff algorithm to determine  when to retransmit after a collision. The truncated binary exponential backoff algorithm is not complex. This algorithm allows the station that collided stop sending data , instead of waiting for the channel to become idle before sending data again immediately, it backs off for a random time.    

        In order to minimize the probability of another collision during retransmission, the backoff algorithm has the following specific provisions:

        (1) The basic backoff time is the contention period 2 t, and   the specific contention period time is 51.2   μ  s . For 10  Mbit /s  Ethernet,  512 bits, or 64 bytes, can be sent during the contention period. It can also be said that the contention period is 512  bit times.  1   bit time  is the time required to send 1 bit. So this unit of time is closely related to the data rate. For convenience, bits can also be used directly as the unit of contention period.  The contention period is 512 bits, that is, the contention period is the time required to send 512 bits. 

        (2) Randomly pick out a number from   the discrete integer set [0,1,…,(2⁴ -1)], recorded as r. The time that retransmission should be postponed is r times the contention period . The above parameter k  is calculated according to the following formula:

k=Min  [Number of retransmissions, 10]                      

It can be seen that when the number of retransmissions does not exceed 10, the parameter k  is equal to the number of retransmissions; but when the number of retransmissions exceeds 10,  k  does not increase and remains equal to 10. 

        (3) When the retransmission  fails 16 times (this indicates that there are too many stations intending to send data at the same time, resulting in continuous  collisions), the frame is discarded and reported to the higher layer.

        Summary of the key points of the CSMA/CD agreement

  1. Prepare to send: The adapter obtains a packet from the network layer, adds a header and a trailer to form an Ethernet frame, and puts it into the adapter buffer. Detect the channel before sending.
  2. Detect the channel: If the channel is detected to be busy, it will continue to detect until the channel is idle. If idle is detected and remains idle within 96 bits (the minimum interval between frames is guaranteed), this frame is sent.
  3. The detection continues during the sending process, that is, the adapter needs to listen while sending. There are two situations at this time
    1. Sent successfully: No collision was detected during the contention period. Returns to 1 after successful sending.
    2. Transmission failure: If a collision is detected during the contention period, transmission will be stopped immediately and artificial interference signals will be sent as required. The adapter then performs an exponential backoff algorithm, waiting enough time to return to 2. If the retransmission is still unsuccessful after 16 times, the retransmission will be stopped and an error will be reported.

        After Ethernet sends a frame, it must retain the sent frame. If a collision is detected during the contention period, retransmission will be delayed for a period of time.

        Star topology using hubs Today's Ethernet uses a star topology, using a very high-reliability hub in the star center. Each station uses two pairs of twisted pairs, respectively for sending and receiving .

        Hub features:

  1. On the surface, a LAN using a hub is physically a star network, but logically it is still a bus network. Each station shares the logical bus and still uses the CSMA/CD protocol.
  2. A hub has many interfaces, like a multi-interface repeater.
  3. The hub works at the physical layer, and each interface is only responsible for forwarding bits and does not perform collision detection.

3. Ethernet channel utilization

        Because collisions waste channel resources, the channel utilization rate of Ethernet cannot reach 100%. Reducing the end-to-end propagation delay can improve channel utilization. Therefore, the length of the Ethernet connection cannot be too long, and the length of the Ethernet frame cannot be too short.

 

 

4. MAC layer of Ethernet

        1.Hardware address of MAC layer

                In LAN, the hardware address is also called MAC address. IEEE specifies a 6-byte global address for LAN, which is the address fixed in the adapter of every computer on the LAN. Therefore, if a new adapter is replaced, the hardware address will also change. The identifier EUI-48 on the adapter is the computer's hardware address. When a router is connected to a LAN through an adapter, the hardware address on the adapter identifies an interface on the router. If the router is connected to multiple networks at the same time, multiple adapters with multiple hardware addresses are required.

        2. There are three types of frames received by the adapter in the LAN:

                1. Unicast frame (one-to-one): that is, the MAC address of the received frame is the same as the address of this station.

                2. Broadcast frame (a pair of all).

                3. Multicast frames (one-to-many).

                The adapter can recognize at least the first two types of frames. Ethernet adapters work in a special way: promiscuous mode. The promiscuous mode adapter will quietly receive the frame as long as it "hears" it and then transmits it . The hybrid method can be used to monitor and analyze traffic on the Ethernet. Hackers also use hybrid methods to illegally obtain information.

        3.Frame format of MAC layer

                The most commonly used MAC frame format is the "Ethernet V2 standard", in addition to the IEEE 802.3 standard. The header of the MAC frame has three fields: the source address field, the destination address field, and the type field used to identify the protocol used by the upper layer. There is a frame check sequence FCS at the end . MAC frames have no frame delimiter and no frame length field. Because it uses Manchester code, there is a voltage jump in the middle of the symbols of Manchester code. When the sender finishes sending a frame, it stops sending symbols. This is when the receiver finds that there is no jump and knows that the frame is over. When the MAC frame is transmitted down to the physical layer, 8 bytes are inserted in front of the frame, including a preamble and a frame start delimiter. The preamble is used to notify the receiving end to adjust the clock frequency to synchronize with the sending end's clock. The minimum length of a MAC frame is 64 bytes, of which the minimum length of the data field is 46 bytes. If it's not enough, fill it up. There is a "total length" field in the header of the IP datagram, which is used by the network layer to identify the length of the padding field and discard it.

Guess you like

Origin blog.csdn.net/qq_63032911/article/details/130539429