CCN Unit 2
CCN Unit 2
By
Mr. Raghuram K. M.
Assistant Professor,
Department of Electronics and Communication Engineering
SDM College of Engineering and Technology, Dharwad, Karnataka.
1
• functions include framing, flow and error
control, and software implemented protocols
that provide smooth and reliable transmission
of frames between nodes.
2
1. FRAMING
3
Variable-Size Framing
• need a way to define the end of the frame and the
beginning of the next
• prevalent in local area networks
• two approaches
1. Character-Oriented Protocols
• data to be carried are 8-bit characters from a coding
system such as ASCII
• Header and trailer are also multiples of 8 bits
• To separate one frame from the next, an 8-bit (I-byte)
flag is added at the beginning and the end of a frame.
4
• when only text was exchanged, flag could be
selected to be any character not used for text
communication
• While sending other types such as graphs,
audio, and video, any pattern used for the flag
could also be part of the information, which
makes receiver wrongly think that it has
reached the end of the frame
• byte-stuffing strategy to fix this problem
Byte Stuffing: process of adding 1 extra byte
whenever there is a flag or escape character in
the text.
5
Byte stuffing and unstuffing
6
Bit-Oriented Protocols
• data section of a frame is a sequence of bits to be
interpreted by the upper layer as text, graphic,
audio, video, and so on
• Most protocols use a special 8-bit pattern flag
01111110 as the delimiter to define the
beginning and the end of the frame
• Bit stuffing strategy to over come the same flag
related problem
8
2. FLOW AND ERROR CONTROL
Flow Control
• set of procedures used to restrict the amount of
data that the sender can send before waiting for
acknowledgment
• flow of data must not be allowed to overwhelm
the receiver since it has limited speed and
limited memory
• receiving device must be able to inform the
sending device before those limits are reached –
ex: if the buffer is filled
9
Error Control
• Refers to the methods of error detection and
retransmission
• allows the receiver to inform the sender if any
frames lost or damaged in transmission -
coordinates the retransmission of those
frames by the sender
• often implemented simply: Any time an error
is detected in an exchange, specified frames
are retransmitted. This process is called
automatic repeat request (ARQ)
10
3. PROTOCOLS
• normally implemented in software by using one of
the common programming languages
• for noiseless (error-free) channels and those that
can be used for noisy (error-creating) channels
11
4. NOISELESS CHANNELS
• ideal channel in which no frames are lost, duplicated, or
corrupted – but practically non existant
Simplest Protocol
Assumptions:
• no flow control and no error control
• unidirectional - data frames are traveling in only one
direction
• processing time that is small enough to be negligible
• receiver can never be overwhelmed with incoming
frames
12
Design
13
Sender-site algorithm for the simplest protocol
14
Receiver-site algorithm for the simplest protocol
15
Example Flow Diagram
16
Stop-and-Wait Protocol
• Flow control is added to prevent the receiver
from becoming overwhelmed with frames
• sender sends one frame, stops until it receives
confirmation from the receiver (okay to go
ahead), and then sends the next frame
• unidirectional communication for data frames,
but auxiliary ACK frames (simple tokens of
acknowledgment) travel from the other
direction
17
Design
18
Sender-site algorithm for Stop-and-Wait Protocol
19
Receiver-site algorithm for Stop-and-Wait Protocol
20
Example
21
5. NOISY CHANNELS
• Protocols use error control
23
Sequence Numbers
• Since we want to minimize the frame size, we look for the
smallest range of sequence numbers that provides
unambiguous communication
• if we decide that the field is m bits long, the sequence
numbers start from 0, go to 2m - 1, and then are repeated
• Assuming three possibilities i.e. [1] Successful delivery of
frame and ACK [2] ACK is corrupted or lost [3] Frame is
corrupted or lost
• sequence numbers are based on modulo-2 arithmetic – i.e.
0,1,0,1 is sufficient (m=1)
Acknowledgment Numbers
• acknowledgment numbers always announce the sequence
number of the next frame expected by the receiver
• Ex: if frame 0 has arrived safe and sound, the receiver
sends an ACK frame with acknowledgment
24
25
Sender Site
26
……….
27
Receiver Site
28
29
Go-Back-N Automatic Repeat Request
• multiple frames must be in transition while
waiting for acknowledgment – pipelining
• keep a copy of these frames until the
acknowledgments arrive
Sequence Numbers
• sequence numbers are modulo-2m
• Ex: 0, 1,2,3,4,5,6, 7,8,9, 10, 11, 12, 13, 14,
15,0, 1,2,3,4,5,6,7,8,9,10, 11, ... For m=4
30
Sliding Window
• an abstract concept that defines the range of
sequence numbers that is the concern of the
sender and receiver
• Send sliding window is an imaginary box
covering the sequence numbers of the data
frames which can be in transit
• Maximum size of the window is 2m – 1
• let the size be fixed and set to the maximum
value - sliding window of size 15 (m =4)
31
Send window
32
• window at any time divides the possible sequence numbers
into four regions
1. Acknowledged frames – copy removed
2. Outstanding frames – sent frames
3. Frames not received by upper layer – not yet sent
4. Frames that cannot be sent until the window slides
• Three variables
1. Sf defines the sequence number of the first (oldest)
outstanding frame
2. Sn holds the sequence number that will be assigned to the
next frame to be sent.
3. Ssize defines the size of the window
• send window can slide one or more slots to the right when
an acknowledgment arrives from the other end
33
• size of the receive window is always 1.
• Any frame arriving out of order is discarded
and needs to be resent
• only one variable Rn (receive window, next
frame expected)
34
Timers
• Only one timer
• timer for the first outstanding frame always expires
first; we send all outstanding frames when this timer
expires
Acknowledgment
• If a frame is damaged or is received out of order, the
receiver is silent and will discard all subsequent frames
until it receives the one it is expecting
• Silence of the receiver causes the timer of the
unacknowledged frame at the sender site to expire
• This makes sender to go back and resend all frames,
beginning with the one with the expired timer
• Reciever can send one cumulative acknowledgment for
several frames
35
Figure 11.14 Design of Go-Back-N ARQ
11.36
Figure 11.15 Window size for Go-Back-N ARQ
11.37
Note
11.38
Algorithm 11.7 Go-Back-N sender algorithm
(continued)
11.39
(continued)
Algorithm 11.7 Go-Back-N sender algorithm
11.40
Algorithm 11.8 Go-Back-N receiver algorithm
11.41
Figure 11.16 Flow diagram for Example 11.6
11.42
Figure 11.17 Flow diagram for Example 11.7
11.43
Selective Repeat Automatic Repeat Request
• For more noisy links
• does not resend N frames when just one
frame is damaged; only the damaged frame is
resent
• processing at the receiver is more complex
• size of the send window is much smaller; max
size is 2m- 1
• receive window is the same size as the send
window
44
Figure 11.18 Send window for Selective Repeat ARQ
11.45
Receive Window
• allows as many frames as the size of the
receive window to arrive out of order and be
kept until there is a set of in-order frames to
be delivered to the network layer
• all the frames in the send frame can arrive out
of order and be stored until they can be
delivered
• receiver never delivers packets out of order to
the network layer
46
Figure 11.19 Receive window for Selective Repeat ARQ
11.47
Figure 11.20 Design of Selective Repeat ARQ
11.48
Figure 11.21 Selective Repeat ARQ, window size
11.49
Figure 11.23 Flow diagram for Example 11.8
11.50
Algorithm 11.9 Sender-site Selective Repeat algorithm
(continued)
11.51
(continued)
Algorithm 11.9 Sender-site Selective Repeat algorithm
11.52
(continued)
(continued)
Algorithm 11.9 Sender-site Selective Repeat algorithm
11.53
Algorithm 11.10 Receiver-site Selective Repeat algorithm
11.54
Algorithm 11.10 Receiver-site Selective Repeat algorithm
11.55
Piggybacking
• to improve the efficiency of the bidirectional
protocols
• When a frame is carrying data from A to B, it
can also carry control information about
arrived (or lost) frames from B and visa versa
56
Figure 11.24 Design of piggybacking in Go-Back-N ARQ
11.57
• both sites must use the same algorithm
• each node now has two windows: one send
window and one receive window
• Both are involved in three types of events:
request, arrival, and time-out
• The request event uses only the send window
at each site; the arrival event needs to use
both windows
58
Unit II
“Multiple Access”
By
Mr. Raghuram K. M.
Assistant Professor,
Department of Electronics and Communication Engineering
SDM College of Engineering and Technology, Dharwad, Karnataka.
59
Figure 12.1 Data link layer divided into two functionality-oriented sublayers
12.61
1. RANDOM ACCESS
• In random access or contention methods, no station is
superior to another station and none is assigned the
control over another
• Decision of a station on whether or not to send the data
depends on the state of the medium (idle or busy) – so
testing of the state of the medium needed
• Two features
1. there is no scheduled time for a station to transmit.
Transmission is random among the stations – “ Random
Access”
2. no rules specify which station should send next. Stations
compete with one another to access the medium
“Contention Based”
62
• each station has the right to the medium without
being controlled by any other station
• if more than one station tries to send, there is an
access conflict-collision-and the frames will be
either destroyed or modified
Conflict resolution questions
When can the station access the medium?
What can the station do if the medium is busy?
How can the station determine the success or
failure of the transmission?
What can the station do if there is an access
conflict?
63
ALOHA
• earliest random access method, was
developed at the University of Hawaii in early
1970
Pure ALOHA
• original ALOHA protocol, simple, but elegant
protocol
• each station sends a frame whenever it has a
frame to send
64
Figure 12.3 Frames in a pure ALOHA network
66
Figure 12.4 Procedure for pure ALOHA protocol
12.67
Example 12.1
12.68
Example 12.1 (continued)
12.69
• Vulnerable time length of time, the vulnerable
time, in which there is a possibility of collision
• Pure ALOHA vulnerable time = 2 x Tfr
70
Example 12.2
Solution
Average frame transmission time Tfr is 200 bits/200 kbps
or 1 ms. The vulnerable time is 2 × 1 ms = 2 ms. This
means no station should send later than 1 ms before this
station starts transmission and no station should start
sending during the one 1-ms period that this station is
sending.
12.71
Throughput : average number of successful
transmissions for pure ALOHA is S = G x e-2G.
• The maximum throughput Smax is 0.184, for G
= 1/2.
where G the average number of frames
generated by the system(all stations togather)
during one frame transmission time
• if one frame is generated during two frame
transmission time, then 18.4 percent of these
frames reach their destination successfully
72
Example 12.3
A pure ALOHA network transmits 200-bit frames on a
shared channel of 200 kbps. What is the throughput if
the system (all stations together) produces
a. 1000 frames per second b. 500 frames per second
c. 250 frames per second.
Solution
The frame transmission time is 200/200 kbps or 1 ms.
a. If the system creates 1000 frames per second, this is 1
frame per millisecond. The load is 1. In this case
S = G× e−2 G or S = 0.135 (13.5 percent). This means
that the throughput is 1000 × 0.135 = 135 frames. Only
135 frames out of 1000 will probably survive.
12.73
Example 12.3 (continued)
b. If the system creates 500 frames per second, this is
(1/2) frame per millisecond. The load is (1/2). In this
case S = G × e −2G or S = 0.184 (18.4 percent). This
means that the throughput is 500 × 0.184 = 92 and that
only 92 frames out of 500 will probably survive. Note
that this is the maximum throughput case,
percentagewise.
12.74
Slotted ALOHA
• Time is divided into slots of Tfr s and
force the station to send only at the
beginning of the time slot
• station is allowed to send only at the
beginning of the synchronized time slot,
if a station misses this moment, it must
wait until the beginning of the next time
slot
75
Figure 12.6 Frames in a slotted ALOHA network
12.76
• vulnerable time is now reduced to one-half, equal
to Tfr
• The throughput for slotted ALOHA is S = G ×
e−G .
• The maximum throughput Smax = 0.368 when
G = 1.
77
Example 12.4
A slotted ALOHA network transmits 200-bit frames on a
shared channel of 200 kbps. What is the throughput if
the system (all stations together) produces
a. 1000 frames per second b. 500 frames per second
c. 250 frames per second.
Solution
The frame transmission time is 200/200 kbps or 1 ms.
a. If the system creates 1000 frames per second, this is 1
frame per millisecond. The load is 1. In this case
S = G× e−G or S = 0.368 (36.8 percent). This means
that the throughput is 1000 × 0.0368 = 368 frames.
Only 386 frames out of 1000 will probably survive.
12.78
Example 12.4 (continued)
b. If the system creates 500 frames per second, this is
(1/2) frame per millisecond. The load is (1/2). In this
case S = G × e−G or S = 0.303 (30.3 percent). This
means that the throughput is 500 × 0.0303 = 151.
Only 151 frames out of 500 will probably survive.
12.79
Carrier Sense Multiple Access (CSMA)
• chance of collision can be reduced if a station senses
the medium before trying to use it
• CSMA requires that each station first listen to the
medium (or check the state of the medium) before
sending
• based on the principle "sense before transmit" or
"listen before talk
• possibility of collision still exists because of
propagation delay; when a station sends a frame, it still
takes time (although very short) for the first bit to
reach every station and for every station to sense it.
• vulnerable time for CSMA is the propagation time Tp -
time needed for a signal to propagate from one end of
the medium to the other
80
Figure 12.8 Space/time model of the collision in CSMA
12.81
Figure 12.9 Vulnerable time in CSMA
12.82
Persistence Methods
1-persistent method
• after the station finds the line idle, it sends its frame
immediately (with probability 1)
• highest chance of collision because two or more
stations may find the line idle and send their frames
immediately
nonpersistent method
• If the line is idle, it sends immediately
• If the line is not idle, it waits a random amount of time
and then senses the line again
• reduces the chance of collision
• reduces the efficiency of the network
83
The p-persistent method
• is used if the channel has time slots with a slot
duration equal to or greater than the maximum
propagation time
• combines the advantages of the other two strategies -
reduces the chance of collision and improves efficiency
• after the station finds the line idle it follows these
steps:
1. With probability p, the station sends its frame.
2. With probability q = 1 - p, the station waits for the
beginning of the next time slot and checks the line
again.
a. If the line is idle, it goes to step 1.
b. If the line is busy, it acts as though a collision has
occurred and uses the backoff procedure.
84
Figure 12.10 Behavior of three persistence methods
12.85
Figure 12.11 Flow diagram for three persistence methods
12.86
Carrier Sense Multiple Access with
Collision Detection (CSMA/CD)
• specifies the procedure following a collision
• station monitors the medium after it sends a
frame to see if the transmission was successful
87
Figure 12.12 Collision of the first bit in CSMA/CD
12.88
Figure 12.13 Collision and abortion in CSMA/CD
12.89
Minimum Frame Size
• need a restriction on the frame size
Worst case:
two stations involved in a collision are the
maximum distance apart, the signal from the first
takes time Tp to reach the second
effect of the collision takes another time Tp to
reach the first
• So the requirement is that the first station must
still be transmitting after 2Tp
• frame transmission time Tfr must be at least two
times the maximum propagation time Tp
90
Example 12.5
12.92
Observations
1. addition of the persistence process – one of
the three
2. transmission and collision detection is a
continuous process - station transmits and
receives continuously and simultaneously
(using two different ports)
3. sending of a short jamming signal that
enforces the collision in case other stations
have not yet sensed the collision
93
Energy Level
• level of energy in a channel can have three values:
zero, normal, and abnormal
• At the zero level, the channel is idle.
• At the normal level, a station has successfully captured
the channel and is sending its frame
• At the abnormal level, there is a collision and the level
of the energy is twice the normal level
94
Throughput
• greater than that of pure or slotted ALOHA
• For I-persistent method the maximum
throughput is around 50 percent when G =1
• For nonpersistent method, the maximum
throughput can go up to 90 percent when G is
between 3 and 8.
• Maximum throughput occurs at a different
value of G and is based on the persistence
method and the value of p in the p-persistent
approach
95
Carrier Sense Multiple Access with
Collision Avoidance (CSMA/CA)
• in a wireless network, much of the sent energy
is lost in transmission. The received signal has
very little energy. Therefore, a collision may add
only 5 to 10 percent additional energy. This is
not useful for effective collision detection
• We need to avoid collisions on wireless networks
because they cannot be detected
• three strategies: the interframe space, the
contention window, and acknowledgments
96
Figure 12.16 Timing in CSMA/CA
12.97
Interframe Space (IFS)
• deferring transmission even if the channel is found idle
• IFS time allows the front of the transmitted signal by the
distant station to reach this station
• IFS variable can also be used to prioritize - For example, a
station that is assigned a shorter IFS has a higher priority
Contention Window
• contention window is an amount of time divided into slots
• number of slots in the window changes according to the
binary exponential back-off strategy
• station needs to sense the channel after each time slot
98
12.99
2. CONTROLLED ACCESS
• stations consult one another to find which station has the
right to send
Reservation
• station needs to make a reservation of time slot before
sending data
• Time is divided into intervals
• In each interval, reservation frame precedes the data
frames sent in that interval
• If there are N stations in the system, there are exactly N
reservation minislots in the reservation frame
• Each station makes a reservation in its own minislot
• stations that have made reservations can send their data
frames after the reservation frame
100
Figure 12.18 Reservation access method
12.101
Polling
• works with topologies in which one device is
designated as a primary station and the other
devices are secondary stations
• All data exchanges must be made through the
primary device even when the ultimate
destination is a secondary device
• The primary device controls the link; the
secondary devices follow its instructions
102
Figure 12.19 Select and poll functions in polling access method
12.103
Select
• used whenever the primary device has something to
send
• primary must alert the secondary to the upcoming
transmission and wait for an acknowledgment of the
secondary's ready status
• Before sending data, the primary creates and transmits
a select (SEL) frame, one field of which includes the
address of the intended secondary
Poll
• When the primary is ready to receive data, it must ask
(poll) each device in turn if it has anything to send
• Secondary responds either with a NAK frame if it has
nothing to send or with data (in the form of a data
frame) if it does
104
Token Passing
• stations in a network are organized in a logical
ring
• for each station, there is a predecessor and a
successor
• right to this access has been passed from the
predecessor to the current station
• right will be passed to the successor when the
current station has no more data to send
• a special packet called a token circulates through
the ring
• Possession of the token gives the station the right
to access the channel and send its data
105
Token management
• Stations must be limited in the time they can
have possession of the token
• The token must be monitored to ensure it has
not been lost or destroyed
• assign priorities to the stations and to the
types of data being transmitted
• make low-priority stations release the token to
high priority stations
106
Logical Ring
• stations do not have to be physically
connected in a ring
1.physical ring topology:
• when a station sends the token to its
successor, the token cannot be seen by other
stations; the successor is the next one in line
• token does not have to have the address of
the next successor
• if one of the links-the medium between two
adjacent stations fails, the whole system fails
107
Figure 12.20 Logical ring and physical topology in token-passing access method
12.108
2. dual ring topology:
• uses a second (auxiliary) ring which operates in
the reverse direction
• second ring is for emergencies only - If one of the
links in the main ring fails, the system
automatically combines the two rings to form a
temporary ring
• After the failed link is restored, the auxiliary ring
becomes idle again
• The high-speed Token Ring networks called FDDI
(Fiber Distributed Data Interface) and CDDI
(Copper Distributed Data Interface) use this
topology.
109
bus ring topology:
• also called a token bus
• each station knows the address of its
successor
• When a station has finished sending its data, it
releases the token and inserts the address of
its successor in the token
• Only the station with the address matching
the destination address of the token gets the
token to access the shared media
• The Token Bus LAN, standardized by IEEE, uses
this topology.
110
4. star ring topology
• wiring inside the hub makes the ring; the
stations are connected to this ring through the
two wire connections
• less prone to failure because if a link goes
down, it will be bypassed by the hub and the
rest of the stations can operate
• used in the Token Ring LAN designed by IBM.
111
3. CHANNELIZATION
• available bandwidth of a link is shared in time,
frequency, or through code, between different
stations
12.113
• stream data (a continuous flow of data that
may not be packetized) can easily be used
with FDMA
• although FDMA and FDM conceptually seem
similar, there are differences between them.
114
Time-Division Multiple Access (TDMA)
• stations share the bandwidth of the channel in
time
• Each station is allocated a time slot
• main problem with TDMA lies in achieving
synchronization between the different stations
• To compensate for the propagation delays, we
can insert guard times
• synchronization bits (normally refered to as
preamble bits) at the beginning of each slot can
be used
• although TDMA and TDM conceptually seem the
same, there are differences between them
115
Figure 12.22 Time-division multiple access (TDMA)
12.116
Code-Division Multiple Access (CDMA)
• differs from FDMA because only one channel
occupies the entire bandwidth of the link
• differs from TDMA because all stations can send
data simultaneously; there is no timesharing.
• assigned codes have two properties.
1. If we multiply each code by another, we get O.
2. If we multiply each code by itself, we get 4 (the
number of stations – assuming 4 stations).
• Suppose Station 2 wants to hear what station I is
saying. It multiplies the data on the channel by cl'
the code of station 1.
• Data = {d1.C1+ d2.C2+d3.C3+d4.C4}.C1=4d1
117
Figure 12.23 Simple idea of communication with code
12.118
• Each station is assigned a code, which is a sequence of
numbers called chips
• Chip Sequences
120
Encoding and Decoding
121
Figure 12.27 Digital signal created by four stations in CDMA
12.122
Figure 12.28 Decoding of the composite signal for one in CDMA
12.123
Figure 12.29 General rule and examples of creating Walsh tables
12.124
• For a two-station network, we have
[+1 +1] and [+1 −1].
125
Note
12.126
Example 12.6
???????
12.127
Example 12.7
Solution
The number of sequences needs to be
2m. We need to choose m = 7 and N = 27
or 128. We can then use 90
of the sequences as the chips.
12.128
129