Computer network is more and more important in today's life, so we learn the network knowledge is very necessary. Network communication is divided into 5 layers, namely: physical layer, Data link layer, network layer, Transport layer, application layer.
In the data link layer is responsible for the transmission of data, there are many kinds of protocols, the most used is the Ethernet protocol in the LAN, and the PPP protocol in the WAN, HDLC protocol.
Etherne II
Header 8 Destination Address 6 Source Address 6 ether Type 2 payload 46-1500 frame Test sequence 4
Header: 8 bytes, the first 7 0,1 alternating bytes (10101010) are used to synchronize the receiving station, and a 1010101011 byte indicates the starting position of the frame. The header provides receiver synchronization and frame demarcation services.
Destination Address: 6 bytes, unicast, multicast, or broadcast. Unicast addresses are also called personal, physical, hardware, or MAC addresses. The broadcast address is all 1,0XFF FF FF ff.
Source Address: 6 bytes. Indicates the unicast address of the sending node.
Ether Type: 2 bytes, used to indicate the upper layer protocol contained within the Ethernet frame. The protocol identifier for the frame format. For IP messages, the field value is 0x0800. For ARP information, the value of the Ether Type field is 0x0806.
Payload: A protocol Data unit PDU consisting of an upper layer protocol. The maximum payload that can be sent is 1500 bytes. The payload is at least 46 bytes due to the collision detection feature of Ethernet. If the upper-layer protocol data unit is less than 46 bytes long, it must be added to 46 bytes.
Frame Inspection sequence: 4 bytes. Verify bit integrity.
650) this.width=650; "src=" Http://s3.sinaimg.cn/large/52f2688et655b25a939c2 "alt=" 52f2688et655b25a939c2 "/>
HDLC Frame Format
650) this.width=650; "class=" Fit-image "src=" http://s3.51cto.com/wyfs02/M00/2D/25/wKioL1OVH2mg2ESlAAEPQRWi_44381. JPG "width=" 473 "border=" 0 "height=" 324 "alt=" HDLC Frame format Introduction "style=" border:0px; "/>
Segmentation of Frame Information
A frame of information for the SDLC/HDLC consists of the following fields (field), all of which are routed from the least significant bit.
1. SDLC/HDLC Flag Character
The SDLC/HDLC protocol stipulates that all information transmissions must begin with a single marker character and end with the same character. This flag character is 01111110, called the Sign field (F). A complete unit of information, called a frame, is formed between the start sign and the end flag. All information is transmitted as frames, while the marker character provides the bounds of each frame. The receiver can establish frame synchronization by searching for "01111110" to detect the beginning and end of the frame.
PPP There are three components of the agreement:
1 " Span style= "font-family: ' The song Body '; >) One will ip ppp Supports both asynchronous links (no parity 8 bit Data", also supports bit-oriented synchronization links.
( 2 ) A Link control protocol that is used to establish, configure, and test data links LCP ( Link Control Protocol ). The two sides of the communication can negotiate some options. Each type of LCP grouping is defined in [RFC 1661] .
(3) A set of network control protocolsNCP(Network Control Protocol) to support different network layer protocols, such asIP,OSIthe network layer,DECnet,AppleTalkand so on.
two,
ppp frame format and HDLC Similar frame format, 1 The main difference: ppp is character-oriented, and HDLC Span style= "font-family: ' The song body '; color: #FF0000;" > is bit-oriented.
650) this.width=650; "border=" 0 "src=" http://blog.chinaunix.net/attachment/201106/15/25132162_1308147637JyA2.jpg " Style= "border:0px;" alt= "25132162_1308147637jya2.jpg"/>
Figure 1 PPP frame format
as you can see, the first 3 fields of aPPP frame and the last two fields are the same as the HDLC format. The Flag field F is 0x7E(0x for 7E), but address field a and control field C are fixed, respectively, by 0xFF ,0x03. The PPP protocol is not bit-oriented, so all PPP frame lengths are integer bytes.
Unlike HDLC , the Protocol field is more than 2 bytes. The type of information field after the Agreement field is different. such as:
0x0021 --The Information field is an IP Datagram
0xc021 --Information field is link Control Data LCP
0x8021 --Information field is the network control data NCP
0xc023 --Information fields are security certified PAP
0xc025 --Information field is LQR
0xc223 --Information field is security authenticated CHAP
     0x7E is present in the information field that is the same as the Flag field, some action must be taken. Because the PPP protocol is character-oriented, it cannot take the 0-bit insertion method used by HDLC , but instead uses a special character fill. This is done by converting each 0x7E byte that appears in the information field into a 2 byte sequence ( 0x7d , 0x5E ). If a 0x7d byte appears in the Information field, it is converted to a 2 byte sequence ( 0x7d , 0x5d ). If the control character of the ASCII code appears in the Information field, a 0x7d byte is added before the character. The purpose of this is to prevent the ASCII code control characters on these surfaces from being incorrectly interpreted as control characters.
Third,PPP Link Work Process
when the user dials the accessISP, the router's modem responds to dialing and establishes a physical connection. At thisPCthe router sends a series ofLCPgrouping (encapsulated into multiplePPPframe). These groupings and their responses select some of the ones that will be usedPPPparameters, and then the network layer is cultivated,NCPto the new accessPCthe machine assigns a temporaryIPaddress, soPCMachine becomesInternetthe previous host.
When the user is finished communicating, NCP Release the network layer connection and reclaim the original assigned IP address. the LCP then releases the data link layer connection and finally releases the physical layer connection.
The above procedure can be shown 2 to describe.
650) this.width=650; "border=" 0 "src=" http://blog.chinaunix.net/attachment/201106/15/25132162_1308147562D90d.jpg " Style= "border:0px;" alt= "25132162_1308147562d90d.jpg"/>
Figure 2 PPP protocol process state diagram
There is no physical layer connection when the line is in a stationary state. When the carrier signal of the modem is detected and the physical layer connection is established, the line enters the established state, when LCP begins to negotiate some options. After the negotiation is over, enter the status of identification. If both sides of the communication identify their identities successfully, they enter the network status. the NCP Configures a network rub, assigns an IP address, and then enters the open state where data communication can take place. After the data transfer is over, go to the terminating state. When the carrier stops, it returns to the stationary state.
Several protocols of data link layer