CN Unit 2
CN Unit 2
UNIT-2
Data link layer: Design issues, Framing: fixed size framing, variable size framing, flow control, errorcontrol, error detection
and correction codes, CRC, Checksum: idea, one’s complement internetchecksum, services provided to Network Layer,
Elementary Data Link Layer protocols: simplexprotocol, Simplex stop and wait, Simplex protocol for Noisy Channel.
Sliding window protocol: One bit, Go back N, Selective repeat-Stop and wait protocol, Data link layer inHDLC:
configuration and transfer modes, frames, control field, point to point protocol (PPP): framingtransition phase,
multiplexing, multi link PPP.
DATA LINK LAYER DESIGN ISSUES:
Functions of data link layer are
1. Providing well defined service interface to the network layer.
2. Dealing with transmission errors.
3. Regulating the flow of data.
To achieve these goals, the data link layer takes the packets it gets from the network layer and change as them into frames for
transmission.
Each frame contains a frame header, a payload field for holding the packet, and a frame trailer.
The principal service of data link layer is transferring data from the network layer on the source machine to the
network layer on the destination machine.
Three commonly provided services are:
1. Unacknowledged connection less service.
Unacknowledged connectionless service consists of having the source machine send independent frames to the
destination machine without having the destination machine acknowledge them..
No logical connection is established between source & destination.
If a frame is lost, no attempt is made to detect the loss of the frame.
This service is appropriate when the error rate is low.
In this the destination m/c does not send any acknowledgement back to the sender.
It is useful when an error rate is very low.
Most LAN’s are used unacknowledged connectionless services.
If the recomputed check sum is different from the one contained in the frame.
An error has occurred and the data link layer deals with the errors.
To mark the start and end of each frame, we use four methods. They are
1. Character count.
2. Flag bytes with byte stuffing.
3. Starting and ending flags with bit stuffing.
4. Physical layer coding violations.
1. Character count:
This method uses a field in the header to specify the number of characters in the frame.
The first framing method uses a field in the header to specify the number of characters in the frame. When the
data link layer at the destination sees the character count, it knows how many characters follow and hence
where the end of the frame is. This technique is shown in Fig.1(a) for four frames of sizes 5, 5, 8, and 8
characters, respectively.
Fig . (a) A frame delimited by flag bytes. (b) Four examples ofbyte sequences before and after byte stuffing.
The sender’s data link layer inserts a special escape byte “ESC“just before each flag byte the data. At the
receiving end, the data link layer removes the escape byte before the data are given to the network layer. This
technique is called” byte stuffing” or “character stuffing”.
A framing flag byte can be identified by the absence or presence of an escape byte in the data. If an escape byte
occurs in the middle of data that, too, is stuffed with an escape byte.
Any single escape byte is part of an escape sequence, where as a doubled one indicates that a single escape
occurred naturally in the data. Examples of the byte sequences before & after byte stuffing.
A major disadvantage of this framing method is What happens if an escape byte occurs in the middle of the
original data already. The transmission takes place by stuffed with an escape byte. Thus, any single escape
byte is part of an escape sequence, whereas a doubled one indicates that a single escape occurred naturally
in the data.
It is used for 8-bit character only. Not all character codes use 8-bit characters, some use 16-bit characters, so a
new technique had to developed to allow sized characters.
3. Starting and ending flags, with bit stuffing:
In this method, each frame begins and ends with a special bit pattern, 01111110 a flag byte.
When the sender’s data link layer encounters five consecutive 1’s in the data, it automatically stuffs a 0 bit into
outgoing bit stream.
This bit stuffing is similar to byte stuffing.
When the receiver sees five consecutive incoming 1 bits, followed by a 0 bit, it automatically destuffs (i.e.,
deletes) the 0 bit. Just as byte stuffing is completely transparent to the network layer in both computers, so
is bit stuffing. If the user data contain the flag pattern, 01111110, this flag is transmitted as 011111010 but
stored in the receiver's memory as 01111110.
The boundary between two frames can be recognized by the flag pattern.
If the receiver losses its track the receives has to scan the input for flag sequences.
The flag sequences occur only at frame boundaries and never with in the data.
Error control:
To make sure that all frames are eventually delivered to the network layer at the destination & in the proper order.
The protocol calls for the receiver to send back special control frames bearing positive or negative acknowledgements
about the incoming frames.
If a +ve acknowledgement is received the frame has arrived safely. If a – ve acknowledgement is received the frame has
gone wrong & the frame must be transmitted again.
If a frame is lost due to hardware failure the receiver will not react & does not send any acknowledgement.
Timers are introduced into the data link layer. When a frame is exacted the timer also starts, the frame will be correctly
received & the acknowledgement will get back before the timer runs out.
If the frame or acknowledgement is lost the timer will go off, here the frame is transmitted again. If a frame is
transmitted multiple times the receiver may accept the same and pass it to the network layer more than once.
To prevent this, sequence numbers are assigned to outgoing frames, so that the receiver can distinguish retransmission
from originals.
Flow control:
Flow control occurs when the sender wants to transmit frames faster than the receiver can accept them. Even if the
transmission is error free, the receiver will simply be unable to handle the frames as they arrive & will start to lose
them.
Feed back based flow control & rate based flow control are the two approaches that are commonly used. In feedback –
based flow control, the receiver sends back information to the sender giving it permission to send more data.
In rate based flow control, the protocol has a built – in –mechanism that limits the rate at which senders may transmit
data, with out using feedback from the receiver.
Error detection and correction has great practical importance in maintaining data (information) integrity across noisy
Communication Networks channels and lessthan- reliable storage media.
Error Correction : Send additional information so incorrect data can be corrected and accepted. Error correction is the
additional ability to reconstruct the original, error-free data. Error Detection Schemes : In telecommunication, a redundancy
check is extra data added to a message for the purposes of error detection. Several schemes exist to achieve error detection,
and are generally quite simple. All error detection codes transmit more bits than were in the original data. Most codes are
"systematic": the transmitter sends a fixed number of original data bits, followed by fixed number of check bits usually
referred to as redundancy which are derived from the data bits by some deterministic algorithm.
The receiver applies the same algorithm to the received data bits and compares its output to the received check bits; if the
values do not match, an error has occurred at some point during the transmission. In a system that uses a "non-systematic"
code, such as some raptor codes, data bits are transformed into at least as many code bits, and the transmitter sends only the
code bits.
Parity check : A parity bit is an error detection mechanism . A parity bit is an extra bit transmitted with a data item,
chose to give the resulting bitseven or odd parity. Parity refers to the number of bits set to 1 in the data item. There
are 2 types of parity
Even parity - an even number of bits are 1 Even parity - data: 10010001, parity bit 1
Odd parity - an odd number of bits are 1 Odd parity - data: 10010111, parity bit 0
The stream of data is broken up into blocks of bits, and the number of 1 bits is counted. Then, a "parity bit" is set (or cleared)
if the number of one bits is odd (or even).This scheme is called even parity; odd parity can also be used. There is a limitation
to parity schemes. A parity bit is only guaranteed to detect an odd number of bit errors (one, three, five, and so on). If an
even number of bits (two, four, six and so on) is flipped, the parity bit appears to be correct, even though the data is corrupt.
For example
Hamming code:
Hamming code can be applied to data units of any length & uses the relationship between data & redundancy
bits or check bits.
Here, m is the no. of redundancy bits & r is the no. of redundancy bits added to the bits.
Consider, m=7 &r=4
Here redundancy bits are occupy the positions . Each redundancy bit is the parity bit which depends on the
combination of data bits at different positions.
Redundancy bit : The bit positions from which the bit value are task for calculating the redundancy by
value .
1 1,3,5,7,9,11
2 2,3,6,7,10,11
4 4,5,6,7
8 8, 9, 10, 11
Redundancy Positions used for redundancy Bit values in the positions Bit required for creating even
bit Bit calculation mentioned in column 2 parity(redundancy bit values)
R1 1,3,5,7,9,11 Nill,1,0,1,0,1 1
R2 2,3,6,7,10,11 Nil,1,1,1,0,1 0
R4 4,5,6,7 Nil,0,1,1 0
R8 8,9,10,11 Nil,0,0,1 1
After adding the redundancy bits in the proper positions along with the data unit we will be getting hamming code.The
hamming code or code word is 10011100101 This code will be transmitted.
Error Correction
If any data bit changes then it can be corrected as follows
Original code word is 10011100101 changed code word is 11011100101
Redundancy Positions used for redundancy Bit values in the positions Bit required for creating even
bit Bit calculation mentioned in column 2 parity(redundancy bit values)
R1 1,3,5,7,9,11 1,1,0,1,0,1 0
R2 2,3,6,7,10,11 0,1,1,1,1,1 1
R4 4,5,6,7 0,0,1,1 0
R8 8,9,10,11 1,0,1,1 1
If we represent the redundancy bits in the binary representation 1010 it shows the location of the error bit. Hamming is
the single bit Error correction method
Protocols in which the sender sends one frame and then waits for an acknowledgement before proceeding are called stop-
and-wait. The protocol we discuss now is called the Stop-and-Wait Protocol because the
sender sends one frame, stops until it receives confirmation from the receiver (okay to go ahead), and then sends
the next frame. We still have unidirectional communication for data frames, but auxiliary ACK frames (simple
tokens of acknowledgment) travel from the other direction. We add flow control to our previous protocol.
When a data frame arrives, instead of immediately sending a separate control frame, the receiver restrains itself and waits
until the network layer passes it the next packet. The acknowledgement is attached to the outgoing data frame (using the ack
field in the frame header). In effect, the acknowledgement gets a
free ride on the next outgoing data frame.
The technique of temporarily delaying outgoing acknowledgements so that they can be hooked onto the next
outgoing data frame is known as piggybacking.
The principal advantage of using piggybacking over having distinct acknowledgement frames is a better use of the available
channel bandwidth.
Timers
Although there can be a timer for each frame that is sent, in our protocol we use only one. The reason is that the
timer for the first outstanding frame always expires first; we send all outstanding frames when this timer expires.
Acknowledgment
The receiver sends a positive acknowledgment if a frame has arrived safe and sound and in order. If a frame is
damaged or is received out of order, the receiver is silent and will discard all subsequent frames until it receives
the one it is expecting. The silence of the receiver causes the timer of the unacknowledged frame at the sender site
to expire. This, in turn, causes the sender to go back and resend all frames, beginning with the one with the expired
timer. The receiver does not have to acknowledge each frame received. It can send one cumulative
acknowledgment for several frames.
Resending a Frame
When the timer expires, the sender resends all outstanding frames. For example, suppose the sender has already
sent frame 6, but the timer for frame 3 expires. This means that frame 3 has not been acknowledged; the sender
goes back and sends frames 3, 4,5, and 6 again. That is why the protocol is called Go-Back-N ARQ.
GOBACK-N ARQ:
To improve the efficiency of transmission (filling the pipe), multiple frames must be in transition while waiting for
acknowledgment. In other words, we need to let more than one frame be outstanding to keep the channel busy while the
sender is waiting for acknowledgment. The first is called Go-Back-N Automatic Repeat Request (the rationale for the
name will become clear later). In this protocol we can send several frames before receiving acknowledgments; we keep
a copy of these frames until the acknowledgments arrive.
Sequence Numbers
Frames from a sending station are numbered sequentially. However, because we need to include the sequence number
of each frame in the header, we need to set a limit. If the header of the frame allows m bits for the sequence number, the
sequence numbers range from 0 to 2m - 1. For example, if m is 4, the only sequence numbers are 0 through 15 inclusive.
However, we can repeat the sequence. So the sequence numbers are
0, 1,2,3,4,5,6, 7,8,9, 10, 11, 12, 13, 14, 15,0, 1,2,3,4,5,6,7,8,9,10, 11, ...
In other words, the sequence numbers are modulo-2m
.
In the Go-Back-N Protocol, the sequence numbers are modulo 1!", where m is the size of the sequence number field in bits.
Frame Format: Each frame in HDLC may contain up to six fields, as shown in Fig: a beginning flag field, an
address field, a control field, an information field, a frame check sequence (FCS) field, and an ending flag field.
In multiple-frame transmissions, ending flag of one frame can serve as the beginning flag of the next frame.
Fields:Let us now discuss the fields and their use in different frame types.
Flag field. The flag field of an HDLC frame is an 8-bit sequence with the bit pattern 01111110 that identifies both
the beginning and the end of a frame and serves as a synchronization pattern for the receiver.
Address field. The second field of an HDLC frame contains the address of the secondary station. If a primary
station created the frame, it contains a to address. If a secondary creates the frame, it contains afrom address. An
address field can be 1 byte or several bytes long, depending on the needs of the network. One byte can identify
up to 128 stations (l bit is used for another purpose). Larger networks require multiple-byte address fields. If the
address field is only 1 byte, the last bit is always a 1. If the address is more than 1 byte, all bytes but the last one
will end with 0; only the last will end with 1. Ending each intermediate byte with 0 indicates to the receiver that
there are more address bytes to come.
Control field. The control field is a 1- or 2-byte segment of the frame used for flow and error control. The
interpretation of bits in this field depends on the frame type.
Information field. The information field contains the user's data from the network layer or management
information. Its length can vary from one network to another.
FCS field. The frame check sequence (FCS) is the HDLC error detection field. It can contain either a 2- or 4-byte
ITU-T CRC.
Control Field: The control field determines the type of frame and defines its functionality. So let us discuss the
format of this field in greater detail. The format is specific for the type of frame
Control Field for I-Frames: I-frames are designed to carry user data from the network layer. In addition, they
can include flow and error control information (piggybacking). The subfields in the control field are used to
define these functions. If the first bit of the control field is 0, this means the frame is an I-frame.
The next 3 bits, called N(S), define the sequence number of the frame. Note that with 3 bits, we can define a
sequence number between and 7; but in the extension format, in which the control field is 2 bytes, this field is
larger. The last 3 bits, called N(R), correspond to the acknowledgment number when piggybacking is used.
The single bit between N(S) and N(R) is called the PIF bit. The PIP field is a single bit with a dual purpose. It has
meaning only when it is set (bit = 1) and can mean poll or final. It means poll when the frame is sent by a primary
station to a secondary (when the address field contains the address of the receiver). It means final when the frame
is sent by a secondary to a primary
Control Fieldfor S-Frames:Supervisory frames are used for flow and error control whenever piggybacking is
either impossible or inappropriate. S-frames do not have information fields. If the first 2 bits of the control field
is 10, this means the frame is an S-frame. The last 3 bits, called N(R), corresponds to the acknowledgment
number (ACK) or negative acknowledgment number (NAK) depending on the type of S-frame.The 2 bits called
code is used to define the type of S-frame itself. four types of S-frames, as described below:
Receive ready (RR). If the value of the code subfield is 00, it is an RR S-frame. This kind of frame acknowledges
the receipt of a safe and sound frame or group of frames. In this case, the value N(R) field defines the
acknowledgment number.
Receive not ready (RNR). If the value of the code subfield is 10, it is an RNR S-frame. This kind of frame is an
RR frame with additional functions. It acknowledges the receipt of a frame or group of frames, and it announces
that the receiver is busy and cannot receive more frames.
Reject (REJ). If the value of the code subfield is 01, it is a REJ S-frame. This is a NAK frame, but not like the one
used for Selective Repeat ARQ. It is a NAK that can be used in Go-Back-N ARQ to improve the efficiency of
the process by informing the sender, before the sender time expires, that the last frame is lost or damaged..
Selective reject (SREJ). If the value of the code subfield is 11, it is an SREJ S-frame. This is a NAK frame used
in Selective Repeat ARQ. Note that the HDLC Protocol uses the term selective reject instead of selective repeat.
The value of N(R) is the negative acknowledgment number.
Control Fieldfor U-Frames: Unnumbered frames are used to exchange session management and control
information between connected devices.
Unlike S-frames, U-frames contain an information field, but one used for system management information, not
user data.
As with S-frames, however, much of the infonnation carried by U-frames is contained in codes included in the
control field
1. PPP provides framing method that describes the end of one frame & the start of the next one frame format also
handles error detection.
2. Link control protocol(LCP) for bringing lines up, testing them & bringing them down again when they are no
longer needed.
3. Network control protocol method chooser to have a different NCP for each network layer supported.
All PPP frames begin with the std HDLC flag byte 01111110.
Address field indicate that all stations accept the frame. It always sets to binary value 111111111.
Control field indicates an unnumbered frame. Its default value is 00000011.
Protocol field indicates the type of packet in payload field.
Protocol starting with 0 bit is network layer.
Protocol starting with 1 are other protocols
Payload field is variable length, if the length is not defined using LCP, a default length of 1500 bytes is used.
Checksum field is used for error detection.
The simplified phase diagram shows the phases that a line goes through when it is brought up, used & taken
down again.
The protocol starts with the line in the DEAD state, which means that no physical layer carrier is present and no
physical layer connection exists.
After physical connection is established, the line moves to ESTABLISH.
At that point LCP option negotiation begins, which, if successful, leads to AUTHENTICATE.
Now the two parties can check on each other's identities if desired.
When the NETWORK phase is entered, the appropriate NCP protocol is invoked to configure the network layer. If
the configuration is successful, OPEN is reached and data transport can take place.
When data transport is finished, the line moves into the TERMINATE phase, and from there, back to DEAD when
the carrier is dropped.