poB1js-ECOM432 Spring2019 DataLinkLayer PDF
poB1js-ECOM432 Spring2019 DataLinkLayer PDF
Overview of LANs
Typical LAN Structure Section 13.1
Transmission
Medium
Network Interface
Card (NIC)
Unique MAC
“physical” address
Ethernet
RAM
Processor
ROM
RAM
MAC FCS
Header
Ethernet
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
frame
Interconnecting Hubs
Repeater: Signal regeneration
All traffic appears in both LANs
Bridge: MAC address filtering Higher
Local traffic stays in own LAN
Scalability
Routers: Internet routing
All traffic stays in own LAN
?
Hub Hub
Two Twisted Two Twisted
Pairs Pairs
Multiple Access
Communications
Multiple Access Communications
3
2
4
1
Shared multiple
access medium
M 5
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:
transmission
Cellular Aloha
Telephone Ethernet
Dr. Atef Abdrabou 23
Channelization Section 12.3
Example: Satellite Communications Section 6.2.3
uplink f1 ; downlink f2
uplink f3 ; downlink f4
• 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
Data
Stations
• 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
M
Ring networks
token
Data to M
token
Multitapped Bus
Crash!!
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
collisions
S
0.1
S 0.08
Number of frame transmiss ion attempts 0.06
0.04
0.02
For pure Aloha protocol, 0
25
5
25
5
0
4
5
25
5
S = G x e-2G
12
12
12
0.
56
06
0.
78
03
0.
01
0.
00
0.
0.
0.
where G is the number of G
Solution
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
correctly
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)
Backoff period B
t
kTfr (k+1)Tfr t0 +Tfr+2tprop t0 +Tfr+2tprop+ B
Time-out
Vulnerable
period
Vulnerability period
is the time duration
in which a collision
is possible
In slotted Aloha
protocol, the
vulnerability period
equals to Tfr
Solution
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)
8
0.5
0.25
0.0625
0.125
0.01563
0.03125
frame per millisecond. The load is (1/4). In
this case
S = G × e −G or S = 0.195 (19.5 percent).
G
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
Station A begins
transmission at
t=0 A
Station A captures
channel at t = tprop
Dr. Atef Abdrabou 41
A
Vulnerability Period in CSMA
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
transmission
Dr. Atef Abdrabou 43
Similarly, A stops its transmission at t4, when it receives the first bit from C
Ethernet Minimum Frame Size
Solution
• 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
Max. Segment
100 m 100 m 2 km
Length
direct access if t
medium is free IFS slot time
(c)
B
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
CSMA/CA
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
Portals attached to DS
provide gateways as access
to Internet or other ESS
Portal Gateway to
Server
Distribution System Portal the Internet
AP1
AP2
A1
B1
A2 B2
BSS A
could be in one classroom Dr. Atef Abdrabou
BSS B could be in another classroom
56
IEEE 802.11 Frame Format & Addressing
(Section 15.1.3)
58
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
IP→PPP→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
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
Data to be sent
41 7D 42 7E 50 70 46
7E 41 7D 5D 42 7D 5E 50 70 46 7E
- 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
pattern
If received block doesn’t satisfy the pattern, it is in
error
Channel may transform a codeword into another
codeword
All inputs to channel Channel
satisfy pattern or condition output
Deliver user
User Pattern
Encoder Channel information or
information checking
set error alarm
Recalculate
check bits
k bits
Channel
Calculate
check bits Compare
Sent Received Information
check check bits accepted if
bits check bits
n – k bits match
Multiplication:
(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
140
32 remainder
x3 + x2 + x = q(x) quotient
Polynomial
Division x3 + x + 1 ) x6 + x5
x6 + x4 + x3 dividend
divisor
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
q(x)
g(x) ) xn-k i(x) xn-ki(x) = q(x)g(x) + r(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
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
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
b0=1100 = 12
b1=1010 = 10
b2 = -7 = 15 – 7 mod 15 = 8 mod15
Therefore
b2=1000
Header
CRC
Information Header
packet CRC
Dr. Atef Abdrabou 87
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
Time-out
Time
A Frame
0 Frame Frame Frame
ACK 0 1 2
ACK
B
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
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:
http://www.eecis.udel.edu/~amer/450/TransportApplets/GBN/GBNindex
.html
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
B
A A A out of sequence A A A A A A
C C C frames C C C C C C
K K K K K K K K K
1 2 3 4 5 6 7 8 9
Rnext 0 1 2 3 3 4 5 6 7 8 9
http://computerscience.unicam.it/marcantoni/reti/applet%20%20Kurose%20
Ross%20%20Reti%20di%20Calcolatori%20e%20Internet/SelectiveRep
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
A
B
A A N A A A A A A A A A
C C A C C C C C C C C C
K K K K K K K K K K K K
1 2 2 2 2 2 7 8 9 1 1 1
0 1 2
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