Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 70

UNIT 2

Data Link Layer


 Multiplexing
• FDM
• TDM
• WDM
 Switching
• Circuit
• Message
• Packet
 LAN Components
• Repeaters
• Hubs
• Bridges
• Switches
• Routers
• gateways
Multiplexing
 When two communicating machines are connected through a
media, it generally happens that bandwidth of media is several
times greater than that of the communicating machines.
 Also Transfer of a single signal at a time is both slow and
expensive.
 The whole capacity of the link is not being utilized in this case.
 This link can be further exploited by sending several signals
combined into one. This combining of signals into one is called
multiplexing.
Frequency Division Multiplexing
 when transmission media has a bandwidth lower than the required bandwidth of signals
to be transmitted.
 A number of signals can be transmitted at the same time. Each source is allotted a
frequency range in which it can transfer it's signals, and a suitable frequency gap is given
between two adjacent signals to avoid overlapping.
 This is type of multiplexing is commonly seen in the cable TV networks.

(a) The original


bandwidths.
(b) The bandwidths
raised in frequency.
(b) The multiplexed
channel.
Time Division Multiplexing
 when data transmission rate of the media is much higher than that of the
data rate of the source.
 Multiple signals can be transmitted if each signal is allowed to be
transmitted for a definite amount of time.
 These time slots are so small that all transmissions appear to be in parallel.
Wavelength Division Multiplexing
 Multiplexing
• FDM
• TDM
• WDM
 Switching
• Circuit
• Message
• Packet
 LAN Components
• Repeaters
• Hubs
• Bridges
• Switches
• Routers
• gateways
Switching
 Circuit Switching
• Dedicated end-to-end connection
• Guaranteed service
• Resources are reserved
• Intermediate switches maintains the connection
• Eg. Telephone network

 Packet Switching
• Data is sent in Packets
• Per-packet routing
• At each node the entire packet is received, stored, and then
forwarded (store-and-forward networks)
• No capacity is allocated, Best effort service
• Link is allocated on demand
• Different packets might follow different paths, reordering required
• Eg. Internet
Switching

(a) Circuit switching.


(b) Packet switching.
Comparison of circuit switched and
packet-switched networks.
 Multiplexing
• FDM
• TDM
• WDM
 Switching
• Circuit
• Message
• Packet
 LAN Components
• Repeaters
• Hubs
• Bridges
• Switches
• Routers
• gateways
Repeaters, Hubs, Bridges, Switches,
Routers and Gateways

(a) Which device is in which layer.


(b) Frames, packets, and headers.
A repeater forwards every frame; it
has no filtering capability.
A repeater is a regenerator, not an
amplifier.
(a) A hub. (b) A bridge. (c) a switch.
Function of a Bridge
Routers in an Internet
A Gateway
A

B
C’

switch

B’ A’
 Repeaters:
• Analog devices connected to two cable segments.
• Not understand frames, packets or header.
• Understand only Volts.
 Hubs:
• It has no. of input lines that it joins electrically.
• Frames on any of the lines are sent out on all the others.
 Bridges:
• It connects two or more LANs.
• When frame arrives, software in the bridge extracts the destination address and act
accordingly.
 Switches:
• Similar to bridges.
• The main difference is that switch is most often used to connect individual
computers.
 Routers:
• When a packet arrive at router, the frame header & trailer are stripped off and passed
to the routing software.
• The software uses the packet header to choose the output lines.
 Gateways:
• They connect two computers that uses different connection-oriented transport
protocols
• Transport gateways copy the packets from one connection to the other and
reformatting then as needed.
• Application gateways understand the format & contents of the data massage are
translate from one format to another.
The Data Link Layer
 Design issue
• Provide service interface to the network layer
• Dealing with transmission errors
• Regulating data flow
 Function of Data Link Layer
• Framing
• Error Control
• Flow Control
 Elementary Data Link Protocols
• An Unrestricted Simplex Protocol
• A Simplex Stop-and-Wait Protocol
• A Simplex Protocol for a Noisy Channel
 Sliding Window Protocols
• A One-Bit Sliding Window Protocol
• A Protocol Using Go Back N
• A Protocol Using Selective Repeat
Functions Layer/Design Issue of the
Data Link
• Provide service interface to the network
layer
• Dealing with transmission errors
• Regulating data flow

The data link layer is responsible for transmitting


frames from one node to the next.
Functions of the Data Link Layer
 Design issue
• Provide service interface to the network layer
• Dealing with transmission errors
• Regulating data flow
 Function of Data Link Layer
• Framing
• Error Control
• Flow Control
 Elementary Data Link Protocols
• An Unrestricted Simplex Protocol
• A Simplex Stop-and-Wait Protocol
• A Simplex Protocol for a Noisy Channel
 Sliding Window Protocols
• A One-Bit Sliding Window Protocol
• A Protocol Using Go Back N
• A Protocol Using Selective Repeat
Framing
1. A character count
2. Starting and Ending Character (Flag byte with byte stuffing)
3. Starting and Ending Flag (with byte stuffing)

(a) Without errors. (b) With one error.


Starting and Ending Character (Flag byte with byte
stuffing)

(a) A frame delimited by flag bytes.


(b) Four examples of byte sequences before and after stuffing.
Starting and Ending Flag (with bit stuffing)

Bit stuffing
(a) The original data.
(b) The data as they appear on the line.
(c) The data as they are stored in receiver’s memory
after destuffing.
Error Control
 Timer
 Sequence number
Error Detecting and Correcting
Codes
 Parity bit:
• The parity bit is chosen that the number of 1 bits in the code
word is either even( for even parity) or odd (for odd parity).
For example when 10110101 is transmitted then for even
parity an 1 will be appended to the data and for odd parity a
0 will be appended. This scheme can detect only single bits.
So if two or more bits are changed then that can not be
detected.
Suppose the sender wants to send the word world. In
ASCII the five characters are coded as
1110111 1101111 1110010 1101100 1100100
The following shows the actual bits sent
11101110 11011110 11100100 11011000 11001001

Now suppose the word world in Example 1 is received by


the receiver without being corrupted in transmission.
11101110 11011110 11100100 11011000
11001001
The receiver counts the 1s in each character and comes up
with even numbers (6, 6, 4, 4, 4). The data are accepted.
Now suppose the word world in Example 1 is corrupted
during transmission.
11111110 11011110 11101100 11011000
11001001
The receiver counts the 1s in each character and comes up
with even and odd numbers (7, 6, 5, 4, 4). The receiver
knows that the data are corrupted, discards them, and asks
for retransmission.
Hamming Code
 Used for error correcting and detecting.
 The hamming distance between two binary sequences of a given length is is
defined as the number of positions in which the bits are different.
• For example the Hamming distance between the sequences 1100 and 0110 is 2.
 Note that the Hamming distance between a codeword and a corresponding
received sequence is equal to the number of errors in the received sequence.
 Suppose k bit errors occur in a transmitted codeword which means that
the transmitted codeword has hamming distance of k from the received
sequence.
 Construction of Hamming Code:
• Powers of 2 correspond to check bits (redundancy)
• Non-powers of 2 correspond to the information bits
 To detect d error: dmin > d+1
 To correct t error: dmin > 2t+1
Cyclic Redundancy Checksum
(CRC)
 We have an n-bit message. The sender adds a k-bit
Frame Check Sequence (FCS) to this message before
sending.
 The resulting (n+k) bit message is divisible by some
(k+1) bit number.
 The receiver divides the message (n+k) bit by the same
(k+1) bit number and if there is no remainder, assumes
that there was no error.
 To understand CRC, it is useful to represent bit strings
as polynomials with binary coefficients. For example
the string 10010 is represented as:
1x4 + 0x3 + 0x2 + 1x1 + 0x0 = x4 + x
 A CRC code is defined in terms of a generator polynomial
G(x), let k be the degree of this polynomial, i.e. G(x) = x k (as
k is the number of check bits added to each packet.)
 We represent the bit string to be encoded as a polynomial,
M(x).
 To encode this bit stream we perform the following steps:
• 1. Form the product xkM(x), note this corresponds to appending L zeroes to
M(x).
• 2. Divide the product xkM(x) by G(x), using polynomial division mod 2, let
R(x) denote the remainder of this division.
• 3. Set the transmitted codeword T(x) = xkM(x) - R(x).
 Note that R(x) will have a degree of at most k - 1, and T(x) will
correspond to the polynomial representing the original bit
string plus k additional bits.
 Also, T(x) must be evenly divisible by G(x) (with no
remainder).
 The receiver can check if the received sequence is divisible by
G(x), and if not it will know that an error has occurred.
CHECKSUM
 The sender follows these steps:
 The unit is divided into k sections, each of n
bits.
 All sections are added using one’s
complement to get the sum.
 The sum is complemented and becomes the
checksum.
 The checksum is sent with the data.
Suppose the following block of 16 bits is to be sent using a
checksum of 8 bits.
10101001 00111001
The numbers are added using one’s complement
10101001
00111001
------------
Sum 11100010
Checksum 00011101
The pattern sent is 10101001 00111001 00011101
 The receiver follows these steps:
 The unit is divided into k sections, each of n
bits.
 All sections are added using one’s
complement to get the sum.
 The sum is complemented.
 If the result is zero, the data are accepted:
otherwise, rejected.
Now suppose the receiver receives the pattern sent in Example 7
and there is no error.
10101001 00111001 00011101
When the receiver adds the three sections, it will get all 1s, which,
after complementing, is all 0s and shows that there is no error.
10101001
00111001
00011101
Sum 11111111
Complement 00000000 means that the pattern is OK.
Now suppose there is a burst error of length 5 that affects 4 bits.
10101111 11111001 00011101
When the receiver adds the three sections, it gets
10101111
11111001
00011101
Partial Sum 1 11000101
Carry 1
Sum 11000110
Complement 00111001 the pattern is corrupted.
Flow control
 The sender transmits frames faster than the receiver can
accept them.
 If the sender keeps pumping out frames at high rate, at
some point the receiver will be completely swamped
and will start losing some frames.
 This problem may be solved by introducing flow
control.
 Most flow control protocols contain a feedback
mechanism to inform the sender when it should transmit
the next frame.
• Feedback based flow control
• Rate based flow control
 Design issue
• Provide service interface to the network layer
• Dealing with transmission errors
• Regulating data flow
 Function of Data Link Layer
• Framing
• Error Control
• Flow Control
 Elementary Data Link Protocols
• An Unrestricted Simplex Protocol
• A Simplex Stop-and-Wait Protocol
• A Simplex Protocol for a Noisy Channel
 Sliding Window Protocols
• A One-Bit Sliding Window Protocol
• A Protocol Using Go Back N
• A Protocol Using Selective Repeat
Elementary Data Link Protocols
• An Unrestricted Simplex Protocol
• A Simplex Stop-and-Wait Protocol
• A Simplex Protocol for a Noisy
Channel
An Unrestricted Simplex Protocol
 At Transmitter:
• 1. take packet from Network layer
• 2. construct the frame
• 3. send the frame on the way.
 At Receiver:
• 1. the receiver waits for something to happen.
• 2. Packet received, then send to the higher
layer.
 Note: the receiver can not send back an ACK
and no sequence number is required.
Simplex Stop-and-Wait Protocol
 This is the simplest file control protocol in which the sender
transmits a frame and then waits for an acknowledgement.
 If a acknowledgement is received, the sender transmits the next
packet.

 At Transmitter:
• 1. take packet from Network layer
• 2. construct the frame
• 3. send the frame on the way.
• 4. wait for the ACK then repeat step 1.

 At Receiver:
• 1. the receiver waits for frame.
• 2. Packet received, send to the higher layer and send the
dummy packet (ACK).
 Note: A half duplex physical channel.
A Simplex Protocol for a Noisy Channel
 The sender transmits a frame and then waits for an
acknowledgement, either positive or negative, from the
receiver before proceeding.
 If a positive acknowledgement is received, the sender
transmits the next packet; else it retransmits the same
frame.
 If a packet or an acknowledgement is completely
destroyed in transit due to a noise burst, a deadlock will
occur because the sender cannot proceed until it receives
an acknowledgement.
 This problem may be solved using timers on the sender's
side.
 When the frame is transmitted, the timer is set. If there is
no response from the receiver within a certain time
interval, the timer goes off and the frame may be
retransmitted.
 At transmitter:
• 1. Set sequence number, SN=0
• 2. Wait until packet available to be sent (from higher layer)
• 3. Send current packet in frame with number SN, start timer.
• 4. If time-out, go to 3.
• 5. If an error free ACK received with request number (RN) ≠ SN,
set SN = RN, go to 2.

 At receiver:
• 1. Set RN=0, repeat 2 and 3 forever.
• 2. If packet received with SN = RN, then release the packet
to the higher layer, set RN = RN+1 (mod 2).
• 3. After receiving any data frame, transmit ACK containing
RN.

 Note: the receiver can not send back an ACK only after
receiving a packet with SN=RN or the protocol may fail.
 Think about why.
A positive acknowledgement with retransmission protocol.
 Design issue
• Provide service interface to the network layer
• Dealing with transmission errors
• Regulating data flow
 Function of Data Link Layer
• Framing
• Error Control
• Flow Control
 Elementary Data Link Protocols
• An Unrestricted Simplex Protocol
• A Simplex Stop-and-Wait Protocol
• A Simplex Protocol for a Noisy Channel
 Sliding Window Protocols
• A One-Bit Sliding Window Protocol
• A Protocol Using Go Back N
• A Protocol Using Selective Repeat
Sliding Window Protocols
• A One-Bit Sliding Window Protocol
• A Protocol Using Go Back N
• A Protocol Using Selective Repeat
Piggybacking
 The stop-and-wait protocol addressed one-way
(simplex) communication of data packets.
 Rather than send separate ACK’s on the reverse link,
the acknowledgements for messages coming in one
direction can be included with the data going the
other direction. This is called piggybacking.
Sliding Window Protocol
 For long propagation times and high transmission rates stop-
and-wait clearly becomes inefficient.
 One way to improve the efficiency of stop-and-wait is to use
larger packets, i.e., more data bits per packet.
 But to send larger packets, the data would have to be delayed.
 A better way to improve the efficiency is to allow the sender
to send more than 1 frame before receiving an ACK.
 For example, let the transmitter send up to N packets before it
receives an ACK for the first packet.
 Such protocols are called Sliding Window Protocols.
 The total number of unacknowledged packets that may be sent
is referred to as the sender's maximum window size.
 For example, suppose that the sender has a window of size W.
In this case, the transmitter can send packets numbered 1,2,…,W,
before receiving an acknowledgment for packet 1.
A One-Bit Sliding Window Protocol

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


(a) Initially.
(b) After the first frame has been sent.
(c) After the first frame has been received.
(d) After the first acknowledgement has been received.
A One-Bit Sliding Window Protocol

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.
A Protocol Using Go Back N
 When a sliding window protocol is used, we still want to
have a retransmission protocol that provides a reliable service,
i.e. delivers packets in order, correctly, and only once.
 There are two classes of such protocols that are commonly used,
the first is called go-back-n, and the second is called
selective repeat.
 In a Go Back N protocol, the transmitter has a maximum window
size of N packets. The receiver keeps a counter of the current
frame it is waiting to accept, and will accept only that frame.
 When the receiver receives any frame it returns an ACK to the
transmitter containing the number of the next packet expected.
 When the transmitter receives an ACK with request number
RN, it can assume that every packet with number less than
RN has been correctly received.
A Protocol Using Go Back N

Pipelining and error recovery. Effect on an error when


(a) Receiver’s window size is 1.
(b) Receiver’s window size is large.
A Sliding Window Protocol Using Selective
Repeat

 When a packet is not acknowledged before a time-


out, the transmitter will go back and begin
retransmitting.
 When the transmitter times out due to an error in
a transmitted packet, all of the packets sent during
the time-out time will have to be retransmitted.
 Even if these other packets had arrived correctly,
by the operation of the protocol they would not be
saved at the receiver.
 Such effects can limit the efficiency of go back N.
 So an alternative strategy called selective repeat can
be used to improve the efficiency of go back N.
Protocol Using Selective Repeat
A Sliding Window Protocol Using Selective Repeat

(a) Initial situation with a window size seven.


(b) After seven frames sent and received, but not acknowledged.
(c) Initial situation with a window size of four.
(d) After four frames sent and received, but not acknowledged.
End of Unit 2

You might also like