Chapter 3 - Datalink Layer - 4.4m
Chapter 3 - Datalink Layer - 4.4m
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
TRƯỜNG CÔNG NGHỆ THÔNG TIN VÀ TRUYỀN THÔNG
School of Information and Communication Technology
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
D D
Y
N
<D’, R’> mod G = 0 ?
<D, R> mod G = 0
D R D’ R’
19
Reaction when errors detected
20
Stop-and-wait ARQ
Normal case
Sender Receiver
pkt0 is OK
ACK
rcv ACK
send pkt1 pkt1
pkt1 is
NAK corrupted
Time
TRƯỜNG CÔNG NGHỆ THÔNG TIN VÀ TRUYỀN THÔNG
School of Information and Communication Technology
21
Stop-and-wait ARQ
Error ACK/NAK
Sender Receiver
• ACK error, resend the
previous packet
• Duplicated packets send pkt0 pkt0
problem.
pkt0 is OK
• To eliminate repeated ACK
packet: Use Seq.# rcv ACK
send pkt1 pkt1
• All packets are
assigned Seq# before pkt1 is OK
sending out. Repeated ACK
packet has identical
Seq# rcv sth corrupted! pkt1
resend pkt1 rcv pkt1
duplicate,
Time discard it
TRƯỜNG CÔNG NGHỆ THÔNG TIN VÀ TRUYỀN THÔNG
School of Information and Communication Technology
22
Stop-and-wait ARQ
not using NAK
• ACK packet carries
Sender Receiver
#Seq of the packet
to be
send pkt0
pk t 0 acknowledged.
This number is
pkt0 is OK
ACK0 called
rcv ACK0
acknowledgment
pk t 1
send pkt1 number
ACK1 pkt1 is OK • An ACK with
acknowledgment
rcv ACK1 pk t 2 pkt2 is corrupted number n
send pkt2
implicitly confirms
ACK1 that all packet with
rcv ACK1 pk t 2
#seq number <
resend pkt2 =n have been well
received
Time
TRƯỜNG CÔNG NGHỆ THÔNG TIN VÀ TRUYỀN THÔNG
School of Information and Communication Technology
23
Stop-and-wait ARQ: When ACK is lost
25
ARQ with timeout
26
Media access control
27
Connection types
• Point-to-point
• ADSL
• Telephone modem
• Leased Line….
• Broadcast
• 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.
28
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:
• Nodes can send data one after the other.
• Token Ring, Token Bus….
29
Channel division
30
TDMA và FDMA
example
4 stations
FDMA
frequency
time
TDMA:
frequency
32
CDMA
33
Random access: Pure Aloha
35
Random access: Slotted Aloha
36
Random access: CSMA
37
CSMA
38
Collision in CSMA
39
CSMA/CA (Collision Avoidance)
40
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.
TRƯỜNG CÔNG NGHỆ THÔNG TIN VÀ TRUYỀN THÔNG
School of Information and Communication Technology
41
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: compromise between the two
above methods.
42
Token Ring
43
Summary on Media access control mechanisms
• Channel division
• Random access
• Token
• What do you thinks about their
advantages and weaknesses ?
44
Point-to-Point
forwarding mechanism
Hub, Switch, Bridge
45
Devices of LAN
46
Hub
47
Devices of LAN (cont.)
Bridge
More intelligent than hub
Can store and forward data (Ethernet frame)
according to MAC address.
Bridge breaks the network into two collision
domains.
Layer 2 intermediate system
Switch
More ports than bridge
Can store and forward data according
to MAC address
Receive full frame, check error, forward
48
Bridge
49
Switch
50
Switch: Self learning mechanism
Source: A
Dest: A’
A A A’
Switch learns the MAC
addresses of all hosts C’ B
connected to the switch
Each time switch receive 1 2
6 3
a frame, it may update the
source MAC address of the 5 4
frame and corresponding
connected port C
• if the address is not in MAC
table
B’ A’
• If the address is in the MAC
table, but the corresponding pỏt
is different to that in the table
MAC addr interface TTL
Forwarding table
A 1 60
51
Switch: forwarding mechanism
52
Source: A
Dest: A’
Ex: A A A’
C’ B
Outgoing port 1 2
unknown: Broadcast A6A’ 3
5 4
Know A:
C
A’ A
Direct transfering
B’ A’
53
Connecting switches in cascade
Switches could be connected to eachother
S4
S1
S3
A S2
F
D I
B C
G H
E
54
A typical LAN
mail server
Connect to
outside
router web server
IP subnet
55
Flow control
56
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
57
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.
58
Stop-and-wait
transmitter receiver
Packet Packet
frame
frame
frame
59
Stop-and-wait
60
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
TRƯỜNG CÔNG NGHỆ THÔNG TIN VÀ TRUYỀN THÔNG
62
Sliding window: principle
63
Sliding windows: principle
65
Sliding windows
66
Sliding windows
67
Piggyback
68
Exercices
69
Transmission time with Stop-
and-wait
transmitter receiver
Packet Packet
T transmit
frame
RTT
frame
frame
70
Transmission time with Stop-and-wait
71
Transmission schema with Sliding windows
72
Trasmission time with window
size 7
• T fastest= (T transmit 7 frames+ wait) *
Nb. Waiting time.
• 1 waiting= (T transmit 1 frame+ RTT) – T
transmit 7 frames
• Nb. Waiting time= Nb frame /7
73
Fastest transmission time with sliding window
74
Fastest transmission time with sliding window
75
LAN: Local Area Network
Reading: 4.3 Computer Networks,
Tanenbaum
76
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
77
LAN Standards
78
Ethernet LAN
Metcalfe’s Ethernet
sketch
79
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
81
Structure of Ethernet frame
82
Switched Ethernet
Switched Ethernet (popular nowdays):
Star topology,
Use a central switch Ethernet
The switch outputs a frame only to the port linking to the
destination independent connection for each pair of two
nodes
No collision
No media access control is needed.
switch
83
Wireless LAN
84
Overview of 802.11 LAN
AP station
Ad hoc mode:
Stations pay also the
85
Standards
802.11b 802.11g
Band 2.4-5 GHz Band 2.4-5 GHz
(unlicensed spectrum) Maximum speed 54
Maximum speed 11 Mbps Mbps
802.11a 802.11n: use multiple
Band 5-6 GHz antennas (MIMO)
Band 2.4-5 GHz
Maximum speed 54 Mbps
Maximum speed 200
Mbps
86
802.11: Chanel and connection
87
802.11: Chanel and connection
88
Scanning mechanism: active/passive
AP 1 AP 2 AP 1 1 AP 2
1 1 2 2
2 3
3 4
H1 H1
89
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
90
IEEE 802.11 MAC Protocol:
CSMA/CA
Sender
1 If the channel is available during DIFS Sender Receiver
time then
Send the entire frame (no CD) DIFS
2 if channel is busy then
Starting random back-off (waiting)
data
At the end of back-off time, send data
If no ACK is received, double the back-
off time and try again.
SIFS
Receiver
ACK
- If receive well a frame then
reply by an ACK after SIFS
92
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)
93
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
94
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
95
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
96
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
TRƯỜNG CÔNG NGHỆ THÔNG TIN VÀ TRUYỀN THÔNG
School of Information and Communication Technology
Technologies for connecting to ISP using
cable
101
Optical access network: FTTx
108
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.