Computer Network Notes - Data Link Layer

Computer Network Notes - Data Link Layer

3. Data link layer

3.1 Functions of the data link layer

The data link layer provides services to the network layer based on the services provided by the physical layer, that is, improving the original, error-prone physical lines into logically error-free data links, thereby providing high-quality services to the network layer.

3 basic services: connectionless service without confirmation, connectionless service with confirmation and connected service with confirmation.

The main function:

  • Link management: Responsible for the establishment, maintenance and release of data links,Mainly used for connection-oriented services
  • Frame synchronization: The receiver determines the start and end positions of a frame in the received bit stream.
  • Error control: used to make the receiver determine that the data received is the data sent by the sender.
  • Transparent transmission: No matter what bit combination the data is, it should be transmitted on the link.

Frame delimitation : When two hosts transmit information to each other, the network layer packets must be encapsulated into frames and transmitted in frame format. Adding a header and a trailer before and after a piece of data forms a frame. The header and trailer contain a lot of control information. One of the important functions of this information is to determine the boundaries of the frame, that is, frame delimitation.

3.2 Framing

What if there is an error in transmitting the bit stream? Then the entire bit stream must be retransmitted. andThe advantage of framing is that if an error occurs, you only need to send the error frame. This is worth the increase in frame synchronization, frame delimitation, and transparent transmission problems.. Frames cannot be combined arbitrarily and must be understood by the receiver. Therefore, the packets submitted by the network layer need to be assembled into frames according to certain rules.

becauseFrames are transmitted in the smallest unit in the network, so the receiving end must receive the frame correctly,It is necessary to know where the frame starts and ends in the bit stream.= (Because what the receiving end receives is a series of bit streams with headers and tails that cannot be distinguished correctly).The packet (also called IP datagram) is only included in the data part of the frame, so there is no need to add a tail to delimit it.

character counting

A special character is used to indicate the beginning of a frame, and a count field is used to indicate the number of bytes contained in the frame. When the destination host receives the frame, it can know the end bit of the frame and the start bit of the next frame based on the number of bytes provided in this field.

Insert image description here

The number of bytes provided by the count field includes one byte of its own.

Disadvantages: If errors occur in the count field during transmission, the receiver cannot determine the end bit of the transmitted frame, and of course cannot know the start bit of the next frame, making frame synchronization impossible. For this reason, character counting is rarely used.

Head and tail delimiter method for character padding

Bit stuffing head and tail mark method (zero bit stuffing method)

The head and tail mark method of bit filling is to use 01111110 as the start and end mark. It seems that the delimitation is solved, but what if 01111110 appears in the frame data part? Transparent transmission is still a problem.

It is not difficult to find that there are 6 consecutive "1"s in 01111110.As long as the data detects 5 consecutive "1"s, it will immediately insert "0" after them, and the receiver will do the reverse operation of the process, that is, every time it receives 5 consecutive "1"s, it will automatically delete the following ones. "0" to restore the original data.

physical coding violation law

physical coding violation lawUtilize illegal flags encoded on physical media to distinguish the beginning and end of a frame, for example, in Manchester encoding, symbol 1 is encoded as high-low level, symbol 0 is encoded as low-high level, and the high-high and low-low level encoding methods are invalid and can be used respectively. as the start mark and end mark of the frame.

3.3 Error control

3.3.1 Error detection coding

Through certain encoding and decoding,Ability to detect transmission errors during decoding at the receiving end, but cannot correct errors. Common error detection codes include parity check codes and cyclic redundancy codes (CRC) .

parity code

The parity check code is to add a check code after the information code.

  • Odd parity: After adding a check code, the number of 1's in the entire codeword is an odd number. After receiving the data, the receiving end checks the number of 1's in the data.If an odd number of 1s is detected, it is considered that there is no error in the transmission: if an even number of 1s is detected, it means that
    the data has changed during the transmission process and requires retransmission.
  • Even parity: After adding a check code, the number of 1's in the entire codeword is an even number. After receiving the data, the receiving end checks the number of 1's in the data. If an even number of 1's is detected, it is considered that the transmission was not error-free; if an odd number of 1's is detected, it means that the data has changed during the transmission process and requires retransmission. .

It can be seen that when one bit of data in the data changes,It can be detected through parity check, but it is not known which bit is wrong.If two bits of data in the data are changed at the same time, the parity check cannot detect the data error, so its error checking capability is limited.

cyclic redundancy code

Extremely high error detection rate, low overhead, and easy to implement

Important features

  • A polynomial with r detection bits can detect all burst errors less than or equal to r.
  • The probability of an error with length greater than r+1 escaping is 1/2 r .

Assume G(x)=1101 (i.e. r=3), the data to be transmitted is M=101001 (i.e. m=6), write the sent data.

After division operation, we get the quotient Q=110101 and the remainder R=001 (FCS), so the data sent is 101001001 (i.e. M+FCS)

Problem solving skills

  • 0+(-)1=1, 0+(-)0=0, 1+(-)0=1, 1+(-)1=0 (can be simplified asXOR operation, during the division process, some remainders are calculated, all using XOR operations, if they are the same, they will be 0, if they are different, they will be 1.
  • The rule for raising the quotient is to look at the first position of the remainder. If it is 1, the quotient is raised by 1; if it is 0, the quotient is raised by 0.
  • When the number of digits in the partial remainder is less than the number of digits in the divisor, the remainder is the final remainder.

3.3.2 Error correction coding

The receiving end can not only check for errors, but also correct the detected errors.

Hamming code

Also known as Hamming code, it inserts several bits of data into the information field to monitor which bit of data in the codeword has changed.Has one error correction capability.

Assuming that there are k information bits, the length of the entire code is k+r bits; each bit of data has only two states, either 1 or 0. There are r bits of data that can represent 2 r states . If each state represents an error in a code element, and there are k+r code elements, there will be k states to represent it, and there will also be one state to represent the correctness of the data, so 2 r -1 > = Only k+r can check one bit error, that is**2r>=k+r+1**. For example, the information data has 4 bits. From 2 r >=k+r+1, we get r>=3. That is, at least 3 bits of supervision data are needed to detect and correct 1 bit error.

3.4 Flow control and reliable transmission mechanism

3.4.1 Flow control

Control the rate at which the sender sends data so that the receiver has time to receive it.

A basic approach is byThe receiver controls the data flow of the sender. There are two common methods: stop-and-wait flow control and sliding window flow control.

  • Stop-and-wait flow control: The simplest form of flow control. The working principle is that the sender sends a frame, and then waits for the response signal to arrive before sending the next frame: after the receiver receives a frame, it returns a response signal, indicating that the next frame can be received. If the receiver does not return a response, it sends The party must keep waiting.
  • Sliding window flow control:Allow multiple frames to be sent at once. At any time, the sender maintains a set of consecutive sequence numbers of frames that are allowed to be sent, calledSend window. At the same time, the receiver also maintains a set of consecutive sequence numbers of frames that are allowed to be received, calledreceive windowThe upper and lower bounds of the serial numbers of the sending window and the receiving window do not have to be the same, and even the sizes can be different.. Sequence numbers within the sender's window represent frames that have been sent but have not yet been acknowledged, or frames that can be sent . Each time the sender receives an acknowledgment of a frame, the sending window slides forward by one frame.When the send window size reaches the maximum size, the sender will forcefully close the network layer until a free buffer appearsAt the receiving end, only when the transmission sequence number of the received data frame falls within the receiving window, the data frame is allowed to be received and the window is moved forward one position. If the received data frame falls outside the receiving window (that is, the received frame number cannot be found corresponding to the frame number in the receiving window), it will be discarded.

Insert image description here

3.4.2 Reliable transmission mechanism

Designers of computer networks adopt a strategy, which is "end-to-end reliable transmission". More specifically, it uses connection-oriented TCP at the transport layer, which ensures end-to-end reliable transmission. As long as host B's TCP detects an error in data transmission, it tells host A to retransmit the part of the data with the error until this part of the data is correctly transmitted to host B. The probability that TCP cannot detect data errors is very small.It can not only make the network part cheap, flexible and reliable, but also ensure end-to-end reliable transmission.

3.4.3 Sliding window mechanism

Only when the receiving window slides forward (confirmation is also sent at the same time), the sending window may slide forward.

Reliable transmission mechanisms include stop-and-wait protocol, fallback-N protocol and selective retransmission protocol. These three protocols only differ in the size of the sending window and receiving window.

  • Stop-wait protocol: send window size=1, receive window size=1.
  • Backward N frame protocol: sending window size > 1, receiving window size = 1.
  • Select retransmission protocol: sending window size > 1, receiving window size > 1.

When the size of the receive window is 1, it is guaranteed that the frameReceive in order

Because the receiving window is 1, there is a unique sequence number in it. No matter how many bytes the sending window can send at one time, the receiving window only selects the frame sequence number in the receiving window to receive. Only when the frame is reached, the receiving window moves backward, so Frames received in this order must be in order.

3.4.4 Stop-Wait Protocol

How to achieve reliable transmission?

Reliable transmission means that the receiver receives whatever the sender sends.

Reliable transmission method:

  • Acknowledgment (send acknowledgment frame): The acknowledgment frame is a control frame without a data part. It is only used to tell the sender that a certain frame sent by the sender has been received. Sometimes in order to improve transmission efficiency, the confirmation is piggybacked in a reply frame, which is called piggyback confirmation.
  • Timeout retransmission: The sender sets a timeout timer when sending a data frame. If an acknowledgment of the frame is not received within the specified time limit, the data frame will be resent.
    • reason:
      • When the receiver detects an error frame, the receiver directly discards the frame without returning an acknowledgment.
      • The frame was lost during transmission.

The strategy of using two mechanisms, acknowledgment and timeout retransmission, to achieve reliable transmission is also called automatic request retransmission (ARO).

The basic idea of ​​the stop-and-wait protocol: after the sender transmits a frame, it must wait for the other party's confirmation before sending the next frame. If no acknowledgment is received within the specified time, the sender times out and retransmits the original frame.

Protocol = Technology + Consider Disadvantages——>Stop-Wait Protocol = Stop-Wait Flow Control Technology + Disadvantage

Errors that can occur in the stop-wait protocol:

Frames are generally divided intoData frames and acknowledgment frames

  • The first type of error isThe data frame is damaged or lost, then the receiver will detect it when performing error checking. When dealing with data frame corruption, use a timer to solve the problem. In this way, after the sender sends a frame, if the data can be received correctly, the receiver will send a confirmation frame, no problem; if the receiver receives a damaged data frame, it will be discarded directly. The sender is still waiting there, but it doesn't matter, as long astimerAfter timeout, the sender will resend the data frame, and so on, until the data frame is error-free.
  • The second type of error isConfirm that frames are corrupted or lost. Once the confirmation frame is damaged or lost, the consequence is that the sender will continuously resend the frame, causing the receiver to continuously re-receive the frame. How to solve it? Obviously, for the receiver, it needs to be able to distinguish whether a certain frame is a new frame or a repeated frame. The solution is simple, just letThe sender adds a number to the header of each frame to be sent., and the receiver identifies the number of each arriving frame and determines whether it is a new frame or a duplicate frame to be discarded.

3.4.5 Backoff N frames (GBN) protocol

If n bit pairs are used for numbering, their**The sending window size W T must satisfy 1<W≤2 n -1**, the receiving window size is 1. If the sending window size is larger than 2 n -1, it will cause the receiver to be unable to distinguish between new and old data frames. Since the receive window size is 1, the receiver can onlyReceive data frames in order

Basic principle : After the sender sends a piece of data, it does not stop and wait for the confirmation frame, but can send several more data frames continuously. If an acknowledgment frame from the receiver is received at this time, the data frame can then be sent.If an error occurs in a frame, the receiver simply discards the frame and all subsequent frames.. After the sender times out, it needs to resend the error frame and all subsequent frames. Due to the reduced waiting time, the back-off N protocol improves the throughput of the entire communication. However, once the receiver discovers an error frame, it will no longer receive subsequent frames, causing a certain amount of waste.

As long as ACKn is received, it is considered that all the previous n-1 frames must have been received.

3.4.6 Select retransmission (SR) protocol

W T ≤ 2 n-1,W R ≤2 n-1

When the sending window takes the maximum value, W R =W T =2 n-1 (all cases areThe sending window is equal to the receiving window and is equal to 2 n -1 because this achieves maximum efficiency, just remember). at this time,If W T takes a value greater than 2 n-1 , it may cause the new and old receiving windows to overlap.

The basic idea of ​​selecting a retransmission protocol: If an error occurs in a frame, the subsequent frames will be stored in the receiver's buffer first, and the sender will be required to retransmit the error frame. Once the retransmission frame is received, it will be the same as the original buffer. The remaining frames are sent to the host in the correct order . Select =The retransmission protocol avoids repeated transmission of data frames that have arrived at the receiver correctly, further improving channel utilization, but at the cost of increasing buffer space.

3.4.7 Send buffer and receive buffer

Insert image description here

Those that arrive in sequence and are not delivered to the host are placed in the receive buffer (the part of the receive cache outside the receive window, the receive cache mentioned below refers to this part) (because the confirmation has been sent and is just waiting for the host application) program to fetch), rather than inside the receiving window.Those frames that do not arrive in sequence and have no errors must be placed in the receiving window, because these frames cannot be directly given to the host, and the frames placed in the receiving buffer are given to the host. After the missing frames are received, Then put them in the receive cache together

Caching is used extensively during communication between computer processes.A cache is a space set up in the computer's memory to temporarily store data. The sending process first writes the data to be sent into the cache, and then the receiving process reads the data at the appropriate time.

3.5 Media access control

3.5.1 Media access control classification

Media access control is to solve the problem of how to better allocate channel usage rights when competition occurs in the use of shared channels .

  • Channel Division Medium Access Control
  • Random access media access control
  • Polling access media access control

3.5.2 Channel Division Medium Access Control

Multiplexing Technology: YesWays to implement channel division medium access control. Multiplexing technology can combine multiple signals on a physical channel for transmission, allowing multiple computers or terminal devices to share channel resources, thereby improving channel utilization .

Insert image description here

frequency division multiplexing

Split a channel into multiple channels of different frequencies, if the number of multiplexing increases, the bandwidth of the channel must be increased .

The bandwidth allocated to each sub-channel can be different (think of sidewalks and motor vehicle lanes being different widths), but theirThe sum must not exceed the total bandwidth of the channel. In practical applications, in order to prevent interference between sub-channels, "protection bands" should be added between adjacent channels (think of the role of railings between sidewalks and motor vehicle lanes, or motor vehicle lanes and motor vehicle lanes).

time division multiplexing

Suppose there is only one toy, but 10 children want to play with it. At this time, a fixed time can only be divided into 10 parts, and the 10 children take turns playing with this toy, which is multiplexed in real time.

Divide a fixed time into several parts, if the number of multiplexing increases, there is no need to increase the channel bandwidth, just reduce the time obtained by each channel .

If it happens to be a child's turn to play at a certain time, but the child is asleep now, wouldn't this time be wasted? Yes, it is wasted. At this time, time-division multiplexing needs to be improved, so statistics are introduced Time division multiplexing.

If it is a child's turn to play with the toy now, but he also falls asleep, skip him immediately and give it to the next child. This basically ensures that the toy will not have any idle time. It can be seen that the next time each child will have his turn to play is uncertain. If there are many people sleeping, it will be his turn soon; if there are few people sleeping, it will be very slow.

Statistical time division multiplexing is a kind of dynamic time allocation, and it is asynchronous at the same time (the time period for each child to play with toys is not fixed), so statistical time division multiplexing is also called asynchronous time division multiplexing. Ordinary time-division multiplexing is synchronous time-division multiplexing (because each child can get a toy in a fixed period, even if a child sleeps in the middle, he has to wait).

wavelength division multiplexing

Wavelength division multiplexing is frequency division multiplexing of light, multiple signals of different frequencies (lengths) are transmitted in one optical fiber. Since the frequencies (wavelengths) of each light are different, the optical signals of each light do not interfere with each other. Finally, a wavelength splitter is used to decompose light with different wavelengths.

Insert image description here

code division multiplexing

Code division multiplexing is also called code division multiple access (CDMA).It shares both the frequency and time of the channel and is a true dynamic multiplexing technology.

Each site maintains a chip sequence belonging to that site and is fixed. If the chip sequence of station A is 00011011, then station A sends 00011011 to indicate sending bit 1; and inverts each bit of 00011011, that is, sending 11100100 indicates sending bit 0. It is customary to write 0 in the chip sequence as -1 and 1 as +1, so the chip sequence at station A is (-1 -1 -1 +1 +1 -1 +1 +1),This vector is generally called the chip vector of the station

  • The chip vectors of any two different stations are orthogonal, that is, the normalized inner product of the chip vectors of any two stations must be 0.
  • The normalized inner product of the chip vector of any site and the chip vector itself must be 1; the normalized inner product of the chip vector of any site and the inverse code vector of the chip must be -1.
    Insert image description here

Code division multiplexing technology has the advantages of strong anti-interference ability, strong confidentiality, and good voice quality. It can also reduce investment and operating costs., mainly used in wireless communication systems, especially mobile communication systems. CDMA mobile phones use this technology.

3.5.3 Access random media access control

  • Static channel division: As long as a user is assigned a channel, there will be no conflict with other users. However, the cost of this method of dividing channels is quite high. It is really inappropriate to use this method in a small local area network.
  • Dynamically allocate channels
    • Random access: All users can send information randomly according to their own wishes, which will cause conflicts (or collisions), causing all conflicting users to fail to send data. In order to solve the collision that occurs in random access, protocols such as CSMA/CD were introduced.
    • Controlled access: Data cannot be sent randomly. You must get something before you have the right to send data.

Four protocols for random access: ALOHA protocol, CSMA protocol, CSMA/CD protocol, and CSMA/CA protocol.

The above 4 protocolsThe core idea is that through contention, the winner can obtain the channel and thus obtain the right to send information.. Because of this idea, random access media access control has another nickname:contention-based protocol

  • ALOHA Agreement

    • Pure ALOHA protocol: When any node in the network needs to send data, it can send the data without any detection. If no acknowledgment is received within a certain period of time, the node assumes that a collision occurred during transmission. The node in conflict needs to wait for a random period of time before sending data until the transmission is successful.
    • Time-division ALOHA protocol: The time of all nodes is divided into time slots (Slots) with the same interval, and it is stipulated that each node can only send data until the next time slot arrives.
  • CSMA protocol: Each node uses carrier sensing technology to determine whether the communication channel is idle before sending data.

    • 1-Adhere to CSMA:When the sending node detects that the channel is idle, it immediately sends data, otherwise it continues to listen.
    • p-Adhere to CSMA:When the sending node detects that the channel is idle, it sends data with probability p, delays for a period of time with probability 1-p and listens again.
    • Non-persistent CSMA:Once the sending node detects that the channel is idle, it immediately sends data, otherwise it delays for a random period of time and then listens again.
  • CSMA/CD Protocol: Carrier Sense Multiple Access Protocol with Collision Detection

    • Principle: In the CSMA mechanism, there may be multiple nodes that hear the channel is idle and start transmitting data at the same time, causing conflicts. However, even if there is a conflict, the CSMA protocol must finish sending the damaged ones, reducing the bus utilization. An improved solution to CSMA is to continue to monitor the channel during transmission by the sending station to detect whether there is a conflict. If a conflict occurs, the amplitude of the carrier signal that exceeds the carrier signal sent by the sending station itself can be detected on the channel. From this, the existence of the conflict is judged, and then the sending is stopped immediately (postponed for a random time before sending), and a series of messages is sent to the bus. The blocking signal is used to notify other relevant stations on the bus. When each relevant station receives the blocking signal, it will no longer send data.

    • Work flow: Before each station sends data, it must first test whether there are other computers sending data. If so, the data will not be sent temporarily to avoid conflicts; if not, the data will be sent. The computer detects whether there is a conflict on the channel while sending data. If so, it uses a truncated binary exponential backoff algorithm to wait for a random period of time before retransmitting. Generally speaking, it can be summarized as “Listen first and then send, listen and send at the same time, stop sending when conflict occurs, and resend randomly.”。

    • Contention period: Ethernet end-to-end round-trip delay (represented by Insert image description here
      ), also known as the conflict window or collision window. Only when no conflict is detected after the contention period can we be sure that this transmission will not conflict.
      Insert image description here

      The binary exponential backoff algorithm solves the problem of how long a site continues to wait after detecting a conflict.

  • CSMA/CA protocol: CSMA/CA is mainly used in wireless LANs. It is based on CSMAAdded conflict avoidance function. conflict avoidance requirementsEach node listens to the channel before sending data. If the channel is free, data is sent. After sending a frame, the sending node must wait for a period of time (called the interval) to check whether the receiving party sends back a confirmation of the frame (indicating that the CSMA/CA protocol confirms the correctly received data). When a confirmation is received, it indicates that there is no A conflict occurs; no acknowledgment is received within the specified time, indicating that a conflict occurs and the frame is retransmitted.

3.5.4 Polling access media access control

It is mainly used in Token Ring LAN and is rarely used at present.

Users cannot send information randomly, but a centrally controlled monitoring station determines channel allocation after a polling process. A typical polling access media access control protocol is the token passing protocol .

3.6 LAN

3.6.1 Basic concepts and architecture of LAN

Local Area Network (LAN) refers to multiple computers or other communication devices within a small range (such as a company), which are interconnected through twisted pairs, coaxial cables and other connection media to achieve the purpose of sharing resources and information. Internet.

The main characteristics of LAN

  • The local area network is owned by an organization.
  • Limited geographical scope and number of sites.
  • Compared with previous non-fiber wide area networks, LANs have higher data rates, lower delays and smaller bit error rates.

Main advantages of LAN

  • With broadcast function, the entire network can be easily accessed from one site. Hosts on the LAN can share various hardware and software resources connected to the LAN.
  • Facilitating system expansion and evolution, the location of each device can be flexibly adjusted and changed.
  • Improved system reliability and availability.
  • Each station has an equal relationship rather than a master-slave relationship.

Main technical elements of local area network

  • Network topology - determines the technical characteristics of the local area network
  • Transmission media and media access control methods

The main topology of LAN

  • star network
  • ring network
  • bus network
  • tree net

The main transmission medium of LAN

  • twisted pair
  • copper cable
  • optical fiber

Control method of main access medium of local area network

  • CSMA/CD——acting on bus network
  • Token bus - for bus-type networks
  • Token Ring - works on ring networks

3.6.2 How Ethernet works

Ethernet is by far the most successful LAN product in the world.

Ethernet adoptionBus topology, all computers share a bus,Messages are sent as broadcasts. In order to ensure the convenience and reliability of data communication,Ethernet uses CSMA/CD technologyControl access to the bus.

Considering the good quality of the LAN channel, Ethernet has taken the following two important measures to make communication easier.

  • Adopt connectionless working mode.
  • The data frames sent are not numbered, and acknowledgment is not required to be sent to the sender.

The services provided by Ethernet areunreliable service, that is, best-effort delivery, and error correction is completed by TCP at the transport layer.

Ethernet has a retransmission mechanism

3.6.3 Ethernet MAC frame

Each computer in a local area network has a unique number, called MAC address or physical address, hardware address.

Since broadcast communication is used on the bus, every time the network card receives a MAC from the network, it must first use hardware to check the MAC address in the MAC. If it is sent to the local station, it will be accepted, otherwise it will be discarded.

Insert image description here

MAC frame components

  • Preamble: Insert 8B in front of the preamble to synchronize the clocks of the receiving end and the sending end. This 8B can be divided into two parts: preamble (7B) and start delimiter (1B).

    MAC does not require a terminator because when Ethernet transmits frames, there must be a certain gap between them. Therefore, as long as the receiving end finds the frame start delimiter, the subsequent bit streams arriving after it all belong to the same MAC

  • Destination address and source address: both use 48bit (6B) MAC addresses.

    The address field includes two parts: the destination address and the source address. The address field in the front is the destination address, and the address field in the back is the source address.

    The destination address field has more regulations because a frame may be sent to a certain workstation, a group of workstations, or all workstations. Therefore, the latter two cases are calledMulticast frames and broadcast frames

    • When the last digit of the first 8 bits of the destination address is "0", it means that it is to be sent to a certain workstation (this is why the last digit of the first 8 bits of the source address field is always "0"), that is, the so-calledSingle station address
    • When the last digit of the first 8 bits of the destination address is "1" and the rest are not all "1", it means that it is sent to a group of workstations, which is the so-calledmulticast address
    • When the last digit of the first 8 bits of the destination address is "1" and the rest are all "1", it means that it is sent to all workstations, which is the so-calledbroadcast address
  • type:Accounting for 2B, indicating which protocol entity the data carried in the data field should be handed over for processing.

  • data:Accounting for 46~1500B. Where did 46 and 1500 come from? First of all, according to the CSMA/CD algorithm, the shortest frame length of the Ethernet frame is 64B, and the length of the MAC header and tail is 18B, so the shortest data is 64B-18B=46B. Secondly, the maximum 1500B is specified for no reason.

  • Padding: As mentioned before, due to the limitation of the CSMA/CD algorithm, the minimum length is 64B. Therefore, excluding the header 18B, if the data length is less than 46B, then padding is required to make the frame length not less than 64B. When the data field length is less than 46B, it needs to be padded to 46B; when the data field length is greater than or equal to 46B, there is no need to pad. Therefore, the padding data length ranges from0~46B

  • Check code (FCS):Accounting for 4BUse cyclic remainder codeNot only the data part of the MAC needs to be verified, but also the destination address, source address and type field, but the preamble is not verified.

The differences between the 802.3 format and the DIX Ethernet frame format:

  1. Frame start flag: Compatible with 802. and 802.5.
  2. Length field: replaces the type field in DIX and indicates the length of the data field.

3.6.4 Ethernet transmission media

Insert image description here

3.6.5 Fast Ethernet

Generally, Ethernet whose data transmission rate reaches or exceeds 100Mbit/s is called high-speed Ethernet.

  • 100Base-T Ethernet (Fast Ethernet): A star topology Ethernet that transmits 100Mbit/s baseband signals on twisted pairs, using the CSMA/CD protocol.Work in full duplex modeIf no conflict occurs, there is no need to use the CSMA/CD protocol at this time.Work in half-duplex modeThe CSMA/CD protocol still needs to be used.
    • In order to increase the data transmission rate, 100Base-T Ethernet keeps the shortest frame length unchanged, but reduces the maximum cable length of a network segment to 100m, and the inter-frame time interval is changed from the original 9.6ms to the current 0.96ms.
  • Gigabit Ethernet (Gigabit Ethernet): When Gigabit Ethernet works in half-duplex mode, the CSMA/CD protocol must be used for conflict detection.
    • Allows to work in both full-duplex and half-duplex modes at 1Gbit/s
    • Use the CSMA/CD protocol in half-duplex mode (the CSMA/CD protocol is not required in full-duplex mode).
    • If you want to increase the data transmission rate, you can only reduce the maximum cable length or increase the minimum frame length, so that the channel utilization rate is relatively high.
  • 10 Gigabit Ethernet
    • The Ethernet format, minimum frame length, and maximum frame length specified by the IEEE 802.3 standard are retained for easy upgrade.
    • Copper wires are no longer used and only fiber optics are used as the transmission medium.
    • Only works in full-duplex mode, so there are no contention issues and the CSMA/CD protocol is not used.

Characteristics of Ethernet

  • Scalable (10Mbit/s~10Gbit/s).
  • Flexible (multiple transmission media, full/half duplex, sharing/switching).
  • Easy to install.
  • Good robustness.

3.6.6 Wireless LAN

IEEE 802.11 is the protocol standard for wireless LAN, including IEEE 802.11a and IEEE 802.11b.

The composition of wireless LAN

  • Have fixed infrastructure
    • The minimum component is the Basic Service Set (BSS)
    • A basic service set includes a base station and several mobile stations. All stations can communicate directly within the BSS, but must pass through the base station of the BSS when communicating with stations outside the BSS. Therefore, the base station in the BSS is called an access point (AP).
    • A basic service set can be isolated, or it can be connected to a backbone distribution system (Distribution System, DS) through an access point, and then connected to another basic service set to form an extended service set (ESS) .
  • No fixed infrastructure (autonomous network)
    • The autonomous network does not have a centralized access point for the above-mentioned basic services, but is a temporary network composed of some mobile stations in an equal state communicating with each other. These mobile stations all have the function of routers.

Physical layer in the IEEE 802.11 standard

The physical layer in the IEEE802.11 standard has the following three implementation methods.

  • Frequency Hopping Spread Spectrum (FHSS)
  • Direct sequence spread spectrum (DSS).
  • Infrared (IR)

MAC layer in IEEE802.11 standard

The MAC layer is above the physical layer and includes two sub-layers, from bottom to top:

  • Distributed Coordination Function (DCF)
  • Point Coordination Function (PCF) sublayer.

Since it is too expensive to use the CSMA/CD protocol to detect conflicts in wireless LANs, and conflicts may still occur after conflict detection indicates that the channel is idle, the CSMA/CA protocol with collision avoidance function is used in the MAC layer of the wireless LAN. , and also added a confirmation mechanism.

3.6.7 How Token Network works

Insert image description here

In Token Ring, nodes are connected into a physical ring through ring interfaces. The token is a special MAC control frame with a token token (free/busy) in the frame. Tokens are always transmitted station by station in one direction along the physical ring,The order of transmission is the same as the order in which the nodes are arranged in the ring.

The transfer process of tokens and data in the Token Ring network:

  • When the network is idle, only tokens are passed around the network in the loop.
  • The token is passed to the node that has data to send, and the node modifies a flag bit in the token, and then appends the data it needs to transmit to the token, so thatConverted the token into a data frame, the source node sends this data frame.
  • The data frame is passed along the ring, and the receiving node forwards the data while checking the destination address of the frame. If the destination address is the same as its own address, the receiving node copies the data frame for further processing.
  • The data frame is transmitted along the ring until it reaches the source node of the frame. The source node receives the data frame sent by itself and no longer forwards it. At the same time, the source node can check the returned data frame to see if there are any errors during the data transmission. If there are errors, retransmit the frame.
  • After the source node completes transmitting the data, it regenerates a token and passes the token to the next site to surrender the authority to send data frames.

3.7 WAN

3.7.1 Basic concepts of WAN

Refers to a long-distance network that covers a wide area (far beyond the scope of a city).A WAN consists of node switches and the links connecting these switches. The node switch will complete the function of packet storage and forwarding

internetAlthough the coverage is also very wide, it is generally not called a wide area network. Because in this kind of network, the "interconnection" of different networks (which can be local area networks or wide area networks) is its most important feature.Usually connected using a router

A WAN is just a single network,itConnect using a node switchEach hostNot using a routerConnect to various networks.

Insert image description here

The protocols used by LAN are mainly at the data link layer, while the protocols used by WAN are mainly at the network layer.

3.7.2 PPP

Insert image description here

PPP mainly consists of the following three parts:

  • A method of encapsulating IP datagrams onto a serial link.

  • A Link Control Protocol (LCP). It is used to establish, configure and test data link connections and release them when no longer needed.

  • A set of Network Control Protocols (NCP). Each protocol supports different network layer protocols and is used to establish and configure different network layer protocols.

  • Flag field (F): The header and tail each occupy 1 byte, specified as Ox7E.

  • Address field (A): occupies 1 byte, specified as 0xFF.

  • Control field (C): occupies 1 byte, specified as Ox03.

  • Protocol field: 2 bytes. For example, when the protocol field is 0x0021, the PPP information field is the IP datagram: if it is 0xC021, the information field is PPP link control data: if it is 0x8021, it means that this is network control data
    .

  • Information part: 0-1500 bytes. Why not 46~1500 bytes? BecausePPP is point-to-point, not bus type,soThere is no need to adopt the CSMA/CD protocol, and naturally there is no shortest. In addition, when the same bit combination as the flag bit appears in the data part, some measures need to be taken to achieve transparent transmission (byte stuffing method).

  • Check sequence (FCS): occupies 2 bytes, which is the remainder code in the cyclic remainder code check. The verification interval includes address field, control field, protocol field and information field.

Summarize:

  • PPP is a byte-oriented protocol.
  • Functions not required by PPP: error correction (PPP is only responsible for error detection), flow control (responsible by TCP), sequence number (PPP is an unreliable transmission protocol, so frames do not need to be numbered.), multipoint lines (PPP is a point-to-point communication method), half-duplex or simplex (PPP only supports full-duplex links)。

3.7.3 HDLC protocol

Basic Features:

  • Bit-oriented.
  • Two basic configurations apply to links: unbalanced and balanced.
    • The characteristic of unbalanced configuration is that one master station controls the operation of the entire link.
    • The characteristic of balanced configuration is that the two stations at both ends of the link are composite stations. Each composite station can initiate data transmission equally without the permission of the other composite station.

Insert image description here

  • Flag field (F): 8 bits, "01111110", with a "0" at the beginning and end as the frame boundary. To prevent "01111110" between two flag fields F, HDLC usesBit stuffing head and tail marking method. When no control information is added to a bit stream, the entire frame is scanned, and as long as 5 consecutive "1"s are found, a "0" is immediately filled in.
  • Address field (A): 8 bits. If the unbalanced mode is used to transmit data, it is the address of the secondary station; if the balanced mode is used to transmit data, it is the address of the confirmation station. All "1" means broadcast mode, all "0" means invalid address.
  • Control field ©: occupies 8 bits,The most complex field,Many important functions of HDLC are implemented by ,control fields. According to the value of the first two digits, HDLC can be divided into three categories: information frames (I frames), supervision frames (S frames) and unnumbered frames (U frames).
    • Information frames are used to transmit data information, or use piggyback technology to confirm and respond to data.
    • Supervisory frames are used for flow control and error control, and perform functions such as acknowledging information frames, requesting retransmission, and requesting suspension of transmission.
    • Unnumbered frames are used to provide link establishment, teardown, and various control functions.
  • Information field (Info): Any length, storing protocol data units from the network layer.
  • Frame check sequence (FCS): occupies 16 bits, which is the remainder code in the cyclic remainder code check. The test interval includes address fields, control fields and information fields.

The difference between PPP frames and HDLC protocol frames

  • PPP is byte-oriented, and HDLC protocol is bit-oriented.
  • PPP uses byte stuffing, HDLC uses bit stuffing
  • PPP protocol frames have one more protocol field than HDLC protocol frames.
  • PPP does not apply sequence numbers and confirmation mechanisms and only ensures error-free reception. HDLC uses numbering and confirmation mechanisms.

3.8 Data link layer equipment

3.8.1 Concept and basic principles of network bridge

Extending the LAN at the physical layer uses repeaters and hubs.

The disadvantages are as follows:

  • The collision domain is enlarged without improving the overall throughput.
  • Cannot interconnect LANs using different Ethernet technologies

Extending the LAN at the data link layer uses bridges

The bridge works at the data link layer, and itsFeatures the function of filtering frames. A network bridge has at least two ports, and each port is connected to a network segment. Each time the bridge receives a frame from a port, it is temporarily stored in the cache. If there is no error in the frame and the MAC address of the destination station to which it is sent belongs to another network segment (The same network segment does not need to be forwarded and should be discarded.),butBy looking up the forwarding table, send the frame from the corresponding port. Therefore, frames communicated only in the same network segment will not be forwarded by the bridge to another network segment, thus not increasing the burden on the entire network.

Insert image description here

Advantages of bridges:

  • Filter traffic.
  • Expanded physical range.
  • Improved reliability.
  • It can interconnect Ethernet networks with different physical layers, different MAC sublayers and different rates (such as 10Mbit/s and 100Mbit/s).

Disadvantages of bridges:

  • Store-and-forward increases latency.
  • There is no flow control function in the MAC sublayer.
  • Latency is greater when network segments with different MAC sublayers are bridged together.
  • Network bridges are only suitable for LANs with a small number of users (no more than a few hundred) and a small amount of traffic. Otherwise, network congestion, that is, a broadcast storm, may sometimes occur due to the spread of too much broadcast information.

3.8.2 Classification of network bridges

  • Transparent Bridge (The route chosen is not the best one

    "Transparent" means that sites on the local area network do notIt is not known which bridges the frame sent will pass through, because the bridges are invisible to each station.. The transparent bridge is a plug-and-play device, which means that as long as the bridge is connected to the LAN, the bridge can start working without manual configuration of the forwarding table.

    • How does the bridge learn on its own?

      • After receiving a frame, the bridge firstself-studyLook for an entry in the forwarding table that matches the source address of the received frame. If not, add an item (source address, entry interface and time) to the forwarding table; if so, update the original item.
      • forward frame. Check whether there is an entry in the forwarding table that matches the destination address of the received frame.If not, forward through all other interfaces except the interface entering the bridgeIf so, forward according to the interface given in the forwarding table., if the interface given in the forwarding table is the interface through which the frame enters the bridge, the frame should be discarded (because it does not need to be forwarded through the bridge at this time).
  • Source routing bridge (selects the best route)

    In a source routing bridge, the source station that sends the data frame is responsible for route selection, and the bridge only receives and forwards the frame based on the routing information in the data frame.

    In order to discover the appropriate route,The source station first sends a transmission frame to the destination station to communicate in broadcast mode. The sent frame will be transmitted along all possible routes throughout the LAN and the routes taken will be recorded. When the sent frame reaches the destination station, it returns to the source station along the original path. After the source station learns these routes, it selects the best route from all possible routes.

    In addition to determining the best route, sending frames can also be used to determine the maximum length of frames that can pass through the entire network .

    The best route mentioned in transparent bridges and source routing bridges is not necessarily the route that passes through the fewest routers, but can also be the route with the shortest round-trip time for sending frames, so that load balancing can be truly achieved. Because the round trip time is long, it means that one of the routers in the middle may be overloaded, so instead of taking this route, take another route with a shorter round trip time.

    3.8.3 LAN switch and its working principle

    A LAN switch is essentially a multi-port bridge that works at the data link layer. Each port of a LAN switch is directly connected to the host or hub, and generally works in full-duplex mode. When a host needs to communicate, the switch can connect many pairs of ports at the same time, so that each pair of hosts communicating with each other can transmit data without conflict as if it were an exclusive communication medium, and disconnect after the communication is completed.

Calculation method of total switch capacity :

  • Number of ports x bandwidth per port (half duplex).
  • Number of ports x bandwidth per port x2 (full duplex).

Two switching modes of the switch:

  • Cut-through switching:Only check the destination address of the frame, which allows the frame to be forwarded immediately after being received. This method is fast, but lacks security and cannot support switching of ports with different speeds.
  • Store-and-forward switching: First store the received frame in the cache and check whether the data is correct. After confirming that it is correct, search the forwarding table and forward the frame from the queried port. If the frame is found to have errors, it is discarded. The advantage of store-and-forward switching is that it has high reliability and can support conversion between ports with different speeds. The disadvantage is that it has a large delay.
  • Fragment-free forwarding: The switch forwards the datagram after getting the first 64 bytes. For datagrams smaller than 64 bytes, the switch considers them to be fragments and does not forward them. . This method not only avoids the problem of slow storage and forwarding speed, but also avoids the problem of fragmentation in cut-through forwarding.

How a LAN switch works

Similar to a bridge, it detects the source MAC address and destination MAC address of frames entering the switch from a certain port, and then compares them with the dynamic lookup table within the system. If the MAC address of the datagram is not in the lookup table, the address is added to the lookup table. table and send the datagram to the corresponding destination port.

3.8.4 Broadcast domain, collision domain and summary of equipment at each layer

When a network card sends information, as long as it may conflict with another network card, these possibly conflicting network cards constitute a conflict domain.

A network card sends a broadcast, and the set of all network cards that can receive the broadcast is called a broadcast domain.

Generally speaking, a network segment is a collision domain, and a LAN is a broadcast domain.

Physical layer equipment

  • Repeater: Reorganizes the attenuated and incomplete signals to regenerate complete signals before continuing transmission.Amplifiers and repeaters both amplify signals, but amplifiers amplify analog signals, while repeaters amplify digital signals.
  • Hub: A repeater is the predecessor of an ordinary hub. A hub is actually a multi-port repeater.

Data link layer equipment

  • Switch: A switch is also called a switching hub. It regenerates information and forwards it to designated ports after internal processing. It has automatic addressing capabilities and switching functions. Because the switch independently sends each datagram from the source port to the destination port according to the destination address of the transmitted datagram, collisions with other ports are avoided. To put it simply, if a host connected to a certain port of the switch wants to communicate with a host connected to another port, the switch will send it to that port through the forwarding table. It is impossible to go to other ports. There is no wrong port (wrong call), so Each port of the switch is a collision domain, that is,Switches can isolate conflict domains.

Insert image description here

Network layer equipment

  • Router: A router sends data from one network to another.

    Conflict domains can be isolated
    Insert image description here

Guess you like

Origin blog.csdn.net/pipihan21/article/details/129493068