0% found this document useful (0 votes)
11 views78 pages

ComputerNetwork C3 en

The document covers the Data Link Layer in computer networks, focusing on its services such as framing, error detection and correction, and local area networks (LANs) like Ethernet and VLANs. It discusses various link layer protocols, including Simplex Stop-and-Wait and Sliding Window protocols, as well as error detection methods like parity checks and cyclic redundancy checks (CRC). The document also outlines the implementation of the link layer in network interface cards (NICs) and the importance of MAC addressing.

Uploaded by

pttam12345678
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)
11 views78 pages

ComputerNetwork C3 en

The document covers the Data Link Layer in computer networks, focusing on its services such as framing, error detection and correction, and local area networks (LANs) like Ethernet and VLANs. It discusses various link layer protocols, including Simplex Stop-and-Wait and Sliding Window protocols, as well as error detection methods like parity checks and cyclic redundancy checks (CRC). The document also outlines the implementation of the link layer in network interface cards (NICs) and the importance of MAC addressing.

Uploaded by

pttam12345678
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/ 78

COMPUTER NETWORKS

THE DATALINK LAYER

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
6.4 data link protocols
Application Application
- stop-n-wait Presentation Data Presentation
Session Session
- stop-n-wait ARQ Transport Data
segments Transport
Data packets
Network Network
Data Link Data frames Data Link
Physical Physical
10010111001011010010110101011110101

Link Layer and LANs 6-3


Link layer: introduction
terminology:
• hosts and routers: nodes
• communication channels that
connect adjacent nodes along
communication path: links
– wired links
– wireless links
– LANs
• layer-2 packet: frame, encapsulates
datagram

data-link layer has responsibility of


transferring datagram from one node
to physically adjacent node over a link
Link Layer and LANs 6-4
Link layer: context
• datagram transferred by transportation analogy:
different link protocols over • trip from Princeton to Lausanne
different links: – limo: Princeton to JFK
– e.g., Ethernet on first link, – plane: JFK to Geneva
frame relay on intermediate – train: Geneva to Lausanne
links, 802.11 on last link • tourist = datagram
• each link protocol provides • transport segment =
different services communication link
– e.g., may or may not provide • transportation mode = link
rdt over link layer protocol
• travel agent = routing algorithm

Link Layer and LANs 6-5


Link layer services
• framing, link access:
– encapsulate datagram into frame, adding header, trailer
– channel access if shared medium
– “MAC” addresses used in frame headers to identify source, destination
• different from IP address!
• reliable delivery between adjacent nodes
– we learned how to do this already (chapter 3)!
– seldom used on low bit-error link (fiber, some twisted pair)
– wireless links: high error rates
• Q: why both link-level and end-end reliability?

Link Layer and LANs 6-6


Link layer services (more)
• flow control:
– pacing between adjacent sending and receiving nodes
• 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
• half-duplex and full-duplex
– with half duplex, nodes at both ends of link can transmit, but not at same
time

Link Layer and LANs 6-7


Where is the link layer implemented?
• in each and every host
• link layer implemented in
“adaptor” (aka network
interface card NIC) or on a chip
– Ethernet card, 802.11 card; application
transport
Ethernet chipset network
link
cpu memory

– implements link, physical


layer host
bus
controller
• attaches into host’s system link
(e.g., PCI)

buses physical
physical
transmission
• combination of hardware,
software, firmware network adapter
card

Link Layer and LANs 6-8


Adaptors communicating

datagram datagram

controller controller

sending host receiving host


datagram

frame

• sending side: • receiving side


– encapsulates datagram in – looks for errors, rdt, flow
frame control, etc.
– adds error checking bits, – extracts datagram, passes to
upper layer at receiving side
rdt, flow control, etc.

Link Layer and LANs 6-9


Link layer, LANs: outline
6.1 introduction, services
6.2 framing
6.3 error detection,
correction
6.4 elementary data link
protocols
- stop-n-wait
- stop-n-wait ARQ

Link Layer and LANs 6-10


Framing Methods

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

• A frame delimited by flag bytes.


• Four examples of byte sequences before and after byte stuffing.
Framing (3): Flag with bit stuff

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

Link Layer and LANs 6-17


Error detection
EDC= Error Detection and Correction bits (redundancy)
D = Data protected by error checking, may include header fields

• Error detection not 100% reliable!


• protocol may miss some errors, but rarely
• larger EDC field yields better detection and correction

otherwise

Link Layer and LANs 6-18


Error detection
• Parity check
• Internet checksum
• Cyclic redundancy check (CRC)

1-19
Parity checking
single bit parity: two-dimensional bit parity:
 detect single bit errors  detect and correct single bit errors

 The two types of parity


checking are
 Even Parity
 Odd Parity

* Check out the online interactive exercises for more


examples: http://gaia.cs.umass.edu/kurose_ross/interactive/ Link Layer and LANs 6-20
Internet checksum (1)
goal: detect “errors” (e.g., flipped bits) in transmitted packet (note:
used at transport layer only)

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 – YES - no error detected.
value into UDP checksum But maybe errors
field nonetheless?

Link Layer and LANs 6-21


Internet checksum (2)
• Transmitter

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
Sum of all segments (wrapped around) + Checksum value
= 00100101 + 11011010 = 11111111
No errors
1-22
Exercise
• Computer networks, Chapter 3, p. 253
– Exercise 15

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)

Link Layer and LANs 6-24


CRC example
want:
D.2r XOR R = nG
equivalently:
D.2r = nG XOR R r bits
equivalently:
if we divide D.2r by G, want
remainder R to satisfy:

𝐷.2𝑟
𝑅= 𝑟𝑒𝑚𝑎𝑖𝑛𝑑𝑒𝑟( )
𝐺

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

Link Layer and LANs 6-28


Elementary Data Link Protocols (1)

• Utopian Simplex Protocol


• Simplex Stop-and-Wait Protocol
• Error-Free Channel
• Simplex Stop-and-Wait Protocol
• Noisy Channel
• Sliding Window Protocol
• Go-back-N
• Selective repeat
Elementary Data Link Protocols (2)
Implementation of the physical, data link, and network layers.
Utopian Simplex Protocol (1)
• It is hypothetical protocol designed for unidirectional data
transmission over an ideal channel, i.e. a channel through which
transmission can never go wrong. Since this protocol is totally
unrealistic, it is often called Utopian Simplex protocol.

Example Utopian protocol written in C 1-31


Simplex Stop-and-Wait Protocol
for a Noisy Channel (1)
• Simplex Stop – and – Wait protocol for noisy channel is data link
layer protocol for data communications with error control and flow
control mechanisms.
• It is popularly known as Stop – and –Wait Automatic Repeat
Request (Stop – and –Wait ARQ) protocol. It adds error control
facilities to Stop – and – Wait protocol.

1-32
Simplex Stop-and-Wait Protocol
for a Noisy Channel (2)

Example Stop and Wait protocol written in C 1-33


Sliding Window Protocols (1)
• In this protocol, multiple frames
can be sent by a sender at a time
before receiving an
acknowledgment from the
receiver. The term sliding window
refers to the imaginary boxes to
hold frames.
• the sender has a buffer called the
sending window and the receiver
has buffer called the receiving
window.
• two categories
– Go – Back – N ARQ
– Selective Repeat ARQ
1-34
Protocol Using Go-Back-N (1)
Pipelining and error recovery. Effect of an error when
(a) receiver’s window size is 1
Protocol Using Go-Back-N (2)
Pipelining and error recovery. Effect of an error when
(b) receiver’s window size is large.
Protocol Using Selective Repeat (1)
• This protocol also provides for sending multiple frames before
receiving the acknowledgment for the first frame. However, here
only the erroneous or lost frames are retransmitted, while the
good frames are received and buffered.

1-37
Example Data Link Protocols

• HDLC – High-Level Data Link Control


• The Data Link Layer in the Internet
HDLC – High-Level Data Link Control
• HDLC is a group of data link (Layer 2) protocols used to transmit
synchronous data packets between point-to-point nodes (RFC
1662).
• HDLC uses a zero-insertion/deletion process (bit stuffing) to
ensure that the bit pattern of the delimiter flag does not occur in
the fields between flags.

1-39
HDLC – High-Level Data Link Control
Frame format for bit-oriented protocols.

Data is usually sent in multiples of 8 bits, but only some variants


require this; others theoretically permit data alignments on other than
8-bit boundaries.
The frame check sequence (FCS) is a 16-bit CRC or a 32-
bit CRC computed over the Address, Control, and Information fields.
HDLC – High-Level Data Link Control

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.1/24 192.168.10.1/30 192.168.10.2/30 192.168.1.1/24

192.168.2.2/24 192.168.1.2/24

////////////////////////// Serial link Router-B(config)#interface serial 0/0/0


Router-A(config)#interface serial 0/0/0 Clock: 2500000 Hz Router-B(config-if)#clock rate 250000
Router-A(config-if)#encapsulation hdlc //////////////////////////
Router-A(config-if)#ip address 192.168.10.1 255.255.255.252 Router-B(config)#interface serial 0/0/0
Router-A(config-if)#no shutdown Router-B(config-if)#encapsulation hdlc
Router-B(config-if)#ip address 192.168.10.2 255.255.255.252
Router-B(config-if)#no shutdown

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.

– Error detection and correction


• Parity check
• Internet checksum
• CRC
– Elementary data link protocols
• Utopian Simplex Protocol
• Simplex Stop-and-Wait Protocol
– Noisy Channel
• Sliding window Protocol
– Go-back-N
– Selective Repeat

1-43
Appendix

1-44
Utopian Simplex Protocol (2)

...
A utopian simplex protocol.
Utopian Simplex Protocol (3)
A utopian simplex protocol.

Go back to Utopian protocol


Elementary Data Link Protocols (3)
Some definitions needed in the protocols to follow. These definitions
are located in the file protocol.h.

...
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)

...

A simplex stop-and-wait protocol.


Simplex Stop-and-Wait Protocol
for a Noisy Channel (4)

A simplex Stop-and-Wait protocol.


Go back to Stop and Wait protocol
Sliding Window Protocols (2)
A positive acknowledgement with retransmission protocol.

...
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)

A sliding window of size 1, with a 3-bit sequence number


(c) After the first frame has been received. (d) After the first acknowledgement has
been received.
One-Bit Sliding Window Protocol (1)

...

A 1-bit sliding window protocol.


One-Bit Sliding Window Protocol (2)

...

A 1-bit sliding window protocol.


One-Bit Sliding Window Protocol (3)

A 1-bit sliding window protocol.


One-Bit Sliding Window Protocol (4)

Two scenarios for protocol 4. (a) Normal case. (b) Abnormal


case. The notation is (seq, ack, packet number). An asterisk indicates
where a network layer accepts a packet
Protocol Using Go-Back-N (3)
A sliding window protocol using go-back-n.

...
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)

Simulation of multiple timers in software. (a) The queued


timeouts (b) The situation after the first timeout has expired.
Protocol Using Selective Repeat (2)
A sliding window protocol using selective repeat.

...
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)

a) Initial situation with a window of size 7


• After 7 frames sent and received but not acknowledged.
• Initial situation with a window size of 4.
• After 4 frames sent and received but not acknowledged.

You might also like