Important content of this chapter
- 1) Characteristics of data link layer point-to-point channel and broadcast channel and characteristics of protocols used by these two channels
- 2) Three basic problems of data link layer: frame encapsulation, transparent transmission and error detection
- 3) Hardware address of Ethernet MAC layer
- 4) Functions and applications of adapters, transponders, hubs, Bridges and Ethernet switches
(3.0) Channel model
The data link layer uses two main channels:
(1) Point-to-point channel: one-to-one point-to-point communication mode is used. (2) Broadcast channel: one-to-many broadcast communication mode is used, which is relatively complicated. There are many hosts connected on the broadcast channel, so a dedicated shared channel protocol must be used to coordinate the data transmission of these hosts.
This chapter focuses on how packets are transferred from one host to another (without a router) on the same LAN – is this a data link layer
The data link layer is only concerned with the flow of data at the link layer:
H1 and H2TA all have a complete five-layer protocol stack, but the router only uses the following three layers when forwarding. Data is continuously transmitted up and down in R1, R2 and R3 (the network layer records the address of the next station). However, when studying data transmission at the link layer, we only care about the data link layer in the horizontal direction of the protocol stack.
(3.1) Data link layer using point-to-point channel
(3.1.1) Data links and frames
(1) link
Links and data links are not the same thing!
1. Link: Also known as a physical link, a physical line (wired/wireless) from one node to its neighbors without any switching nodes in between. Data link: Also called logical link, communication protocol + physical channel
(The most common approach today is to use adapters (network cards) to implement the hardware and software of these protocols); Generally, adapters include the data link layer and the physical layer.
(2) frames
Frame, the protocol data unit of the data link layer of a point-to-point channel
A,The data link layer encapsulates the packets of the network layer into frames (which are delivered to the physical layer) and sends them to the link. And received (from the physical)frameThe IP datagram is taken out and delivered to the network layer.
twoThe data link layer does not have to consider the details of how the physical layer realizes bit transmission. It is even simpler to think of frames as being sent directly to each other horizontally between two data link layers.
(3.1.2) Three basic questions
There are many protocols at the data link layer, but there are three basic problems in common!
Packaging into frames, transparent transmission, error control
① Encapsulate into frames
Framing: Framing a piece of data by adding a header and a tail.
One important function of headers and tails is frame delimiting (determining the start and end of frames).
In addition, a lot of control information must be added to the head and tail. The link layer protocol defines the upper limit of the length of the data part of the frame that can be transmitted, and the Maximum Transfer Unit (MTU).
Special frame delimiters can be used when the data is a text file consisting of printable ASCII codes
The control character SOH (Start Of Header) is placed at the beginning Of a frame, indicating the Start Of the frame. End Of Transmission (EOT) indicates the End Of a frame.
② Transparent transmission
First, the problem occurs: If the data part of the frame contains the same content as SOH and EOT, the start and end positions of the frame will be judged incorrectly.
If what needs to be transmitted happens to be an escape character, then an escape character is added in front of the escape character, and the original data can be restored after processing by the receiver. This process transparently transfers escaped characters that the user is unaware of.
Two, solution: byte stuffing or character stuffing
The data link layer at the sending end inserts an escape character “ESC” (whose hexadecimal code is 1B) before the occurrence of the control character “SOH” or “EOT” in the data.
The data link layer at the receiving end removes the inserted escape character before sending the data to the network layer.
If the escape character is also present in the data, an escape character ESC should be inserted before the escape character. When the receiver receives two consecutive escape characters, it deletes the first one of them.
③ Error detection
The real link is not ideal, and bit errors may occur during transmission:
1 –> 0/0 –> 1
In a period of time, the ratio of the wrong bits to the total number of transmitted bits is called Bit Error Rate (BER). In order to ensure the reliability of data transmission, various Error detection measures must be adopted when the data is transmitted on the computer network.
(1) Cyclic redundancy test
The error detection technology of Cyclic Redundancy Check (CRC) is widely used in frames transmitted in the data link layer.
Detection object: the data part of each data frame. Therefore, it has no detection function for frame repetition, disorder and loss
At the sending end, the data is first divided into groups. Let’s say we have k bits per group.
Suppose the set of data to be transmitted is M = 101001 (now k = 6). We add n bit redundancy code for error detection after M and send it together.
The operation of 2^n by M using binary modulo 2 is equivalent to adding n zeros after M (n bits to the left). The resulting number of (k + n) bits divided by the pre-selected divisor P of length (n+1) bits gives the quotient Q and the remainder R, which is 1 bit less than the divisor P, that is, R is n bits. The remainder R is concatenated after the data M as a redundancy code.
Example:
Now k = 6, M = 101001, let n = 3, divisor P = 1101, dividend 2^nM = 101001000. The result of modulus 2 operation is: quotient Q = 110101, remainder R = 001. Send the remainder R after the data M as a redundancy code. The actual data sent is: 2^nM + R. That is, 101001001, consisting of (K + N) bits. Note: In the subtraction process, do not borrow.
The PPP protocol (3.2)
High level Data Link Control (HDLC) used to be a popular Data Link layer Protocol. For point-to-point links, the most widely used Data Link layer Protocol is point-to-point Protocol (PPP).
(3.2.1) Characteristics of PPP
When users use dial-up phone lines to access the Internet, Internet users usually need to connect to an ISP before accessing the Internet. PPP is a data link layer protocol used by users’ computers to communicate with AN ISP.
① The demand that THE PPP agreement should meet
p73 – p74
② Composition of PPP protocol
The PPP protocol has three components:
(1) A method to encapsulate IP datagrams into serial links. (2) A Link Control Protocol (LCP) It is used to establish, configure, and test data links. (3) A set of Network Control Protocol (NCP). Each of these protocols supports a different network layer protocol
(3.2.2) Frame format of PPP protocol
① The meaning of each field
A PPP frame consists of four fields at the beginning and two fields at the end.
- The flag field F(flag) = 0x7E (the symbol “0x” indicates that the following character is represented in hexadecimal, and the binary representation of the hexadecimal 7E is 01111110)
- Address field A(address) is only set to 0xFF. The address field doesn’t actually work.
- Control field C(control) is usually set to 0x03.
- Protocol field:
PPP is byte-oriented, and all PPP frames are integer bytes in length.
Attached: PPP protocol transparent transmission problem
Like data transmitted over a channel, PPP addresses the issue of transparent transmission to ensure frame demarcation.
- When PPP is used on a synchronous transport link, the protocol specifies the hardware to do the bit filling (as HDLC does).
- If the information field is a character stream, a special character padding method is used when PPP is used for asynchronous transmission
② Byte fill
When the combination of bits (0x7E) that is the same as the marker field appears in the information field, the data part can be completely transmitted to the receiver by means of byte filling. The filling methods are as follows:
- Convert each 0x7E byte present in the information field to a 2-byte sequence (0x7D, 0x5E)
- If a 0x7D byte is present in the information field (that is, the same combination of bits as the escape character is present), it is converted to a 2-byte sequence (0x7D, 0x5D)
- If an ASCII control character (that is, a character with a value less than 0x20) is present in the information field, a 0x7D byte is added before the character and the encoding of the character is changed
③ Zero bit filling
PPP, when used on SONET/SDH links, uses synchronous transmission (a series of bits transmitted continuously). Then PPP protocol uses zero-bit filling method to realize transparent transmission.
Specific practices:
- At the sending end, whenever five consecutive ones are found, one is immediately filled in
0
. - The receiver scans the bit stream in the frame and finds five consecutive bits each time
1
, delete the zeros after the five consecutive ones
P.S. PPP does not provide reliable transmission using serial numbers and acknowledgements
- When the probability of errors at the data link layer is small, PPP is a relatively simple protocol.
- In the Internet context, the PPP information field puts the data into the IP datagram. Reliable transmission at the data link layer does not guarantee reliable transmission at the network layer.
- PPP protocol only realizes error-free acceptance, and FCS field of frame check sequence can guarantee error-free acceptance.
(3.2.3) Working status of PPP protocol (optional)
The user dials up to the ISP. The end machine sends a series of LCP packets to the ISP. The end machine configures the network layerCopy the code
- When a user dials into an ISP, the router’s modem confirms the call and establishes a physical connection.
- The PC sends a series of LCP packets (encapsulated into multiple PPP frames) to the router.
- These packets and their responses select some PPP parameters and perform network layer configuration. NCP assigns a temporary IP address to the newly connected PC, making the PC a host on the Internet.
- When the communication is complete, NCP releases the network layer connection and takes back the original IP address. Next, LCP releases the data link layer connection. Finally, the physical layer connections are released.
Therefore, PPP protocol is not a pure data link layer protocol, it also includes the physical layer and network layer content.
(3.3) Using the data link layer of broadcast communication
(3.3.1) The data link layer of the LAN
Point-to-point channels are generally used for wide area networks, while lans generally use the data link layer of broadcast channels.
From the network topology, it can be seen that many computers in the LAN are connected to the Internet through the shared channel, and the shared channel should focus on a problem, how to make many users can reasonably and conveniently share media resources. There are two technical solutions:
(1) Static channel division. After channel division, frequency division multiplexing, time division multiplexing, wavelength division multiplexing, code division multiplexing and other technologies can be used to share channel resources efficiently.
- Disadvantages: when there is computer access, to the new division of the channel.
(2) Dynamic media access control
- Random access (main use)
- Controlled access
(3.3.2 rainfall distribution on 10-12 CSMA/CS) agreement
The original Ethernet connected many computers to a single bus. The connection was thought to be simple and reliable because there were no active devices on the bus. So the problem Ethernet has to solve is how to coordinate the work of each computer. Ethernet uses CSMA/CD protocols like random access technology to coordinate the work of computers on a LAN. These are the main points of the CSMA/CD protocol
- Multipoint access: A bus network in which multiple computers are connected on a single line.
- Carrier sense: Each station continuously checks the channel to see if there are other stations transmitting signals before and during transmission.
- Collision detection: sending while monitoring, if there are at least two stations on the channel at the same time to send information will occur collision, so that the information sent by both sides are invalid;
Ethernet implements one-to-one broadcasting
- Every working computer on the bus can detect the data signal sent by B.
- Since only computer D’s address matches the address written at the beginning of the data frame, only D receives the data frame.
- All the other computers (A, C, and E) have detected A data frame that was not sent to them, so they discard it without being able to collect it.
- One-to-one communication is realized on the bus with broadcast characteristics.
Two important measures have been taken to simplify Ethernet communication
- The flexible connectionless working mode is adopted, that is, data can be sent directly without establishing a connection first.
- The Ethernet does not number data frames and does not require confirmation.
- The reason for this is that the quality of the LAN channel is so good that the probability of error is small.
Services provided by Ethernet
- Ethernet provides services that are unreliable delivery, that is, best effort delivery.
- When the destination station receives an errant data frame it discards it and does nothing else. The correction of errors is at the top.
- If the upper layer finds that some data is missing and retransmits it, Ethernet does not know that it is a retransmitted frame, but sends it as a new data frame.
(3.4) Ethernet using broadcast communication
3.4.1 Star topology using hubs
Star Ethernet 10BASE-T:
10
: 10 MB/sBASE
: : The signal on the connection line is baseband signalT
: the twisted pair
Characteristics of the hub
- Hubs use electronics to simulate the work of real cables, so Ethernet using hubs is still logically a network of buses, which are logically shared among stations. And it was with or
CSMA/CD
Agreement; - The hub acts as a multi-interface repeater; Hubs work at the physical layer, where each interface simply forwards bits without collision detection,
- The hub adopts a special chip to carry out adaptive crosstalk echo cancellation. (So that the strong signal of the same interface does not interfere with the weak signal)
3.4.2 Ethernet Channel utilization
Ethernet channel utilization
The frame length is L (bit) and the data transmission rate is C (b/s), so the frame transmission time T0 is L/C.
Requirements on Ethernet parameters
Maximum channel usage Smax
3.4.3 MAC Layer of Ethernet
1. Hardware addresses in the MAC layer
- A hardware address is also called a physical address or MAC address.
- The hardware address is not strictly an address because it does not specify a specific location. The hardware address is the unique adapter number used to uniquely identify the adapter on each computer
- The first 24 bits of the MAC address represent the vendor and the last 24 bits identify the adapter address
The MAC address of the host can be changed
2. Format of MAC frames
There are two common Ethernet MAC frame formats:
DIX Ethernet V2 standard
IEEE 802.3 standard
The most common MAC frame is the Ethernet V2 format. The details are shown below.
- Destination address and source address are hardware addresses.
- The type field is used to indicate the protocol used by the upper-layer data, shown above as IP datagrams.
- FCS frame check sequence, using CRC check
- The pre-synchronization code is used to synchronize the clock of the adapter with the bitstream.
A frame whose target address is all F is a broadcast address frame
3. Invalid MAC frame
4. Minimum interval for MAC frames
- The minimum interval between frames is 9.6 subtleties, equivalent to 96 bits of transmission time.
- After a station detects that the bus is idle, it has to wait 9.6 minutes before sending data again.
- This is done so that the receiving cache of the station that has just received the data frame can be cleared in time to receive the next frame.
(3.5) High-speed Ethernet
Ethernet with the rate >=100Mb/s
3.5.2 Extending lans at the Data Link Layer
- Extended Lans at the data link layer use Bridges.
- The bridge works at the data link layer and forwards and filters incoming MAC frames based on their destination address.
- The bridge has the function of filtering frames. When the bridge receives a frame, it does not forward the frame to all interfaces. Instead, it checks the destination MAC address of the frame and determines which interface to forward the frame to
1. Advantages of using a bridge
- Filter traffic. When A communicates with B, C and D can also communicate, and the communication between A and C requires the forwarding of bridge B1.
- Expanded the physical range.
- Improved reliability (aka high availability).
- Interconnect lans of different physical layers, different MAC sub-layers, and different rates (e.g. 10 Mb/s and 100 Mb/s Ethernet).
2. Disadvantages of network Bridges
- Store-and-forward increases latency. The received frame is stored and forwarded by CSMA/CD algorithm.
- There is no flow control in the MAC sub-layer.When the network is overloaded, the cache space of the bridge overflows, resulting in frame loss.
- When network segments with different MAC sublayers are bridged together, the delay is larger.
- Bridges are only suitable for lans with not too many users (no more than a few hundred) and not too much traffic, otherwise there will sometimes be congestion due to the spread of too much broadcast information. That’s what it’s calledBroadcast storm.
4. Ethernet switch
A multi-interface bridge
— — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — – — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — —