DCN Unit - 3
DCN Unit - 3
Switching
Data Link layer
1
Switching
1. Circuit-Switched Networks
2. Packet Switching
3. Message Switching
Data Link Layer
Design issues in data link layer:
4. Services
5. Data Link Control
6. Framing
7. Flow and Error control
Error detection and correction:
8. CRC
9. Checksum
10. Hamming code
Flow control:
11. Sliding window protocols
Applications:
12. Data link layer protocols: HDLC, PPP
2
Introduction
• A network is a set of connected devices.
• Whenever we have multiple devices, we have the problem of how to
connect them to make one-to-one communication possible.
• Possible solutions are
- make a point-to-point connection between each pair of devices ( a
mesh topology)
- make a point-to-point connection between a central device and every
other device (a star topology)
- multipoint connections, a bus
• All the above are more or less impractical and wasteful when applied
to very large networks.
• A better solution is switching.
3
Switching
• A switched network consists of a series of interlinked nodes, called switches.
• Switches are devices capable of creating temporary connections between two or more
devices linked to the switch.
• In a switched network, some of these nodes are connected to the end systems, others
are used only for routing.
Switched Network 4
Taxonomy of Switched Networks
Setup phase
• Before the parties can communicate, a channel (circuit) is reserved on each link.
• Combination of channels defines the dedicated path.
Teardown phase
• When one of the parties needs to disconnect, a signal is sent to each switch to
release the resources.
8-8
• Not as efficient as the other two types of networks as resources
allocated for a connection are unavailable to other connections during
the entire duration of the connection.
• Delay is minimal.
• Switching at the physical layer
switching approach.
10
Circuit-Switched Network: Example 2
• A circuit-switched network that connects computers in two remote
offices of a private company.
11
2. Packet-Switched Networks
8-12
Datagram Networks
• In a datagram network, each packet is treated independently of all
others.
8-13
Datagram Networks
Routing Table
8-14
Datagram Networks
• Efficiency of a datagram network is better than of a circuit-switched
network.
• Datagram network may have greater delay than a virtual-circuit
network.
• Although there are no setup and teardown phases, each datagram may
experience a wait at a switch before it is forwarded.
• Delay is not uniform.
8-15
Delay in datagram network
Virtual-Circuit Networks
• A virtual-circuit network (VCN) is a cross between a circuit-switched network and a
datagram network.
• It has some characteristics of both:
- there are setup, data transfer, and teardown phases as in a circuit-switched
network
(CSN)
- resources can be allocated during setup phase, as in a CSN, or on demand as in a
datagram network (DN)
- As in DN, data are packetized and each packet carries an address in the header. This
address is local i.e., it is the address of the next switch not the end system
- As in CSN, all packets follow the same path established during the connection
- VCN is normally implemented in the data link layer, while CSN is in physical layer
and
DN in the network layer
8-16
Virtual-Circuit Networks
Addressing
• Two types of addressing: global and local (virtual-circuit identifier: VCI)
• Global address is used only to create a VCI.
8-17
Virtual-Circuit Networks
Three Phases
• Data transfer phase, setup phase, teardown phase
Setup Phase
• Switch creates an entry for a virtual-circuit.
• Two steps are required: the setup request and the acknowledgement.
Teardown Phase
• Two frames are exchanged: the teardown request and teardown confirmation.
8-18
Data transfer Phase
19
Setup Phase: Setup Request
8-20
Setup Phase: Acknowledgement
8-21
Virtual-Circuit Networks
• In virtual-circuit switching, all packets belonging to the same source and
destination travel the same path; but the packets may arrive at the
destination with different delays if resource allocation is on demand.
• Switching at the data link layer in a switched WAN is normally implemented
by using virtual-circuit techniques.
8-22
4. Data Link Layer Services
• Two main functions of the data link layer are
- data link control
- media access control
5. Data Link Control
Data link control deals with the design and procedures for
communication between two adjacent nodes:
node-to-node communication
• Variable-size framing
– Need a way to define the end of the frame and the beginning of the next
– Character-oriented approach and bit-oriented approach
24
Character-Oriented Protocols
• Frame structure
25
Bit-Oriented Protocols
• Frame structure
26
7. Flow and Error Control
• Data link control = flow control + error control
• Flow control refers to a set of procedures used to restrict the amount of data
that the sender can send before waiting for acknowledgement
• Error control in the data link layer is based on automatic repeat request (ARQ).
27
Error Detection and Correction
Data can be corrupted
during transmission.
A burst error means that 2 or more bits in the data unit have changed.
To detect or correct errors, we need to send extra (redundant) bits with data.
28
Cyclic codes are special linear block codes with
one extra property. In a cyclic code, if a codeword
is cyclically shifted (rotated), the result is another
codeword.
Cyclic Redundancy Check
Hardware Implementation
Polynomials
Cyclic Code Analysis
Advantages of Cyclic Codes
Other Cyclic Codes
29
8. A CRC code with C(7, 4)
30
CRC encoder and decoder
31
Division in CRC encoder
32
Division in the CRC decoder for two cases
33
The CRC encoder design using shift registers
34
General design of encoder and decoder of a CRC code
35
Using Polynomials
36
A polynomial to represent a binary word
37
CRC division using polynomials
38
The divisor in a cyclic code is normally called the generator polynomial
or simply the generator.
In a cyclic code,
If s(x) ≠ 0, one or more bits is corrupted.
If s(x) = 0, either
a. No bit is corrupted. or
b. Some bits are corrupted, but the
decoder failed to detect them.
39
Standard polynomials
40
9. CHECKSUM
The checksum is used in the Internet by several
protocols, not at the data link layer.
Suppose our data is a list of five 4-bit numbers that we want to send to a
destination. In addition to sending these numbers, we send the sum of the
numbers. For example, if the set of numbers is (7, 11, 12, 0, 6), we send (7, 11,
12, 0, 6, 36), where 36 is the sum of the original numbers. The receiver adds the
five numbers and compares the result with the sum. If the two are the same, the
receiver assumes no error, accepts the five numbers, and discards the sum.
Otherwise, there is an error somewhere and the data are not accepted.
We can make the job of the receiver easier if we send the negative (complement)
of the sum, called the checksum. In this case, we send (7, 11, 12, 0, 6, −36). The
receiver can add all the numbers received (including the checksum). If the result
is 0, it assumes no error; otherwise, there is an error.
41
42
10. Hamming Code
Hamming codes were originally designed with dmin = 3 (2 bit error detection and
single bit error correction).
A codeword consists of n bits of which k are data bits and r are check bits.
Let m = r, then we have: n = 2m -1
and k = n-m
43
The structure of the encoder and decoder for a Hamming code
44
Logical decision made by the correction logic analyzer
Let us trace the path of three datawords from the sender to the destination:
46
Burst Errors
• Burst errors are very common, in particular in wireless environments
where a fade will affect a group of bits in transit. The length of the
burst is dependent on the duration of the fade.
• One way to counter burst errors, is to break up a transmission into
shorter words and create a block (one word per row), then have a
parity check per word.
• The words are then sent column by column. When a burst error
occurs, it will affect 1 bit in several words as the transmission is read
back into the block format and each word is checked individually.
47
Burst error correction using Hamming code
48
11. Sliding Window Protocols
Noiseless Channels: Simplest Protocol
• Simplest protocol with no flow or error control
49
Simplest Protocol
• Sender-site algorithm
• Receiver-site algorithm
50
Stop-and-Wait Protocol
• Simple tokens of ACK and flow control added
51
Stop-and-Wait Protocol
• Sender-site algorithm
• Receiver-site algorithm
52
Stop-and-Wait Protocol: Example
53
Noisy Channels: Stop-and-Wait ARQ
54
Stop-and-Wait ARQ
55
• Sender-site algorithm
56
Stop-and-Wait ARQ
• Receiver-site algorithm
57
Stop-and-Wait ARQ: Example
58
Go-Back-N ARQ
• Pipelining improves the efficiency of the transmission
• In the Go-Back-N Protocol, the sequence numbers are modulo 2m, where m
is the size of the sequence number field in bits
• The send window is an abstract concept defining an imaginary box of size 2m
− 1 with three variables: Sf, Sn, and Ssize
• The send window can slide one or more slots when a valid acknowledgment
arrives.
59
Go-Back-N ARQ
• Receive window for Go-Back-N ARQ
• The receive window is an abstract concept defining an imaginary box of size 1
with one single variable Rn. The window slides when a correct frame has
arrived; sliding occurs one slot at a time.
60
Go-Back-N ARQ
• Sliding windows, Timers, ACK, Resending a frame
61
Go-Back-N ARQ: Send Window Size
• In Go-Back-N ARQ, the size of the send window must be less than 2m; the size
of the receiver window is always 1
• Stop-and-Wait ARQ is a special case of Go-Back-N ARQ in which the size of the
send window is 1
62
Go-Back-N ARQ: Sender Algorithm
63
Go-Back-N ARQ: Receiver Algorithm
64
Go-Back-N ARQ: Example 1
65
Go-Back-N ARQ: Example 2
66
Selective Repeat ARQ
• Sender window size
67
Selective Repeat ARQ
68
Selective Repeat ARQ: Window Size
• The size of the sender and receiver window must be at most one-half of 2m
69
Selective Repeat ARQ: Sender-Site Algorithm
70
Selective Repeat ARQ: Receiver-Site Algorithm
71
Selective Repeat ARQ: Example
72
Piggybacking
• To improve the efficiency of the bidirectional protocols
• Piggybacking in Go-Back-N ARQ
73
12. HDLC
• High-level Data Link Control
• Two common transfer mode: normal response mode (NRM) and
asynchronous balanced mode (ABM)
74
HDLC: Frames
• I(information)-frames, S(supervisory)-frames, U(unnumbered frame)-
frames
• Flag field: 01111110 to identify both the beginning and the end of a frame
and serve as synchronization pattern for receiver
• FCS field: 2- or 4-byte ITU-T CRC for error detection
75
HDLC: Frames
• Control Field: 1- or 2-byte segment of the frame used for flow and
error control
• Determine the type of frame and define its functionality
• Control field for I-frame: P/F (poll/final bit for primary/secondary)
76
HDLC: Frames
• Control field for S-frame
• Receive ready (RR), Receive not ready (RNR), Reject (REJ) Selective
reject (SREJ)
77
HDLC: Frames
• Control field for U-frame
78
HDLC: Example 1
• Connection and disconnection
79
HDLC: Example 2
• Piggybacking without error
80
HDLC: Example 3
• Piggybacking with error
81
HDLC: Bit Stuffing and Unstuffing
82
Point-to-Point Protocol: PPP
• One of the most common protocols for point-to-point access
• Many Internet users who need to connect their home
computer to the server of an Internet service provider use
PPP
• A point-to-point link protocol is required to control and
manage the transfer of data
• PPP defines/provides
– the format of the frame to be exchanged between devices
– how two devices negotiate the establishment of the link and the exchange of
data
– how network layer data are encapsulated in the data link frame
– how two devices can authenticate each other
– multiple network layer services
– connection over multiple links
– Network address configuration
• But, several services are missing for simplicity
– no flow control, simple error control (detection and discard), no sophisticate
addressing for multipoint configuration
83
PPP Frame
• Flag: 01111110 the same as HDLC, but it treated as a byte because of PPP
is a byte-oriented protocol
• Address: 11111111 (broadcast address)
• Control: No need because PPP has no flow control and limited error
control
• PPP is a byte-oriented protocol using byte stuffing with the escape byte
01111101
84
PPP: Transition States
85
PPP: Multiplexing
• PPP uses another set of other protocols to establish the link, authenticate
the parties, and carry the network layer data
• Three sets of protocols defined for powerful PPP: LCP, two APs, several
NCPs
86
LCP: Encapsulated in a Frame
8-87
LCP: Common Options
• Options are inserted in the information field of the
configuration packets
8-88
Authentication
• Authentication means validating the identity of a user
who needs to access
• PPP is designed for use over dial-up links
User authentication is necessary
• PPP has two protocols for authentication
– Password Authentication Protocol (PAP)
– Challenge Handshake Authentication Protocol
(CHAP)
89
Password Authentication Protocol (PAP)
90
Challenge Handshake Authentication
Protocol (CHAP)
• Three-way hand-shaking authentication protocol with greater security
than PAP
91
Network Control Protocol: NCP
• PPP is a multiple-network layer protocol.
• It can carry a network data packet from protocols defined by the
Internet, OSI, Xerox, DECnet, AppleTalk, Novel
• IPCP (IP Control Protocol)
– Configures the link used to carry IP packets in the Internet
92
IPCP Packet
93
Multiple PPP
94
Example (1)
95
Example (2)
96
The End
97