Chapter 3 - Datalink Layer
Chapter 3 - Datalink Layer
Datalink layer
• Functionalities:
• Encapsulation, addressing
• Error detection and correction
• Flow control
• Media access control
1
Overview of Data link layer
2
Network nodes and links
“link”
• Network nodes:
• PCs, Laptop, Routers,
Server…
• Links:
• Communication chanel
between adjacent nodes
• Wired link: Ethernet LAN,
ADSL, fiber optic…
• Wireless link: Wi-fi, FSO,
Satellite,…
• Datalink layer responsibility:
• Transmit data between
adjacent elements.
3
Datalink layer in Layer architecture
Network LLC
(Logical Link Control)
Data-link
MAC
Physical (Media Access Control) Media dependent sub-
layer
802.2 LLC
4
Functionalities
Datalink layer
5
Functionalities
• Framing:
• Sender: place the network layer packet into the
frame, add header, tail
• Receiver: Remove the header, tail for extracting the
network packet.
• Addressing:
• Physical address in the header of the frame for
identifying the source and the destination.
6
Framing-Example of HDLC frame
7
Functionalities (2)
8
Error control
• Error detection
• Error correction
9
Principle of error detection
Data Data
Y
Error
All bit in Dataʼ
OK?
N
10
Principal of error detection
11
Parity code
13
Checksum code
• Sender:
• Divides data into small parts of n bit
• Calculates binary sum of all parts. If there are some overflow bit,
add the overflow bit to the result.
• Alters all bits (two’s complement) to get the checksum
• Sends the checksum with data
• Receiver:
• Extracts data and checksum
• Divides data into block of n bits
• Calculates the sum as in the sender side including with the
checksum received
• If result contains at least one bit 0à error.
14
Checksum: Example
15
Checksum: Processing on receiver
16
CRC: Cyclic Redundancy Check
• Data is considered as a binary string: D
• We wants to generate a error code with length r
• Choose another binary string of (r+1) bit, G (Generator)
• Find a string R with length r bits such that the concatenation of D and
R is a binary number that divides G (modulo 2)
• <D, R> divides G
D D
Y
N
<Dʼ, Rʼ> mod G = 0 ?
<D, R> mod G = 0
D R Dʼ Rʼ
• 1011 ß> x3 +x +1
• Example of some CRC generators using in the pratice:
• CRC-8 = x8 + x2 + x + 1
• CRC-12 = x12+x11+x3+x2+x
• CRC-16-CCITT = x16 + x12 + x5 + 1
• CRC-32 = x32 + x26 + x23 + x22 + x16 + x12 + x11 + x10 + x8 + x7 +
x5 + x4 + x2 + x + 1
• The longer G is, the more possible that CRC detects
errors.
• CRC is widely used in the practice
• Wi-fi, ATM, Ethernet…
• Operation XOR is implemented in hardware
• Capable to detect less than r+1 bits errors
19
Ex
20
Reaction when errors detected
21
Stop-and-wait ARQ
Normal case
Sender Receiver
pkt0 is
ACK OK
rcv ACK
send pkt1 pkt1
pkt1 is
NAK corrupted
Time
TRƯỜNG CÔNG NGHỆ THÔNG TIN VÀ TRUYỀN THÔNG
Time
TRƯỜNG CÔNG NGHỆ THÔNG TIN VÀ TRUYỀN THÔNG
School of Information and Communication Technology
24
Stop-and-wait ARQ: When ACK is lost
26
ARQ with timeout
27
Media access control
28
Connection types
• Point-to-point
• ADSL
• Telephone modem
• Leased Line….
• Broadcast (point-to-multipoint)
• LAN using bus topology
• Wireless LAN
• HFC:
• …
• Broadcast networks need media access control
protocol in order to avoid collision when nodes try
to send data.
29
Classification of MAC protocol
• Chanel division:
• Resources of the media is divided into small parts (time -
TDMA, frequency- FDMA, Code- CDMA)
• Distribute a part to each nodes
• Random access:
• Chanel is not divided; all nodes are allowed to access
simultaneously with collision possibility
• Need a mechanism to avoid collision
• e.g. Pure Aloha, Slotted Aloha, CSMA/CD, CSMA/CA…
• Sequent access/Taking turns:
• Nodes can send data one after the other.
• Token Ring, Token Bus….
30
Channel division
31
TDMA và FDMA
example
4 stations
FDMA
frequency
time
TDMA:
frequency
33
CDMA
34
Random access: Pure Aloha
36
Random access: Slotted Aloha
37
Random access: CSMA
38
CSMA
39
Collision in CSMA
40
CSMA/CA (Collision Avoidance)
41
CSMA/CD
• Used in Ethernet
• CSMA with Collision Detection:
• “Listen while talk”.
• A sender listen to the channel,
• If the channel is free then transmit data
• While a station transmit data, it listens to the channel. If it detects a
collision then transmits a short signal warning the collision then stop
• Do not continue the transmission even in collision as CSMA
• If the channel is busy, wait then transmit with
probability p
• Retransmit after a random waiting time.
42
Comparison between channel division and
random access
• Channel division
• Efficient, treat stations equally.
• Waste of resources if one station has much smaller data
to send than the others
• Random access
• When total load is small: Efficient since each station can
use the whole chanel
• When total load is large: Collision possibility increases.
• Token control/Take turn: compromise between the
two above methods.
43
Token Ring
a ring topo
l Only the token holder can
transmit data (nothing
l After finishing sending to send)
data, the token need to T
be passed to next nodes.
l Some problem
l Time consuming in passing
token
l Loss of token due to some
reasons data
TRƯỜNG CÔNG NGHỆ THÔNG TIN VÀ TRUYỀN THÔNG
School of Information and Communication Technology
44
Summary on Media access control mechanisms
• Channel division
• Random access
• Token
• What do you thinks about their advantages and
weaknesses ?
45
Point-to-Point forwarding
mechanism
Hub, Switch, Bridge
46
Devices of LAN
47
Hub
48
Devices of LAN (cont.)
lBridge
lMore intelligent than hub
lCan store and forward data (Ethernet frame)
according to MAC address.
lBridge breaks the network into two collision
domains.
lLayer 2 intermediate system
lSwitch
lMore ports than bridge
lCan store and forward data according to
MAC address
l Receive full frame, check error, forward
49
Bridge
Collision domains
bridge
hub hub
50
Switch
51
Switch: Self learning mechanism
Source: A
Dest: A’
A A A’
lSwitch learns the MAC
addresses of all hosts C’ B
connected to the switch
lEach time switch receive a 1 2
frame, it may update the 6 3
source MAC address of the frame 4
and corresponding connected 5
port
• if the address is not in MAC table C
• If the address is in the MAC table,
but the corresponding pỏt is B’
different to that in the table A’
lForwarding table
MAC addr interface TTL
A 1 60
52
Switch: forwarding mechanism
53
Source: A
Dest: A’
Ex: A A A’
C’ B
lOutgoing port 1 2
unknown: Broadcast A6A’ 3
5 4
l Know A:
C
A’ A
Direct transfering
B’ A’
54
Connecting switches in cascade
S4
S1
S3
A S2
F
D I
B C
G H
E
55
A typical LAN
mail server
Connect to
outside
router web server
IP subnet
56
Flow control
57
What is flow control
• Goal: Make sure that the sender does not overload the receiver
• Why overloading?
• The receiver stores data frame in buffer.
• Receiver performs some processing before deliver data to the upper
level.
• Buffer could be full, leaving no space for receiving more frame à some
data fram must be dropped.
• Problem of errors in transmission is excluded
• All frames are transmitted to correct receiver without error
• Propagation time is small and could be ignored
• Solution
• Stop-and-wait mechanism
• Sliding window mechanism
58
Stop-and-wait
• Principles
• Transmitter sends a single frame
• Receiver receives the fram, process and then
informs the transmitter that it is ready to receives
next frames by a clear acknowledgement (ACK).
• Transmitter waits until reception of the ACK before
sending next frames.
59
Stop-and-wait
e2
transmitter
Emetteur receiver
Récepteur
péter
Reseau.donnerPaquet() Packet
Paquets Paquets
Packet
eTrame(p)
que.prendreTrame(t)
que.attendreAquittement() frame
Trâme
Ack
péter
hysique.donnerTrame()
Paquet(t) frame
Trâme
au.prendrePaquet(p)
que.envoyerAcquittement()
frame
Trâme
Trâme
60
Conception et architectures des réseaux 16
Stop-and-wait
61
Stop-and-wait
• Advantage
• Simple, suitable for transmission of big size
frames
• Weakness
• When frames are small, the transmission
chanel are not used efficiently.
• Cannot use often for big size frame due to
• Limitation in buffer size
• Big size frame prones to bigger error probability
• In shared medium, it is not convenient to leave
one station using medium for long time
62
Sliding window: principle
63
Sliding window: principle
64
Sliding windows: principle
66
Sliding windows
67
Sliding windows
68
Piggyback
69
Exercices
70
le 2 Transmission time with Stop-and-wait
transmitter
Emetteur receiver
Récepteur
péter
Packet
Paquets Packet
Paquets
Reseau.donnerPaquet()
eTrame(p)
que.prendreTrame(t) T transmit
que.attendreAquittement() frame
Trâme
RTT Ack
péter
hysique.donnerTrame()
Paquet(t) frame
Trâme
au.prendrePaquet(p)
que.envoyerAcquittement()
frame
Trâme
Trâme
72
Transmission schema with Sliding windows
73
Trasmission time with window size 7
74
Fastest transmission time with sliding window
75
Fastest transmission time with sliding window
76
LAN: Local Area Network
Reading: 4.3 Computer Networks, Tanenbaum
77
LAN topology
WLAN
Traditional bus
topo
hub, switch
Ring
TRƯỜNG CÔNG NGHỆ THÔNG TIN VÀ TRUYỀN THÔNG
School of Information and Communication Technology Star
78
LAN Standards
79
Ethernet LAN
Metcalfe’s Ethernet
sketch
80
IEEE 802.3 and Ethernet Standards
MAC protocol
application and frame format
transport
network 100BASE-TX 100BASE-T2 100BASE-FX
link 100BASE-T4 100BASE-SX 100BASE-BX
physical
Transceiver
Interface
cable
Ether
Ref: Computer
Figure 4-13. Network,
Architecture ofTanenbaum
School of Information and Communication Technology
classic Ethernet.
82
83
Switched Ethernet
l Switched Ethernet (popular nowdays):
l Star topology,
l Use a central switch Ethernet
l The switch outputs a frame only to the port linking to the
destination è independent connection for each pair of two nodes
l No collision
l No media access control is needed.
switch
84
Wireless LAN
85
Overview of 802.11 LAN
l802.11b l802.11g
lBand 2.4-5 GHz (unlicensed lBand 2.4-5 GHz
spectrum) lMaximum speed 54
lMaximum speed 11 Mbps Mbps
87
802.11: Chanel and connection
88
802.11: Chanel and connection
89
Scanning mechanism: active/passive
AP 1 AP 2 AP 1 1 AP 2
1 1 2 2
2 3
3 4
H1 H1
90
IEEE 802.11: Multiple access control
• 802.11: CSMA
• 802.11: CA – Collision Avoidance
• It is difficult to implement Collision detection (CD) in
wireless environment.
• In some cases, it is even impossible to detect the collision :
hidden terminal, fading
A B C
C
A’s signal C’s signal
B strength strength
A
91
IEEE 802.11 MAC Protocol: CSMA/CA
Sender
1 If the channel is available during DIFS time then Sender Receiver
Send the entire frame (no CD)
2 if channel is busy then DIFS
Starting random back-off (waiting)
At the end of back-off time, send data
data
If no ACK is received, double the back-off
time and try again.
Receiver SIFS
93
Collision Avoidance using RTS-CTS
A B
AP
RTS(A) RTS(B)
reservation collision
RTS(A)
CTS(A) CTS(A)
DATA (A)
defer
time
ACK(A) ACK(A)
94
802.11 frame: Addressing
2 2 6 6 6 2 6 0 - 2312 4
frame address address address seq address
duration payload CRC
control 1 2 3 control 4
Address 4: Using in
adhoc mode
Address 1: address of
the destination Address 3: MAC address of
the router attached to the
AP
Address 2: address of the source
95
802.11 frame: Addressing
Internet
H1 R1 router
AP
802.3 frame
802.11 frame
TRƯỜNG CÔNG NGHỆ THÔNG TIN VÀ TRUYỀN THÔNG
School of Information and Communication Technology
96
802.11 frame
frame seq #
Duration of the reservation (RTS/CTS) (ACK)
2 2 6 6 6 2 6 0 - 2312 4
frame address address address seq address
duration payload CRC
control 1 2 3 control 4
2 2 4 1 1 1 1 1 1 1 1
Protocol To From More Power More
Type Subtype Retry WEP Rsvd
version AP AP frag mgt data
frame type
(RTS, CTS, ACK, data)
TRƯỜNG CÔNG NGHỆ THÔNG TIN VÀ TRUYỀN THÔNG
School of Information and Communication Technology
97
Access networks using
optical fiber
Access networks
• Hub
– Device on the service provider side receiving
data
• Network Interface Unit (NIU)
– Device on the user side connecting an user or an
organization
• Remote Node (RN)
– In broadcasting networks, RN distribute data
from Hub to NIUs
– In switched networks, RN receive data from Hub
and distribute different flows to NIUs
102
Optical access network: FTTx
109
WPON (WDM PON)
• Developed by compagnies and has not been standardized
• Each ONT use a wavelength to transmit data
• Remote note is AWG (arrayed waveguide grating). The AWG is
capable to MUX/DEMUX wavelengths from up and down
streams.