Data link control - Lunds tekniska högskolaprotocols although not at the data link layer. The main...
Transcript of Data link control - Lunds tekniska högskolaprotocols although not at the data link layer. The main...
Data link control
Maria Kihl
2
Book chapters
Forouzan 4th: 10.1-5, 11.1-5, 11.7
Forouzan 5th: (9.1), 10.1-3, 10.4.1, 11.1-2, 11.4, 23.2
Kihl: 4.1-4.3, 4.5
Repetition
3 (or digital signal)
4
Data communication on a link
A stream of bits would not be very efficient or manageable.
5
Data packets
Therefore, data is divided into packets before transmission.
header data trailer
Header and trailer contains control information needed
for the transmission.
6
Application Protocols
Application protocol Application Application
Physical link PHY PHY
information information
bits bits
signals
7
HTTP, an application protocol
HTTP = Hyper Text Transfer Protocol
HTTP request
HTTP reply
Web server
8
Link layer protocol
The sender and receiver uses a link layer protocol that
provides error detection and correction for data that is
sent on a physical link.
Link
application
PHY
data
bits
Link
application
PHY
data
bits
link protocol
application protocol
9
Framing
• The Physical layer protocol sends a bitstream. The
Link layer protocol needs to separate the packets.
• Therefore, the link layer protocol at the sender
packetize data in frames so that the receiver can
distinguish one frame from another.
10
Bitstuffing
Bitstuffing is used so that the data cannot be interpreted
as a flag.
11
The need for error control
The data packets must be received without errors.
Otherwise, the reciever cannot understand them.
110111 010011 001111 100111
12
Bit errors
Due to transmission impairments, data can be
corrupted during transmission. If the receiver
interprets a 1 as a 0, a bit error has occured.
1 0 link
13
Single-bit error
In a single-bit error, only 1 bit in the data unit has changed.
14
Burst errors
A burst error means that 2 or more
bits in the data unit have changed.
15
To find bit errors
To detect and/or correct errors, extra (redundant) bits
is added to the data message.
Data Extra bits
The value of the extra bits depends on the data.
16
Error detection process
17
Error detection with Block coding
In block coding, we divide our message into blocks, each of k
bits, called datawords. We add r redundant bits to each block
to make the length n = k + r. The resulting n-bit blocks are
called codewords.
18
Error detection schemes
Simple Parity-Check Code
Cyclic Redundancy Check
Checksum
19
Simple Parity-Check Code
A k-bit dataword is changed to an n-bit codeword,
where n = k+1. In (Even) Parity-Check the extra bit is
selected to make the total number of 1s in the
codeword even.
10011100 + 0 = 100111000
A simple parity-check code can detect an odd
number of errors.
Simple Parity-check code
20
Cyclic Redundancy Check (CRC)
21
In CRC, the sender and receiver uses a predefined shared divisor
to calculate the codeword. The math behind the choice of
divisor is out of the scope of this course.
22
Dataword representation
The dataword of k bits be represented by a
polynomial, d(x).
23
Encoder process
The objective is to find a codeword, c(x), of n bits.
The codeword is determined with a generator polynomial
(divisor), g(x), of degree n-k.
The encoder process is quite impossible to describe in
Powerpoint, instead we will work with it in the problem
solving classes this week.
24
CRC encoder process
1. Left-shift the dataword n-k bits (i.e. xn-k * d(x)).
2. Divide xn-k * d(x) with g(x) using modulo-2
division.
3. The remainder, r(x), of the division is used as
redundant bits (i.e. c(x) = xn-k * d(x) + r(x)).
CRC example
Dataword: 1001
Polynomial representation:
Divisor: 1011
Polynomial representation:
Dataword multiplied with :
25
13 x
13 xx
3x 36 xx
26
CRC example
27
CRC at the receiver
The received codeword is c(x)+e(x) where e(x) is the
error that have occurred during the transmission.
The receiver calculates the following:
Received codeword
g(x) =
c(x)
g(x) +
e(x)
g(x)
If the result is 0, the dataword is assumed to be correct.
28
Detected errors
In a cyclic code, those e(x) errors that are divisible by
g(x) are not caught.
If the generator has more than one term and the
coefficient of x0 is 1, all single errors can be caught.
If a generator cannot divide xt + 1 (t between 0 and
n – 1), then all isolated double errors can be detected.
A generator that contains a factor of x + 1 can detect
all odd-numbered errors.
29
Generator polynomial
Therefore, a good polynomial generator needs to have
the following characteristics:
1. It should have at least two terms.
2. The coefficient of the term x0 should
be 1.
3. It should not divide xt + 1, for t
between 2 and n − 1.
4. It should have the factor x + 1.
30
Some standard CRC polynomials
31
Checksum
The checksum is used in the Internet by several
protocols although not at the data link layer.
The main principle is to divide the data into segments
of n bits. Then add the segments and use the sum as
redundant bits.
Checksum process
32
Checksum example
Message: 1100 0101 1010
Checksum using 4 bits:
1100+0100+1010 => 12+4+10=29 => 11101
11101 is more than 4 bits. Use one’s complement
addition: 0001 1101 => 0001+1101 = 1110
The checksum is complemented to help the receiver. 33
34
Checksum (another example)
1
1 1
0
35
Link layer protocol
The link layer protocol should make sure that the data
is correctly transmitted over the physical link.
Link
application
PHY
data
bits
Link
application
PHY
data
bits
link protocol
application protocol
36
The need for Error control
When a corrupted packet has been detected, the error
must be corrected in some way.
Two basic principles:
Forward Error Correction (FEC)
Extra bits are added in the data that makes it possible for the
receiver to correct bit error.
FEC is not included in this course
Retransmission of the data
The data is retransmitted until correctly received
Rules for retransmission is needed
The need for Flow control
The receiver must be able to handle all recieved
frames. If the transmission rate is too high, the
receiever may become overloaded and drop frames
due to full buffers.
37
38
Error and flow control
The basic principle in error and flow control is that the
receiver acknowledges all correctly received packets.
Data
ACK
39
Automatic Repeat Request (ARQ)
schemes
Stop-and-wait ARQ
Go-back-N ARQ
Selective Repeat ARQ
Unfortunately, Fouruzan 5th edition has become rather confused on these schemes
with descriptions in two different chapters. Please follow the lecture slides for a more
compact view.
40
Stop-and-wait ARQ
The receiver sends an ACK for every data packet that is correctly received.
The sender transmits the next packet when it has received an ACK for the previous one.
The sender uses a time-out for each packet. If the time-out expires (i.e. no ACK has arrived), the packet is retransmitted.
Packets are identified with a sequence number, alternating between 0 and 1.
41
Stop-and-Wait, example
42
Go-back-N ARQ
The sender can transmit several packets without an
ACK from the receiver.
The receiver ACKs all packets that are correctly
received in the right order.
The sender can transmit new packets when ACKs are
received for previous packets.
This is called pipelining.
43
Sequence numbers
The packets are identified with a seqence number.
If the header allows m bits for the sequence number, the numbers can range from 0 to 2m-1.
This means that the maximum number of outstanding packets (transmitted packets that haven’t been ACKed) is 2m-1.
A sliding window defines the range of sequence numbers that currently concerns the sender and receiver.
44
Sliding window at sender
45
Importance of window size
46
Go-back-N, example (lost ACK)
47
Go-back-N, example (lost data)
48
Selective repeat ARQ
Works as Go-back-N as long as there are no lost
packets.
The receiver sends a negative acknowledgment (NAK)
when it detects a lost packet.
Only the lost packets are retransmitted.
49
Send and receive windows
50
Selective repeat, example
Point-to-Point Protocol (PPP)
Point-to-point protocol (PPP) is one of the classical
Internet protocols, and it is in this course used as an
example of the function of a link layer protocol.
It is a byte-oriented (character-oriented) protocol, that
is, everything in the frame is treated in bytes.
Frame format:
Byte stuffing
When the flag appears in the data field, it needs to be
escaped.
Since PPP is a byte-oriented protocol, byte stuffing is
used.
Every time the flaglike pattern appears in the data
field, the escape byte 01111101 is stuffed to tell the
receiver that the next byte is not a flag.
Error and flow control
• PPP uses a 2 or 4 byte CRC for error detection.
• However, no further error or flow control is
provided.
53
Transition phases
A PPP connection goes through a number of phases:
Help protocols
PPP uses a set of other protocols to manage the connection:
Link Control Protocol (LCP) is responsible for establishing,
maintaining, configuring, and terminating links.
Password Authentication Protocol (PAP) and Challenge Handshake
Authentication Protocol (CHAP) are used in the authentication process.
A Network Control Protocol (NCP) configures the link for the network
protocol. One example is Internet Protocol Control Protocol (IPCP) for
Internet.
Other protocols in PPP