Вы находитесь на странице: 1из 97

Data Link Layer

Data Link Layer

Chapter Outline
 Local Area Networks
 Multiple Access Methods
 Wireless Local Area Networks
 Point-to-Point Protocols
 Error Control
 Error Detection
 Error Correction

Dr. Atef Abdrabou 2

Data Link Layer

Data Link Layer

Multiple Access Connections Point-to-Point Connections

• Local Area Networks (e.g., Ethernet) • Point-to-Point Protocols

• Multiple Access Methods (e.g. PPP protocol)
• Wireless Local Area Networks (WLANs)

Dr. Atef Abdrabou 3

Medium Access Control
Protocols and Local Area Networks

Overview of LANs
Typical LAN Structure Section 13.1

 Transmission
 Network Interface
Card (NIC)
 Unique MAC
“physical” address



Dr. Atef Abdrabou 5

The IEEE 802 LAN Standards Section 13.1
In IEEE 802.1, Data Link Layer divided into:
1- Logical Link Control Sublayer
2- Medium Access Control Sublayer

Network layer Network layer

LLC 802.2 Logical link control

Data link
802.3 802.5 802.11 Other
MAC Ethernet
Token Ring Wireless LANs

Various physical layers Physical

Dr. Atef Abdrabou 6
Logical Link Control Sublayer
 IEEE 802.2: LLC enhances service provided
by MAC
 It provides a means for exchanging frames
between LANs that use different MAC
 Offer the network layer a set of services while
hiding the details of the underlying MAC

Dr. Atef Abdrabou 7

Medium Access Control Sublayer
 Coordinate access to medium
 Connectionless frame transfer service
 Machines identified by MAC/physical
 Broadcast frames with MAC addresses

Dr. Atef Abdrabou 8

Encapsulation of MAC frames


PDU Header


Dr. Atef Abdrabou 9

Medium Access Control
Protocols and Local Area

IEEE 802.3 MAC Frame Section 13.2
802.3 MAC Frame
7 1 6 6 2 4
Destination Source
Preamble SD Length Information Pad FCS
address address
Synch Start 64 - 1518 bytes

 Every frame transmission begins “from scratch”

 Preamble helps receivers synchronize their clocks
to transmitter clock
 7 bytes of 10101010 generate a square wave
 Start frame byte changes to 10101011
 Receivers look for change in 10 pattern
Dr. Atef Abdrabou 11
IEEE 802.3 MAC Frame Section 13.2
802.3 MAC Frame
7 1 6 6 2 4
Destination Source
Preamble SD Length Information Pad FCS
address address
Synch Start 64 - 1518 bytes

0 Single address • Destination address

• single (unicast) address
• group (multicast) address
1 Group address • broadcast = 111...111
• Source address
•first 24 bits assigned to manufacturer;
• next 24 bits assigned by manufacturer
• Cisco 00-00-0C
• 3COM 02-60-8C
Dr. Atef Abdrabou 12
MAC Destination Address
Types Section 13.2
 The least significant bit of the first
byte defines the type of address
 If the bit is 0 (the second
hexadecimal digit from the left is
even), the address is unicast;
otherwise, it is multicast
 The broadcast destination address
is a special case of the multicast
address in which all bits are 1s
 Example: Determine the type of the
following MAC destination
 a. 4A:30:10:21:10:1A
c. FF:FF:FF:FF:FF:FF Dr. Atef Abdrabou 13
IEEE 802.3 MAC Frame Section 13.2
802.3 MAC Frame
7 1 6 6 2 4
Destination Source
Preamble SD Length Information Pad FCS
address address
Synch Start 64 - 1518 bytes

 Length: # bytes in information field

 Max frame 1518 bytes, excluding preamble & SD
 Max information 1500 bytes: 05DC
 The length field is replaced by the upper protocol type in
Ethernet II frames (e.g., 0x0800 for the IP protocol)
 Pad: ensures min frame of 64 bytes
 FCS: CCITT-32 CRC, covers addresses, length,
information, pad fields
Dr. Atef Abdrabou 14
 NIC discards frames with improper lengths or failed CRC
IEEE 802.3 Physical Layer Section 13.2

IEEE 802.3 10 Mbps medium alternatives

10base5 10base2 10baseT 10baseFX

Medium Thick coax Thin coax Twisted pair Optical fiber

Max. Segment Length 500 m 200 m 100 m 2 km
Topology Bus Bus Star
point link

Hubs & Switches!

(a) transceivers (b)

Thick Coax: Stiff, hard to work withDr. Atef Abdrabou

T connectors flaky 15
Ethernet Hubs & Switches Section 13.2 &

Single collision domain

High-Speed backplane
(a)       (b) or interconnection fabric

   

Twisted Pair Cheap

Easy to work with Twisted Pair Cheap
Reliable Bridging increases scalability
Star-topology CSMA-CD Separate collision domains
Dr. Atef Abdrabou
Full duplex operation 16
Hubs, Bridges & Routers
Section 13.2 & 17.1

 Interconnecting Hubs
 Repeater: Signal regeneration
 All traffic appears in both LANs
 Bridge: MAC address filtering Higher
 Local traffic stays in own LAN
 Routers: Internet routing
 All traffic stays in own LAN

Hub Hub
Two Twisted Two Twisted
Pairs Pairs

Station Station StationDr. Atef Abdrabou

Station Station
Bridge Function Section 13.2

Dr. Atef Abdrabou 18

Transparent Bridges Section 17.1.2

 Interconnection of IEEE LANs with

complete transparency
 Use table lookup, and S1 S2 S3
 discard frame, if source &
destination in same LAN
 forward frame, if source & LAN1
destination in different LAN
 use flooding, if destination
unknown LAN2
 Use backward learning to build table
 observe source address of
arriving LANs
S4 S5 S6
 handle topology changes by
removing old entries

Dr. Atef Abdrabou 19

Transparent Bridge (LAN Switch) Design
Aspects Section 17.1.2
 Connects similar or different LANs
 Identical physical / link layer protocols for
similar LANs
 Bridging between similar LANs means no
modification to frame content or format
 Can map between MAC formats for different
 Minimal processing
 No encapsulation
 Bridging is transparent to stations
Dr. Atef Abdrabou
Medium Access Control
Protocols and Local Area

Multiple Access
Multiple Access Communications

 Shared media basis for broadcast networks

 Inexpensive: radio over air; copper or coaxial cable
 M users communicate by broadcasting into medium
 Key issue: How to share the medium?


Shared multiple
access medium

M 5

Dr. Atef Abdrabou 22

Approaches to Media Sharing

Medium sharing techniques

Static Dynamic medium

channelization access control

 Partition medium to
channels Scheduling Random access
 Dedicated channel
allocation to users  Stations take turns  Loose coordination
to send data  Send, wait, retry if
 Examples:
 Examples: necessary
 Satellite
 Token ring  Examples:
 Cellular  Aloha

Telephone  Ethernet
Dr. Atef Abdrabou 23
Channelization Section 12.3
Example: Satellite Communications Section 6.2.3

Satellite Channel:Frequency Division Multiple Access (FDMA)

uplink fin downlink fout

Dr. Atef Abdrabou 24

Channelization: Section 12.3
Example: Cellular Frequency Division Multiple Access (FDMA)

• In FDMA, the data of each user is sent on a separate frequency channel

• An uplink and a downlink channels are assigned to the users on demand
• FDMA is data link layer protocol that uses FDM as a physical layer

uplink f1 ; downlink f2

uplink f3 ; downlink f4

Dr. Atef Abdrabou 25

Scheduling: Polling Section 12.2.2

• In polling, one device works as a primary (master) while all other devices as secondary
(slaves) stations
• Data communication has to be done through the primary station even if two secondary
stations want to send data to each other

Inbound line
Data from 1 from 2

Poll 1 Poll 2 Data to M

Outbound line
1 2 M
computer 3

• The primary station can send data directly to any station it selects
• The primary has to poll (ask) every secondary station (one by one) 26
if the secondary station has data to send Dr. Atef Abdrabou
Scheduling: Token-Passing Section 12.2.3

Ring networks

Data to M

• Stations are organized in a ring

• Station that holds token transmits into ring
• When no data are being sent, the token keeps circulating
• A station that has data Dr.toAtefsend
must wait for the token 27
Random Access Section 12.1

Multitapped Bus


Transmit when ready

Simultaneous transmissions may occur; need retransmission strategy

Dr. Atef Abdrabou 28

Medium Access Control
Protocols and Local Area

Random Access
1- The pure ALOHA Protocol Section 12.1.1
 A station attempts to transmit whenever it has data to transmit
 Every frame has a frame transmit time
Tfr = number of bits per frame / transmission rate in bits/sec
 If more than one frame are transmitted at the same time, they interfere with
each other (collide) and are lost
 If the receiver station received a frame correctly, it sends an
acknowledgement (ACK) to the transmitter station
 Every frame or ACK takes an average propagation time tprop to reach the
other station
 If the transmitter station did not receive the ACK within timeout tout = 2 tprop, it
retransmits the frame after a random backoff time B to avoid repeated

First transmission Retransmission

Backoff period B
t0-Tfr t0 t0+Tfr t0+Tfr+2tprop t0+Tfr+2tprop + B
Vulnerable Time-out
period Dr. Atef Abdrabou 30
Frame Transmission Attempts
in a pure Aloha Network

Dr. Atef Abdrabou 31

Vulnerability Period
 Vulnerability period
is the time duration
in which a collision
is possible
 In pure Aloha
protocol, the
vulnerability period
equals to 2 Tfr

Dr. Atef Abdrabou 32

Throughput of the Pure Aloha
Protocol Section 12.1.1
 Throughput S is defined as the
ratio of successfully received 0.5e-1 = 0.184
frames to the number of frame 0.2
transmission attempts 0.16
Number of succesfully received frames

S 0.08
Number of frame transmiss ion attempts 0.06
 For pure Aloha protocol, 0



S = G x e-2G










where G is the number of G

transmission attempts per

frame transmission time
G = Number of frame transmission attempts per second x Tfr
Dr. Atef Abdrabou 33
Example: Pure Aloha Throughput
 A pure ALOHA network transmits 200-bit frames on a shared
channel of 200 kbps. What is the throughput if the network (all
stations together) send
a. 1000 frames per second b. 500 frames per second
c. 250 frames per second

The frame transmission time Tfr = 200 bit/ (200 kbps) = 1 ms
a. There are 1000 frame transmission attempts per second, this means1
frame transmission attempt per millisecond.
Therefore, G = 1000 x Tfr = 1

In this case,
S = 1× e−2 or S = 0.135 (13.5 percent)
This means that the number of successfully received frames is
1000 × 0.135 = 135 frames. Only 135 frames out of 1000 will be received
Dr. Atef Abdrabou 34
Example: Pure Aloha Throughput (cont)
 b. If the network stations send 500 frames per second, this means
G = 500 x Tfr = 0.5
In this case, S = 0.5 × e −1 or S = 0.184 (18.4 %).
This means that the number of successfully received frames = 500 × 0.184 = 92.
(only 92 frames out of 500 will probably received correctly)
Note that this is the maximum throughput case.

 c. If the network stations send 250 frames per second, this means
G = 250 x Tfr = 0.25
In this case,
S = 0.25 × e-0.5 or S = 0.152 (15.2 %).
This means that the number of successfully received frames is 250 × 0.152 = 38.
(Only 38 frames out of 250 will be successfully received)

Dr. Atef Abdrabou 35

2. The Slotted ALOHA protocol Section 12.1.1

 Time is slotted in Tfr seconds slots

 Stations synchronized to frame times
 Stations transmit frames in first slot after frame
 Backoff intervals in integer multiple of slots

Backoff period B

kTfr (k+1)Tfr t0 +Tfr+2tprop t0 +Tfr+2tprop+ B

Only frames that arrive during prior Tfr seconds collide 36

Dr. Atef Abdrabou
Throughput of the Slotted Aloha protocol Section 12.1.1

 Throughput S is defined as the ratio of successfully received

frames to the number of frame transmission attempts
Number of succesfully received frames
Number of frame transmiss ion attempts

 For Slotted Aloha protocol,

S = G x e-G
where G is the number of transmission attempts
per frame transmission time or

G = Number of frame transmission attempts per second x Tfr

Dr. Atef Abdrabou 37

Slotted Aloha Vulnerability Period

 Vulnerability period
is the time duration
in which a collision
is possible
 In slotted Aloha
protocol, the
vulnerability period
equals to Tfr

Dr. Atef Abdrabou 38

Example: Slotted Aloha Throughput
 A slotted ALOHA network transmits 200-bit frames on a shared channel of
200 kbps. What is the throughput if the system (all stations together)
 a. 1000 frames per second b. 500 frames per second
 c. 250 frames per second

The frame transmission time Tfr = 200 bits/200 kbps = 1 ms
a. If the system creates 1000 frames per second, this means
G = 1000 x Tfr = 1 frame transmission attempt per frame transmission time.
In this case,
S = G× e−G or S = 0.368 (36.8%). This is the maximum throughput, why?
This means that the number of successfully received frames is
1000 × 0.0368 = 368 frames.
(Only 386 frames out of 1000 will be successfully received)

Dr. Atef Abdrabou 39

Example: Slotted Aloha Throughput (cont)
b. If the system creates 500 frames per
second, this means
G = 500 X 0.001 = 1/2 frame transmission
attempts per frame transmission time In this
0.4 Slotted Aloha Ge-G
S = G × e−G or S = 0.303 (30.3 percent). 0.35
This means that the number of successfully 0.3

received frames is 500 × 0.0303 = 151. 0.25

(Only 151 frames out of 500 will be S 0.2

successfully received) 0.15

0.1 Pure Aloha Ge-2G

c. If the system creates 250 frames per
second, this is (1/4)



frame per millisecond. The load is (1/4). In
this case
S = G × e −G or S = 0.195 (19.5 percent).
This means
that the throughput is 250 × 0.195 = 49.
Only 49
frames out of 250 will be successfully
received Dr. Atef Abdrabou 40
Carrier Sensing Multiple Access (CSMA) Section 12.1.2

 A station senses the channel before it starts transmission

 If busy, either wait or schedule backoff (different options)
 If idle, start transmission
 Vulnerable period is reduced to tprop (due to channel capture effect)
 When collisions occur they involve entire frame transmission times

Station A begins
transmission at
t=0 A

Station A captures
channel at t = tprop
Dr. Atef Abdrabou 41
Vulnerability Period in CSMA

 Vulnerability period is the time duration in

which a collision is possible
 In CSMA protocol, the vulnerability period
equals to tprop
Dr. Atef Abdrabou 42
IEEE 802.3 Carrier Sense Multiple Access with
Collision Detection (CSMA/CD) Section 12.1.3

Duration Duration

 Each station monitors the medium during frame transmission to see if the
transmission was successful
 If there is a collision, the frame will be sent again
 At time t1 , station A starts to send its first bit to station D
 At time t2 , station C starts to send its first bit to station A since the first bit from A has
not arrived yet
 Collision happens at some time after t2
 C detects the collision at t3 when the first bit of A arrives to it and stops (aborts) its
Dr. Atef Abdrabou 43
 Similarly, A stops its transmission at t4, when it receives the first bit from C
Ethernet Minimum Frame Size

 A restriction on Ethernet frame size is required for CSMA/CD to

 A transmitting station should detect a collision before the last bit of
the frame is sent
 If the last bit is sent without detecting a collision, the station will not
keep a copy of the frame
 If two communicating stations A & B are at the maximum distance
apart, the signal from A takes tprop to reach B
 If the first bit of a frame sent by A just before reaching B, collided
with the first bit of a frame sent by B
 A will take 2 tprop to know that a collision happens
 This means the minimum frame transmission time Tfr(min) = 2 tprop
 Tfr(min) = minimum frame size in bits / transmission rate in bits/sec

Dr. Atef Abdrabou 44

Ethernet Minimum Frame Size Calculation
A network using CSMA/CD has a bandwidth of 10 Mbps.
If the maximum propagation time is 25.6 μs,
What is the minimum size of the Ethernet frame?

• The minimum frame transmission time is Tfr(min) = 2 × Tprop = 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

Dr. Atef Abdrabou 45

Fast Ethernet Section 13.3.2

100baseT4 100baseT 100baseFX

Twisted pair category 3 Twisted pair category 5 Optical fiber multimode

UTP 4 pairs UTP two pairs Two strands

Max. Segment
100 m 100 m 2 km

Topology Star Star Star

To preserve compatibility with 10 Mbps Ethernet:

 Same frame format, same interfaces, same protocols
 Hub topology only with twisted pair & fiber
 Bus topology & coaxial cable no longer used
 Category 3 twisted pair (ordinary telephone grade) requires 4 pairs
 Category 5 twisted pair requires 2 pairs (most popular)
Dr. Atef Abdrabou 46
Gigabit Ethernet Section 13.4.2

1000baseSX 1000baseLX 1000baseCX 1000baseT

Optical fiber Optical fiber Twisted pair
Shielded category 5
Medium multimode single mode
copper cable
Two strands Two strands UTP
Max. Segment
550 m 5 km 25 m 100 m

Topology Star Star Star Star

 Frame structure preserved but CSMA-CD is not used since Gigabit

Ethernet uses only switches.
 Extensive deployment in backbone of enterprise data networks and
in server farms

Dr. Atef Abdrabou 47

Typical Ethernet Deployment
Server farm

Server Server Server

Gigabit Ethernet links

Switch/router Switch/router
Gigabit Ethernet links

Server Fast Fast Server Fast

Ethernet Ethernet Ethernet
switch switch switch
100 Mbps links
100 Mbps links 100 Mbps links

Ethernet Ethernet Ethernet

Switch Switch Switch
10 Mbps links 10 Mbps links 10 Mbps links

Department A Department B Department C


Dr. Atef Abdrabou

IEEE 802.11 Wireless LAN Section 15.1

 Stimulated by availability of unlicensed spectrum

 U.S. Industrial, Scientific, Medical (ISM) bands

 902-928 MHz, 2.400-2.4835 GHz, 5.725-5.850 GHz

 MAC for high speed wireless LAN

 Ad Hoc & Infrastructure networks
 Variety of physical layers

Dr. Atef Abdrabou 49

IEEE 802.11 Wireless LAN
CSMA with Collision Avoidance CSMA/CA Section 12.1.4
contention window
IFS IFS (randomized back-off

medium busy next frame

direct access if t
medium is free  IFS slot time

 A station having data to send starts sensing the medium

 if the medium is free for the duration of an Inter-Frame Space
(IFS), the station can start sending
 if the medium is busy, the station has to wait for a free IFS, then
the station must additionally wait a random back-off time
(collision avoidance, multiple of slot-time)
 During the backoff time, the station always senses the medium
every time slot
 if another station occupies the medium during the back-off time of
the station, the back-off timer stops and resumes when the
channel becomes idle for an IFS
Dr. Atef Abdrabou 53
CSMA/CA: Avoiding the hidden
terminal problem Section 12.1.4
A requests to send C


B announces A ok to send

Data Frame
A sends Dr. Atef Abdrabou C remains quiet 51
CSMA/CA: Avoiding the hidden
terminal problem Section 12.1.4
 Suppose there are 3 stations in the network A, B and
C where C cannot sense A transmission
 If A has data a frame to send to B, it sends a request-
to-send (RTS) frame
 In the RTS frame A includes the duration of
transmission of the data frame
 When B receives the RTS, it broadcasts a CTS frame
 Both A and C listen to the CTS frame
 When C receives the CTS frame, it knows the
duration that the data frame of A will take
 C waits until A finishes its transmission before it
sends any RTS to B
Dr. Atef Abdrabou 52
CSMA with Collision Avoidance
CSMA/CA Section 12.1.4
 CSMA/CA is different from CSMA/CD
as there is no collision detection in
 The main reason is that wireless
transceivers used in WLANs cannot
send and receive at the same time
 Also, the hidden terminal problem
prevents detecting collisions efficiently

Dr. Atef Abdrabou 53

IEEE 802.11 Basic and Extended Service Sets
1- Basic Service Set (BSS) Section 15.2.1

 Basic Service Set (BSS) – tens of meters

 Operate in Basic Service Area (BSA) that is much like the area of
cell in mobile communications
 BSSs may geographically overlap, be physically disjoint, or they
may be collocated (one BSS may use several antennas)
 Ad-hoc or Infrastructure mode: Access coordinated by the MAC
Dr. Atef Abdrabou 54
IEEE 802.11 Basic and Extended Service Sets
2- Extended Service Set (ESS) Section 15.2.1

 Extended Service Set (ESS)

 Multiple BSSs
interconnected by
Distribution System (DS)

 Each BSS is like a cell and

stations in BSS
communicate with an Access
Point (AP).

 Portals attached to DS
provide gateways as access
to Internet or other ESS

Dr. Atef Abdrabou 55

Example: Infrastructure Network

Portal Gateway to
Distribution System Portal the Internet


A2 B2
could be in one classroom Dr. Atef Abdrabou
BSS B could be in another classroom
IEEE 802.11 Frame Format & Addressing
(Section 15.1.3)

 IEEE 802.11 frame format is quite different from IEEE 802.3

 In addition to the preamble, the frame header contains the fields
 We focus here on addressing
 The frame contains four address fields based on where the frame is
coming from
 Address 1 refers to the address the frame is going to
 Address 2 refers to the address the frame is directly coming from
 Address 3 refers to the final or intermediate destination or the actual
source if they differ from the above
 Address 4 refers to the actual source in case the distribution system
is wireless
Dr. Atef Abdrabou 57
IEEE 802.11 Frame Format & Addressing

Dr. Atef Abdrabou
Peer-to-Peer Protocols
and Data Link Layer
Point-to-Point Links
Point-to-Point Protocol (PPP)
PPP Applications Section 11.4.2

PPP used in many point-

to-point applications
 Telephone Modem Links
30 kbps
 Used for DSL links
 Packet over (SONET)
Synchronous Optical Etisalat
Networks (SONET)

Dr. Atef Abdrabou 60
PPP: Point-to-Point Protocol Section 11.4.2
 Data link protocol suite for point-to-point lines in Internet
 Router-router; dial-up to router

1. Provides Framing and Error Detection

 Character-oriented frame structure

 Error detection via CRC

 No error correction is provided

2. Link Control Protocol

 A signaling protocol

 Bringing up, testing, bringing down lines; negotiating options

 Authentication: key capability in ISP access

3. A family of Network Control Protocols specific to different network

layer protocols
 Used to configure the network layer protocol

 One of the most important protocols in this family is IPCP

 It is responsible for providing the IP configuration (IP, netmask, 61

gateway, DNS…etc) from the ISP to the client Dr. Atef Abdrabou
PPP Phases Section 11.4.3
1. Carrier Home PC to Internet Service Provider
Dead detected
7. Carrier
1. PC calls router via modem
2. PC and router exchange LCP
Failed packets to negotiate PPP parameters
Terminate Establish 3. Check on identities
4. NCP packets exchanged to configure
2. Options the network layer, e.g. TCP/IP (
6. Done negotiated requires IP address assignment)
Failed 5. Data transport, e.g. send/receive IP
Authenticate packets
5. Open 6. NCP used to tear down the network
layer connection (free up IP
3. Authentication 7. LCP used to shut down data link layer
4. NCP completed connection
configuration Network 8. Modem hangs up

Dr. Atef Abdrabou 62

PPP FrameSection
Format 11.4.2 CRC 16 or
CRC 32
1 or 2 Bytes variable 2 or 4 Bytes
Flag Address Control Protocol Flag
Information CRC
01111110 1111111 00000011 01111110

integer # of bytes

All stations are to Unnumbered Specifies what kind of packet is contained in the
accept the frame frame payload, e.g., LCP, NCP, IP, OSI CLNP, IPX

 PPP uses byte-oriented or character-oriented frame structure

 All the fields are carried in integer multiple of bytes
 PPP uses the one byte flag to start and to end frames,
 PPP uses byte stuffing
 Problems with PPP byte stuffing
 Size of frame varies unpredictably due to byte insertion
 Malicious users can inflate bandwidth by inserting 7D & 7E
Dr. Atef Abdrabou 63
Byte-Stuffing in PPP
 PPP is character-oriented version of HDLC
 Flag is 0x7E (01111110)
 Control escape 0x7D (01111101)
 Any occurrence of flag or control escape inside of frame is
replaced with 0x7D followed by original octet XORed with
0x20 (00100000)

Data to be sent

41 7D 42 7E 50 70 46

7E 41 7D 5D 42 7D 5E 50 70 46 7E

After stuffing and framing 64

Dr. Atef Abdrabou
Error Control in Data Link

- Error Detection
- Error Correction
Error Control in Data Link Layer
 Two basic approaches:
 Error detection
 Error correction by retransmission (ARQ)
 All transmitted data blocks (“codewords”) satisfy a
 If received block doesn’t satisfy the pattern, it is in
 Channel may transform a codeword into another
All inputs to channel Channel
satisfy pattern or condition output
Deliver user
User Pattern
Encoder Channel information or
information checking
set error alarm

codewords Dr. Atef Abdrabou 66

Error Detection
Checkbits & Error Detection
Section 10.2.1
Information bits Received information bits

check bits
k bits
check bits Compare
Sent Received Information
check check bits accepted if
bits check bits
n – k bits match

 Three different methods:

 Single Parity Check
 Cyclic Redundancy Check
Dr. Atef Abdrabou 68
 Internet Checksum
1- Single Parity Check Section 10.2.1

 Append an overall parity check to k information bits

Info Bits: b1, b2, b3, …, bk

Check Bit: bk+1= b1+ b2+ b3+ …+ bk modulo 2

Codeword: (b1, b2, b3, …, bk,, bk+1)

 All code words have even # of 1s (for even parity)

 Receiver checks to see if # of 1s is even
 All error patterns that change an odd # of bits are
 All even-numbered patterns are undetectable
 Parity bit used in ASCII code
Dr. Atef Abdrabou 69
Example of Single Parity Code
 Information (7 bits): (0, 1, 0, 1, 1, 0, 0)
 Parity Bit: b8 = 0 + 1 +0 + 1 +1 + 0 mod 2 = 1
 Codeword (8 bits): (0, 1, 0, 1, 1, 0, 0, 1)

 If single error in bit 3 : (0, 1, 1, 1, 1, 0, 0, 1)

 # of 1’s =5, odd
 Error detected

 If errors in bits 3 and 5: (0, 1, 1, 1, 0, 0, 0, 1)

 # of 1’s =4, even
 Error not detected

Dr. Atef Abdrabou 70

2- Polynomial Codes (Cyclic
Redundancy Check) Section 10.3.1
 Polynomials instead of vectors for codewords
 Polynomial arithmetic instead of check sums
 Implemented using shift-register circuits
 Also called cyclic redundancy check (CRC)
 Most data communications standards use
polynomial codes for error detection
 Polynomial codes also basis for powerful
error-correction methods
Dr. Atef Abdrabou 71
Binary Polynomial Arithmetic
 Binary vectors map to polynomials
(ik-1 , ik-2 ,…, i2 , i1 , i0)  ik-1xk-1 + ik-2xk-2 + … + i2x2 + i1x + i0
 Modulo-2 Arithmetic:
Addition (XOR operations):
(x7 + x6 + 1) + (x6 + x5) = x7 + x6 + x6 + x5 + 1
= x7 +(1+1)x6 + x5 + 1
= x7 +x5 + 1 since 1+1=0 mod2

(x + 1) (x2 + x + 1) = x(x2 + x + 1) + 1(x2 + x + 1)
= (x3 + x2 + x) + (x2 + x + 1)
= x3 + 1
Dr. Atef Abdrabou 72
Binary Polynomial Division
 Division with Decimal Numbers
34 quotient dividend = quotient x divisor +remainder
35 ) 1222 dividend
105 1222 = 34 x 35 + 32
divisor 17 2
32 remainder

x3 + x2 + x = q(x) quotient
 Polynomial
Division x3 + x + 1 ) x6 + x5
x6 + x4 + x3 dividend
x5 + x4 + x3
x5 + x3 + x2
Note: Degree of r(x) is less than x4 + x2
degree of divisor
x4 + x2 + x
Dr. Atef Abdrabou 73
x = r(x) remainder
Polynomial Coding
 Code has binary generating polynomial of degree n–k
g(x) = xn-k + gn-k-1xn-k-1 + … + g2x2 + g1x + 1
 k information bits define polynomial of degree k – 1
i(x) = ik-1xk-1 + ik-2xk-2 + … + i2x2 + i1x + i0
 Find remainder polynomial of at most degree n – k – 1
g(x) ) xn-k i(x) xn-ki(x) = q(x)g(x) + r(x)
 Define the codeword polynomial of degree n – 1
b(x) = xn-ki(x) + r(x)
Dr. Atef Abdrabou 74
n bits k bits n-k bits
Polynomial example: k = 4, n–k = 3
Generator polynomial: g(x)= x3 + x + 1
Information: (1,1,0,0) i(x) = x3 + x2
Encoding: x3i(x) = x6 + x5
x3 + x2 + x
x3 + x + 1 ) x6 + x5
x6 + x 4 + x3

x5 + x4 + x3
x5 + x 3 + x2
x4 + x2
x4 + x2 + x
Transmitted codeword:
b(x) = x6 + x5 + x
b = (1,1,0,0,0,1,0) Dr. Atef Abdrabou 75
The Pattern in Polynomial Coding

 All codewords satisfy the following pattern:

b(x) = xn-ki(x) + r(x) = q(x)g(x) + r(x) + r(x) = q(x)g(x)

 All codewords are a multiple of g(x)!

 Receiver should divide the received codeword by g(x)
and check if remainder is zero
 If remainder is nonzero, then received codeword has
an error

Dr. Atef Abdrabou 76

Shift-Register Implementation
1. Accept information bits ik-1,ik-2,…,i2,i1,i0
2. Append n – k zeros to information bits
3. Feed sequence to shift-register circuit that
performs polynomial division
4. After n shifts, the shift register contains the

Dr. Atef Abdrabou 77

Example (k= 5, n-k = 6)

Dr. Atef Abdrabou 78

Shift Register Division Example

Dr. Atef Abdrabou 79

Shift Register Implementation

Dr. Atef Abdrabou 80

Standard Generator Polynomials
 CCITT-16:
= x16 + x12 + x5 + 1 PPP protocol

 CCITT-32: IEEE 802

= x32 + x26 + x23 + x22 + x16 + x12 + x11 + x10 + x8 + x7 + x5 + x4 + x2 + x + 1

Dr. Atef Abdrabou 81

3- Internet Checksum Section 10.4.1

 Several Internet protocols (e.g. IP, TCP, UDP) use

check bits to detect errors in the IP header (or in the
header and data for TCP/UDP)
 A checksum is calculated for header contents and
included in a special field.
 Checksum recalculated at every router, so algorithm
selected for ease of implementation in software
 Let header consist of L, 16-bit words,
w0, w1, w2, ..., wL-1
 The algorithm appends a 16-bit checksum wL

Dr. Atef Abdrabou 82

Checksum Calculation Section 10.4.1
The checksum wL is calculated as follows:
 Treating each 16-bit word as an integer, find

x = w0 + w1 + w2+ ...+ wL-1 modulo 216-1

 The checksum is then given by:

wL = - x modulo 216-1
Thus, the headers must satisfy the following pattern:
0 = w0 + w1 + w2+ ...+ wL-1 + wL modulo 216-1
 The checksum calculation is carried out in software
using one’s complement arithmetic

Dr. Atef Abdrabou 83

Internet Checksum Example
Use Modulo Arithmetic
 Assume 4-bit words

 Use mod 24-1 arithmetic

 b0=1100 = 12

 b1=1010 = 10

 b0+b1=12+10= 22 mod 15 = 15 + 7 mode 15 = 7 mod15

 b2 = -7 = 15 – 7 mod 15 = 8 mod15

 Therefore

 b2=1000

Dr. Atef Abdrabou 84

Error Correction
Automatic Repeat Request (ARQ)
 Purpose: to ensure a sequence of information
packets is delivered in order and without errors or
duplications despite transmission errors & losses
 We will study:
 Stop-and-Wait ARQ
 Go-Back N ARQ
 Selective Repeat ARQ
 Basic elements of ARQ:
 ACKs (positive acknowledgments
 NAKs (negative acknowledgments)
 Timeout mechanism

Dr. Atef Abdrabou 86

Stop-and-Wait ARQ Section 23.2.2
Transmit a frame, wait for ACK
Information frame
Transmitter Receiver
Timer set after (Process A) (Process B)
each frame
transmission Control frame

Information Header
packet CRC
Dr. Atef Abdrabou 87

Information frame Control frame: ACKs

Need for Sequence Numbers
(a) Frame 1 lost Time-out
A Frame Frame Frame Frame
0 1 1 2

(b) ACK lost Time-out

A Frame Frame Frame Frame
0 1 1 2

 In cases (a) & (b) the transmitting station A acts the same way
 But in case (b) the receiving station B accepts frame 1 twice
 Question: How is the receiver to know the second frame is also frame 1?
 Answer: Add frame sequence number in header
Dr. Atef Abdrabou 88
 Slast is sequence number of most recent transmitted frame
Sequence Numbers
(c) Time-out

A Frame
0 Frame Frame Frame
ACK 0 1 2

 The transmitting station A misinterprets duplicate ACKs

 Incorrectly assumes second ACK acknowledges Frame 1
 Question: How does the sender know that the second ACK is for frame
 Answer: Add frame sequence number in ACK header
 Rnext is sequence number of next frame expected by the receiver
 Implicitly acknowledges receipt of all prior frames
Dr. Atef Abdrabou 89
Stop-and-Wait ARQ

Dr. Atef Abdrabou 90

Stop-and-Wait ARQ
Transmitter Receiver
Ready state Always in Ready State
 Await request from higher layer for  Wait for arrival of new frame
packet transfer  When frame arrives, check for errors
 When request arrives, transmit  If no errors detected and sequence
frame with updated Slast and CRC number is correct (Slast=Rnext), then
 Go to Wait State  accept frame,
Wait state  update Rnext (new Rnext = old Rnext + 1),
 Wait for ACK or timer to expire;  send ACK frame with new Rnext,
block requests from higher layer  deliver packet to higher layer
 If timeout expires  If no errors detected and wrong
 retransmit frame and reset timer sequence number
 If ACK received:  discard frame
 send ACK frame with Rnext
 If sequence number is incorrect or if
errors detected: ignore ACK  If errors detected
 If sequence number is correct (Rnext  discard frame
= Slast +1): accept frame, go to
Ready state

Dr. Atef Abdrabou 91

Efficiency of Stop-and-Wait ARQ
 Example:
A transmission link has a data rate of 1 Mbps. Determine the
efficiency of the stop-and-wait ARQ, if a 1000 bit-frame takes 20
ms for the transmitter to send the frame and to get the ACK from
the receiver.

 Solution:
The number of frames the can be transmitted in one second
without waiting for the acknowledgement =
(1) (106 )/ 1000 = 1000 frames
The number of frames that can be transmitted in one second using
stop-and-wait protocol = 1 / (20) (10-3 ) = 50 frames
The stop-and-wait efficiency = 50/1000 = 5%
Dr. Atef Abdrabou 92
Go-Back-N Section 23.2.3
 Improve Stop-and-Wait by not waiting!
 Keep channel busy by continuing to send frames

 Allow a window of up to Ws outstanding frames

 If ACK for oldest frame arrives before all the window is finished, we
can slide the window and continue transmitting
 If window is finished, wait for the ACK of the last unacknowledged
frame (the first frame in the new window)
 If no ACK received within a timeout pull back and retransmit all
outstanding frames in the current window (go back N)
 Check the protocol demo at:


Dr. Atef Abdrabou 93

Go-Back-N ARQ
Go-Back-4: 4 frames are outstanding; so go back 4

fr fr fr fr fr fr fr fr fr fr fr fr fr fr Time
0 1 2 3 4 5 6 3 4 5 6 7 8 9

A A A out of sequence A A A A A A
C C C frames C C C C C C
1 2 3 4 5 6 7 8 9

Rnext 0 1 2 3 3 4 5 6 7 8 9

 Frame transmission are pipelined to keep the channel busy

 Frame with errors and subsequent out-of-sequence frames are ignored
Dr. Atef Abdrabou 94
 Transmitter is forced to go back when window of 4 is exhausted
Selective Repeat ARQ Section 23.2.4
 Go-Back-N ARQ inefficient because multiple frames are resent when
errors or losses occur
 Selective Repeat retransmits only an individual frame

 Timeout causes individual corresponding frame to be resent

 NAK causes retransmission of oldest un-acked frame

 Receiver maintains a receive window of sequence numbers that can be

 Error-free, but out-of-sequence frames with sequence numbers within
the receive window are buffered
 Arrival of frame with Rnext causes window to slide forward by 1 or
 Check the protocol demo at

eat/SelectiveRepeat.html Dr. Atef Abdrabou 95
Selective Repeat ARQ

fr fr fr fr fr fr fr fr fr fr fr fr fr fr Time
0 1 2 3 4 5 6 2 7 8 9 10 11 12

1 2 2 2 2 2 7 8 9 1 1 1
0 1 2

Dr. Atef Abdrabou 96

Applications of Stop-and-Wait

 Applications of Stop-and-Wait
 Trivial File Transfer Protocol TFTP: simple
protocol for file transfer over UDP
 Applications of Go-Back-N
 HDLC (High-Level Data Link Control): bit-
oriented data link control
 Applications of Selective Repeat
 TCP (Transmission Control Protocol) uses a
variation of selective repeat to provide reliable
stream service
Dr. Atef Abdrabou 97