Unit Iv: Framing, Flow Control, Error Detection & Correction, CSMA, CSMA/CD, HDLC and PPP
Unit Iv: Framing, Flow Control, Error Detection & Correction, CSMA, CSMA/CD, HDLC and PPP
Unit Iv: Framing, Flow Control, Error Detection & Correction, CSMA, CSMA/CD, HDLC and PPP
Types of Framing
1. Fixed-Size Framing
2. Variable-Size Framing
FRAMING
1. Fixed-Size Framing
In fixed-size framing, there is no need for defining the boundaries of the
frames; the size itself can be used as a delimiter
Ex : ATM wide-area network
2. Variable-Size Framing
In variable-size framing, we need a way to define the end of the frame
and the beginning of the next
Two approaches used to delimit the frame
i. a character-oriented approach
ii. a bit-oriented approach
FRAMING
Character-Oriented Protocols
The flag could be selected to be any character not used for text communication.
The data section is stuffed with an extra byte. This byte is usually called the
escape character (ESC), which has a predefined bit pattern.
Whenever the receiver encounters the ESC character, it removes it from the
data section and treats the next character as data, not a delimiting flag.
Bit-Oriented Protocols
In a bit-oriented protocol, the data section of a frame is a sequence of bits to be
interpreted by the upper layer as text, graphic, audio, video, and so on
Most protocols use a special 8-bit pattern flag 01111110 as the delimiter to
define the beginning and the end of the frame,
❖ Enquiry/Acknowledgment (ENQ/ACK)
❖ Poll/Select
Flow Control
Second aspect of Data link control- Flow Control
Set of procedures that tells the sender as how much data it can
transmit before waiting for an acknowledgment from the receiver.
Receiver got set of memory blocks called the BUFFER that store
the incoming data before they are processed.
If buffer begins to fill up, receiver must be able to tell the sender to
send fewer data frames or halt the transmission until the buffer is
free to accept the data frame again.
Under this we got two techniques:
Frames can be sent one after another i.e. link can carry
several frames at once and its capacity can be used
efficiently
At receiver we got not n-1 data frames but n-1 spaces for frames
As new frames come in the size of the receiver window shrinks
Receiver window does not represent number of frames received but
number of frames that may still be received before an ACK can be
sent.
If a receiver got a window size of w, if three frames are received
without being acknowledged , number of spaces in window is w-3.
As soon as ACK is received , the window expands to include more
spaces for number of frames equal to number of frames
acknowledged
Let us take the receiving window of size 7 i.e 0 through 6
With the arrival of data frame 0, receiving window shrinks moving
from 0 to 1 and receiver window has now shrunk to six frames before
sending an ACK
Once say frames 0 through 3 are received without sending an ACK,
receiving window now shrinks to 3 frame spaces.
Sliding Window
Automatic Repeat Request (ARQ)
42
Error Detection & Correction
❖ Single bit error: Error where only one bit of given data
unit such as byte, character or packet is changed from 0
to 1.
❖ Burst Error : Error where two or more bits in a given data
unit have changed from 1 to 0 or 0 to 1.
43
Single Bit Error
44
Burst Error
45
Error Detection Techniques
46
Redundancy
47
48
Four types of redundancy checks are used
in data communications
Vertical Redundancy Check - VRC
Performance
▪ If two bits in one data units are damaged and two bits in
exactly the same positions in another data unit are also
damaged, the LRC checker will not detect an error.
VRC and LRC
Cyclic Redundancy Check (CRC)
67
Checksum
68
At the sender
• Error Detection:
• For a single bit error detection, the distance between any pair of valid
codewords must be at least 2
• Suppose C1 and C2 are two valid codewords and the distance between
C1 and C2 is 1: C1 = 101101 and C2 = 101100 (the last bit differs)
• Due to single bit error in C2 in the last bit position, C2 becomes C1,
also a valid codeword
• Error detection fails
• If the distance is 2, a single bit error still make their difference at least 1
• Error detection successful
• For detecting k errors, the distance must be at least (k+1)
Hamming Code
• Error Correction:
• Received codeword with bit errors can only be corrected if we can
determine the bit positions where the bit errors have been taken place
• After correction, the received codeword will be converted to one and only one
valid codeword
• For single bit error correction, the distance must be at least 3
110101 010101
Invalid Invalid
101101 codewords 001101
codewords
100001 000001
100111 000111
Valid Valid
100100 codewords 000100 codeword
Hamming Code
• Illustration of k bit Error Correction:
• For k bit error correction, the distance must be at least (2k+1)
Distance = 2k
Common Part K bit K bit Unchanged Part K bit changed
C1
C2
C1
C2
K bit changed
bit
Distance = 2k+1
Hamming Code
• Encoding and decoding technique developed by R.W. Hamming [1950]
• Up to one bit error correction and two bit error detection can be done
• Minimum distance in hamming code is 3
• Number of redundancy bits (r) can be determined for a given data block
size of ‘m’ bits by using the following formula:
f8 f4 f2 f1
Step 4: Now we perform even parity check for each column of the
above table. Set a parity bit to 1 to ‘f1’ if the total number of ones in
the corresponding positions of its column is
odd. Set a parity bit to 0 if the total number of ones in the positions
it checks is even. Then, we repeat this process for ‘f2’, ‘f4’, ‘f8’ and
so on.
Hamming Code
Example: Suppose we have to transmit a data block 7 bits: 1001101. We
need to generate a hamming code of this data block.
Step 1: We need to determine minimum value of ‘r’ first, where 2r >= 7+r+1.
We find r = 4.
Step 2: The codeword will be looked like as follows:
11 10 9 8 7 6 5 4 3 2 1
1 0 0 f8 1 1 0 f4 1 f2 f1
Step 3 & 4: Determination of redundancy bits:
f1 depends upon the bits in the positions of 3, 5, 7, 9, 11. Number of ones
is 3, which is odd. To make it even, the redundancy bit f1 will be 1
f2 depends upon the bits in the positions of 3, 6, 7, 10 and 11. Number of
ones is 4, which is even. So, the redundancy bit f2 will be 0
Following the similar procedure, the value of f4 and f8 will be 0 and 1
respectively
Hence the final codeword will be as follows:
11 10 9 8 7 6 5 4 3 2 1
1 0 0 1 1 1 0 0 1 0 1
Hamming Code
Illustration:
f1
f2
f4
f8
Hamming Code
• Error Detection and Correction:
Suppose in the above example the 5th bit is changed from 0 to 1
during data transmission, then it gives new parity values for the
codeword:
11 10 9 f8 7 6 5 f4 3 f2 f1 11 10 9 f8 7 6 5 f4 3 f2 f1
1 0 0 1 1 1 0 0 1 0 1 1 0 0 1 1 1 1 0 1 0 1
Sent bits Received bits
Bit Positions Number New Parity The bits give the binary number
of 1s values as 0101 whose decimal
representation is 5. Thus, the bit
f1,3,5,7,9,11 5 (odd) 1 5 contains an error. To correct
f2,3,6,7,10,11 4 (even) 0 the error the 5th bit is changed
from 1 to 0.
f4,5,6,7 3 (odd) 1
f8,9,10,11 2 (even) 0
Hamming Code
▪ b1 ⊕ b3 ⊕ b5 ⊕ b7 ⊕ b9 ⊕ b11 = 0 c1 ⊕ d1 ⊕ d2 ⊕ d4 ⊕ d5 ⊕ d7 = 0 0 ⊕ 1 ⊕
0⊕0⊕x⊕1=0 x=0
▪ b2 ⊕ b3 ⊕ b6 ⊕ b7 ⊕ b10 ⊕ b11 = 0 c2 ⊕ d1 ⊕ d3 ⊕ d4 ⊕ d6 ⊕ d7 = 0 1 ⊕ 1
⊕ 1 ⊕ 0 ⊕ 0 ⊕ 1 = 0 (No x or y)
▪ b4 ⊕ b5 ⊕ b6 ⊕ b7 ⊕ b12 = 0 c4 ⊕ d2 ⊕ d3 ⊕ d4 ⊕ d8 = 0 0 ⊕ 0 ⊕ 1 ⊕ 0 ⊕ 1
= 0 (No x or y)
▪ b8 ⊕ b9 ⊕ b10 ⊕ b11 ⊕ b12 = 0 c8 ⊕ d5 ⊕ d6 ⊕ d7 ⊕ d8 = 0 y ⊕ x ⊕ 0 ⊕ 1 ⊕
1 = 0 y =0
Forward Error Correction (FEC)
Convolutional codes
• A convolutional code encoder accepts k-bit blocks of the
information sequence "u" and generates an encoded
sequence "v" of n-symbol blocks. However, each encoded
block is dependent on "m" prior message blocks and the
matching k-bit message block at the same time unit.
• To provide reliable transmission across a noisy channel and
redundant bits, n-k, further redundancy is added by raising the
memory order "m" of the code.
Medium Access control
Methods –CSMA, CSMA/CA &
/CD
MULTIPLE ACCESS PROTOCOLS
• When nodes or stations are connected and use a common link called
a multipoint or broadcast link. We need a multiple-access protocol to
coordinate access to the link.
• The problem of controlling the access to the medium is similar to the
rules of speaking in an assembly.
• The procedures guarantee that the right to speak is upheld and ensure
that
• Two people do not speak at the same time,
Each station has the right to the medium without being controlled by
another station
If more than one station tries to send, there is an access conflict-
collision and frames will be either destroyed or modified
To avoid access conflict or to resolve it when it happens, each
station follows a procedure which answers the following queries:
▪ When can station access the medium
▪ What can station do if medium is busy
▪ How can the station determine the success or failure of the
transmission
▪ What can station do if there is an access conflict
Random access methods we would be studying have evolved
from a very interesting protocol known as ALOHA which uses a
very simple procedure called Multiple Access (MA)
97
CSMA protocol
■ CSMA requires that each station first listen to the medium before sending
■ CSMA can reduce the possibility of collision but cannot eliminate it.
■ When a station sends a frame and any other station sends a frame
during this time, a collision will result.
■ But if the first bit of frame reaches the end of medium, every
station will have heard the bit and will refrain from sending.
■ Figure in next slide shows the worst case where a frame sent by
station A at time t1 reaches the rightmost station D at time t1+ Tp
Vulnerable Time in CSMA
Behavior of three persistence methods
1-Persistent CSMA protocol
If the medium is busy it waits until it becomes idle and sends its
frame with a probability of 1.
Before sending the last bit of frame, sending station must detect
collision , if any must abort the transmission
Reason for this is a station once sent the entire frame does not
monitor the line for collision detection
Solution
The frame transmission time is Tfr = 2 × Tp = 51.2 μs. This means, in the worst
case, a station needs to transmit for a period of 51.2 μs to detect the collision. The
minimum size of the frame is 10 Mbps × 51.2 μs = 512 bits or 64 bytes. This is
actually the minimum size of the frame for Standard Ethernet.
HDLC and PPP
The Data Link Layer in the Internet
A home personal computer acting as an internet host.
115
PPP Design Requirements [RFC 1557]
116
PPP Design Requirements (cont.)
117
PPP non-requirements
• No error correction/recovery
(modems do one layer FEC, one layer packetization +
retransmission “under the covers” anyway; other
technologies are pretty reliable)
• No flow control
• Out of order delivery OK
118
PPP Data Frame
119
PPP Data Frame
120
Byte Stuffing
flag byte
pattern
in data
to send
122
Where does PPP get used?
123
High-Level Data Link Control (HDLC)
Unbalanced Mode
Commands
Primary
Responses
Secondary Secondary
Balanced
mode
Combined Combined
commands/Responses
HDLC
Both the above modes mean that the secondary node is logically
disconnected from the primary node
• Initialization Mode
• A node negotiates transmission parameters with the other node E.g., flow
control information
• Parameters negotiated in this mode are used during any of the data
transfer modes
Data Link Control HDLC frame structure
(a) Frame
Format
(b) Control
field
format
Data Link Control
HDLC frame structure
• Flag: 01111110- start and ending delimiter. Bits are stuffed for flags in data frames
• FCS: 16-bit CRC using generating polynomial
G(x) = x16 + x12 + x5 + 1
• Address field:
• mainly used in multidrop link configuration, and not used in point-to-point
• In unbalanced configuration, every secondary is assigned a unique address. Contains
address of secondary station in both command and response frames
• In balanced mode, command frame has destination address and response frame has sending
node’s address
• Group addresses are also possible. E.g., One command sent to all the secondaries
• In I-frames, N(s) is the sequence number of the frame being sent, and R(s) is the
sequence number of the frame being expected.
• The P/F bit, known as the poll/final bit, is used with different meaning in different
contexts.
• It is used to indicate polling, to indicate the final I-frame, etc
HDLC
• Services
• Framing
• Error control
• Reliability
• Connection management
• Medium access control
• Switching
• Protocols, Standards
• Ethernet
• Token Ring
• FDDI
• Wireless
• PPP
• HDLC