Cchapter 3-Part I
Cchapter 3-Part I
2
Data Link Layer Responsibilities
• Framing:
• Media Access control:
• Flow control:
• Error control:
3
i. Framing
• separates a message from one source to a destination, or from
other messages to other destinations, by adding a sender address
and a destination address.
• The destination address defines where the packet is to go; the
sender address helps the recipient acknowledge the receipt.
• Although the whole message could be packed in one frame, that is
not normally done.
reason:
• a frame can be very large, making flow and error control very
inefficient.
• When a message is carried in one very large frame, even a
single-bit error would require the retransmission of the whole
4
message.
Cont.
Frames can be of fixed or variable size
6
Cont.
Bit-Oriented Protocols
7
Cont.
• This flag can create the same type of problem we saw in the byte-
oriented protocols.
• That is, if the flag pattern appears in the data, we need to somehow
inform the receiver that this is not the end of the frame.
• We do this by stuffing 1 single bit (instead of 1 byte) to prevent
the pattern from looking like a flag.
• The strategy is called bit stuffing.
• In bit stuffing, if a 0 and five consecutive 1 bits are encountered,
an extra 0 is added. This extra stuffed bit is eventually removed
from the data by the receiver.
• Note that the extra bit is added after one 0 followed by five
1s regardless of the value of the next bit.
8
• This guarantees that the flag field sequence does not appear in the
Cont.
Bit stuffing is the process of adding one extra 0 whenever five consecutive
1s follow a 0 in the data, so that the receiver does not mistaken the
pattern 0111110 for a flag.
9
Cont.
• Note that even if we have a 0 after five 1s, we still stuff a 0. The 0
will be removed by the receiver.
• This means that if the flag like pattern 01111110 appears in the
data, it will change to 011111010 (stuffed) and is not mistaken as
a flag by the receiver.
10
ii. Media Access control
11
iii. Flow Control
• Flow control refers to a set of procedures used to restrict the amount
of data that the sender can send before waiting for
acknowledgment.
• Flow control coordinates the amount of data that can be sent before
receiving an acknowledgment and is one of the most important duties
of the data link layer.
• In most protocols, flow control is a set of procedures that tells the
sender how much data it can transmit before it must wait for
an acknowledgment from the receiver.
• The flow of data must not be allowed to overwhelm the receiver. Any
receiving device has a limited speed at which it can process incoming
data and a limited amount of memory in which to store incoming data.
• The receiving device must be able to inform the sending device before
12
those limits are reached and to request that the transmitting device
iv. Error control
13
Cont.
Detecting Errors
• Usually, noise levels are fairly low and most of the bits are
received correctly by the receiver.
• The question is, how can the receiver know when an error
has occurred?
• Because errors occur randomly, there is no way of
knowing with complete certainty if the data is correct.
• The best we can do is detect most errors.
• Even when we detect an error, the next question is: what to do
about it?
14
Cont.
Error Detection Process
15
Cont.
16
Types of Error
17
1. Parity Checking (Vertical Redundancy Check (VRC))
• If the received character does not have an even (or odd) number
of bits then an error must have occurred.
• Both the sender and receiver must know which form of parity to
use. 18
Cont.
20
3. Cyclic Redundancy Check
by multiplying D by 2^ (n-k)
we have in effect shifted it to the left by n-k bits and padded out the result
with zeroes.
22
Cont.
23
Cont.
24
2. Polynomials
25
26
3. Digital Logic
27
Protocols
o Data link layer can combine framing, flow control, and error control to achieve
the delivery of data from one node to another.
o Protocols are those that can be used for noiseless (error-free) channels and
those that can be used for noisy (error-creating) channels.
28
Noiseless channels
o channel in which no frames are lost, duplicated, or corrupted
Simplest Protocol
o is one that has no flow or error control
o unidirectional protocol in which data frames are traveling in
only one direction-from the sender to receiver.
29
Stop-and-wait Protocol
Sender sends one frame, stops until it receives confirmation from
the receiver (okay to go ahead), and then sends the next frame.
still have unidirectional communication for data frames, but
auxiliary ACK frames (simple tokens of acknowledgment) travel
from the other direction.
30
Noisy channels
31
Go-Back-N Automatic Repeat Request (Go-Back-N ARQ)
Multiple frames must be in transition while waiting for
acknowledgment.
let more than one frame be outstanding to keep the channel busy
while the sender is waiting for Acknowledgment
can send several frames before receiving acknowledgments; we
keep a copy of these frames until the acknowledgments arrive.
32
Sliding Window
• is an abstract concept that defines the range of sequence numbers
that is the concern of the sender and receiver.
• In other words, the sender and receiver need to deal with only part
of the possible sequence numbers.
• The range which is the concern of the sender is called the send
sliding window
• The range that is the concern of the receiver is called the receive
sliding window
33
The send window can slide one or more slots when a valid
acknowledgment arrives.
The window slides when a correct frame has arrived; sliding
occurs one slot at a time during receiver window sliding
34
High-level Data Link Control HDLC
o is a bit-oriented protocol for communication over point-to-point
and multipoint links.
o It implements the Automatic Repeat Request ARQ mechanisms
We will discuss some concepts of:
Configurations and Transfer Modes
Frames
Control Field
Configurations and Transfer Modes
o HDLC provides two common transfer modes that can be used in
different configurations:
normal response mode (NRM) and
asynchronous balanced mode (ABM)
11.35
Normal response mode
36
Asynchronous balanced mode
o The station configuration is balanced
Frames
o HDLC defines three types of frames:
information frames (I-frames)
supervisory frames (S-frames) and
unnumbered frames (U-frames)
o Each type of frame serves as an envelope for the transmission of
a different type of message.
37
o I-frames are used to transport user data and control information
relating to user data
o S-frames are used only to transport control information
o U-frames are reserved for system management.
Information carried by U-frames is intended for
managing the link itself
Frame Format
Each frame in HDLC may contain up to six fields:
a beginning flag field
an address field
a control field
an information field
a frame check sequence (FCS) field and
an ending flag field.
38
HDLC frames
39
HDLC frames
Let us now discuss the fields and their use in different frame types.
Flag field. is an 8-bit sequence with the bit pattern 01111110 that
identifies both the beginning and the end of a frame and serves as a
synchronization pattern for the receiver.
Address field.
• An address field can be 1 byte or several bytes long, depending on
the needs of the network. One byte can identify up to 128 stations
(1 bit is used for another purpose).
• Larger networks require multiple-byte address fields.
• If the address field is only 1 byte, the last bit is always a 1.
• If the address is more than 1 byte, all bytes but the last one will end
with 0; only the last will end with 1.
• Ending each intermediate byte with 0 indicates to the receiver that 40
HDLC frames
Information field. The information field contains the user's data from
the network layer or management information.
• Its length can vary from one network to another.
FCS field. The frame check sequence (FCS) is the HDLC error
detection field.
• It can contain either a 2- or 4-byte ITU-T CRC.
41
Control field
The control field determines the type of frame and defines its functionality
Control field format for the different frame types
42
Control field
I-frames are designed to carry user data from the network layer.
• In addition, they can include flow and error control information
(piggybacking).
• The first bit defines the type. If the first bit of the control field is 0,
this means the frame is an I-frame.
• The next 3 bits, called N(S), define the sequence number of the
frame. Note that with 3 bits, we can define a sequence number
between 0 and 7; but in the extension format, in which the control
field is 2 bytes, this field is larger. The last 3 bits, called N(R),
correspond to the acknowledgment number when piggybacking is
used.
• The single bit between N(S) and N(R) is called the P/F bit.
• The P/F field is a single bit with a dual purpose. It has meaning only
when it is set (bit = 1) and can mean poll or final. It means poll 43
Control field
44
Control field
46
Error Correction
48
How Error Correction Works
49
Cont.
50
Hamming Distance
51
Cont.
52
Hamming ECC
Why this ordering? Because we want the syndrome, the Hamming test word,
to yield the address of the error.
54
Example:
Data stored = 00111001
Check bits:
Putting it together:
Example:
Example:
Word fetched: Check Bits:
Comparing:
C8 C4 C2 C1
0 1 1 1 Orig Check
Bits
0 0 0 1 New Check Bits
0 1 1 0 Syndrome
0110 = 6 bit
position 6 is wrong,
Putting it all together: i.e. bit D3 is wrong
58
Random Access
• This method later evolved into two parallel methods: carrier sense multiple
access with collision detection (CSMA/CD) and carrier sense multiple access
with collision avoidance (CSMA/CA).
• CSMA/CD tells the station what to do when a collision is detected. 61
1. Pure ALOHA
62
Procedure for pure ALOHA protocol
63
Procedure for pure ALOHA protocol
64
• Under what conditions will the shaded packet arrive undamaged?
Vulnerable Period
65
2. Slotted ALOHA
• Divide time up into discrete intervals, each
corresponding to one packet.
• The vulnerable period is now reduced in
half.
66
Figure Vulnerable time for slotted ALOHA protocol
67
3. Carrier Sense Multiple Access (CSMA)
Protocols that listen for a carrier and act accordingly are called
carrier sense protocols.
Carrier sensing allows the station to detect whether the medium is
currently being used.
There are two variants of CSMA: CSMA/CD and CSMA/CA
The simplest CSMA scheme is for a station to sense the medium,
sending packets immediately if the medium is idle.
If the station waits for the medium to become idle it is called
persistent otherwise it is called non persistent.
68
Assumptions with CSMA
Networks
1. Constant length packets
2. No errors, except those caused by collisions
3. Each host can sense the transmissions of all other hosts
4. The propagation delay is small compared to the transmission time
69
1-Persistent CSMA
• Sense the channel.
– If busy, keep listening to the channel and transmit immediately when
the channel becomes idle.
– If idle, transmit a packet immediately.
• If collision occurs,
– Wait a random amount of time and start over again.
The protocol is called 1-persistent because the host transmits
with a probability of 1 whenever it finds the channel idle.
70
Figure Behavior of three persistence methods
71
Non-Persistent CSMA
• Sense the channel.
– If busy, wait a random amount of time and sense the channel again
– If idle, transmit a packet immediately
• If collision occurs
– wait a random amount of time and start all over again
72
Figure Behavior of three persistence methods
73
P-Persistent
CSMA
• Optimal strategy: use P-Persistent CSMA
• Assume channels are slotted
• One slot = contention period (i.e., one round trip propagation delay)
74
Figure Behavior of three persistence methods
75
3.1 Carrier Sense Multiple Access/Collision Detection
(CSMA/CD)
If another collision occurs, the time intervals from which the random
waiting time is selected are increased step by step.
76
This is known as exponential back off.
Flow diagram for the CSMA/CD
77
3.2 Carrier Sense Multiple Access with Collision Avoidance
(CSMA/CA)
• We need to avoid collisions on wireless networks because they
cannot be detected.
• Collisions are avoided by deferring transmission even if the channel
is found idle.
• When an idle channel is found, the station does not send
immediately. It waits for a
period of time called the inter frame space or IFS.
• In CSMA/CA, the Inter frame space (IFS) can be used to define the
priority of a station or a frame.
• In CSMA/CA, if the station finds the channel busy, it does not restart
the timer of the contention window (amount of time divided in time
slots); it stops the timer and restarts it when the channel becomes
idle.
78
79
Controlled access
In controlled access, the stations consult one another to
find which station has the right to send.
80
1. Reservation
81
Cont.
82
2. Polling
All data exchanges must be made through the primary device even
when the ultimate destination is a secondary device.
The primary device controls the link; the secondary devices follow
its instructions.
86
Channelization protocols
• FDMA
the available bandwidth of the common channel is divided into
bands that are separated by guard bands.
• TDMA
the bandwidth is just one channel that is timeshared between
different stations.
• CDMA
one channel carries all transmissions simultaneously.
87
Thank You!
Questions?
88