ComputerNetwork C3 en
ComputerNetwork C3 en
1-1
Chapter 3: Data Link layer
our goals:
• understand principles behind link layer
services:
– framing
– error detection, correction
– sharing a broadcast channel: multiple access
– link layer addressing (MAC address)
– local area networks: Ethernet, VLANs
• instantiation, implementation of various link
layer technologies
Link Layer and LANs 6-2
Link layer, LANs: outline
6.1 introduction,
services
6.2 framing
6.3 error detection,
correction Application Application
Presentation Data Presentation
6.4 data link protocols Session segments
Session
Transport Data Transport
- stop-n-wait Network Data packets
Network
Data Link Data frames Data Link
- stop-n-wait ARQ Physical Physical
10010111001011010010110101011110101
• error detection:
– errors caused by signal attenuation, noise.
– receiver detects presence of errors:
• signals sender for retransmission or drops frame
• error correction:
– receiver identifies and corrects bit error(s) without resorting to
retransmission
• combination of hardware,
software, firmware network adapter
card
datagram datagram
controller controller
frame
1.Byte count.
2.Flag bytes with byte stuffing.
3.Flag bytes with bit stuffing.
4.Physical layer coding violations.
Framing (1): Byte count
A byte stream. (a) Without errors. (b) With one error.
Framing (2): Flag with byte stuff
10101010 10101010
Bit stuffing. (a) The original data. (b) The data as they appear on
the line. (c) The data as they are stored in the receiver’s memory after destuffing.
Framing (4): Physical layer coding violations
• This method is only applicable to networks in which the encoding
on the physical medium contains some redundancy. For example,
some LANs encode 1 bit of data by using 2 physical bits. Normally,
a 1 bit is a high-low pair and a 0 bit is a low-high pair.
• 11 or 00 are not used for data but are used for delimiting frames in
some protocols.
1-15
Exercise
• Computer networks, Chapter 3, p.252
– Exercise 2
– Exercise 4
– Exercise 6
1-16
Link layer, LANs: outline
6.1 introduction,
services
6.2 framing
6.3 error detection,
correction
6.4 elementary data link
protocols
otherwise
1-19
Parity checking
single bit parity: two-dimensional bit parity:
detect single bit errors detect and correct single bit errors
sender: receiver:
• treat segment contents as • compute checksum of received
sequence of 16-bit integers segment
• checksum: addition (1’s • check if computed checksum
complement sum) of equals checksum field value:
segment contents – NO - error detected
• sender puts checksum value – YES - no error detected.
into UDP checksum field But maybe errors
nonetheless?
Now, all the segments are added and the result is obtained as-
10011001 + 11100010 + 00100100 + 10000100 = 1000100011
Since the result consists of 10 bits, so extra 2 bits are wrapped around.
00100011 + 10 = 00100101 (8 bits)
Now, 1’s complement is taken which is 11011010.
Thus, checksum value = 11011010
Transmit Data + Checksum
• Receiver
1-23
Cyclic redundancy check
• more powerful error-detection coding
• view data bits, D, as a binary number
• Let r be the degree of (generator), G
– e.g. G(x) = x3 + 1 = 1.x3 + 0.x2 + 0.x1 + 1.x0 => G = 1001, r = 3
• goal: choose r CRC bits, R, such that
– <D,R> exactly divisible by G (modulo 2)
– receiver knows G, divides <D,R> by G. If non-zero remainder: error detected!
– can detect all burst errors less than r bits
• widely used in practice (Ethernet, 802.11 WiFi, ATM)
equivalently:
if we divide D.2r by
G, want remainder R
to satisfy:
)
Transmit 1 0 1 1 1 0 0 1 1
* Check out the online interactive exercises for more
examples: http://gaia.cs.umass.edu/kurose_ross/interactive/ Link Layer and LANs 6-25
CRC example
• At the receiver
G
Receive 1 0 1 1 1 0 0 1 1 1 0 01
1 0 0 1 1 0 1 0 1 1
1 0 1
0 0 0
1 0 1 0
1 0 0 1
1 1 0
0 0 0
1 1 0 1
1 0 0 1
1 0 0 1
1 0 0 1 1-26
0 0 0 0
Exercise
• Computer Networks, Chapter 3, p. 253
– Exercise 16, 17
1-27
Link layer, LANs: outline
6.1 introduction,
services
6.2 framing
6.3 error detection,
correction
6.4 elementary data link
protocols
1-32
Simplex Stop-and-Wait Protocol
for a Noisy Channel (2)
1-37
Example Data Link Protocols
1-39
HDLC – High-Level Data Link Control
Frame format for bit-oriented protocols.
Control field of
(a) An information frame.
(b) A supervisory frame.
(c) An unnumbered frame.
Practice
• Packet Tracer
– Generate a HDLC between 2 router A and B over a serial link.
192.168.2.2/24 192.168.1.2/24
Router-B#ping 192.168.10.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.10.5, timeout is 2 seconds:
!!!!! Success rate is 100 percent (5/5), round-trip min/avg/max = 3/3/4 ms 1-42
Summary
• Principles of data link layer services:
– Framing
• Byte count.
• Flag bytes with byte stuffing.
• Flag bytes with bit stuffing.
1-43
Appendix
1-44
Utopian Simplex Protocol (2)
...
A utopian simplex protocol.
Utopian Simplex Protocol (3)
A utopian simplex protocol.
...
Elementary Data Link Protocols (4)
Some definitions needed in the protocols to follow. These definitions
are located in the file protocol.h.
...
Elementary Data Link Protocols (5)
Some definitions needed in the protocols to follow. These definitions
are located in the file protocol.h.
Simplex Stop-and-Wait Protocol
for a Noisy Channel (3)
...
...
Sliding Window Protocols (2)
A positive acknowledgement with retransmission protocol.
...
Sliding Window Protocols (4)
A positive acknowledgement with retransmission protocol.
Sliding Window Protocols (5)
A sliding window of size 1, with a 3-bit sequence number.
(a) Initially. (b) After the first frame has been sent.
Sliding Window Protocols (6)
...
...
...
Protocol Using Go-Back-N (4)
A sliding window protocol using go-back-n.
...
Protocol Using Go-Back-N (5)
A sliding window protocol using go-back-n.
...
Protocol Using Go-Back-N (6)
A sliding window protocol using go-back-n.
...
Protocol Using Go-Back-N (7)
A sliding window protocol using go-back-n.
...
Protocol Using Go-Back-N (8)
A sliding window protocol using go-back-n.
...
Protocol Using Go-Back-N (9)
A sliding window protocol using go-back-n.
Protocol Using Go-Back-N (10)
...
Protocol Using Selective Repeat (3)
A sliding window protocol using selective repeat.
...
Protocol Using Selective Repeat (4)
A sliding window protocol using selective repeat.
...
Protocol Using Selective Repeat (5)
A sliding window protocol using selective repeat.
...
Protocol Using Selective Repeat (6)
A sliding window protocol using selective repeat.
...
Protocol Using Selective Repeat (7)
A sliding window protocol using selective repeat.
...
Protocol Using Selective Repeat (7)
A sliding window protocol using selective repeat.
...
Protocol Using Selective Repeat (8)
A sliding window protocol using selective repeat.
...
Protocol Using Selective Repeat (9)
A sliding window protocol using selective repeat.
Protocol Using Selective Repeat (10)