CN U2
CN U2
CN U2
UNIT – II
• For ideal channel (no distortion, unlimited bandwidth and no delay), the
job of data link layer would be trivial. But limited bandwidth, distortions
and delay makes its job very difficult.
• Transmission at data link layer starts with breaking up the bit stream
- Into discrete frames
- Computation of a checksum for each frame and
- Include the checksum into the frame before it is transmitted.
• Burst error - Two or more bits in the data unit have changed.
Error Detection and Correction - Redundancy
• To detect or correct errors, extra (redundant) bits are added along with the
data.
• Ratio of redundant bits to data bits and robustness of the process are
important in coding schemes.
• We add ‘r’ redundant bits to each block to make the length n = k + r. The
resulting n-bit blocks are called Codewords.
• The receiver receives 011. It is a valid codeword. The receiver extracts the dataword
01 from it.
• The codeword is corrupted during transmission and 111 is received. This is not a
valid codeword and is discarded.
• The codeword is corrupted during transmission, and 000 is received. This is a valid
codeword. The receiver incorrectly extracts the dataword 00. Two corrupted bits
have made the error undetectable.
Example (Contd.)
• By adding more redundant bits to previous example, see if the receiver can correct
an error without knowing what was actually sent.
• We add 3 redundant bits to the 2-bit dataword to make 5-bit codeword. Table
shows the datawords and codewords.
• Assume the dataword is 01. The sender creates the codeword 01011.
• The codeword is corrupted during transmission, and 01001 is received. First, the
receiver finds that the received codeword is not in the table. This means an error
has occurred.
• The receiver, assuming that there is only 1 bit corrupted, uses the following
strategy to guess the correct dataword.
Example (Contd.)
• Comparing the received codeword with the first codeword in the table (01001
versus 00000), the receiver decides that the first codeword is not the one that
was sent because there are two different bits.
• By the same reasoning, the original codeword cannot be the third or fourth one
in the table.
• The original codeword must be the second one in the table because this is the
only one that differs from the received codeword by 1 bit. The receiver replaces
01001 with 01011 and consults the table to find the dataword 01.
Hamming distance
• One of the key concepts in coding for error control is Hamming distance.
• The Hamming distance between two words is the number of differences
between the corresponding bits.
• The minimum Hamming distance, dmin is the smallest Hamming distance
between all possible pairs in a set of words which is used for designing a
code.
Ex: Let us find the Hamming distance between two pairs of words.
Solution:
• Error Correction:
• To guarantee the correction of up to ‘t’ errors in all cases, the minimum
Hamming distance in a block code must be dmin = 2t + 1.
• A code scheme has a Hamming distance dmin = 4. What is the error detection
and correction capability of this scheme?
Linear Block Codes
• Almost all block codes used today belong to a subset called Linear Block
Codes. A linear block code is a code in which the exclusive OR (XOR)
(modulo-2 addition) of any two valid codewords creates another valid
codeword.
2. One single-bit error changes a1 . The received codeword is 10011. The syndrome is 1. No
dataword is created.
3. One single-bit error changes r0 . The received codeword is 10110. The syndrome is 1. No
dataword is created.
4. An error changes r0 and a second error changes a3 .The received codeword is 00110. The
syndrome is 0. The dataword 0011 is created at the receiver. Note that here the dataword is
wrongly created due to the syndrome value.
5. Three bits a3, a2, and a1 are changed by errors. The received codeword is 01011. The
syndrome is 1. The dataword is not created. This shows that the simple parity check,
guaranteed to detect one single error, can also find any odd number of errors.
Two-dimensional parity-check code
• Performance can be improved by using two-dimensional parity check.
• The whole table is sent to the receiver, which finds the syndrome for each
row and each column.
Two-dimensional parity-check code
Two-dimensional parity-check code
Hamming codes
• Single parity bit can only detect error, not correct it.
• Hamming code is an important error correcting code that requires more than a
single parity bit.
• Hamming codes are codewords formed by adding redundant check bits, or parity
bits to a data word.
r0 = a2 + a1 + a0 s0 = b2 + b1 + b0 + q0
r1 = a3 + a2 + a1 s1 = b3 + b2 + b1 + q1
r2 = a1 + a0 + a3 s2 = b1 + b0 + b3 + q2
Logical decision made by the correction logic analyzer:
• The words are then sent column by column. When a burst error occurs, it
will affect 1 bit in several words as the transmission is read back into the
block format and each word is checked individually.
Burst error correction using Hamming code
Checksum
• In checksum error detection scheme, the data is divided into ‘k’ segments
each of ‘m’ bits.
• In the sender’s end the segments are added using 1’s complement arithmetic
to get the sum.
• The sum is complemented to get the checksum.
• The checksum segment is sent along with the data segments.
• At the receiver’s end, all received segments are added using 1’s complement
arithmetic along with the checksum to get the sum.
• The sum is complemented. If the result is zero, the received data is accepted;
otherwise it is discarded.
• The checksum detects all errors involving an odd number of bits. It also
detects most errors involving even number of bits.
Example
Cyclic Codes
• Cyclic codes are special linear block codes with one extra property.
• It is done to make flow control and error control efficient. Frames can be of
fixed or variable size.
Byte stuffing -
Process of
adding 1 extra
byte whenever
there is a flag or
escape character
in the text.
Bit Oriented Protocols
• Data section of a frame is a sequence of bits to be interpreted as text,
graphic, audio, video and so on..
• In addition to header and possible trailers, a delimiter is used to separate
one frame from the other.
• Most protocols use a special 8-bit pattern flag 01111110 as delimiter.
• If the flag pattern appears in the data, we stuff 1 bit to prevent the pattern
from looking like a flag – BIT STUFFING.
• If a 0 is followed by 5 consecutive 1’s, an extra 0 bit is added regardless of
the next bit.
• This guarantees that the flag sequence does not appear in the frame.
A Frame In A Bit-Oriented Protocol
• The most important responsibilities of the data link layer are flow control
and error control. Collectively, these functions are known as data link control.
• Flow control refers to a set of procedures that tells the sender how much
data it can send before waiting for an acknowledgment from the receiver.
• The flow of data must not be allowed to overwhelm the receiver. Most of the
receivers are provided with buffers for storing incoming data until they are
processed. If buffer is full, receiver asks to halt the transmission.
• Unidirectional protocol.
• Sender cannot send a frame until network layer has packet to send.
• Procedures at both sites are constantly running as they don’t know when
the event occurs.
Design of simplest protocol with no flow or error control
Sender-site algorithm
Receiver-site algorithm
Simplest Protocol
Flow diagram
Stop-and-Wait Protocol
• If frames arrive at the receiver faster than they can be processed, they must
be stored until their use. Receiver may not have enough buffer space (may
receive data from other sources also) which results in discarding of frames
or denial of service.
• To detect and correct corrupted frames in Stop-and-Wait ARQ, redundant bits are
added.
• When the frames arrive at receiver, they are checked and if it is corrupted, it is
silently discarded. Detection is manifested by the silence of the receiver.
• Error correction in Stop-and-Wait ARQ is done by keeping a copy of the sent frame
and starts a timer. It retransmits the frame if ACK is not received before the timer
expires.
• Receiver has buffer ‘W’ long and we can send up to ‘W’ frames without ACK.
• If header of frame allows m-bits for sequence number, the sequence numbers
range from 0 to 2m – 1.
• Example for m = 3, sequence numbers are: 0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5,
6, 7.
• Sliding window defines the range of sequence numbers that is the concern of
sender and receiver.
• The send window is an imaginary box with three variables: Sf, Sn, Ssize.
• Receiver has only one variable, Rn, that holds the sequence number of the
frame it expects to receive.
Sender Sliding Window
• If the frames are damaged/out of order, receiver is silent and discard all subsequent
frames until it receives the one it is expecting.
• The silence of the receiver causes the timer of the unacknowledged frame to expire.
• Then the sender resends all frames, beginning with the one with the expired timer.
• For example, suppose the sender has sent frame 6, but the timer for frame 3 expires
(i.e. frame 3 has not been acknowledged), then the sender goes back and sends frames
3, 4, 5, 6 again. Thus it is called Go-Back-N-ARQ.
• The receiver does not have to acknowledge each frame received, it can send one
cumulative ACK for several frames.
Go-Back-N ARQ, Normal Operation
• The sender keeps track of the outstanding frames and updates the
variables and windows as the ACKs arrive.
Go-Back-N ARQ, lost Frame
• Frame 2 is lost.
• When the receiver
receives frame 3, it
discards frame 3 as it is
expecting frame 2
(according to window).
• After the timer for frame
2 expires at the sender
site, the sender sends
frame 2 and 3 (go back to
2).
Go-Back-N ARQ, Sender Window Size
• Size of the sender window must be less than 2m .
• Size of the receiver is always 1.
• If m = 2, window size = 2 m – 1 = 3.
• Fig. compares a window size of 3 and 4.
Accepts
as the 1st
frame in
the next
cycle-an
error
Design of Go-Back-N ARQ
Selective Repeat ARQ
• Go-Back-N ARQ is inefficient for a noisy link.
• In a noisy link, frames have higher probability of damage, which means the
resending of multiple frames.
• This resending consumes the bandwidth and slows down the transmission.
Solution:
• Selective Repeat attempts to retransmit only those frames that are actually
lost (due to errors).
– Receiver must be able to accept frames out of order.
• It defines a Negative Acknowledgement (NAK) that report the sequence
number of a damaged frame before the timer expires.
• It is more efficient for noisy link, but the processing at the receiver is more
complex. Size of the window is (2m-1).
Selective Repeat ARQ, sender and receiver windows
• The window size is reduced to one half of 2m
• Sender window size = receiver window size = 2m/2
• Window size = 2m-1
• If m = 2, Window size = 4/2=2
• Sequence number = 0, 1, 2, 3
Selective Reject (NAK)
• Also called selective retransmission
• Minimizes retransmission
• The receiver waits until its network layer passes in the next data packet.
The delayed acknowledgement is then attached to this outgoing data
frame.
• Every node has two windows: Send and Receive both using the same algorithms.
• Although HDLC is a general protocol that can be used for both point-to-
point and multipoint configurations, one of the most common protocols for
point-to-point access is the Point-to-Point Protocol (PPP).
• PPP is a byte-oriented protocol using byte stuffing with the escape byte to
be 01111101.
High-level Data Link Control
HDLC Station Types:
Flag: 8-bit and the sequence 01111110 identifies the beginning and end of
the frame. Serves as synchronization pattern for receiver.
FCS: Frame Check Sequence is error detection field. Contains 2/4-byte CRC.
Address: Contains the address of the secondary station.
If ‘primary’ created the frame, it contains to address else a from address. It
can be one byte (last bit is 1) or more . If the address is more than one byte, all
bytes end with zero except the last byte ends with 1. Ending each
intermediate byte with 0 indicates to the receiver that more address bytes are
to come.
Control Field: Determine the type of frame and defines its functionality (used
for flow and error control). It is 1 or 2 byte long.
Control field format for different frame types
I-Frame
- Final: Frame sent by secondary station (the address field contain the address of the
sender) to primary.
S-Frame Control Field in HDLC
1. Receiver ready (RR): 00 - receiver acknowledges the receipt of a safe frame and ready
to accept more frames.
2. Receiver not ready (RNR): 10 - receiver not ready to accept more frames because it is
busy.
3. Reject (REJ): 01 - This is NAK Frame that can be used in ‘Go-Back-N’ to improve the
efficiency by informing the sender that the last frame is lost or damaged.
• Control: No need because PPP has no flow control and limited error control
• PPP is a byte-oriented protocol using byte stuffing with the escape byte
01111101
PPP: Transition States
• Multiple access protocols are needed in LANs, Wi-Fi, and satellite networks to control
the share media.
Human Communication Protocols
Problem of controlling the access to the medium is similar to the rules of
speaking in an assembly :
• Give everyone a chance to speak
• Raise your hand if you have a question
• Don’t speak until you are spoken to
• Don’t interrupt when someone is speaking
• Don’t monopolize the conversation
ALOHA
• Collision: an access conflict occurs when more than one station tries to send,
as a result the frame will be either destroyed or modified.
• Each station follows a procedure that answer the following questions to
avoid collision:
• When can the station access the medium?
• What can the station do if the medium is busy?
• How can the station determine the success or failure of the
transmission?
• What can the station do if there is an access conflict ?
Evolution of Random-Access methods
ALOHA: Uses MA (Multiple Access) No carrier sense
• It divides the time into slots of Tfr and force the station to send only at the
the beginning of the time slot.
• If the station miss the beginning of synchronized time slot, it must wait
until the beginning of next time slot.
Frames in a Slotted ALOHA network
Carrier Sense Multiple Access (CSMA)
Developed to minimize collisions and increase the performance
• A station now “follows” the activity of other stations
• Simple rules for a polite human conversation
• If someone else begins talking at the same time as you, stop talking
• Based on the principle “Listen before talk” or “Sense before transmit”
CSMA
• A node should not send, if another node is already sending → carrier
sensing
C
Vulnerable time in CSMA
• Vulnerable time: Time in which there is a possibility of collision
• Vulnerable time for CSMA is the max propagation time, Tp needed for a
signal to propagate from one end of the medium to the other.
• When a station sends a frame, and any other station tries to send during this
time it leads to collision.
• But if the first bit of frame reaches the end of medium, every other station
will already have heard the bit and will refrain from sending
Types of CSMA Protocols
1. 1-persistence method
2. Non-persistence method
3. P-Persistence method
1-persistence method
Jamming signal enforces the collision in case other stations have not yet sensed
the collision
Collision Detection
• How the station detects a collision?
• Detecting voltage level on the line
• Detecting energy level.
• Detecting simultaneous transmissions and receptions
• Energy in channel can have three values: zero, normal, and abnormal.
• At zero level, the channel is idle
• At the normal level, a station has successfully captured the channel and is
sending its frame.
• At the abnormal level, there is a collision and the level of the energy is twice
the normal level
CSMA/CA
• In CSMA/CA, if the station finds the channel busy, it does not restart the
timer of the contention window; it stops the timer and restarts it when the
channel becomes idle.
• CSMA/CA was mostly intended for use in wireless networks
Contention window
size is 2K-1
• Predecessor is the station which is logically before the station in the ring
• Successor is the station which is logically after the station in the ring
• How is the right to access the channel passed from one station to another?
• Station is authorized to send data when it receives a special packet called a
token
• Stations are arranged around a ring.
• When no data are being sent, a token circulates the ring.
• If a station needs to send data, it waits for the token.
• The station captures the token and sends one or more frames (as long as it
has frames to send or the allocated time has not expired), and finally it
releases the token to be used by next station (successor).
• The maximum time any station can hold the token is limited.
• Since there is only one token, only one station transmits at a time, and
collisions never occur.
Token management is needed for this access method:
• Stations must be limited in the time they can have possession of the token.
• The token must be monitored to ensure it has not been lost or destroyed (if
the station that is holding the token fails, the token will disappear from the
network).
• With the above two properties taken into consideration, let us see
how the 4 stations can send data using the common channel.
Simple idea of communication with code
• Any station that wants to receive data from one of the other 3
multiplies the data on the channel by the code of the sender.
• For example, stations 3 and 4 are talking to each other. Station 4
wants to hear what station 3 is saying. It multiplies the data on the
channel by c3.
• Data = (d1⋅ c1 + d2 ⋅ c2 + d3 ⋅ c3 + d4 ⋅ c4) ⋅ c3
= d1⋅ c1⋅ c3 + d2 ⋅ c2 ⋅ c3 + d3 ⋅ c3 ⋅ c3 +d4 ⋅ c4 ⋅ c3
= 4 × d3
Chip Sequences
• Each station is assigned a unique chip sequence
• Data Representation
Transmission in CDMA
CDMA Encoding
Signal Created by CDMA
CDMA Decoding
IEEE 802.11 Wireless LAN Standard
• In response to lacking standards, IEEE developed the first
internationally recognized wireless LAN standard – IEEE 802.11
• IEEE published 802.11 in 1997, after seven years of work
• Scope of IEEE 802.11 is limited to Physical and Data Link Layers
• Benefits:
Appliance Interoperability
Fast Product Development
Stable Future Migration
Price Reductions
The 802.11 standard takes into account the following significant
differences between wireless and wired LANs:
Power Management
Security
Bandwidth
IEEE 802.11 Terminology
Access Point (AP): A station that provides access to the DS.
Basic Service Set (BSS) :
A set of stationary or mobile wireless stations and an optional central
base station, known as the access point (AP).
Distribution System (DS): A system used to interconnect a set of BSSs
to create an ESS.
DS is implementation-independent. It can be a wired 802.3
Ethernet LAN, 802.4 token bus, 802.5 token ring or another
802.11 medium.
Extended Service Set (ESS):Two or more BSS interconnected by DS
Extended service set uses two types of stations: mobile and
stationary
The mobile stations are normal stations inside a BSS. The
stationary stations are AP stations that are part of a wired LAN.
IEEE 802.11 – MAC Sublayer
• IEEE 802.11 defines two MAC sublayers:
• The Distributed Coordination Function (DCF) and the Point
Coordination Function (PCF)
Frame Control (FC): The FC field is 2 bytes long and defines the type of
frame and some control information
Subfields in FC field
Frame format (Contd.)
• D (Duration):
• In all frames types (except in one type), this field defines the value of
NAV.
• In one control frame only, this field defines the ID of the frame.
• Addresses:
• There are 4 address fields, each 6 bytes long.
• The meaning of each address field depends on the value of To DS and
From DS subfields.
• Sequence Control:
• This field defines the sequence number of the frame to be used in
flow control.
Frame format (Contd.)
• Frame body:
• This field, which ranges between 0 and 2312 bytes, contains
information based on the type and the subtype defined in the FC field.
• FCS:
• The FCS field is 4 bytes long and contains a CRC-32 error detection
sequence.
Frame Types
• IEEE 802.11 has 3 categories of frames: Management frames, Control
frames, Data frames.
• Management frames: Management frames are used for the initial
communication between stations and access points.
• Control frames: Control frames are used for accessing the channel
and acknowledging frames.
Values of subfields in
control frames
Data Frames: Data frames are used for carrying data and control information.