Unit 2
Unit 2
Unit 2
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
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
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
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
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