Computer Networks And Security
19CS2109
ELEMENTARY DATA LINK PROTOCOLS
© 2020-21 KL University – The contents of this presentation are an intellectual and copyrighted property of KL University. ALL RIGHTS RESERVED 2
WHAT IS A PROTOCOL?
• The set of rules and regulations is called a Protocol.
• That provide smooth and reliable transmission of frames between nodes.
In networking, a frame is a unit of data.
• Frames also help to determine how data receivers interpret a stream of
data from a source.
• Nodes are devices or data points on a larger network.
NOISELESS CHANNELS
• Let us first assume we have an ideal channel in which no frames are
lost, duplicated, or corrupted. We introduce two protocols for this
type of channel.
• Simplest Protocol
• Stop-and-Wait Protocol
FLOW AND ERROR CONTROL
• The most important responsibilities of the data link layer are flow
control and error control. Collectively, these functions are known as
data link control.
• Flow control refers to a set of procedures used to restrict the amount
of data that the sender can send before waiting for acknowledgment.
• Error control in the data link layer is based on automatic repeat
request, which is the retransmission of data.
The data link layer can combine framing, flow control, and error control to
achieve the delivery of data from one node to another. The protocols are
normally implemented in software by using one of the common programming
languages. To make our discussions language-free, we have written in
pseudocode a version of each protocol that concentrates mostly on the procedure
instead of delving into the details of language rules.
Sliding window protocol :
allows the sender to send
multiple frames before needing
the acknowledgements.
The design of the simplest protocol with no flow or error control
• Figure shows an example of
communication using this protocol.
It is very simple. The sender sends
a sequence of frames without even
thinking about the receiver. To send
three frames, three events occur at
the sender site and three events at
the receiver site. Note that the data
frames are shown by tilted boxes;
the height of the box defines the
transmission time difference
between the first bit and the last bit
in the frame.
Design of Stop-and-Wait Protocol
• Figure shows an example of
communication using this
protocol. It is still very simple.
The sender sends one frame and
waits for feedback from the
receiver. When the ACK arrives,
the sender sends the next frame.
Note that sending two frames in
the protocol involves the sender
in four events and the receiver in
two events.
NOISY CHANNELS
Although the Stop-and-Wait Protocol gives us an idea of how to add flow
control to its predecessor, noiseless channels are nonexistent. We discuss
three protocols in this section that use error control.
• Stop-and-Wait Automatic Repeat Request
• Go-Back-N Automatic Repeat Request
• Selective Repeat Automatic Repeat Request
Note :
• Error correction in Stop-and-Wait ARQ is done by keeping a copy of the
sent frame and retransmitting of the frame when the timer expires.
• In Stop-and-Wait ARQ, we use sequence numbers to number the frames.
• The sequence numbers are based on modulo-2 arithmetic.
• In Stop-and-Wait ARQ, the acknowledgment number always announces in
modulo-2 arithmetic the sequence number of the next frame expected.
Design of the Stop-and-Wait ARQ Protocol
• Figure shows an example of Stop-
and-Wait ARQ. Frame 0 is sent and
acknowledged. Frame 1 is lost and
resent after the time-out. The resent
frame 1 is acknowledged and the
timer stops. Frame 0 is sent and
acknowledged, but the
acknowledgment is lost. The sender
has no idea if the frame or the
acknowledgment is lost, so after the
time-out, it resends frame 0, which
is acknowledged.
Computer Networks And Security
19CS2109
ELEMENTARY DATA LINK PROTOCOLS
© 2020-21 KL University – The contents of this presentation are an intellectual and copyrighted property of KL University. ALL RIGHTS RESERVED 17
Sliding Window Protocols
• 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
Send window for Go-Back-N ARQ or more slots when a valid acknowledgment arrives.
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.
Design of Go-Back-N ARQ
Window size for Go-Back-N ARQ
In Go-Back-N ARQ, the size of the send window must be less than 2 m;
the size of the receiver window
is always 1.
Go-Back-N sender algorithm
Stop-and-Wait ARQ is a special case of Go-
Back-N ARQ in which the size of the send
window is 1.
Go-Back-N receiver algorithm
• Figure shows an example of Go-Back-N.
This is an example of a case where the
forward channel is reliable, but the
reverse is not. No data frames are lost, but
some ACKs are delayed and one is lost.
• The example also shows how cumulative
acknowledgments can help if
acknowledgments are delayed or lost.
After initialization, there are seven sender
events. Request events are triggered by
data from the network layer; arrival
events are triggered by acknowledgments
from the physical layer.
• There is no time-out event here because
all outstanding frames are acknowledged
before the timer expires. Note that
although ACK 2 is lost, ACK 3 serves as
both ACK 2 and ACK 3.
Flow diagram
• Figure shows what happens when a frame is
lost. Frames 0, 1, 2, and 3 are sent. However,
frame 1 is lost. The receiver receives frames 2
and 3, but they are discarded because they are
received out of order. The sender receives no
acknowledgment about frames 1, 2, or 3. Its
timer finally expires. The sender sends all
outstanding frames (1, 2, and 3) because it
does not know what is wrong. Note that the
resending of frames 1, 2, and 3 is the response
to one single event. When the sender is
responding to this event, it cannot accept the
triggering of other events. This means that
when ACK 2 arrives, the sender is still busy
with sending frame 3.
• The physical layer must wait until this event is
completed and the data link layer goes back to
its sleeping state. We have shown a vertical
line to indicate the delay. It is the same story
with ACK 3; but when ACK 3 arrives, the
sender is busy responding to ACK 2. It
happens again when ACK 4 arrives. Note that
before the second timer expires, all
outstanding frames have been sent and the
timer is stopped.
Send window for Selective Repeat ARQ Receive window for Selective Repeat ARQ
Design of Selective Repeat ARQ
Selective Repeat ARQ, window size
In Selective Repeat ARQ, the size of the sender and receiver window
must be at most one-half of 2m.
Delivery of data in Selective Repeat ARQ
Flow diagram
• This example frame 1 is lost. We show how Selective Repeat behaves in this case. Figure shows the
situation. One main difference is the number of timers. Here, each frame sent or resent needs a timer, which
means that the timers need to be numbered (0, 1, 2, and 3). The timer for frame 0 starts at the first request,
but stops when the ACK for this frame arrives. The timer for frame 1 starts at the second request, restarts
when a NAK arrives, and finally stops when the last ACK arrives. The other two timers start when the
corresponding frames are sent and stop at the last arrival event.
• At the receiver site we need to distinguish between the acceptance of a frame and its delivery to the network
layer. At the second arrival, frame 2 arrives and is stored and marked, but it cannot be delivered because
frame 1 is missing. At the next arrival, frame 3 arrives and is marked and stored, but still none of the frames
can be delivered. Only at the last arrival, when finally a copy of frame 1 arrives, can frames 1, 2, and 3 be
delivered to the network layer. There are two conditions for the delivery of frames to the network layer:
First, a set of consecutive frames must have arrived. Second, the set starts from the beginning of the window.
• Another important point is that a NAK is sent after the second arrival, but not after the third, although both
situations look the same. The reason is that the protocol does not want to crowd the network with
unnecessary NAKs and unnecessary resent frames. The second NAK would still be NAK1 to inform the
sender to resend frame 1 again; this has already been done. The first NAK sent is remembered (using the
nakSent variable) and is not sent again until the frame slides. A NAK is sent once for each window position
and defines the first slot in the window.
• The next point is about the ACKs. Notice that only two ACKs are sent here. The first one acknowledges only
the first frame; the second one acknowledges three frames. In Selective Repeat, ACKs are sent when data
are delivered to the network layer. If the data belonging to n frames are delivered in one shot, only one ACK
is sent for all of them.
Computer Networks And Security
19CS2109
Multiple Access Protocols
© 2020-21 KL University – The contents of this presentation are an intellectual and copyrighted property of KL University. ALL RIGHTS RESERVED 33
Multiple access links, protocols
two types of “links”:
§ point-to-point
• point-to-point link between Ethernet switch, host
• PPP for dial-up access
§ broadcast (shared wire or medium)
• old-fashioned Ethernet
• upstream HFC in cable-based access network
• 802.11 wireless LAN, 4G/4G. satellite
shared wire (e.g., humans at a cocktail party
cabled Ethernet) shared radio: 4G/5G shared radio: WiFi shared radio: satellite
(shared air, acoustical)
Multiple access protocols
§ single shared broadcast channel
§ two or more simultaneous transmissions by nodes: interference
• collision if node receives two or more signals at the same time
multiple access protocol
§ distributed algorithm that determines how nodes share channel,
i.e., determine when node can transmit
§ communication about channel sharing must use channel itself!
• no out-of-band channel for coordination
Link Layer: 6-35
An ideal multiple access protocol
given: multiple access channel (MAC) of rate R bps
desiderata:
1. when one node wants to transmit, it can send at rate R.
2. when M nodes want to transmit, each can send at average
rate R/M
3. fully decentralized:
• no special node to coordinate transmissions
• no synchronization of clocks, slots
4. simple
Link Layer: 6-36
MAC protocols: taxonomy
three broad classes:
§ channel partitioning
• divide channel into smaller “pieces” (time slots, frequency, code)
• allocate piece to node for exclusive use
§ random access
• channel not divided, allow collisions
• “recover” from collisions
§ “taking turns”
• nodes take turns, but nodes with more to send can take longer turns
Link Layer: 6-37
Channel partitioning MAC protocols: TDMA
TDMA: time division multiple access
§ access to channel in “rounds”
§ each station gets fixed length slot (length = packet transmission
time) in each round
§ unused slots go idle
§ example: 6-station LAN, 1,3,4 have packets to send, slots 2,5,6 idle
6-slot 6-slot
frame frame
1 3 4 1 3 4
Link Layer: 6-38
Channel partitioning MAC protocols: FDMA
FDMA: frequency division multiple access
§ channel spectrum divided into frequency bands
§ each station assigned fixed frequency band
§ unused transmission time in frequency bands go idle
§ example: 6-station LAN, 1,3,4 have packet to send, frequency bands 2,5,6 idle
time
frequency bands
FDM cable
Link Layer: 6-39
Random access protocols
§ when node has packet to send
• transmit at full channel data rate R.
• no a priori coordination among nodes
§ two or more transmitting nodes: “collision”
§ random access MAC protocol specifies:
• how to detect collisions
• how to recover from collisions (e.g., via delayed retransmissions)
§ examples of random access MAC protocols:
• ALOHA, slotted ALOHA
• CSMA, CSMA/CD, CSMA/CA
Link Layer: 6-40
Slotted ALOHA
assumptions: operation:
§ all frames same size § when node obtains fresh
§ time divided into equal size frame, transmits in next slot
slots (time to transmit 1 frame) • if no collision: node can send
§ nodes start to transmit only new frame in next slot
slot beginning • if collision: node retransmits
§ nodes are synchronized frame in each subsequent
§ if 2 or more nodes transmit in slot with probability p until
slot, all nodes detect collision success
randomization – why?
Link Layer: 6-41
Slotted ALOHA
node 1 1 1 1 1
node 2 2 2 2
C: collision
S: success
3 3 3
node 3 E: empty
C E C S E C E S S
Pros: Cons:
§ single active node can § collisions, wasting slots
continuously transmit at full rate § idle slots
of channel
§ nodes may be able to detect collision in
§ highly decentralized: only slots in less than time to transmit packet
nodes need to be in sync
§ simple § clock synchronization
Link Layer: 6-42
Slotted ALOHA: efficiency
efficiency: long-run fraction of successful slots (many nodes, all with
many frames to send)
• suppose: N nodes with many frames to send, each transmits in slot
with probability p
• prob that given node has success in a slot = p(1-p)N-1
• prob that any node has a success = Np(1-p)N-1
• max efficiency: find p* that maximizes Np(1-p)N-1
• for many nodes, take limit of Np*(1-p*)N-1 as N goes to infinity, gives:
max efficiency = 1/e = .37
• at best: channel used for useful transmissions 37% of time!
Link Layer: 6-43
Pure ALOHA
§ unslotted Aloha: simpler, no synchronization
• when frame first arrives: transmit immediately
§ collision probability increases with no synchronization:
• frame sent at t0 collides with other frames sent in [t0-1,t0+1]
will overlap will overlap
with start of with end of
i’s frame i’s frame
t0 - 1 t0 t0 + 1
§ pure Aloha efficiency: 18% !
Link Layer: 6-44
Computer Networks And Security
19CS2109
Multiple Access Protocols
© 2020-21 KL University – The contents of this presentation are an intellectual and copyrighted property of KL University. ALL RIGHTS RESERVED 45
Multiple access links, protocols
two types of “links”:
§ point-to-point
• point-to-point link between Ethernet switch, host
• PPP for dial-up access
§ broadcast (shared wire or medium)
• old-fashioned Ethernet
• upstream HFC in cable-based access network
• 802.11 wireless LAN, 4G/4G. satellite
shared wire (e.g., humans at a cocktail party
cabled Ethernet) shared radio: 4G/5G shared radio: WiFi shared radio: satellite
(shared air, acoustical)
Multiple access protocols
§ single shared broadcast channel
§ two or more simultaneous transmissions by nodes: interference
• collision if node receives two or more signals at the same time
multiple access protocol
§ distributed algorithm that determines how nodes share channel,
i.e., determine when node can transmit
§ communication about channel sharing must use channel itself!
• no out-of-band channel for coordination
Link Layer: 6-47
An ideal multiple access protocol
given: multiple access channel (MAC) of rate R bps
desiderata:
1. when one node wants to transmit, it can send at rate R.
2. when M nodes want to transmit, each can send at average
rate R/M
3. fully decentralized:
• no special node to coordinate transmissions
• no synchronization of clocks, slots
4. simple
Link Layer: 6-48
MAC protocols: taxonomy
three broad classes:
§ channel partitioning
• divide channel into smaller “pieces” (time slots, frequency, code)
• allocate piece to node for exclusive use
§ random access
• channel not divided, allow collisions
• “recover” from collisions
§ “taking turns”
• nodes take turns, but nodes with more to send can take longer turns
Link Layer: 6-49
Channel partitioning MAC protocols: TDMA
TDMA: time division multiple access
§ access to channel in “rounds”
§ each station gets fixed length slot (length = packet transmission
time) in each round
§ unused slots go idle
§ example: 6-station LAN, 1,3,4 have packets to send, slots 2,5,6 idle
6-slot 6-slot
frame frame
1 3 4 1 3 4
Link Layer: 6-50
Channel partitioning MAC protocols: FDMA
FDMA: frequency division multiple access
§ channel spectrum divided into frequency bands
§ each station assigned fixed frequency band
§ unused transmission time in frequency bands go idle
§ example: 6-station LAN, 1,3,4 have packet to send, frequency bands 2,5,6 idle
time
frequency bands
FDM cable
Link Layer: 6-51
Random access protocols
§ when node has packet to send
• transmit at full channel data rate R.
• no a priori coordination among nodes
§ two or more transmitting nodes: “collision”
§ random access MAC protocol specifies:
• how to detect collisions
• how to recover from collisions (e.g., via delayed retransmissions)
§ examples of random access MAC protocols:
• ALOHA, slotted ALOHA
• CSMA, CSMA/CD, CSMA/CA
Link Layer: 6-52
Slotted ALOHA
assumptions: operation:
§ all frames same size § when node obtains fresh
§ time divided into equal size frame, transmits in next slot
slots (time to transmit 1 frame) • if no collision: node can send
§ nodes start to transmit only new frame in next slot
slot beginning • if collision: node retransmits
§ nodes are synchronized frame in each subsequent
§ if 2 or more nodes transmit in slot with probability p until
slot, all nodes detect collision success
randomization – why?
Link Layer: 6-53
Slotted ALOHA
node 1 1 1 1 1
node 2 2 2 2
C: collision
S: success
3 3 3
node 3 E: empty
C E C S E C E S S
Pros: Cons:
§ single active node can § collisions, wasting slots
continuously transmit at full rate § idle slots
of channel
§ nodes may be able to detect collision in
§ highly decentralized: only slots in less than time to transmit packet
nodes need to be in sync
§ simple § clock synchronization
Link Layer: 6-54
Slotted ALOHA: efficiency
efficiency: long-run fraction of successful slots (many nodes, all with
many frames to send)
• suppose: N nodes with many frames to send, each transmits in slot
with probability p
• prob that given node has success in a slot = p(1-p)N-1
• prob that any node has a success = Np(1-p)N-1
• max efficiency: find p* that maximizes Np(1-p)N-1
• for many nodes, take limit of Np*(1-p*)N-1 as N goes to infinity, gives:
max efficiency = 1/e = .37
• at best: channel used for useful transmissions 37% of time!
Link Layer: 6-55
Pure ALOHA
§ unslotted Aloha: simpler, no synchronization
• when frame first arrives: transmit immediately
§ collision probability increases with no synchronization:
• frame sent at t0 collides with other frames sent in [t0-1,t0+1]
will overlap will overlap
with start of with end of
i’s frame i’s frame
t0 - 1 t0 t0 + 1
§ pure Aloha efficiency: 18% !
Link Layer: 6-56
CSMA (carrier sense multiple access)
simple CSMA: listen before transmit:
• if channel sensed idle: transmit entire frame
• if channel sensed busy: defer transmission
§ human analogy: don’t interrupt others!
CSMA/CD: CSMA with collision detection
• collisions detected within short time
• colliding transmissions aborted, reducing channel wastage
• collision detection easy in wired, difficult with wireless
§ human analogy: the polite conversationalist
Link Layer: 6-57
CSMA: collisions spatial layout of nodes
§ collisions can still occur with
carrier sensing:
• propagation delay means two nodes
may not hear each other’s just-
started transmission
§ collision: entire packet
transmission time wasted
• distance & propagation delay play
role in in determining collision
probability
Link Layer: 6-58
CSMA/CD: spatial layout of nodes
§ CSMA/CS reduces the amount of
time wasted in collisions
• transmission aborted on collision
detection
Link Layer: 6-59
Ethernet CSMA/CD algorithm
1. NIC receives datagram from network layer, creates frame
2. If NIC senses channel:
if idle: start frame transmission.
if busy: wait until channel idle, then transmit
3. If NIC transmits entire frame without collision, NIC is done with frame !
4. If NIC detects another transmission while sending: abort, send jam signal
5. After aborting, NIC enters binary (exponential) backoff:
• after mth collision, NIC chooses K at random from {0,1,2, …, 2m-1}. NIC waits
K·512 bit times, returns to Step 2
• more collisions: longer backoff interval
Link Layer: 6-60
CSMA/CD efficiency
§ Tprop = max prop delay between 2 nodes in LAN
§ ttrans = time to transmit max-size frame
§ efficiency goes to 1
• as tprop goes to 0
• as ttrans goes to infinity
§ better performance than ALOHA: and simple, cheap, decentralized!
Link Layer: 6-61
“Taking turns” MAC protocols
channel partitioning MAC protocols:
§ share channel efficiently and fairly at high load
§ inefficient at low load: delay in channel access, 1/N bandwidth
allocated even if only 1 active node!
random access MAC protocols
§ efficient at low load: single node can fully utilize channel
§ high load: collision overhead
“taking turns” protocols
§ look for best of both worlds!
Link Layer: 6-62
“Taking turns” MAC protocols
polling:
§ master node “invites” other nodes
to transmit in turn data
poll
§ typically used with “dumb”
devices master
data
§ concerns:
• polling overhead
• latency
slaves
• single point of failure (master)
Link Layer: 6-63
“Taking turns” MAC protocols
T
token passing:
§ control token passed from one
node to next sequentially.
(nothing
§ token message to send)
§ concerns: T
• token overhead
• latency
• single point of failure
(token)
data
Link Layer: 6-64
Cable access network: FDM, TDM and random access!
Internet frames, TV channels, control transmitted
downstream at different frequencies
cable headend
CMTS
…
cable
cable modem
… splitter
modem
ISP termination system
§ multiple downstream (broadcast) FDM channels: up to 1.6 Gbps/channel
§ single CMTS transmits into channels
§ multiple upstream channels (up to 1 Gbps/channel)
§ multiple access: all users contend (random access) for certain upstream
channel time slots; others assigned TDM
Link Layer: 6-65
Cable access network:
MAP frame for
Interval [t1, t2]
CMTS Downstream channel i
Upstream channel j
cable headend
t1 t2 Residences with cable modems
Minislots containing Assigned minislots containing cable modem
minislots request frames upstream data frames
DOCSIS: data over cable service interface specificaiton
§ FDM over upstream, downstream frequency channels
§ TDM upstream: some slots assigned, some have contention
• downstream MAP frame: assigns upstream slots
• request for upstream slots (and data) transmitted random access (binary
backoff) in selected slots
Link Layer: 6-66
Summary of MAC protocols
§ channel partitioning, by time, frequency or code
• Time Division, Frequency Division
§ random access (dynamic),
• ALOHA, S-ALOHA, CSMA, CSMA/CD
• carrier sensing: easy in some technologies (wire), hard in others
(wireless)
• CSMA/CD used in Ethernet
• CSMA/CA used in 802.11
§ taking turns
• polling from central site, token passing
• Bluetooth, FDDI, token ring
Link Layer: 6-67
Pure ALOHA efficiency
P(success by given node) = P(node transmits) *
P(no other node transmits in [t 0-1,t0] * *
P(no other node transmits in [t 0-1,t0]
= p . (1-p)N-1 . (1-p)N-1
= p . (1-p)2(N-1)
… choosing optimum p and then letting n
= 1/(2e) = .18
even worse than slotted Aloha!
Link Layer: 6-68
19CS2109
COMPUTER NETWORKS AND SECURITY
© 2020-21 KL University – The contents of this presentation are an intellectual and copyrighted property of KL University. ALL RIGHTS RESERVED 69
Session-18,19,20
Network Layer Design Issues
Routing Algorithms
© 2019-20 KL University – The contents of this presentation are an intellectual and copyrighted property of KL University. ALL RIGHTS RESERVED
70
Network Layer Design Isues
• Store-and-Forward Packet Switching
• Services Provided to the Transport Layer
• Implementation of Connectionless Service
• Implementation of Connection-Oriented Service
• Comparison of Virtual-Circuit and Datagram Subnets
Store-and-Forward Packet Switching
The environment of the network layer protocols.
fig 5-1
Implementation of Connectionless Service
Routing within a diagram subnet.
Implementation of Connection-Oriented Service
Routing within a virtual-circuit subnet.
Comparison of Virtual-Circuit and Datagram Subnets
5-4
Routing Algorithms
• The Optimality Principle
• Shortest Path Routing
• Flooding
• Distance Vector Routing
• Link State Routing
• Hierarchical Routing
• Broadcast Routing
• Multicast Routing
• Routing for Mobile Hosts
• Routing in Ad Hoc Networks
Routing Algorithms (2)
Conflict between fairness and optimality.
The Optimality Principle
(a) A subnet. (b) A sink tree for router B.
Shortest Path Routing
The first 5 steps used in computing the shortest path from A to D.
The arrows indicate the working node.
19CS2109
COMPUTER NETWORKS AND SECURITY
© 2020-21 KL University – The contents of this presentation are an intellectual and copyrighted property of KL University. ALL RIGHTS RESERVED 80
Distance Vector Routing
(a) A subnet. (b) Input from A, I, H, K, and the new
routing table for J.
Distance Vector Routing (2)
The count-to-infinity problem.
Link State Routing
Each router must do the following:
1.Discover its neighbors, learn their network address.
2.Measure the delay or cost to each of its neighbors.
3.Construct a packet telling all it has just learned.
4.Send this packet to all other routers.
5.Compute the shortest path to every other router.
Learning about the Neighbors
(a) Nine routers and a LAN. (b) A graph model of (a).
Measuring Line Cost
A subnet in which the East and West parts are connected by two lines.
Building Link State Packets
(a) A subnet. (b) The link state packets for this subnet.
Distributing the Link State Packets
The packet buffer for router B in the previous slide (Fig. 5-13).
Hierarchical Routing
Hierarchical routing.
Broadcast Routing
Reverse path forwarding. (a) A subnet. (b) a Sink tree. (c) The tree built by reverse
path forwarding.
Multicast Routing
(a) A network. (b) A spanning tree for the leftmost router.
(c) A multicast tree for group 1. (d) A multicast tree for group 2.