0% found this document useful (0 votes)
66 views

Lecture 4 - Datalink Layer

The document discusses the data link layer. It describes the main functionalities of the data link layer as encapsulation, addressing, error detection and correction, flow control, and media access control. It also discusses network nodes and links, framing, error control techniques like parity codes and CRC, media access control protocols including TDMA, FDMA, and CDMA, and how the data link layer fits into the overall network layer architecture.

Uploaded by

Tong Thanh Vinh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
66 views

Lecture 4 - Datalink Layer

The document discusses the data link layer. It describes the main functionalities of the data link layer as encapsulation, addressing, error detection and correction, flow control, and media access control. It also discusses network nodes and links, framing, error control techniques like parity codes and CRC, media access control protocols including TDMA, FDMA, and CDMA, and how the data link layer fits into the overall network layer architecture.

Uploaded by

Tong Thanh Vinh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 52

Lecture 4:

Datalink layer
l  Functionalities:
l  Encapsulation, addressing
l  Error detection and correction
l  Flow control
l  Media access control

1
Overview of Data link layer

2
Network nodes and links
“link”
l  Network nodes:
l  PCs, Laptop, Routers,
Server…
l  Links:
l  Communication chanel
between adjacent nodes
l  Wired link: Ethernet LAN,
ADSL, fiber optic…
l  Wireless link: Wi-fi, FSO,
Satellite,…
l  Datalink layer
responsibility:
l  Transmit data between
adjacent elements.
3
Datalink layer in Layer
architecture
Application Media independent
sub-layer
Transport

Network LLC
(Logical Link Control)
Data-link
MAC
Physical (Media Access Control) Media dependent
sub-layer

802.2 LLC

802.3 802.4 802.5 802.11 ….. 802.16


Ethernet Token Bus Token Ring Wi-Fi Wi-Max
4
IEEE 802.x series
Functionalities

Framing Flow control

Media Access Control

Addressing Error control

Datalink layer

5
Functionalities
l  Framing:
l  Sender: place the network layer packet into the
frame, add header, tail
l  Receiver: Remove the header, tail for extracting
the network packet.

l  Addressing:
l  Physical address in the header of the frame for
identifying the source and the destination.
6
Framing-Example of HDLC frame

7
Functionalities (2)
l  Media access control:
l  If the nodes in the network share common media,
a Media access control protocol is required.
l  Flow control:
l  Control the transmission speed of the sender so
that the receiver does not overloaded.
l  Error control:
l  Detect and correct errors
l  e.g. parity check, checksum, CRC check
8
Error control
Error detection
Error correction

9
Principle of error correction
EDC= Error Detection Code (redundancy)
EDC is added to data before sending to the destination.

Data Data
Y
All bit in Error
Data’
OK? N

Data EDC Data’ EDC’

Link with bit errors

10
Parity code
A check bit is added to the original data to ensure that the
total number of bit 1 is even (even parity code) or odd (odd
parity code)
l  Single code
l  Able to detect single bit
error
101011 101011
l  Two dimension code 111100 101100
l  Detect and correct single bit 011101 011101
error
001010 001010

l  Application: mainly on hardware, ex: while sending


data on PCI and SCSI bus
11
CRC: Cyclic Redundancy Check

l  Data is considered as a binary string: D


l  We wants to generate a error code with length r
l  Choose another binary string of (r+1) bit, G (Generator)
l  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)
l  <D, R> divides G
D D
Y
N
<D’, R’> mod G =
0?
<D, R> mod G = 0

D R D’ R’

12
Link with bit errors
CRC: How to find R

l  <D, R> = D.2r XOR R l  Ví dụ G


l  Since <D, R> divides G then 10101001000 1001
l  D.2r XOR R = n.G 1001 D 1011110
l  è D.2r = n.G XOR R 1110
(associativity) 1001
l  This means, R is the remainder 1110
of the division D.2r by G (division 1001
modulo 2) 1111
1001
R= D.2 mod G
r
1100
1001
R=110, the string to send is 1010
10101001110 1001
110
D R 13
R
CRC under polynomial form

l  1011 ß> x3 +x +1
l  Example of some CRC using in the pratice:
l  CRC-8 = x8 + x2 + x + 1
l  CRC-12 = x12+x11+x3+x2+x
l  CRC-16-CCITT = x16 + x12 + x5 + 1
l  CRC-32 = x32 + x26 + x23 + x22 + x16 + x12 + x11 + x10 + x8 + x7 + x5
+ x4 + x2 + x + 1
l  The longer G is, the more possible that CRC detects
errors.
l  CRC is widely used in the practice
l  Wi-fi, ATM, Ethernet…
l  Operation XOR is implemented in hardware
l  Capable to detect less than r+1 bits errors
14
Reaction when errors detected
l  Objective: assure that data l  Popular techniques:
are transmitted correctly l  Error detection (as we seen)
even though the chanel is l  Acknowledgement/
confirmation
not realiable. l  Retransmis after timeout
l  Condition l  Retransmis after a clear
confirmation that frame is not
l  Data fram must be arrived
transmitted correctly l  ARQ technique: automatic
l  Negligible transmission repeat request). There are 3
delay. versions:
Stop and Wait ARQ
l  Possible errors l 
l  Go Back N ARQ
l  Whole frame loss l  Selective Reject ARQ
l  Error frame l  Similar to techniques used in
l  Loss of error warning flow control.
message
15
Media access control

16
Connection types
l  Point-to-point
l  ADSL
l  Telephone modem
l  Leased Line….
l  Broadcast
l  LAN using bus topology
l  Wireless LAN
l  HFC:
l  …
l  Broadcast networks need media access control
protocol in order to avoid collision when nodes try to
send data.
17
Classification of MAC protocol
l  Chanel division:
l  Resources of the media is divided into small parts (time -
TDMA, frequency- FDMA, Code- CDMA)
l  Distribute a part to each nodes
l  Random access:
l  Chanel is not divided, all nodes are allowed to access
simultaneously with collision possibility
l  Need a mechanism to avoid collision
l  e.g. Pure Aloha, Slotted Aloha, CSMA/CD, CSMA/CA…
l  Sequent access:
l  Nodes can send data one after the other.
l  Token Ring, Token Bus….
18
Channel division
l  FDMA: frequency division multiple access
l  TDMA: time division multiple access

l  CDMA: code division multiple access

19
ex
TDMA và FDMA 4 stations
FDMA

frequency

time
TDMA:

frequency

time 20
CDMA
l  Several senders can share the same frequency on a
single physical channel.
l  Signals come from different senders are encoded by a
different random code
l  Encrypted signals are mixed and then transmit on a
common frequency.
l  The signals are recovered at the receiver by using the
same codes as at sender side.
l  CDMA use the spread spectrum theory, CDMA shows
a lot of advantages that other technology cannot
achieve.
http://en.wikipedia.org/wiki/Spread_spectrum

21
DS-CDMA System Overview
(Forward link)
CDMA is a multiple spread spectrum.

Freq. Freq. Freq.


Freq.

Data A BPF BPF


Despreade Data A
r

Code A MS-A Code A

Freq. Freq.
Freq. Freq.

BPF BPF
Data B Despreade Data B
r

Code B
Code B MS-B

•••
BS
•••

Difference between each communication path is only the spreading code


Random access: Pure Aloha
l  Aloha is used in mobile network of
1G, 2.5G, 3G using GSM
technology .
l  Pure Aloha:
l  When one sender has data to send, just
sends it
l  If while sending, the senders receive
data from other stations à there is
collision. All stations need to resend their
data.
l  There are possibility to have collision
when retransmit.
l  Problem: Sender does not check to see
if the chanel is free before sending data
l  Grey package are having overlap in 23

timeà causing collision


Random access: Slotted Aloha
l  Times axe is divided
into equal slots.
l  Each station sends
data only at the
beginning of a time
slot.
l  è Collision possibility
is reduced
l  Still have collision in
grey package 24
Random access: CSMA
l  CSMA: Carrier Sense Multiple Access
l  CSMA idea is similar to what happens in a meeting.
l  CSMA:
l  The sender “Listen before talk”
l  If the channel is busy, wait blah
blah
blah
l  If the chanel is free, transmit

25
CSMA

l  CSMA: Sender listens before transmission:


l  If the channel is free, send all the data
l  If the channel is busy, wait.
l  Why there are still collision?
l  Due to propagation delay

26
Collision in CSMA
l  Assume that there are 4
nodes in the channel
l  The propagation of the
signal from one node to
the other requires a
certain delay.
l  Ex:
l  Transmissions from B and D
cause collision

27
CSMA/CA
l  CSMA/CA is used WIFI standard IEEE 802.11
l  If two stations discover that the channel is busy,
and both wait then it is possible that they will try to
resend data in the same time.
l  à collision
l  Solution CSMA/CA.
l  Each station wait for a random period à reduce the
collision possibility

28
CSMA/CD
l  Used in Ethernet
l  CSMA with Collision Detection:
l  “Listen while talk”.
l  A sender listen to the channel,
l  If the channel is free then transmit data
l  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
l  Do not continue the transmission even in collision as CSMA
l  If the channel is busy, wait then transmit with
probability p
l  Retransmit after a random waiting time.
29
Comparison between channel
division and random access
l  Channel division
l  Efficient, treat stations equally.
l  Waste of resources if one station has much smaller data to
send than the others
l  Random access
l  When total load is small: Efficient since each station can
use the whole chanel
l  When total load is large: Collision possibility increases.
l  Token control: compromise between the two above
methods.
30
Token Ring
l  A “tocken” is passed
from one node to the T

other in 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 data
31
some reasons
Summary on Media access control
mechanisms
l  Channel division
l  Random access

l  Token

l  What do you thinks about their advantages


and weaknesses

32
Flow control

33
What is flow control
l  Goal: Make sure that the sender does not overload the receiver
l  Why overloading?
l  The receiver stores data frame in buffer.
l  Receiver performs some processing before deliver data to the upper level.
l  Buffer could be full, leaving no space for receiving more frame à some data
fram must be dropped.
l  Problem of errors in transmission is excluded
l  All frames are transmitted to correct receiver without error
l  Propagation time is small and could be ignored
l  Solution
l  Stop-and-wait mechanism
l  Sliding window mechanism

34
Stop-and-wait
l  Principles
l  Transmitter sends a single frame

l  Receiver receives the fram, process and then informs


the transmitter that it is ready to receives next frames
by a clear acknowledgement (ACK).
l  Transmitter waits until reception of the ACK before
sending next frames.

35
ole 2
Stop-and-wait
transmitter
Emetteur receiver
Récepteur
répéter
eReseau.donnerPaquet() Packet
Paquets Paquets
Packet
uireTrame(p)
sique.prendreTrame(t)
sique.attendreAquittement() frame
Trâme

Ack

répéter
ePhysique.donnerTrame()
ePaquet(t) Trâme
frame
eau.prendrePaquet(p)
sique.envoyerAcquittement()

frame
Trâme
Trâme

36

Conception et architectures des réseaux 16


37
Stop-and-wait
l  Advantage
l  Simple, suitable for transmission of big size
frames
l  Weakness
l  When frames are small, the transmission
chanel are not used efficiently.
l  Cannot use often for big size frame due to
l  Limitation in buffer size
l  Big size frame prones to bigger error probability

l  In shared medium, it is not convenient to leave one


38

station using medium for long time


Sliding window: principle
l  Transmitter sends
more than one frame without waiting in
order to reduce waiting time
l  Transmitted frame without ACK will still be stored in
buffer.
l  Number of frame to be transmitted without ACK depends
on the size of buffer at transmitter
l  When transmitter receives ACK, it realises the
succesfully transmitted frame from buffers
l  Transmitter continues sending a number of frame
equivalent to the number of succesfully trasmitted
frames.
39
Sliding window: principle
l  Assume that A and B are two stations connected by a full
duplex media
l  B has a buffer size of n frame.
l  B can receives n frame without sending ACK
l  Acknowledgement
l  In order to keep track of ACKed frames. It is neccessary to
number frames.
l  B acknowledge a frame by telling A which fram B is waiting for
(by number of frame), implicitely saying that B receives well all
other frame before that.
l  One ACK frame serves for acknowledes several frames.

40
Sliding windows: principle

41

Window list the frames to transmit Window list the frames in waiting to receive
Sliding windows

42
Sliding windows
l  Frame are numbered. The maximum number must
not be smaller than the size of the window.
l  Frame are ACKed by another message with number
l  Accumulated ACK: If frame 1,2,3,4 are well
receive, just send ACK 4
l  ACK with number k means all frame k-1, k-2 …
already well received.

43
Sliding windows
l  Transmitter needs to manage some information:
l  List of frames transmitted sucessfully
l  List of frames transmitted without ACK
l  List of frames to be sent immediatly
l  List of frames NOT to be sent immediately
l  Receiver keep tracks of
l  List of frames well received
l  List of frames expected to receive

44
Piggy backing
l  A and B transmitte data in both sides
l  When B needs to send an ACK while still needs to
send data, B attaches the ACK in the Data frame:
Piggybacking
l  Otherwise, B can send an ACK frame separatly
l  After ACK, if B sends some other data, it still put the
ACK information in data frame.
l  Sliding window is much more efficient than Stop-
and-Wait
l  More complicated in management.

45
Exercices
l  Given a link with rate R=100Mbps
l  We need to send a file over data link layer with file size L=100KB
l  Assume that the size of a frame is: 1KB, header size is ignored
l  Round trip time (RTT) between 2 ends of the link is 3ms
l  An ACK message is sent back from receiver whenever a frame is
arrived. Size of ACK message is negligible
l  What is the transmission time required if using Stop-and-wait
mechanism?
l  Transmission time with sliding window if the window size is =7?
l  Which size of window allow to obtain the fastest transmission?

46
e2 Transmission time with Stop-
and-wait
transmitter
Emetteur receiver
Récepteur
éter
eseau.donnerPaquet() Packet
Paquets Packet
Paquets
Trame(p)
ue.prendreTrame(t) T transmit
ue.attendreAquittement() frame
Trâme

RTT Ack

éter
ysique.donnerTrame()
aquet(t) frame
Trâme
u.prendrePaquet(p)
ue.envoyerAcquittement()

frame
Trâme
Trâme

47

Conception et architectures des réseaux 16


Transmission time with Stop-
and-wait
l  T total= Nb.frame * (T_transmit + RTT)
l  T_transmit (F) = L(Frame)/ R

l  Nb. frame = L/L(frame)

l  With the given parametters


l  Nb. frame =100 KB/1KB =100

l  T_transmit (F) = 1KB/100 Mbps


=10^3*8/10^8 =8. 10^-5 (s)=0.08 (ms)
48
Sliding windows

49
Trasmission time with window
size 7
l  T fastest= (T transmit 7 frames+ wait) * Nb.
Waiting time.
l  1 waiting= (T transmit 1 frame+ RTT) – T
transmit 7 frames
l  Nb. Waiting time= Nb frame /7

50
Fastest transmission time with
sliding window
l  Fastest transmission time
obtained if transmitter
receives ACK of the first
W gói
ACK frame when it finishes
transmitting the last frame
of the sliding window.
l  Window size:W
l  T transmit(W fram) >= T
transmit first frame + RTT

51
Fastest transmission time with
sliding window
l  T transmit (W frame) = W * 1KB/R
l  => (W-1)*1KB/R >= RTT

l  => W >= RTT*R/1KB +1

l  W>= 3ms * 100 Mbps/ 1KB + 1


l  W>=38.5
l  Smallest value of W = 39

l  Time to transmit all data L = L/R + RTT =8


ms +3ms =11 ms
52

You might also like