OSI architecture - Detailed data link layer

Foreword

The second layer is a data link layer in the OSI reference model, somewhere between the physical layer and network layer. The data link layer provides the basic services available on the physical layer to the network layer service, the data link layer is to enhance the function of physical layer transmit the original bitstream, the possibility of error by the physical layer the physical connection is logically transformed into error-free data link, network layer so that error-free performance of a circuit. For this purpose, a series of data link must have the corresponding function. This article describes related to the data link layer has functions.


First, the concept of the data link and basic knowledge

OSI architecture - Detailed data link layer

The picture shows the position of the two hosts communicating data link layer is located over the Internet.

It only cares about each of the data link layer in the protocol stack level defense. When H1 sends data to H2, we can imagine the data is the data link layer of the horizontal transfer from left to right. Thus at the level of the data link layer, the following link: H1 link layer link layer → R1 → R2 → R3 link layer link layer link layer → H2

As a result, we have drawn some basic concepts:

链路(link):一条无源的物理线路段,中间没有其他的交换结点。一条链路只是一条通路的一个组成部分。

数据链路(date link):除了物理线路外,还必须有通信协议来控制这些数据的传输。若把实现这些协议的硬件和软件加到链路上,就构成了数据链路。

Today, the most common method is to use a network adapter (NIC) to achieve these requirements, the card typically contains the data link layer and the physical layer of the two functions.

In the data transmission channel, in which the data unit is called a data link layer frame.
Data link layer to the network layer data encapsulated in a frame cross sent down to the link and removed to the upper layer network layer data frame is received.

If the data link layer protocol consider only point channel, we can use the simple model shown in the figure below:
OSI architecture - Detailed data link layer

The main steps are as follows when the data link layer peer communication channel is performed:

Data link layer (1) source will pay off the network layer IP datagram headers and trailers to add encapsulation framing.
Data link layer (2) source transmits the encapsulated frames to the sink
(3) If the frame data sink link layer receives no error, then the received frame header and trailer extraction, IP data reduction reported to the network layer; if there is an error frame is discarded.


Second, the three major issues of frame transmission

There are a number of data link layer protocol in, but there are three basic problems are common, they are encapsulated in a frame, transparent transmission, error checking.

1, encapsulated in a frame

Encapsulated in a frame (Framing) header and trailer is added before and after each piece of data, this constitutes a frame. After receiving the receiving side physical layer bitstream turned over may, tail marks, to identify the beginning and end frame from the bit stream received in the header. Header and trailer an important role is to frame delimitation, in addition, there are many header and control information necessary to tail. When sending frame, from the frame header starts transmitting. Each data link layer clearly defined frame format of the frame header and tail. To improve the efficiency of the transmission frame, the data should be made as part of the frame length is greater than the length of the header and trailer. Of course, the data portion can not be too large, which, each data link layer specifies the data portion of the frame transmittable maximum length - maximum transmission unit the MTU (the Maximum Transfer Unit).

Encapsulated in a frame diagram:
OSI architecture - Detailed data link layer
When the data is a text file in ASCII printable composition, the frame can use special delimiter frame delimiter.

注:ASCII码是7位编码,一共可组成128个不同的ASCII吗,其中可打印的95个,不可打印的控制字符33个。将控制字符SOH(start of header)放在帧的最前面表示帧的开始;将EOT(end of transmission)放在帧的末尾表示帧的结束。这里SOH和EOT都是控制字符的名称,它们的十六进制编码为01 、04。

When an error occurs during transmission, the more pronounced effect of frame delimiter. If the sending end has finished with a frame transmission fails, the interrupt transmission. Since a delimiter frame, the receiving end determines that it is not detected EOT incomplete frame to be discarded.

2, transparent transmission

Definition: Regardless of what kind of transmitted data bit combination, should be able to transmit on the link. When the bit combination data pass happens when a certain control information is exactly the same, it is necessary to take appropriate measures, such that the recipient will not be mistaken for some kind of data control information. So as to ensure transmission of the data link layer is transparent.

OSI architecture - Detailed data link layer
Solution: padding bytes (byte stuffing) or a character stuffing (character stuffing)

Transmitting side data link layer control character appears in front of "SOH" or "EOT" escape character is inserted into the "ESC" in the data, the receiving side data link layer to delete the escape character before the data is sent to the network layer. If the escape character also appears in the data, then re-insert an escape character before the escape character.

OSI architecture - Detailed data link layer

3, error detection

In real-world applications, the data may be generated during transmission errors, such as "1" may become "0" and the like, which is called error bit error. Period of time, the transmission error bits representing the transmission bit error rate review ratio is called BER (bit error rate). In order to ensure the reliability of data transmission, must use a variety of error detection measures the transmission of data, the data link layer is currently widely used is a cyclic redundancy check the CRC (Cyclic Redundancy Check).

Let us through a simple example to illustrate the principles of a cyclic redundancy check.

In the transmitter, data is divided into first group. Assuming each k bits.

M is assumed to be a set of data transmitted = 101001 (now k = 6). We add redundancy for error detection code using an n-bit sent together at the back of M.

2n performed by M binary arithmetic modulo 2 operation, which is equivalent to later add the n M 0.

The number (k + n) bits obtained by dividing the length of a good pre-selected (n + 1) bits of the divisor P, Q is obtained commercially and R is a remainder, the remainder R is less than the divisor P bit. 1, i.e., R n bits.

The remainder R as a redundant code sent after the data splicing M.

Example: Now k = 6, M = 101001.
Provided n = 3, the divisor P = 1101,
dividend is 2nM = 101001000.
Results molding operation is: commercially Q = 110101, the remainder R = 001.
Add the remainder R M after the data is sent as a redundant code. Data is transmitted: 2nM + R. That is: 101001001, total (k + n) bits.

OSI architecture - Detailed data link layer

The receiving terminal stores the received data in frame units CRC check: the each of the frames received divided by the same divisor P (two-mode operation), then check the remainder obtained R.

余数R存在的可能性:
若得出的余数 R = 0,则判定这个帧没有差错,就接受。
若余数 R≠0,则判定这个帧有差错,就丢弃。

注:数据链路层若仅使用CRC技术,则只能做到对帧的无差错接收,因为CRC只具有检错能力,不具备纠错能力。


Third, Point to Point Protocol PPP

In the era of poor quality communication line, using the reliable transport protocol in the data link layer has a good way. For point to point links, it is currently the most widely used protocol is PPP (point-to-point protocol). Internet users often need to connect to an ISP in order to access the Internet, the data link layer protocol is a user and the ISP PPP protocol is used for communication.

Of course, PPP protocol does not provide reliable transmission using acknowledgment and the sequence number

When there is less probability of errors in the data link layer, using relatively simple PPP protocol is more reasonable.

In the Internet environment, PPP information field into the data IP datagram. Reliable transmission of data link layer can not guarantee the transport network layer is also reliable.

A frame check sequence FCS field can ensure error acceptable.

PPP协议有三个组成部分:
(1) 一个将 IP 数据报封装到串行链路的方法。
(2) 用来建立、配置和测试数据链路连接的链路控制协议 LCP (Link Control Protocol)。
(3) 网络控制协议 NCP (Network Control Protocol)。

The PPP frame format

OSI architecture - Detailed data link layer
The fourth field PPP header is a 2-byte Protocol field.
When the protocol field is 0x0021, the information field of the PPP frame is an IP datagram.
When the protocol field is 0xC021, PPP information field of the data frame is a PPP LCP link control protocol.
Protocol field is 0x8021, the information field of the PPP frame data when the network control layer.

Transparent transmission of PPP

When the flag field and the same bit combination (0x7E) appears in the information field, it is necessary to take some measures:
when used in a synchronous PPP transmission link hardware to complete agreement bit padding (and practices as HDLC).
When used in a PPP asynchronous transfer, to the use of a special character filling.

Character fill

Appearing in the information field of each byte 0x7E transformation into 2-byte sequence (0x7D, 0x5E).

If a 0x7D byte information field appears, it is transformed into 2-byte sequence (0x7D, 0x5D).

If the ASCII control character appears in the information field (i.e., a value less than 0x20 characters), then in front of the character to be added to a 0x7D byte, while the encoded characters to be changed.

Zero padding bits

PPP protocol for SONET / SDH link when using synchronous transmission (continuously transmit a series of bits) in. In this case PPP protocol uses bits zero filling method to implement transparent transmission.

The transmitting side and as soon as five consecutive 1 is immediately filled in a 0.

The receiving end the bit stream frame scans. Whenever found five consecutive 1:00, put the 5 0 deleted after a continuous 1.
OSI architecture - Detailed data link layer

Working status of PPP

The starting and ending state of the PPP link must Jingzhi link (link dead). In this case there is no connection to the physical layer between the user personal computer and the ISP router.
When the user personal computer via a modem call router, the router is able to detect the carrier signal from the modem. In both the physical layer connection is established, PPP link establishment proceeds to state (link establish), its purpose is to establish a link layer connection LCP.
LCP established after the connection start sending LCP configuration request frame (configure-request). This is a PPP frame, the protocol field is set to the code corresponding to the LCP, the information field contains the specific configuration request.

链路的另一端可以发送以下几种响应中的一种:

配置确认帧(configure-ack):所有选项都接受
配置否认帧(configure-nak):所有选项都理解但不能接受
配置拒绝帧(configure-reject):选项中部分无法识别或不能接受,需要协商

OSI architecture - Detailed data link layer

PPPoE

PPPoE (PPP over Ethernet) means "running PPP over Ethernet", which in conjunction with the PPP protocol Ethernet protocol up - the PPP frame is then encapsulated into Ethernet transmission.

FTTx optical broadband access is now to be used PPPoE access way. Type the user name and password in the network operators buy in PPPoE pop-up window, you can perform the broadband Internet access.

When using ADSL broadband Internet access from the user personal computer between the ADSL modem in the home, and also the use of RJ-45 Category 5 (i.e., using an Ethernet cable) connection, and the popup window is PPPoE dial-up connection using of.

Using the data link layer broadcast channel

The broadcast channel may communicate with one to many. LAN is a broadcast channel in use. LAN main advantage is:
has the broadcast feature, you can easily access the entire network from one site. Hosts on the LAN can share the LAN connection on a variety of hardware and software resources.
Facilitates system expansion and evolving position of each device can be flexibly adjusted and changed.
Improve the reliability, availability and survivability systems.

LAN can use a variety of transmission media, which twisted the cheapest. Of course, the work of the local area network level across the data link layer and physical layer. Because the devices are within the local area network to share a channel, channel sharing important consideration is how many users can be reasonably and easily share through new media resources. There are two ways to solve technically:

Static channel is divided: As mentioned in the physical layer frequency division multiplexing technology, users assigned to the channel as long as it does not conflict with other users. But the higher cost of this division channel, the local area network is not suitable for use.

Dynamic Media Access Control: also known as multiple access, can be divided into two types of random access and controlled access. Random access is characterized by all the users can send a random message. But if happen to have two or more users to send information at the same time, it will have a collision (conflict) on shared media, so that all users have failed to send. Characteristics of the user can not access controlled random transmission information, the user must obey certain control. Typical representatives Polling Token Ring line and a centralized point of control.

The IEEE 802 Committee LAN data link layer is split into two sub-layers, i.e., a logical link control LLC (logical link control) and medium access control MAC (medium access control). Access to the transmission medium with the content related to the MAC sublayer are placed, regardless of use of transmission media, for the LLC sub-layer is transparent.

OSI architecture - Detailed data link layer

Now we discuss how the computer is on the LAN to access start on the general concept.

A computer connected to the LAN is through an adapter also known as network interface cards NIC (network interface card). Between the adapter and LAN communication by way of a serial transmission cable or twisted pair. Of course, for present computer, this has been embedded on the motherboard adapter, the card is no longer alone.

适配器的重要功能:
1.进行串行/并行转换。
2.对数据进行缓存。
3.在计算机的操作系统安装设备驱动程序。
4.实现以太网协议。  

OSI architecture - Detailed data link layer


Four, CSMA / CD protocol

CSMA / CD Meaning: Carrier Sense Multiple Access / Collision Detection (Carrier Sense Multiple Access with Collision Detection ).

The earliest Ethernet is to connect many computers to the bus, but the bus is a broadcast communication. In order to achieve one to one communication, you can make each computer has an adapter with other adapters have a different address. When transmitting the data frame, specify the frame header address of the receiving station, one such communication can be realized.

Here are a few basic concepts:
"multiple access" means many computers in a multiple access manner is connected to a bus.

"Carrier sense" refers first to detect before each station sends data to see if there are other computers to send data on the bus, if there is, for the time being not to send data, in order to avoid a collision.
On the bus and there is no "carrier." Thus, "carrier sense" is detected by the electronic bus has no further data signals sent from the computer.

Impact checking

Since the electromagnetic wave propagation rate on the bus is limited, when listening to a station bus is free, the bus may not really free.

A message sent to B, after a certain period of time to can be transferred to B.

B transmits its frame before if reaches B A transmitted information (carrier sense because then B is not detected information A transmitted), then bound to a certain time frame collision and A transmitted.

Result of the collision of the two frames are useless.

So the need for collision detection during transmission, to detect conflicts.

OSI architecture - Detailed data link layer

"Collision detection" is the side of the computer sends a signal edge detecting voltage magnitude data channel.

When several stations simultaneously transmit data on the bus, the signal voltage swing will increase the value on the bus (superimposed with each other).
When a station detects a signal voltage swing exceeds a certain threshold, considered in at least two stations simultaneously transmit data indicating the resulting impact on the bus.
The so-called "collision" is the conflict. Therefore, "Collision Detection" also known as "conflict detection"

Sent again after each station is transmitting data, there has been a collision on the bus if it is found, it must immediately stop sending, so continue to waste network resources, and then wait for a random time

Using CSMA / CD Ethernet protocol can not be full-duplex communications only way alternate communication (half duplex), because the collision of the frame is invalid.

当发送数据的站一旦发现发生了碰撞时:
(1) 立即停止发送数据;

(2) 再继续发送若干比特的人为干扰信号  (jamming signal),以便让所有用户都知道现在已经发生了碰撞。

OSI architecture - Detailed data link layer

work process:

(1) ready to send. But before transmission, the channel must be detected.

(2) detect the channel. If the channel is busy detected, you should not stop testing, has been waiting for the channel becomes idle. When the idle channel is detected, and the 96-bit channel remains idle time (to ensure that the minimum inter-frame interval), the frame is sent.

(3) Check the collision. During transmission, the channel is still kept detected, i.e., the network adapter to send side edge listener.

这里只有两种可能性:

①发送成功:在争用期内一直未检测到碰撞。这个帧肯定能够发送成功。发送完毕后,其他什么也不做。然后回到 (1)。

②发送失败:在争用期内检测到碰撞。这时立即停止发送数据,并按规定发送人为干扰信号。适配器接着就执行指数退避算法,等待 r 倍 512 比特时间后,返回到步骤 (2),继续检测信道。但若重传达 16 次仍不能成功,则停止重传而向上报错。

Fifth, LAN hubs and switches

Hub

Traditional Ethernet was originally used thick coaxial cable, and later evolved to use less expensive thin coaxial cable, and finally the development of cheaper and more flexible use of twisted pair. This Ethernet uses a star topology, using a very high reliability in the center of the hub topology.

OSI architecture - Detailed data link layer

Some explanations are needed:

A hub is the use of electronic devices to simulate the actual work of the cable, so the whole system is still run as a traditional Ethernet.

Use an Ethernet hub logically is still a bus network, each workstation or CSMA / CD protocol, and a shared bus on logic.

Much like a multi-repeater hub interfaces operate at the physical layer, it simply forwards each interface bits, collision detection is not performed.

Hub uses a special chip, crosstalk adaptive echo cancellation, near-end crosstalk is reduced.

OSI architecture - Detailed data link layer

switch

A plurality of hubs can be connected to a larger, multi-level Ethernet star structure.

OSI architecture - Detailed data link layer
Advantages:
causing a computer belonging to different original on Ethernet collision domain is able to communicate across the collision domain.

Expanding the geographical scope of coverage of Ethernet.

Disadvantages:

Collision domain increases, but did not improve overall throughput.

If different collision domains using different data rates, then the hub can not be used to interconnect them together.

Extended Ethernet more common method is carried out in the data link layer.

Early use of the bridge, now use Ethernet Switch

When a bridge receives a frame, not to forward the frame to all the interfaces, but check the destination MAC address of the frame, and then forwards the frame to determine where an interface, or to discard it.

交换机特点:

以太网交换机实质上就是一个多接口的网桥,通常都有十几个或更多的接口。

每个接口都直接与一个单台主机或另一个以太网交换机相连,并且一般都工作在全双工方式。

以太网交换机具有并行性。能同时连通多对接口,使多对主机能同时通信。

相互通信的主机都是独占传输媒体,无碰撞地传输数据。

以太网交换机是一种即插即用设备,其内部的帧交换表(又称为地址表)是通过自学习算法自动地逐渐建立起来的。转发速率要比使用软件转发的网桥快很多。

Six, Ethernet MAC layer

Hardware address MAC layer

In the LAN, the hardware address is also called the physical address, or MAC address.

MAC address:

Standard IEEE 802 MAC address field can be 6 bytes (48 bits) or two bytes (16 bits) in one of these two.

IEEE registries RA is responsible for assigning address field of 6 bytes in the first three bytes of the factory (i.e., upper 24 bits), called the organizational unique identifier.

Address field of 6 bytes three bytes (i.e., low-order 24 bits) assigned by the manufacturers themselves, called Extended Unique Identifier, must ensure that the adapter does not produce a duplicate address.

OSI architecture - Detailed data link layer

Production adapter 6 byte MAC address has been cured in the ROM of the adapter, thus, also known as the hardware address MAC address (hardware address) or a physical address.

"MAC address" is actually an adapter or adapter address identifier EUI-48.

We know that adapter with a filter function. When the adapter receives a MAC frame from each of the network to check the destination address of the MAC frame by the hardware. If it is sent to the site to accept, and then to other treatments. If it is destined for the station, this MAC frame is discarded. So do not waste the host processor and memory resources.

“发往本站”包括以下三种帧:
单播帧(一对一):即收到的帧的MAC地址与本站的硬件地址相同。
广播帧(一对全体):即发送给本局域网上所有站点的帧(全1地址)。
多播帧(一对多):即发送给本局域网上一部分站点的帧。

All adapters are able to identify the first two frames, i.e., can be recognized unicast and broadcast addresses.

Promiscuous mode (promiscuous mode) as long as the working Ethernet adapter "heard" on the Ethernet transmission frame there are received on down.

MAC frame format

Commonly used Ethernet MAC frame format, there are two criteria:

DIX Ethernet V2 standard (most common)

IEEE 802.3 standard

MAC frame structure diagram:
OSI architecture - Detailed data link layer

Invalid frames MAC
value of the length field and the length of the data field is inconsistent;

Length is not an integer bytes of the frame;

By FCS FCS found to have received in error;

Length of the data field is not between 46 to 1500 bytes.

Valid MAC frame length is between 64 to 1518 bytes.

Invalid frames are discarded directly, Ethernet is not responsible for retransmission of dropped frames.

Guess you like

Origin blog.51cto.com/14671287/2482674