0% found this document useful (0 votes)
10 views100 pages

iot06

Iot

Uploaded by

Sana M.saffar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views100 pages

iot06

Iot

Uploaded by

Sana M.saffar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 100

Protocols II:

Multiple Access and Data Flow

Department of Software Engineering,


Multiple Access
When nodes or stations are connected and use a common
link, called a multipoint or broadcast link, we need a
multiple-access protocol to coordinate access to the link.
• For a dedicated link between a sender and receiver?
• How about when you call using mobile phone?

Figure Data link layer divided into two functionality-oriented sublayers


Taxonomy of multiple-access protocols
RANDOM ACCESS

In random access or contention methods, no station is


superior to another station and none is assigned the control
over another. No station permits, or does not permit, another
station to send. At each instance, a station that has data to
send uses a procedure defined by the protocol to make a
decision on whether or not to send.

Important topics:
ALOHA
Carrier Sense Multiple Access
Carrier Sense Multiple Access with Collision Detection
Carrier Sense Multiple Access with Collision Avoidance
(1) ALOHA

Frames in a pure ALOHA network


• The medium is shared between the stations. When a station
sends data, another station may attempt to do so at the same
time. The data from two stations collide and become
garbled.

• A collision involves two or more stations. If all these


stations try to resend their frames after the time-out, the
frames will collide again. Pure ALOHA dictates that when
a time-out period passes, each stations waits for a random
amount of time before resending its frames. The
randomness will help avoid more collisions. We call this
time the back-off time TB.
(1) ALOHA
Figure Procedure for pure ALOHA protocol

Write the procedure


in your own words?
(1) ALOHA

Figure Vulnerable time for pure ALOHA protocol


(1) ALOHA

Note

The throughput for pure ALOHA is


S = G × e −2G .
The maximum throughput
Smax = 0.184 when G= (1/2).

S is in %.
G is average number of frames
generated by the system,
Example
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.
Example (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.

c. If the system creates 250 frames per second, this is (1/4)


frame per millisecond. The load is (1/4). In this case
S = G × e −2G or S = 0.152 (15.2 percent). This means
that the throughput is 250 × 0.152 = 38. Only 38
frames out of 250 will probably survive.
Slotted ALOHA
Note

The throughput for slotted ALOHA is


S = G × e−G .
The maximum throughput
Smax = 0.368 when G = 1.
Figure Vulnerable time for slotted ALOHA protocol
Example
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.
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.

c. If the system creates 250 frames per second, this is (1/4)


frame per millisecond. The load is (1/4). In this case
S = G × e −G or S = 0.195 (19.5 percent). This means
that the throughput is 250 × 0.195 = 49. Only 49
frames out of 250 will probably survive.
(3) Carrier Sense Multiple Access
(CSMA)
The chance of collision can be reduced if the station sense
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. In other words CSMA is based
on “sense before transmit” or “listen before talk.”

CSMA can reduce the possibility of collision, but it can not


eliminate it. An example is shown in figure 12.8, where
Station C sense the medium and find it idle, only because
the first bit sent by Station A has not yet received.
Figure Space/time model of the collision in CSMA
Figure Vulnerable time in CSMA

Vulnerable time for CSMA is the Propagation Time Tp. This is the
time needed for a signal to propagate from one end of the medium
to the other end.
Figure Behavior of three persistence methods
What should a station do if the channel is busy? What should a
station do if the channel is idle?
Figure Flow diagram for three persistence methods
(4) Carrier Sense Multiple Access / Collision Detection (CSMA/CD)

Figure Collision of the first bit in CSMA/CD


Figure Flow diagram for the CSMA/CD

A Jamming Signal enforces the collision in case other stations have not yet sensed
the collision. Jamming Signal temporary suspends the transmissions.
CSMA/CA

Home work?
Note

In CSMA/CA, if the station finds the


channel busy, it does not restart the
timer of the contention window;
it stops the timer and restarts it when
the channel becomes idle.
Figure Flow diagram for CSMA/CA

What is difference between CSMA/CD and CSMA/CA?

Explain the CSMA/CA?


CONTROLLED ACCESS

In controlled access, the stations consult one another to find


which station has the right to send. A station cannot send
unless it has been authorized by other stations. We discuss
three popular controlled-access methods.

Reservation
Polling
Token Passing
Reservation access method

In the reservation method, a station needs make a reservation


before the data frame.
Polling
Figure Select and poll functions in polling access method
Token Passing

Figure Logical ring and physical topology in token-passing access method


CHANNELIZATION

Channelization is a multiple-access method in which the


available bandwidth of a link is shared in time, frequency, or
through code, between different stations. In this section, we
discuss three channelization protocols.

Topics discussed in this section:


Frequency-Division Multiple Access (FDMA)
Time-Division Multiple Access (TDMA)
Code-Division Multiple Access (CDMA)
Frequency-division multiple access (FDMA)

•In FDMA, the available bandwidth is divided into multiple


frequency bands.
•Each station is allocated a band to send its data. In other
words each station is reserved for a specific station, and it
belongs to the station all the time.
•Each station also uses a bandpass filter to continue the
transmitter frequencies. To prevent station interferences, the
allocated bands are separated from one another by small
guard bands.
Frequency-division multiple access (FDMA)
Note

In FDMA, the available bandwidth


of the common channel is divided into
bands that are separated by guard
bands.
Time-division multiple access (TDMA)

•The stations share the bandwidth of channel in time


•Each station is allocated a time slot during which it can send
data
•Each station transmits its data in its assigned time slot
•Synchronization is normally accomplished by having some
synchronization bits (normaly referred to as preamble bits) at
the beginning of each slot
Time-division multiple access (TDMA)
Note

In TDMA, the bandwidth is just one


channel that is timeshared between
different stations.
Code-division multiple access (CDMA)

•CDMA differs from FDMA because only one channel


occupies entire bandwidth of the link
•It differs from TDMA because all stations can send data
simultaneously; there is no time sharing.
Code division multiple access (TDMA)

Note

In CDMA, one channel carries all


transmissions simultaneously.
Simple idea of communication with code
Chip sequences
Data representation in CDMA
Figure Sharing channel in CDMA: The process of Encoding
bit 0
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.

What is Flow Control?

What is Error control?


Flow 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.

• The receiver has a block of memory, called a buffer, reserved for


storing incoming data until they are processed
• If the buffer begins to fill up, the receiver must be able to tell the
sender to halt the transmission until it is once again able to receive.
Error Control
• Error control is both error detection and error correction
• It allows the receiver to inform the sender of any frames
lost or damaged in transmission and coordinates the
retransmission of those frames.

Error control in the data link layer is based on


automatic repeat request, which is the retransmission
of data.
PROTOCOLS

Now let us see how 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.
Taxonomy of protocols discussed in this chapter
NOISELESS CHANNELS

Let us first assume we have an ideal channel in which no


frames are lost, duplicated, or corrupted.
corrupted. We introduce
two protocols for this type of channel.
channel.

Protocols for noiseless channel


Simplest Protocol
Stop-and-Wait Protocol
(1) Simplest Protocol

Figure The design of the simplest protocol with no flow or error control
(1) Simplest Protocol

Algorithm Sender-site algorithm for the simplest protocol


(1) Simplest Protocol

Algorithm 11.2 Receiver-site algorithm for the simplest protocol


Example 1

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.
(1) Simplest Protocol

Figure Flow diagram for Example 1


(2) Stop-and-Wait Protocol

Figure Design of Stop-and-Wait Protocol


(2) Stop-and-Wait Protocol
Algorithm .3 Sender-site algorithm for Stop-and-Wait Protocol
(2) Stop-and-Wait Protocol
Algorithm 4 Receiver-site algorithm for Stop-and-Wait Protocol
Example 2

Figure 9 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.
(2) Stop-and-Wait Protocol
Figure 9 Flow diagram for Example .2
What to do when a frame
is lost?
NOISY CHANNELS

Although the Stop-


Stop-and
and--Wait Protocol gives us an idea of
how to add flow control to its predecessor, noiseless
channels are nonexistent.
nonexistent. We discuss three protocols in
this section that use error control
control..

Protocols for noisy channel


Stop-and-Wait Automatic Repeat Request
Go-Back-N Automatic Repeat Request
Selective Repeat Automatic Repeat Request
(1) Stop-and-Wait ARQ

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.

ARQ – Automatic Repeat Request


(1) Stop-and-Wait ARQ

Note

In Stop-and-Wait ARQ, we use sequence numbers to


number the frames.
The sequence numbers are based on modulo-2
arithmetic.
(1) Stop-and-Wait ARQ

Note

In Stop-and-Wait ARQ, the acknowledgment number


always announces in modulo-2 arithmetic the
sequence number of the next frame expected.
(1) Stop-and-Wait ARQ

Figure 10 Design of the Stop-and-Wait ARQ Protocol


(1) Stop-and-Wait ARQ
Algorithm .5 Sender-site algorithm for Stop-and-Wait ARQ

(continued)
(1) Stop-and-Wait ARQ (continued)

Algorithm 5 Sender-site algorithm for Stop-and-Wait ARQ


(1) Stop-and-Wait ARQ

Algorithm 11.6 Receiver-site algorithm for Stop-and-Wait ARQ Protocol


Example 3

Figure 11 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.
Figure 11 Flow diagram for Example 3
(2) Go-Back-N Protocol

Note

In the Go-Back-N Protocol, the sequence numbers


are modulo 2m,
where m is the size of the sequence number field in
bits.
(2) Go-Back-N Protocol
what is outstanding frame?

Figure 12 Send window for Go-Back-N ARQ


(2) Go-Back-N Protocol

Note

The send window is an abstract concept defining an


imaginary box of size 2m − 1 with three variables: Sf,
Sn, and Ssize.
(2) Go-Back-N Protocol

Note

The send window can slide one


or more slots when a valid acknowledgment arrives.
(2) Go-Back-N Protocol

Figure 13 Receive window for Go-Back-N ARQ


(2) Go-Back-N Protocol

Note

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.
(2) Go-Back-N Protocol

Figure 14 Design of Go-Back-N ARQ


(2) Go-Back-N Protocol
What happens when all the acknowledgements are lost?

Figure 15 Window size for Go-Back-N ARQ


Note

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.
Algorithm 11.7 Go-Back-N sender algorithm

(continued)
Algorithm 11.7 Go-Back-N sender algorithm (continued)
Algorithm 11.8 Go-Back-N receiver algorithm
Example 16

Figure 16 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.
Figure 16 Flow diagram for Example .6

Cumulative ACK
Figure 11.16 Flow diagram for Example 11.6

What is Cumulative ACK?


Example

Figure 17 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.
Example (continued)

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.
Figure 17 Flow diagram for Example .7
Note

Stop-and-Wait ARQ is a special case of Go-Back-N


ARQ in which the size of the send window is 1.
(3) Selective Repeat ARQ

Figure 18 Send window for Selective Repeat ARQ


(3) Selective Repeat ARQ

Figure 19 Receive window for Selective Repeat ARQ


Figure 20 Design of Selective Repeat ARQ
Figure 20 Design of Selective Repeat ARQ

What is difference between ACK and NAK?


Note

In Selective Repeat ARQ, the size of the sender and


receiver window
must be at most one-half of 2m.
Example 8

This example is similar to Example .3 in which frame 1 is


lost. We show how Selective Repeat behaves in this case.
Figure 23 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.
Example 11.8 (continued)

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.
Example 8 (continued)

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.
Example 8 (continued)

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.
Figure 11.23 Flow diagram for Example 11.8
Figure 20 Design of Selective Repeat ARQ

What is difference Go-back N ARQ and Selective repeat


ARQ?

You might also like