HDLC Report
HDLC Report
Ali Hussain
ACKNOWLEDGMENTS First and foremost, we would like to express our sincere gratitude to our advisor Mam Saba Zia for the continuous support of design and development of our internship Project, for her patience, motivation, enthusiasm, and immense knowledge. We are thankful to NEXTEK services for the provision of industrial project and guidance. Lastly, we offer our regards and blessings to all of those who supported us in any respect during the completion of the project.
Contents
ACKNOWLEDGMENTS ............................................................................................................................ 2 ABSTRACT.................................................................................................................................................. 5 CHAPTER 1 ................................................................................................................................................. 6 Introduction to Communication Protocols: ............................................................................................... 6 Basic requirements of protocols:............................................................................................................... 7 Protocol design.......................................................................................................................................... 8 The OSI Model ....................................................................................................................................... 8 OSI Stack Protocol Model; ................................................................................................................... 9 CHAPTER 2 ............................................................................................................................................... 10 HDLC Protocol: ...................................................................................................................................... 10 Types of HDLC Stations:........................................................................................................................ 10 Primary................................................................................................................................................ 10 Secondary............................................................................................................................................ 10 Combined ............................................................................................................................................ 11 Configurations of HDLC: ....................................................................................................................... 11 Unbalanced Configuration .................................................................................................................. 11 Balanced Configuration ...................................................................................................................... 11 Symmetrical Configuration ................................................................................................................. 12 HDLC Operation Modes; ........................................................................................................................ 12 1. 2. 3. Normal Response Mode (NRM) ................................................................................................. 12 Asynchronous Response Mode (ARM) ...................................................................................... 12 Asynchronous Balanced Mode (ABM) ....................................................................................... 12
HDLC Non-Operational Modes;............................................................................................................. 12 Protocol Structure - HDLC: High Level Data Link Control ................................................................... 13 Frame Format .......................................................................................................................................... 13 The Flag field ...................................................................................................................................... 13 Address field ....................................................................................................................................... 13
Unnumbered Format Commands and responses (U-Frame ................................................................ 15 2. 3. Information frames ...................................................................................................................... 16 Supervisory frames ..................................................................................................................... 16
The Poll/Final Bit (P/F) ...................................................................................................................... 17 CHAPTER 3 ............................................................................................................................................... 18 Protocol Operation .................................................................................................................................. 18 Link management................................................................................................................................ 18 Data transfer ........................................................................................................................................ 18 Transparency ........................................................................................................................................... 19 Bit stuffing and removal ..................................................................................................................... 19 FSM of Transparency: ........................................................................................................................ 20 Hardware Implementation: ..................................................................................................................... 20 Detailed Design:.................................................................................................................................. 20 Requirements: ..................................................................................................................................... 21 Framing: .............................................................................................................................................. 21 Design: ................................................................................................................................................ 22 De-Framing: ........................................................................................................................................ 23 Modem Sharing Device: ......................................................................................................................... 23 Modem: ................................................................................................................................................... 24 Data Reception: ....................................................................................................................................... 27 Chapter 4: .................................................................................................................................................... 28 Reception: ............................................................................................................................................... 28
ABSTRACT In the current era networking has played an important role in bringing scientific revolution to mankind. The whole Computer networks are based on reference model. The data link layer is responsible for link management and frame transmission. This project briefly explains the higher level data link layer protocol and its operation as well as its implementation. Chapter 1 is related to basics of communication protocols. The detailed description is given in the second chapter where all the terminologies have been discussed. Types of stations used in HDLC are can be of three types which are generally detected with the help of frames. There are different types of frames as well and they affect the operation of protocol. Chapter 3 gives detailed design of protocol implementation and operation. This includes hardware details and requirements such as modem and modem sharing device. In the last chapter Verilog code is given for data reception at the monitoring end.
CHAPTER 1 Introduction to Communication Protocols: A communications protocol is a formal description of digital message formats and the rules for exchanging those messages in or between computing systems and in telecommunications. Protocols may include signaling, authentication and error detection and correction capabilities. A protocol defines the syntax, semantics, and synchronization of communication, and the specified behavior is typically independent of how it is to be implemented. A protocol can therefore be implemented as hardware or software or both. In computer science the word algorithm is a synonym for the word procedure so a protocol is to communications what an algorithm is to mathematics. Communicating systems use well-defined formats for exchanging messages. Each message has an exact meaning intended to provoke a defined response of the receiver. A protocol therefore describes the syntax, semantics, and synchronization of communication. A programming language describes the same for computations, so there is a close analogy between protocols and programming languages: protocols are to communications what programming languages are to computations. (A less technical reader might appreciate this similar analogy: protocols are to communications what grammar is to writing.) The communications protocols in use on the Internet are designed to function in very complex and diverse settings. To ease design, communications protocols are structured using a layering scheme as a basis. Instead of using a single universal protocol to handle all transmission tasks, a set of cooperating protocols fitting the layering scheme is used. The layering scheme in use on the Internet is called the TCP/IP model. The actual protocols are collectively called the Internet protocol suite. The group responsible for this design is called the Internet Engineering Task Force (IETF). The information exchanged between devices on a network or other communications medium is governed by rules or conventions that can be set out in a technical specification called a communication protocol standard. The nature of the communication, the actual data exchanged and any state-dependent behaviors are defined by the specification. Communicating systems have to communicate with each other using shared transmission media, because there is no common memory. Transmission is not necessarily reliable and can involve different hardware and operating systems on different systems. To implement a networking protocol, the protocol software modules are interfaced with a framework implemented on the machine's operating system. This framework implements the networking functionality of the operating system. The best known frameworks are the TCP/IP model and the OSI model. In communications, message values are transferred using transmission media. By analogy, the equivalent of a store would be a collection of transmission media, instead of a collection of memory locations. A valid assignment in a protocol (as an analog of programming language) could be Ethernet:='message' , meaning a message is to be broadcast on the local Ethernet.
CHAPTER 2 HDLC Protocol: HDLC (High Level Data Link Control) is one of the most common data link layer (layer 2) protocols. Many other common layer 2 protocols are heavily based on HDLC, particularly its framing structure. The HDLC protocol is defined by ISO for use on both point-to-point and multipoint (multidrop) data links. It supports full duplex transparent-mode operation and is now extensively used in both multipoint and computer networks. The rule of HDLC is to ensure that the data has been received without any loss or errors and in the correct order. HDLC has a flow control function which ensures that the data is transmitted as fast as the receiver can receive it. High-level Data Link Control (HDLC) is an enhanced derivative of SDLC from IBM. HDLC is the default serial link protocol for Cisco routers. Nearly all other routers on the market use PPP for link control. HDLC is a Data Link layer protocol. These protocols allow computers on either end of a physical connection (end stations) to communicate. There are two distinct HDLC implementations: HDLC NRM (also known as SDLC) and HDLC Link Access Procedure Balanced (LAPB), the later is a more popular implementation. HDLC is usually used by X.25. LAPB is a bit-oriented synchronous protocol that provides complete data transparency in a full-duplex point-to-point operation. It supports a peer-to-peer link in that neither end of the link plays the role of the permanent master station. HDLC NRM, on the other hand, has a permanent primary station with one or more secondary stations. HDLC LAPB is a very efficient protocol, which requires a minimum of overhead to ensure flow control, error detection and recovery. If data is flowing in both directions (full duplex), the data frames themselves carry all the information required to ensure data integrity. The concept of a frame window is used to send multiple frames before receiving confirmation that the first frame has been correctly been received. This means that data can continue to flow in situations where there may be long "turn-around" time lags without stopping to wait for an acknowledgement. This kind of situation occurs, for instance in satellite communication. Types of HDLC Stations: Primary Primary stations manage the connection to all secondary sessions by sending commands. Primary stations open and close connections and poll remote stations for data, or availability. Primary stations are used primarilly in multi-point networks or with mainframe applications where the mainframe is the primary station. The primary station uses unbalanced mode to communicate with the secondary stations. The primary station is responsible for all error detection, line control and data flow control. Secondary Secondary machines respond to commands sent from the Primary. Secondary stations are usually terminals attatched to mainframes. Communication between secondary stations and
10
Balanced Configuration The balanced configuration in an HDLC link consists of two or more combined stations. Each of the stations has equal and complimentary responsibility compared to each other. Balanced configurations can use only the following:
11
Symmetrical Configuration This third type of configuration is not widely in use today. It consists of two independent pointto-point, unbalanced station configurations as shown in Fig.In this configuration, each station has a primary and secondary status. Each station is logically considered as two stations. HDLC Operation Modes; HDLC has three operational modes: 1. Normal Response Mode (NRM) Normal Response Mode is used in unbalanced configurations, a configuration is which there is only one primary, controlling station. In this mode, slave stations (or secondary) can only transmit when specially instructed by the master (primary station). The link may be point-to-point or multipoint. In the latter case only one primary station is allowed. 2. Asynchronous Response Mode (ARM) Asynchronous Response Mode is used in unbalanced configurations. It allows a secondary station to initiate a transmission without receiving permission from the primary station. This mode is normally used with point-to-point configurations and full duplex links and allows the secondary station to send frames asynchronously with respect to the primary station. 3. Asynchronous Balanced Mode (ABM) The Asynchronous Balanced Mode (ABM) is used mainly on full duplex point-to-point links for computer to computer communications and for connections between a computer and a packed switched data network, in this case each station has an equal status and performs the role of both primary and secondary functions. This mode is used in the protocol set known as X.25. HDLC Non-Operational Modes; HDLC also defines three non-operational modes. These three non-operational modes are: Normal Disconnected Mode (NDM) Asynchronous Disconnected Mode (ADM) Initialization Mode (IM)
12
13
14
Unnumbered Format Commands and responses (U-Frame) The unnumbered format commands and responses are used to extend the number of data link control functions. The unnumbered format frames have 5 modifier bits, which allow for up to 32 additional commands and 32 additional response functions. Below, 13 command functions, and 8 response functions are described. Set Normal Response Mode (SNRM) places the secondary station into NRM. NRM does not allow the secondary station to send any unsolicited frames. Hence the primary station has control of the link. Set Asynchronous Response Mode (SARM) allows a secondary station to transmit frames without a poll from the primary station. Set Asynchronous Balanced Mode (SABM) sets the operational mode of the link to ABM. Disconnect (DISC) places the secondary station in to a disconnected mode. Set Normal Response Mode Extended (SNRME) increases the size of the control field to 2 octets instead of one in NRM. This is used for extended sequencing. The same applies for SARME and SABME. Set Initialization Mode (SIM) is used to cause the secondary station to initiate a station-specific procedure(s) to initialize its data link level control functions. Unnumbered Poll (UP) polls a station without regard to sequencing or acknowledgment. Unnumbered Information (UI) is used to send information to a secondary station. Exchange Identification (XID) is used to cause the secondary station to identify itself and provide the primary station identifications characteristics of itself.
15
3. Supervisory frames Supervisory frames are use for error and flow control. They contain, send and receive sequence numbers. There are four types of supervisory frames but only RR and RNR are used in both NRM and ABM. These frames are used both to indicate the willingness of a secondary station to receive an information frame from the primary station, and for acknowledgment purposes. REJ and SREJ frames are used only in ABM which permits simultaneous two-way communication across a point to point link. The two frames are used to indicate to the other station that a sequence error has occurred, that is an information frame containing an out of sequence N(s) has been received. The SREJ frame is used with a selective repeat transmission procedure, whereas the REJ frame is used with a go back N procedure.
16
Information Transfer Format Responses I - Information Supervisory Format Responses RR - Receive ready RNR - Receive not ready REJ - Reject SREJ - Selective reject Unnumbered Format Commands UA - Unnumbered Acknowledgment DM - Disconnected Mode RIM - Request Initialization Mode RD - Request Disconnect UI - Unnumbered Information XID - Exchange Identification FRMR - Frame Reject TEST - Test
The Poll/Final Bit (P/F) The 5th bit position in the control field is called the poll/final bit, or P/F bit. It can only be recognized when it is set to 1. If it is set to 0, it is ignored. The poll/final bit is used to provide dialogue between the primary station and secondary station. The primary station uses P=1 to acquire a status response from the secondary station. The P bit signifies a poll. The secondary station responds to the P bit by transmitting a data or status frame to the primary station with the P/F bit set to F=1. The F bit can also be used to signal the end of a transmission from the secondary station under Normal Response Mode.
17
CHAPTER 3 Protocol Operation The two basic functions in the protocol are link management and data transfer (which includes error and flow control). Link management Prior to any kind of transmission (either between two stations connected by a point to point link or between a primary and secondary station connected with a multidrop link) a logical connection between the two communication parties must be established. A logical connection between the two communication parties is accomplished by the exchange of two unnumbered frames. The procedure for setting a logical connection (In a multidrop link) is given below: The SNRM is first sent by the primary station with the poll bit set to 1 and the address of the appropriate secondary in the address field. The secondary responds with a UA frame with the final bit set and its own address in the address field. After all the data has been transferred, the link is cleared by the primary sending a DISC frame and the secondary responding with a UA. Data transfer In NRM all data (information frames) is transferred under the control of the primary station. The unnumbered poll frame with the P bit set to 1 is normally used by the primary to poll a secondary. If the secondary has no data to transmit, it returns an RNR frame with the F bit set. If data is waiting, it transmits the data, typically as a sequence of information frames. The two most important aspects associated with the data transfer phase are error control and flow control. Essentially, error control uses a continuous RQ procedure with either a selective repeat or a go back N transmission strategy, while flow controls based on a window mechanism.
18
Transparency The flag sequence must never occur within the content of a frame otherwise it could be confused with an intentionally sent flag. A technique known as 0-bit insertion is used to prevent random data synthesising a flag. The technique is said to make HDLC transparent, since any stream of bits may be present between the open and closing flag of a frame. The transparency is achieved by encoding the data by inserting a 0bit after any sequence of 5 consecutive 1's within the payload, as shown:
Insertion of a "zero-bit" into the content of a frame to ensure transparency Bit stuffing and removal
19
Hardware Implementation:
HDLC protocol finds its application in vast. It can be used with fax machines. Fax machine needs proper communication between two ends. The data is being transferred and received is continuously monitored so that to avoid loss in information and effective operation of protocol. For this HDLC controller is preferred. Detailed Design: Here is a detailed design for HDLC protocol operation. In this design we want to monitor the data transmitted from both end. As it is clear HDLC is single and multipoint communication protocol so modem are typically used for proper data management and modem sharing device(MSD) is used to distribute data among multipoint. These behave like cluster controllers. We can transmit data serially through to the modem from two computers as well as we can use two FPGA. Using two FPGAs is difficult to implement because it needs extensive programming, cost, circuitry and maintenance. So better approach is by using computers and sending data serially. Data is de-framed for reception where it is to be monitored. This process is already defined above. Just for this we need and FPGA interfaced with computer.
20
Framing: The data from transmitting end is framed and send via link. Here is simple FSM of the framing.
21
Master
Modem
Modem
Slave
Deframing
FPGA
22
Modem Sharing Device: The Model 3010 Three Port Modem Sharing Device allows three POS terminals, ATMs or similar RS232 devices to share a single RS-232 modem or multiplexer. The Model 3010 requires no AC power or batteries, operates asynchronously or synchronously and is small enough to plug directly into the DB-25 serial port on a modem or multiplexer. The Model 3010 operates by allowing the modem to pass data and control signals to all three DTE devices in parallel. Concurrently, the Model 3010 monitors each DTE device to see if it has data to send to the modem. When a terminal has data to send, it raises RTS and all its data and control signals are routed to the modem. As soon as that terminal is finished sending data, the Model 3010 resumes monitoring. If two or three terminals raise RTS simultaneously, the Model 3010 prioritizes the inputs: DTE channel one has priority over channel two, and channel two has priority over channel three. The Model 3010 has three DB-25 female DTE ports and on DB-25 male modem port. Either all connected devices must be asynchronous or they must all be synchronous: The Model 301 performs no data conversion. The DTE ports are labeled DTE #1, DTE #2 and DTE #3. The modem port is labeled MODEM. As figure (below) illustrates, input port DTE #1 is on one end of the unit. DTE ports DTE #2 and DTE #3 are on top when the Model 3010 is oriented in a normal fashion.
23
DTE Device
Modem
2 (TD) ------------------------------------------2 (RD) 4 (RTS) ----------------------------------------4 (RTS) 5 (CTS) ----------------------------------------5 (CTS) 20 (DTR) --------------------------------------20 (DTR) Modem: The typical Modem is CX86500. The CX86500 modem, packaged in a 28-pin TSSOP and 38-pin TSSOP, includes a Microcontroller (MCU), a Modem Data Pump (MDP), internal ROM, internal RAM, and SmartDAA interface functions. The modem connects to host via a logical V.24 (EIA/TIA232-E) serial DTE interface or a parallel 16550 UART-compatible host interface (38-pin only). The modem MCU/DSP performs the command processing, host interface functions and telephone line signal modulation/demodulation which reduces computational load on the host processor. The SmartDAA Interface communicates with, and supplies power and clock to the LSD through the DIB. It has following features. Modulations and protocols ITU-T V.92 Modem-on-Hold (MOH) Quick connect (QC) PCM upstream V.90/V.34/V.32bis/V.32 V.22bis/V.22/V.23/V.21
V.23 reverse, V.23 half-duplex Bell 212A/Bell 103 V.29 FastPOS V22bis fast connect V.80 Synchronous Access Mode Data compression V.44/V.42bis/MNP5
Error correction V.42/MNP 4/MNP 2 Call Waiting (CW) detection Type I and Type II Caller ID (CID) decoding DTE/host interface Serial DTE interface
24
25
Some of the applications of modem are: Set top boxes Point-of-Sale terminals ATM machines Metering terminals Video game consoles Internet appliances
26
27
Chapter 4 Reception: `timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 05:37:42 08/24/2011 // Design Name: // Module Name: hdlc_recv // Project Name: // Target Devices: // Tool versions: // Description: // // Dependencies: // // Revision: // Revision 0.01 - File Created // Additional Comments: // ////////////////////////////////////////////////////////////////////////////////// module hdlc_recv(ihdlc_RXD, ihdlc_RXCLK, ihdlc_RESET, ohdlc_TXD, ohdlc_TXCLK, ohdlc_TXDS ); /**************************************************************************/ ///*** input signals define ***/// /**************************************************************************/ input ihdlc_RXD; input ihdlc_RXCLK; input ihdlc_RESET; /**************************************************************************/ ///*** outputs define ***/// /**************************************************************************/ output ohdlc_TXCLK;
28
/**************************************************************************/ ///*** series shifter ***/// /**************************************************************************/ always @(posedge ihdlc_RXCLK or negedge ihdlc_RESET) begin if(!ihdlc_RESET)
29
/**************************************************************************/ ///*** "7E" detectiver ***/// /**************************************************************************/ always @(shifter1[7:0] or byte_counter[6:0] or bit_counter[3:0] or byte_rst_counter_start) begin if(shifter1[7:0]==8'h7e) begin if(byte_counter[6:0]!=0) begin if(bit_counter[3:0]==4'b1111||bit_counter[3:0]==4'b0111)
30
31
32
33
always @(posedge ihdlc_RXCLK or negedge ihdlc_RESET) begin if(!ihdlc_RESET) begin byte_rst_counter_start <= 1'b0; end else begin if(byte_rst_counter[2:0]==3'b111) byte_rst_counter_start <= 1'b0; else if(flag_7e) byte_rst_counter_start <= 1'b1; end end /**************************************************************************/ ///*** bit_counter & byte_counter ***/// /**************************************************************************/ always @(posedge ihdlc_RXCLK or negedge ihdlc_RESET) // bit_counter begin if(!ihdlc_RESET) begin bit_counter[3:0] <= 4'b0; end else begin if(flag_7e||(shifter1[7:0]==8'b1111_1111&&(byte_counter==7'b0&&bit_counter<=4'b1000))) begin
34
always @(posedge ihdlc_RXCLK or negedge ihdlc_RESET) // byte_counter begin if(!ihdlc_RESET) begin byte_counter[6:0] <= 7'b0; end else begin if(byte_rst_counter[2:0]==3'b111) begin byte_counter[6:0] <= 7'b0; end else begin if(bit_counter==4'b1111&&delete_zero!=1'b1) begin if(byte_counter[6:0]!=7'b111_1111) byte_counter[6:0] <= byte_counter[6:0] + 1; else byte_counter[6:0] <= byte_counter[6:0] ; end end end end
/**************************************************************************/
35
always @(posedge ihdlc_RXCLK or negedge ihdlc_RESET) begin if(!ihdlc_RESET) begin ohdlc_TXDS <= 3'b111; end else begin if(byte_rst_counter_start!=1'b1||flag_7e) ohdlc_TXDS <= ohdlc_TXDS_tmp; end end
36
37
38