Você está na página 1de 131

DATA LINK LAYER

11.1

Group
Members

MUHAMMAD ALI

USMAN AHMED MAZHAR

REHMAN RAFIQUE

YASIR ZIADI

06/21/15

11.2

Question to be answered ?
Why it is important to have
Datalink Layer?

What are Functions


performed on Data-link layer?

06/21/15

11.3

Need for Data-link layer


1) Communication circuits make

errors occasionally.
2) Communication circuits have a
limited date rate.
3) There is a nonzero propagation
delay between the time a bit is
sent and the time it is received.

06/21/15

11.4

Data Link Layer

06/21/15

11.5

Data Link Control


Functions performed on Data-link control are:
1- Framing
2- Flow Control
3- Error Control

06/21/15

11.6

Framing
The transmitted bit stream by the physical
layer is not guaranteed to be error free.
It is up to the data-link layer to detect, and if
necessary, to correct errors.
The data-link layer breaks the bit stream up
into discrete frames and compute the checksum
for each frame.
When a frame arrives at the destination, the
checksum is recomputed.

06/21/15

11.7

Framing
Fixed-Size Framing
ATM Wide-area-networks

Variable-Size Framing
Local-area-networks

06/21/15

11.8

Relationship between packet and


frame
Receiving

Sending machine

machine
Packet

Packet
Frame

Header

06/21/15

Payload field Trailer

Header

Payload field

Trailer

11.9

Framing
The easiest way to achieve framing is to

insert time gaps between frames.


Other Framing Methods are:
1) Character count.
2) Flag bytes with byte stuffing
3)Starting and encoding flags, with bit
stuffing

06/21/15

11.10

Framing

Character count framing method uses


a field in the header to specify the
number of characters in the frame.

Character count

06/21/15

Frame 1

Frame 2

Frame 3

4 Characters

6 Characters

2Characters

11.11

Framing
The second method uses in each frame

start and end special bytes (Flag byte) to


get around the problem of
resynchronisation after an error occurred.
Flag bytes used as a delimiters.
A Frame delimited by flag bytes

FLAG

06/21/15

Header

Payload field

Trailer

FLAG

11.12

Figure 11.1 A frame in a character-oriented protocol

06/21/15

11.13

Bit-oriented framing
Bit stuffing
(a) The original data.
(b) The data as they appear on the line.
(c) The data as they are stored in receivers memory after
unstuffing

06/21/15

11.14

Flow Control
&
Error Control
11.15

112FLOWANDERRORCONTROL

The most important responsibilities of the data


link layer are flow control and error control.
Collectively, these functions are known as data
link control.

06/21/15

11.16

Flow Control
Note

Flow control refers to a set of procedures


used to restrict the amount of data
that the sender can send before
waiting for acknowledgment.

06/21/15

11.17

Flow Control

Receiver has a limited speed at which it can


process incoming data and a limited amount of
memory in which to store incoming data.

Receiver must inform the sender before the limits


are reached and request that the transmitter to
send fewer frames or stop temporarily.

Since the rate of processing is often slower than


the rate of transmission, receiver has a block of
memory (buffer) for storing incoming data until
they are processed.

06/21/15

11.18

Flow Control

There are two approaches for flow control:

Feedback-based flow control: where the

receiver sends back information to the


sender giving it permission to send more
data.
2) Rate-based flow control: where there is

a rate limit at which senders may transmit


data, without using feedback from the
receiver.
06/21/15

11.19

Error Control
Note

Error control in the data link layer is


based on automatic repeat request,
which is the retransmission of data.

06/21/15

11.20

Error Control

a.

Error Control is needed to make sure all frames are


eventually delivered to the network layer at the
destination and in the proper order.

b.

The technique of acknowledgment and


retransmission is used to ensure reliable delivery.

c.
06/21/15

This can be achieved by using timer and assigning


11.21

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 pseudo
code a version of each protocol that concentrates mostly on the
procedure instead of delving into the details of language rules.

06/21/15

11.22

Figure 11.5 Taxonomy of protocols

06/21/15

11.23

Simplest Mechanism

06/21/15

11.24

Algorithm 11.2 Receiver-site algorithm for the simplest protocol

11.25
06/21/15

Algorithm 11.1 Sender-site algorithm for the simplest protocol

11.26
06/21/15

Simplest Mechanism

06/21/15

11.27

Stop-and-Wait Mechanism

06/21/15

11.28

Stop-and-Wait
Mechanism

06/21/15

11.29

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.

06/21/15

11.30

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.

06/21/15

11.31

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.

06/21/15

11.32

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

06/21/15

11.33

Figure 11.11 Flow diagram for Example 11.3

06/21/15

11.34

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.

06/21/15

11.35

Figure 11.12 Send window for Go-Back-N ARQ

06/21/15

11.36

Note

The send window is an abstract concept


defining an imaginary box of size 2 m 1
with three variables: Sf, Sn, and Ssize.

06/21/15

11.37

Note

The send window can slide one


or more slots when a valid
acknowledgment arrives.

06/21/15

11.38

Figure 11.13 Receive window for Go-Back-N ARQ

06/21/15

11.39

Note

The receive window is an abstract


concept defining an imaginary box
of size 1 with one single variable R n.
The window slides
when a correct frame has arrived;
sliding occurs one slot at a time.

06/21/15

11.40

Figure 11.14 Design of Go-Back-N ARQ

06/21/15

11.41

Figure 11.15 Window size for Go-Back-N ARQ

06/21/15

11.42

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.

06/21/15

11.43

Figure 11.16 Flow diagram for Example 11.6

06/21/15

11.44

Figure 11.17 Flow diagram for Example 11.7

06/21/15

11.45

Note

Stop-and-Wait ARQ is a special case of


Go-Back-N ARQ in which the size of the
send window is 1.

06/21/15

11.46

Figure 11.18 Send window for Selective Repeat ARQ

06/21/15

11.47

Figure 11.19 Receive window for Selective Repeat ARQ

06/21/15

11.48

Figure 11.20 Design of Selective Repeat ARQ

06/21/15

11.49

Figure 11.21 Selective Repeat ARQ, window size

06/21/15

11.50

Note

In Selective Repeat ARQ, the size of the


sender and receiver window
must be at most one-half of 2m.

06/21/15

11.51

Figure 11.22 Delivery of data in Selective Repeat ARQ

06/21/15

11.52

Figure 11.23 Flow diagram for Example 11.8

06/21/15

11.53

Figure 11.24 Design of piggybacking in Go-Back-N ARQ

06/21/15

11.54

Multiple Access

11.55

Multiple Access

06/21/15

11.56

Taxonomy of multiple-access protocols

12.57
06/21/15

RANDOMACCESS

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.

12.58
06/21/15

Random Access
Two features:
> No schedule time for a station to transmit.
(Random access)
>No rule to specify that which station should
transmit first and then further.(contention
method)
Problem:
> The main problem that occurs due this is
collision.
06/21/15

11.59

ALOHA

ALOHA, the earliest random access


method, It was designed for a radio
(wireless) LAN, but it can be used on
any shared medium.

06/21/15

11.60

ALOHA
There are two versions of ALOHA:
1: Pure ALOHA
2: Slotted ALOHA

06/21/15

11.61

Pure ALOHA

06/21/15

The original ALOHA protocol is called pure


ALOHA. This is a simple, but elegant
protocol. The idea is that each station
sends a frame whenever it has a frame to
send. However, since there is only one
channel to share, there is the possibility of
collision between frames from different
stations.

11.62

Frames in a pure ALOHA network

12.63
06/21/15

Procedure for pure ALOHA protocol

12.64
06/21/15

Example 12.1

The stations on a wireless ALOHA network are a maximum


of 600 km apart. If we assume that signals propagate at 3
108 m/s, we find
Tp = (600 105 ) / (3 108 ) = 2 ms.
Now we can find the value of TB for different values of
K.
a. For K = 1, the range is {0, 1}. The station needs to|
generate a random number with a value of 0 or 1. This
means that TB is either 0 ms (0 2) or 2 ms (1 2),
based on the outcome of the random variable.

12.65
06/21/15

Example 12.1 (continued)


b. For K = 2, the range is {0, 1, 2, 3}. This means that T B
can be 0, 2, 4, or 6 ms, based on the outcome of the
random variable.
c. For K = 3, the range is {0, 1, 2, 3, 4, 5, 6, 7}. This
means that TB can be 0, 2, 4, . . . , 14 ms, based on the
outcome of the random variable.
d. We need to mention that if K > 10, it is normally set to
10.

12.66
06/21/15

Vulnerable time for pure ALOHA protocol

12.67
06/21/15

Example 12.2
A pure ALOHA network transmits 200-bit frames on a
shared channel of 200 kbps. What is the requirement to
make this frame collision-free?

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.68
06/21/15

The throughput for pure ALOHA is


S = G e 2G .
The maximum throughput
Smax = 0.184 when G= (1/2).
S(%)=18.4
Where G=average No. of frames generated by the system during one
frame transmission time.

12.69
06/21/15

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 e2 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.70
06/21/15

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.
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.
12.71
06/21/15

Slotted ALOHA

06/21/15

Why we use slotted ALOHA?


In slotted ALOHA we divide time into
slots of Tfr and force station to send only
at the beginning of time slot.
Improve the efficiency of pure ALOHA.
Vulnerable time= Tfr

11.72

Figure 12.6 Frames in a slotted ALOHA network

12.73
06/21/15

Note
The throughput for slotted ALOHA is
S = G eG .
The maximum throughput
Smax = 0.368 when G = 1.
S(%)=36.8
Where G=average No. of frames generated by the system during one
frame transmission time.

12.74
06/21/15

Figure 12.7 Vulnerable time for slotted ALOHA protocol

12.75
06/21/15

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 eG 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.76
06/21/15

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 eG 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.
12.77
06/21/15

CSMA (carrier sense multiple


access)

Principle of CSMA
Listen Before Talk

06/21/15

11.78

CSMA

It requires that each station first listen to the


medium before sending.

Minimize the chance of collision.

But it cant eliminate the collision.

06/21/15

11.79

Figure 12.8 Space/time model of the collision in CSMA

12.80
06/21/15

What should a station do when channel


is busy?

What should a station do when channel


is idle?

06/21/15

11.81

Figure 12.10 Behavior of three persistence methods

12.82
06/21/15

Figure 12.11 Flow diagram for three persistence methods

12.83
06/21/15

CSMA/CD

Carrier sense multiple access/collision


detection

It is use to handle the collision.

In it station monitors the medium.

06/21/15

11.84

Figure 12.12 Collision of the first bit in CSMA/CD

12.85
06/21/15

Figure 12.13 Collision and abortion in CSMA/CD

12.86
06/21/15

Example 12.5
A network using CSMA/CD has a bandwidth of 10 Mbps. If
the maximum propagation time (including the delays in
the devices and ignoring the time needed to send a
jamming signal, as we see later) is 25.6 s, what is the
minimum size of the frame?
Solution
The frame transmission time is Tfr = 2 Tp = 51.2 s. This
means, in the worst case, a station needs to transmit for a
period of 51.2 s to detect the collision. The minimum size
of the frame is 10 Mbps 51.2 s = 512 bits or 64 bytes.
This is actually the minimum size of the frame for
Standard Ethernet.

12.87
06/21/15

Figure 12.14 Flow diagram for the CSMA/CD

12.88
06/21/15

Figure 12.15 Energy level during transmission, idleness, or collision

12.89
06/21/15

CSMA/CA

06/21/15

Carrier sense multiple access/collision


avoidance
The basic idea behind CSMA/CD is that
a station needs to be able to receive
while transmitting to detect a collision.
It receives two signals(when there is
collision).

11.90

Figure 12.16 Timing in CSMA/CA

12.91
06/21/15

Note
In CSMA/CA, the IFS can also be used to
define the priority of a station or a
frame.

12.92
06/21/15

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.

12.93
06/21/15

Figure 12.17 Flow diagram for CSMA/CA

06/21/15

11.94

THANK YOU!!!

06/21/15

11.95

Chapter 27
WWW and HTTP

27.96

ARCHITECTURE

The WWW today is a distributed client/server service, in which a client using a


browser can access a service using a server. However, the service provided is
distributed over many locations called sites.

06/21/15

27.97

Architecture of WWW

06/21/15

27.98

Browser

06/21/15

27.99

URL

06/21/15

27.100

WEBDOCUMENTS

The documents in the WWW can be grouped into three broad categories: static,
dynamic, and active. The category is based on the time at which the contents of the
document are determined.

06/21/15

27.101

Static document

06/21/15

27.102

Boldface tags

06/21/15

27.103

Effect of boldface tags

06/21/15

27.104

Beginning and ending tags

06/21/15

27.105

Dynamic document using CGI

06/21/15

27.106

Dynamic document using server-site script

06/21/15

27.107

Note

Dynamic documents are sometimes referred to as server-site dynamic


documents.

06/21/15

27.108

Active document using Java applet

06/21/15

27.109

Active document using client-site script

06/21/15

27.110

Note

Active documents are sometimes referred to as client-site dynamic


documents.

06/21/15

27.111

HTTP

The Hypertext Transfer Protocol (HTTP) is a protocol used mainly to access data
on the World Wide Web. HTTP functions as a combination of FTP and SMTP.

06/21/15

27.112

Note

HTTP uses the services of TCP on well-known port 80.

06/21/15

27.113

HTTP transaction

06/21/15

27.114

Request and response messages

06/21/15

27.115

Request and status lines

06/21/15

27.116

Methods

06/21/15

27.117

Table 27.2 Status codes

06/21/15

27.118

Table 27.2 Status codes (continued)

06/21/15

27.119

Figure 27.15 Header format

06/21/15

27.120

Table 27.3 General headers

06/21/15

27.121

Table 27.4 Request headers

06/21/15

27.122

Table 27.5 Response headers

06/21/15

27.123

Table 27.6 Entity headers

06/21/15

27.124

Example 27.1

This example retrieves a document. We use the GET method to retrieve an


image with the path /usr/bin/image1. The request line shows the method
(GET), the URL, and the HTTP version (1.1). The header has two lines that
show that the client can accept images in the GIF or JPEG format. The
request does not have a body. The response message contains the status line
and four lines of header. The header lines define the date, server, MIME
version, and length of the document. The body of the document follows the
header (see Figure 27.16).

06/21/15

27.125

Figure 27.16 Example 27.1

06/21/15

27.126

Example 27.2

In this example, the client wants to send data to the server. We use the POST method. The request
line shows the method (POST), URL, and HTTP version (1.1). There are four lines of headers. The
request body contains the input information. The response message contains the status line and
four lines of headers. The created document, which is a CGI document, is included as the body (see
Figure 27.17).

06/21/15

27.127

Figure 27.17 Example 27.2

06/21/15

27.128

Example 27.3

HTTP uses ASCII characters. A client can directly connect to a server using TELNET, which logs
into port 80 (see next slide). The next three lines show that the connection is successful. We then
type three lines. The first shows the request line (GET method), the second is the header (defining
the host), the third is a blank, terminating the request. The server response is seven lines starting
with the status line. The blank line at the end terminates the server response. The file of 14,230
lines is received after the blank line (not shown here). The last line is the output by the client.

06/21/15

27.129

Example 27.3 (continued)

06/21/15

27.130

Note

HTTP version 1.1 specifies a persistent connection by default.

06/21/15

27.131

Você também pode gostar