Data-Link Layer Functions and Protocols
Data-Link Layer Functions and Protocols
MODULE II
DATA-LINK LAYER
Nodes and Links
Communication at the data-link layer is node-to-node. A data unit from one point in the Internet needs
to pass through many networks (LANs and WANs) to reach another point. Theses LANs and WANs are connected
by routers.
The first node is the source host and the last node is the destination host. The other four nodes are four
routers. The first, third and fifth links represent the three LANs and second and fourth links represent the two
WANs.
The data-link layer is located between the physical and the network layers. The data link layer provides
services to the network layer, it receives services from the physical layer. The duty scope of the data-link layer is
node-to-node. When a packet is travelling in the Internet, the data-link layer of a node (host or router) is
responsible for delivering a datagram to the next node in the path.
The data-link layer of the sending node needs to encapsulate the datagram received from the network in
a frame and the data-link layer of the receiving node needs to decapsulate the datagram from the frame but each
intermediate node needs to both encapsulate and decapsulate.
Each link may be using a different protocol with a different frame format and hence need encapsulation
and decapsulation at each intermediate node. Even if one link and the next are using the same protocol,
encapsulation and decapsulation are needed because the link-layer addresses are normally different.
Framing
The first service provided by the data-link layer is framing. The data-link layer at each node needs to
encapsulate the datagram (packet received from the network layer) in a frame before sending it to the next node.
The node also needs to decapsulate the datagram from the frame received on the logical channel. Frame may
have both a header and a trailer. Different data-link layers have different formats for framing.
1
Flow Control
If the rate of produced frames is higher than the rate of consumed frames, frames at the receiving end
need to be buffered while waiting to be consumed (processed).
Error Control
At the sending node a frame in a data-link layer needs to be changed to bits, transformed to
electromagnetic signals and transmitted through the transmission media.
At the receiving node electromagnetic signals are received, transformed to bits and put together to
create a frame. Since electromagnetic signals are susceptible to error, a frame is susceptible to error
The error needs first to be detected. After detection, it needs to be either corrected at the receiver node
or discarded and retransmitted by the sending node. Since error detection and correction is an issue in every
layer (node-to node or host-to-host).
Congestion Control
Link may be congested with frames which result in frame loss , most data-link layer protocols do not
directly use a congestion control to alleviate congestion. Congestion control is considered an issue in the network
layer or the transport layer because of its end-to-end nature .Two Categories of Links In a point-to-point link ,
the link is dedicated to the two devices; in a broadcast link, the link is shared between several pairs of devices.
The data-link layer is divided into two sub layers: Data link control (DLC) and Media Access Control
(MAC). The data link control sublayer deals with all issues common to both point-to-point and broadcast links.
The media access control sublayer deals only with issues specific to broadcast links. We separate these
two types of links at the data-link layer, as shown in Figure 2.2
Figure 2.2 Dividing the data link layer into two sublayers
LINK-LAYER ADDRESSING
In a connectionless internetwork such as the Internet we cannot make a datagram reach its destination
using only IP addresses. The reason is that each datagram in the Internet from the same source host to the same
destination host may take a different path. The source and destination IP addresses define the two ends but
cannot define which links the datagram should pass through.
A link-layer address is sometimes called a link address or a physical address or a MAC address. A link is
controlled at the data-link layer, the addresses need to belong to the data-link layer. When a datagram passes
from the network layer to the data-link layer, the datagram will be encapsulated in a frame and two data-link
addresses are added to the frame header. These two addresses are changed every time the frame moves from
one link to another. Figure demonstrates the concept in a small internet.
There are different link-layer protocols. Three Types of addresses some link-layer protocols define three
types of addresses: unicast, multicast, and broadcast.
Unicast Address: Each host or each interface of a router is assigned a unicast address. Unicasting means one-to-
one communication. A frame with a unicast address destination is destined only for one entity in the link.
Example: The unicast link-layer addresses in the most common LAN, Ethernet, are 48 bits (six bytes) that are
presented as 12 hexadecimal digits separated by colons; for example,
Multicast Address: Some link-layer protocols define multicast addresses. Multicasting means one-to-many
communication. However, the jurisdiction is local (inside the link).
Example: the multicast link-layer addresses in the most common LAN, Ethernet, are 48 bits (six bytes) that are
presented as 12 hexadecimal digits separated by colons. The second digit, however, needs to be an even number
in hexadecimal. The following shows a multicast address: A3:34:45:11:92:F1
Broadcast Address: Some link-layer protocols define a broadcast address. Broadcasting means one-to-all
communication. A frame with a destination broadcast address is sent to all entities in the link.
Example : the broadcast link-layer addresses in the most common LAN, Ethernet, are 48 bits, all 1s, that are
presented as 12 hexadecimal digits separated by colons.
The following shows a broadcast address: FF: FF: FF: FF: FF:FF
Anytime a host or a router needs to find the link-layer address of another host or router in its network, it
sends an ARP request packet. The packet includes the link-layer and IP addresses of the sender and the IP
address of the receiver. Because the sender does not know the link-layer address of the receiver, the query is
broadcast over the link using the link-layer broadcast address.
Every host or router on the network receives and processes the ARP request packet, but only the
intended recipient recognizes its IP address and sends back an ARP response packet. The response packet
contains the recipient’s IP and link-layer addresses
The packet is unicast directly to the node that sent the request packet. In Figure 2.5(a) the system on the
left (A) has a packet that needs to be delivered to another system (B) with IP address N2. System A needs to pass
the packet to its data-link layer for the actual delivery, but it does not know the physical address of the recipient.
It uses the services of ARP by asking the ARP protocol to send a broadcast ARP request packet to ask for
the physical address of a system with an IP address of N2. This packet is received by every system on the physical
network, but only system B will answer it, as shown in Figure2.5 (b). System B sends an ARP reply packet that
includes its physical address. Now system A can send all the packets it has for this destination using the physical
address it received.
4
Caching
Let us assume that there are 20 systems connected to the network (link): system A, system B, and 18 other
systems. We also assume that system A has 10 datagrams to send to system B in one second.
a. Without using ARP, system A needs to send 10 broadcast frames. Each of the 18 other systems need to receive
the frames, decapsulate the frames, remove the datagram and pass it to their network-layer to find out the
datagrams do not belong to them. This means processing and discarding 180 broadcast frames.
b. Using ARP, system A needs to send only one broadcast frame. Each of the 18 other systems need to receive the
frames, decapsulate the frames, remove the ARP message and pass the message to their ARP protocol to find
that the frame must be discarded. This means processing and discarding only 18 (instead of 180) broadcast
frames. After system B responds with its own data-link address, system A can store the link-layer address in its
cache memory. The rest of the nine frames are only unicast. Since processing broadcast frames is expensive (time
consuming), the first method is preferable.
Packet Format
Figure 2.6 shows the format of an ARP packet.
The hardware type field - defines the type of the link-layer protocol; Ethernet given the type 1.
The protocol type field - defines the network-layer protocol: IPv4 protocol is (0x0800).
The source hardware and source protocol addresses are variable-length fields defining the link layer and
network-layer addresses of the sender.
The destination hardware address and destination protocol address fields define the receiver link-layer
and network-layer addresses.
An ARP packet is encapsulated directly into a data-link frame. The frame needs to have a field to show
that the payload belongs to the ARP and not to the network-layer datagram
Example Figure 2.7: A host with IP address N1 and MAC address L1 has a packet to send to another host
with IP address N2 and physical address L2 (which is unknown to the first host). The two hosts are on the same
network. Figure shows the ARP request and response messages.
The data link control (DLC) deals with procedures for communication between two adjacent nodes—
node-to-node communication—no matter whether the link is dedicated or broadcast. Data link control functions
include framing and flow and error control.
Framing
Data Transmission in the physical layer means moving bits in the form of a signal from the source to the
destination. The physical layer provides bit synchronization to ensure that the sender and receiver use the same
bit durations and timing. The data-link layer, on the other hand, needs to pack bits into frames, so that each
frame is distinguishable from another.
Framing in the data-link layer separates a message from one source to a destination by adding a sender
address and a destination address. The destination address defines where the packet is to go; the sender address
helps the recipient acknowledge the receipt.
Although the whole message could be packed in one frame, that is not normally done. One reason is that
a frame can be very large, making flow and error control very inefficient. When a message is carried in one very
large frame, even a single-bit error would require the retransmission of the whole frame. When a message is
divided into smaller frames, a single-bit error affects only that small frame.
Fixed-size framing: there is no need for defining the boundaries of the frames; the size itself can be used
as a delimiter. An example of this type of framing is the (Asynchronous transfer mode) ATM WAN, which uses
frames of fixed size called cells.
Variable-size framing: prevalent in local-area networks. In variable-size framing, we need a way to define
the end of one frame and the beginning of the next. Two approaches were used for this purpose: a character-
oriented approach and a bit-oriented approach.
Character-Oriented Framing
In character-oriented (or byte-oriented) framing, data to be carried are 8-bit characters from a coding
system such as ASCII. The header, which normally carries the source and destination addresses and other control
information, and the trailer, which carries error detection redundant bits, are also multiples of 8 bits. To separate
one frame from the next, an 8-bit (1-byte) flag is added at the beginning and the end of a frame. The flag,
composed of protocol-dependent special characters, signals the start or end of a frame. Figure 2.8 shows the
format of a frame in a character-oriented protocol.
Character-oriented framing was popular when only text was exchanged by the data-link layers. The flag
could be selected to be any character not used for text communication. Now, we send other types of information
such as graphs, audio, and video. Any character used for the flag could also be part of the information. If this
happens the receiver, when it encounters this pattern in the middle of the data, thinks it has reached the end of
the frame.
To fix this problem, a byte-stuffing strategy was added to character-oriented framing. In byte stuffing (or
character stuffing), a special byte is added to the data section of the frame when there is a character with the
same pattern as the flag. The data section is stuffed with an extra byte. This byte is usually called the escape
character (ESC) and has a predefined bit pattern. Whenever the receiver encounters the ESC character, it
removes it from the data section and treats the next character as data, not as a delimiting flag. Figure2.9 shows
the situation
Byte stuffing by the escape character allows the presence of the flag in the data section of the frame, but
it creates another problem. If the text contains one or more escape characters followed by a byte with the same
pattern as the flag, then receiver removes the escape character, but keeps the next byte, which is incorrectly
interpreted as the end of the frame. If the escape character is part of the text, an extra one is added to show that
the second one is part of the text.
Bit-Oriented Framing
In bit-oriented framing, the 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. We need a delimiter to separate one frame from the other. Most
protocols use a special 8-bit pattern flag, 01111110, as the delimiter to define the beginning and the end of the
frame.
If the flag pattern appears in the data, need to inform the receiver that this is not the end of the frame.
We do this by stuffing 1 single bit (instead of 1 byte) to prevent the pattern from looking like a flag. The strategy
is called bit stuffing.
In bit stuffing, if 0 and five consecutive 1 bits are encountered an extra 0 is added. This extra stuffed bit is
eventually removed from the data by the receiver. Note that the extra bit is added after one 0 followed by five
1s regardless of the value of the next bit. This guarantees that the flag field sequence does not appear in the
frame. Bit stuffing is the process of adding one extra 0 whenever five consecutive 1s follow a 0 in the data, so
that the receiver does not mistake the pattern 0111110 for a flag. Figure 2.11 shows bit stuffing at the sender
and bit removal at the receiver. Note that even if we have a 0 after five 1s, we still stuff a 0. The 0 will be
removed by the receiver. This means that if the flag like pattern 01111110 appears in the data, it will change to
011111010 (stuffed) and is not mistaken for a flag by the receiver. The real flag 01111110 is not stuffed by the
sender and is recognized by the receiver.
Flow Control -Whenever an entity produces items and another entity consumes them, there should be a
balance between production and consumption rates. If the items are produced faster than they can be
consumed, the consumer can be overwhelmed and may need to discard some items. If the items are produced
more slowly than they can be consumed, the consumer must wait, and the system becomes less efficient. Flow
control is related to the first issue. We need to prevent losing the data items at the consumer site.
The Figure 2.12 shows that the data-link layer at the sending node tries to push frames toward the data-
link layer at the receiving node. If the receiving node cannot process and deliver the packet to its network at the
same rate that the frames arrive, it becomes overwhelmed with frames. Flow control in this case can be feedback
from the receiving node to the sending node to stop or slow down pushing frames.
Flow control can be implemented in several ways, one of the solutions is normally to use two buffers.
One at the sending data-link layer and the other at the receiving data-link layer. A buffer is a set of memory
locations that can hold packets at the sender and receiver. The flow control communication can occur by
sending signals from the consumer to the producer. When the buffer of the receiving data-link layer is full, it
informs the sending data link layer to stop pushing frames.
Error Control -The technology at the physical layer is not fully reliable, need to implement error control at the
data-link layer to prevent the receiving node from delivering corrupted packets to its network layer. Error control
at the data-link layer is simple and implemented using one of the following two methods. In both methods, a CRC
is added to the frame header by the sender and checked by the receiver.
In the first method, if the frame is corrupted, it is silently discarded, if it is not corrupted, the packet is
delivered to the network layer. This method is used mostly in wired LANs such as Ethernet.
In the second method, if the frame is corrupted, it is silently discarded, if it is not corrupted, an
acknowledgment is sent (for the purpose of both flow and error control) to the sender.
10
First protocol is a simple protocol with neither flow nor error control. It is assumed that the receiver can
immediately handle any frame it receives i.e the receiver can never be overwhelmed with incoming frames.
Figure 2.13 shows the layout for this protocol.
The data-link layer at the sender gets a packet from its network layer, makes a frame out of it, and sends
the frame. The data-link layer at the receiver receives a frame from the link, extracts the packet from the frame,
and delivers the packet to its network layer. The data-link layers of the sender and receiver provide transmission
services for their network layers.
Flow diagram shows an example of communication using this protocol. It is very simple. The sender sends
frames one after another without even thinking about the receiver
Stop-and-Wait Protocol
Second protocol is called the Stop-and-Wait protocol, which uses both flow and error control.
In this protocol, the sender sends one frame at a time and waits for an acknowledgment before sending
the next one. To detect corrupted frames, need to add a CRC to each data frame. When a frame arrives at the
receiver site, it is checked. If its CRC is incorrect, the frame is corrupted and silently discarded. The silence of the
receiver is a signal for the sender that a frame was either corrupted or lost.
11
Every time the sender sends a frame, it starts a timer. If an acknowledgment arrives before the timer
expires, the timer is stopped and the sender sends the next frame (if it has one to send).
If the timer expires, the sender resends the previous frame, assuming that the frame was either lost or
corrupted. This means that the sender needs to keep a copy of the frame until its acknowledgment arrives. When
the corresponding acknowledgment arrives, the sender discards the copy and sends the next frame if it is ready.
Figure 2.15 shows the outline for the Stop-and-Wait protocol. Note that only one frame and one
acknowledgment can be in the channels at any time.
FSMs Figure 2.16 shows the FSMs for primitive Stop-and-Wait protocol. We describe the sender and receiver
states below.
Sender States. The sender is initially in the ready state, but it can move between the ready and blocking state.
Ready State. When the sender is in this state, it is only waiting for a packet from the network layer. If a packet
comes from the network layer, the sender creates a frame, saves a copy of the frame, starts the only timer and
sends the frame. The sender then moves to the blocking state.
12
Blocking State. When the sender is in this state, three events can occur:
[Link] a time-out occurs, the sender resends the saved copy of the frame and restarts the timer.
[Link] a corrupted ACK arrives, it is discarded.
[Link] an error-free ACK arrives, the sender stops the timer and discards the saved copy of the frame. It then moves
to the ready state
Receiver States
The receiver is always in the ready state. Two events may occur:
a. If an error-free frame arrives, the message in the frame is delivered to the network layer and an ACK is sent.
b. If a corrupted frame arrives, the frame is discarded
The first frame is sent and acknowledged. The second frame is sent, but lost. After time-out, it is resent.
The third frame is sent and acknowledged, but the acknowledgment is lost. The frame is resent. There is a
problem with this scheme. The network layer at the receiver site receives two copies of the third packet, which is
not right. This problem can be corrected using sequence numbers and acknowledgment numbers. Flow diagram
for this example is shown below.
Sequence and Acknowledgment Numbers Problem in above Example needs to be addressed and corrected.
Duplicate packets, as much as corrupted packets, need to be avoided. we need to add sequence numbers to the
data frames and acknowledgment numbers to the ACK frames. Sequence numbers are 0, 1, 0, 1, 0, 1, . . .; the
acknowledgment numbers can also be 1, 0, 1, 0, 1, 0, .The sequence numbers start with 0, the acknowledgment
numbers start with 1. An acknowledgment number always defines the sequence number of the next frame to
receive.
13
Figure 2.18 below shows how adding sequence numbers and acknowledgment numbers can prevent duplicates.
The first frame is sent and acknowledged. The second frame is sent, but lost. After time-out, it is resent. The third
frame is sent and acknowledged, but the acknowledgment is lost. The frame is resent.
Figure2.18 flow diagram for example with sequence and acknoledgement Number
Piggybacking
The two protocols discussed in this section are designed for unidirectional communication, in which data
is flowing only in one direction although the acknowledgment may travel in the other direction. Protocols have
been designed in the past to allow data to flow in both directions. However, to make the communication more
efficient, the data in one direction is piggybacked with the acknowledgment in the other direction. In other
words, when node A is sending data to node B, Node A also acknowledges the data received from node B.
Because piggybacking makes communication at the datalink layer more complicated, it is not a common practice
14
Many protocols have been devised to handle access to a shared link. All of these protocols belong to a sub layer
in the data-link layer called media access control (MAC)
RANDOM ACCESS
In random-access or contention methods, no station is superior to another station and none is assigned control
over another.
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.
This decision depends on the state of the medium (idle or busy). In other words, each station can transmit when
it desires on the condition that it follows the predefined procedure, including testing the state of the medium.
Two features give this method its name. First, there is no scheduled time for a station to transmit. Transmission
is random among the stations. That is why these methods are called random access. Second, no rules specify
which station should send next. Stations compete with one another to access the medium. That is why these
methods are also called contention methods.
In a random-access method, each station has the right to the medium without being controlled by any
other station. However, if more than one station tries to send, there is an access conflict “collision” and the
frames will be either destroyed or modified.
The random-access methods have evolved from a very interesting protocol known as ALOHA, which used a very
simple procedure called multiple access (MA).
The method was improved with the addition of a procedure that forces the station to sense the medium before
transmitting. This was called carrier sense multiple access (CSMA).
CSMA method later evolved into two parallel methods: carrier sense multiple access with collision detection
(CSMA/CD), which tells the station what to do when a collision is detected, and carrier sense multiple access with
collision avoidance (CSMA/CA), which tries to avoid the collision
15
ALOHA
ALOHA, the earliest random access method was developed at the University of Hawaii in early 1970. It was
designed for a radio (wireless) LAN, but it can be used on any shared medium.
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 the two stations collide.
Pure ALOHA
The original ALOHA protocol is called pure ALOHA. This is a simple protocol.
The idea is that each station sends a frame whenever it has a frame to send there is only one channel to share,
hence there is the possibility of collision between frames from different stations.
•There are four stations that compete with one another for access to the shared channel. The above figure 2.20
shows that each station sends two frames, there are a total of eight frames on the shared medium.
• Some of these frames collide because multiple frames are in contention for the shared channel. Figure .2.20
shows that only two frames survive: one frame from station 1 and one frame from station 3.
• If one bit of a frame coexists on the channel with one bit from another frame, there is a collision and both will
be destroyed. It is obvious that the frames have to be resend that have been destroyed during transmission.
•The pure ALOHA protocol relies on acknowledgments from the receiver. When a station sends a frame, it
expects the receiver to send an acknowledgment. If the acknowledgment does not arrive after a time-out period,
the station assumes that the frame (or the acknowledgment) has been destroyed and resends the frame.
• 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 the time-out period passes, each station waits a random amount of time
before resending its frame. The randomness will help avoid more collisions. This time is called as the back off
time TB.
• Pure ALOHA has a second method to prevent congesting the channel with retransmitted frames. After a
maximum number of retransmission attempts Kmax, a station must give up and try later. Figure 2.21 shows the
procedure for pure ALOHA based on the above strategy.
16
• The time-out period is equal to the maximum possible round-trip propagation delay, which is twice the amount
of time required to send a frame between the two most widely separated stations (2 × Tp).
• The back off time TB is a random value that normally depends on K (the number of attempted unsuccessful
transmissions).
• In this method, for each retransmission, a multiplier R = 0 to 2K is randomly chosen and multiplied by Tp
(maximum propagation time) or Tfr (the average time required to send out a frame) to find TB.
Note: The range of the random numbers increases after each collision. The value of Kmax is usually chosen as 15.
Vulnerable time: The length of time in which there is a possibility of collision. The stations send fixed-
length frames with each frame taking Tfr seconds to send. Figure 2.22 shows the vulnerable time for station A.
17
Station B starts to send a frame at time t. Imagine station A has started to send its frame after t − T fr. This
leads to a collision between the frames from station B and station A. On the other hand, suppose that station C
starts to send a frame before time t + Tfr. There is also a collision between frames from station B and station C.
From the Figure 2.22 , it can be seen that the vulnerable time during which a collision may occur in pure ALOHA
is 2 times the frame transmission time. Pure ALOHA vulnerable time = 2 ×Tfr
Throughput
G = the average number of frames generated by the system during one frame transmission time (Tfr) S=
the average number of successfully transmitted frames for pure ALOHA. And is given by, S = G × e− 2G .
Slotted ALOHA
• Pure ALOHA has a vulnerable time of 2 × Tfr. This is so because there is no rule that defines when the station can
send.
• A station may send soon after another station has started or just before another station has finished. Slotted
ALOHA was invented to improve the efficiency of pure ALOHA.
• In slotted ALOHA we divide the time into slots of Tfr seconds and force the station to send only at the beginning
of the time slot.
18
• To minimize the chance of collision and, therefore, increase the performance, the CSMA method was
developed. The chance of collision can be reduced if a station senses the medium before trying to use it.
• Carrier sense multiple access (CSMA) requires that each station first listen to the medium (or check the state of
the medium) before sending.
• CSMA is based on the principle “sense before transmit” or “listen before talk.”
• CSMA can reduce the possibility of collision, but it cannot eliminate it. The reason for this is shown in Figure
2.25 a space and time model of a CSMA network. Stations are connected to a shared channel. The 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.
• A station may sense the medium and find it idle, only because the first bit sent by another station has not yet
been received.
At time t1, station B senses the medium and finds it idle, so it sends a frame. At time t2 (t2 > t1), station C
senses the medium and finds it idle because, at this time, the first bits from station B have not reached station C.
Station C also sends a frame. The two signals collide and both frames are destroyed.
Vulnerable Time
• The 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.
• When a station sends a frame and any other station tries to send a frame during this time, a collision will result.
• But if the first bit of the frame reaches the end of the medium, every station will already have heard the bit and
will refrain from sending.
• Figure 2.26 below shows the worst case. The leftmost station, A, sends a frame at time t1, which reaches the
rightmost station, D, at time t1 + Tp. The gray area shows the vulnerable area in time and space.
19
• 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. (Refer Figure 2.27)
• The p-persistent approach combines the advantages of the other two strategies. It reduces the chance of
collision and improves efficiency. In this method, after the station finds the line idle it follows these steps:
20
21
• At time t1, station A has executed its persistence procedure and starts sending the bits of its frame. At time t2,
station C has not yet sensed the first bit sent by A.
• Station C executes its persistence procedure and starts sending the bits in its frame, which propagate both to
the left and to the right.
• The collision occurs sometime after time t2. Station C detects a collision at time t3 when it receives the first bit
of A’s frame. Station C immediately aborts transmission.
• Station A detects collision at time t4 when it receives the first bit of C’s frame, it also immediately aborts
transmission.
• Before sending the last bit of the frame, the sending station must detect a collision, if any, and abort the
transmission.
• Once the entire frame is sent, station does not keep a copy of the frame and does not monitor the line for
collision detection. Therefore, the frame transmission time Tfr must be at least two times the maximum
propagation time Tp.
• If the two stations involved in a collision are the maximum distance apart, the signal from the first takes time Tp
to reach the second and the 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.
Energy Level
The level of energy in a channel can have three values (Figure 2.30):
1) Zero level: The channel is idle
2) Normal level: A station has successfully captured the channel and is sending its frame.
3) Abnormal level: There is a collision and the level of the energy is twice the normal level.
22
NOTE: A station that has a frame to send or is sending a frame needs to monitor the energy level to determine if
the channel is idle, busy, or in collision mode.
Throughput
• The throughput of CSMA/CD is greater than that of pure or slotted ALOHA.
• The 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.
• For the 1-persistent method, the maximum throughput is around 50 percent when G = 1. For the non-persistent
1. The addition of the persistence process. It is required to sense the channel before sending the frame by using
one of the persistence processes (non- persistent, 1 persistent, or p-persistent).
2. The frame transmission: In ALOHA, there is transmission of the entire frame and then wait for an
acknowledgment. In CSMA/CD, transmission and collision detection are continuous processes.
• It is not like the entire frame is sent and then look for a collision. The station transmits and receives
continuously and simultaneously.
23
• Loop is used to show that transmission is a continuous process. It is constantly monitored in order to
detect one of two conditions: either transmission is finished or a collision is detected.
• Either event stops transmission. When it comes out of the loop, if a collision has not been detected, it
means that transmission is complete, the entire frame is transmitted. Otherwise, a collision has occurred.
3. The sending of a short jamming signal to make sure that all other stations become aware of the collision.
• When an idle channel is found, the station does not send immediately. It waits for a period of time called the
inter frame space or IFS.
• Even though the channel may appear idle when it is sensed, a distant station may have already started
transmitting.
• The distant station’s signal has not yet reached this station. The IFS time allows the front of the transmitted
signal by the distant station to reach this station.
• After waiting an IFS time, if the channel is still idle, the station can send, but it still needs to wait a time equal to
the contention window.
2. Contention Window
• The contention window is an amount of time divided into slots. A station that is ready to send chooses a
random number of slots as its wait time.
• The number of slots in the window changes according to the binary exponential back off strategy. This means
that it is set to one slot the first time and then doubles each time the station cannot detect an idle channel
after the IFS time.
• This is very similar to the p-persistent method except that a random outcome defines the number of slots taken
by the waiting station.
• One interesting point about the contention window is that the station needs to sense the channel after each
time slot. If the station finds the channel busy, it does not restart the process; it just stops the timer and restarts
it when the channel is sensed as idle. This gives priority to the station with the longest waiting time.
3. Acknowledgement
There is still a collision resulting in destroyed data. The data may be corrupted during the transmission. The
positive acknowledgment and the time-out timer can help guarantee that the receiver has received the frame.
24
Frame Exchange Time Line Figure 2.33 shows the exchange of data and control frames in time.
1. Before sending a frame, the source station senses the medium by checking the energy level at the carrier
frequency.
a. The channel uses a persistence strategy with back off until the channel is idle.
b. After the station is found to be idle, the station waits for a period of time called the DCF inter frame space
(DIFS), then the station sends a control frame called the request to send (RTS).
2. After receiving the RTS and waiting a period of time called the short inter frame space (SIFS), the destination
station sends a control frame, called the clear to send (CTS), to the source station. This control frame indicates
that the destination station is ready to receive data.
3. The source station sends data after waiting an amount of time equal to SIFS.
4. The destination station, after waiting an amount of time equal to SIFS, sends an acknowledgment to show that
the frame has been received.
• When a station sends an RTS frame, it includes the duration of time that it needs to occupy the channel.
• The stations that are affected by this transmission create a timer called a Network Allocation Vector (NAV)
that shows how much time must pass before these stations are allowed to check the channel for idleness.
• Each time a station accesses the system and sends an RTS frame, other stations start their NAV. Each station,
before sensing the physical medium to see if it is idle, first checks its NAV to see if it has expired. Figure 2.33
shows the idea of NAV.
ETHERNET PROTOCOL
A local area network (LAN) is a computer network that is designed for a limited geographic area such as a
building or a campus. LAN can be used as an isolated network to connect computers in an organization for the
sole purpose of sharing resources , most LANs today are also linked to a wide area network (WAN) or the
Internet.
The IEEE has subdivided the data-link layer into two sub layers:
Logical link control (LLC)
In IEEE Project 802, flow control, error control, and part of the framing duties are collected into one sub layer
called the logical link control (LLC). Framing is handled in both the LLC sublayer and the MAC sublayer.
The LLC provides a single link-layer control protocol for all IEEE LANs. This means LLC protocol can provide
interconnectivity between different LANs because it makes the MAC sub layer transparent.
Media access control (MAC)
IEEE Project 802 has created a sublayer called media access control that defines the specific access method for
each LAN. For example, it defines CSMA/CD as the media access method for Ethernet LANs and defines the
token-passing method for Token Ring and Token Bus LANs.
Part of the framing function is also handled by the MAC layer.
26
The Ethernet LAN was developed in the 1970s by Robert Metcalfe and David Boggs. The four generations
of Ethernet are : 1. Standard Ethernet (10 Mbps) 2. Fast Ethernet (100 Mbps) 3. Gigabit Ethernet (1 Gbps) and 4.
10 Gigabit Ethernet (10 Gbps)
STANDARD ETHERNET
Ethernet provides a connectionless service, which means each frame sent is independent of the previous or
next frame. Ethernet has no connection establishment or connection termination phases.
The sender sends a frame whenever it has , the receiver may or may not be ready for it. The sender may
overwhelm the receiver with frames, which may result in dropping frames. If a frame drops, the sender will not
know about it. Since IP, which is using the service of Ethernet, is also connectionless, it will not know about it
either. If the transport layer is also a connectionless protocol, such as UDP, the frame is lost and salvation may
only come from the application layer. If the transport layer Protocol is TCP, the sender TCP does not receive
acknowledgment for its segment and sends it again.
Ethernet is also unreliable like IP and UDP. If a frame is corrupted during transmission and the receiver finds
out about the corruption, which has a high level of probability of happening because of the CRC-32, the receiver
drops the frame silently. It is the duty of high-level protocols to find out about it.
2. Frame Format
27
1. Preamble. This field contains 7 bytes (56 bits) of alternating 0s and 1s that alert the receiving system to the
coming frame and enable it to synchronize its clock if it’s out of synchronization. The pattern provides only an
alert and a timing pulse. The preamble is added at the physical layer and is not part of the frame.
2. Start frame delimiter (SFD). This field (1 byte: 10101011) signals the beginning of the frame. The SFD warns
the station or stations that this is the last chance for synchronization. The last 2 bits are (11)2 and alert the
receiver that the next field is the destination address. This field is actually a flag that defines the beginning of
the frame, an Ethernet frame is a variable-length frame. It needs a flag to define the beginning of the frame. The
SFD field is also added at the physical layer.
3. Destination address (DA). This field is six bytes (48 bits) and contains the link layer address of the destination
station or stations to receive the packet. When the receiver sees its own link-layer address, or a multicast address
for a group that the receiver is a member of, or a broadcast address, it decapsulates the data from the frame and
passes the data to the upper layer protocol defined by the value of the type field.
4. Source address (SA). This field is also six bytes and contains the link-layer address of the sender of the packet.
5. Type. This field defines the upper-layer protocol whose packet is encapsulated in the frame. This protocol can
be IP, ARP, OSPF, and so on. It is used for multiplexing and demultiplexing.
6. Data: This field carries data encapsulated from the upper-layer protocols. It is a minimum of 46 and a
maximum of 1500 bytes. If the data coming from the upper layer is more than 1500 bytes, it should be
fragmented and encapsulated in more than one frame. If it is less than 46 bytes, it needs to be padded with extra
0s. A padded data frame is delivered to the upper-layer protocol as it is (without removing the padding), which
means that it is the responsibility of the upper layer to remove or, in the case of the sender, to add the padding.
The upper-layer protocol needs to know the length of its data. For example, a datagram has a field that defines
the length of the data.
7. CRC. The last field contains error detection information. The CRC is calculated over the addresses, types, and
data field. If the receiver calculates the CRC and finds that it is not zero (corruption in transmission), it discards
the frame.
3. Frame Length
Ethernet has imposed restrictions on both the minimum and maximum lengths of a frame. The minimum
length restriction is required for the correct operation of CSMA/CD.
An Ethernet frame needs to have a minimum length of 512 bits or 64 bytes. Part of this length is the header
and the trailer. If we count 18 bytes of header and trailer (6 bytes of source address, 6 bytes of destination
address, 2 bytes of length or type, and 4 bytes of CRC), then the minimum length of data from the upper layer is
64 − 18 = 46 bytes. If the upper-layer packet is less than 46 bytes, padding is added to make up the difference.
The standard defines the maximum length of a frame (without preamble and SFD field) as 1518 bytes. If we
subtract the 18 bytes of header and trailer, the maximum length of the payload is 1500 bytes.
28
1. First, memory was very expensive when Ethernet was designed, a maximum length restriction helped to
reduce the size of the buffer.
2. Second, the maximum length restriction prevents one station from monopolizing the shared medium,
blocking other stations that have data to send.
Addressing
Each station on an Ethernet network (such as a PC, workstation, or printer) has its own network interface
card (NIC). The NIC fits inside the station and provides the station with a link-layer address. The Ethernet address
is 6 bytes (48 bits), normally written in hexadecimal notation, with a colon between the bytes.
A source address is always a unicast address, the frame comes from only one station. The destination
address can be unicast, multicast, or broadcast. Figure 2.38 shows how to distinguish a unicast address from a
multicast address.
If the least significant bit of the first byte in a destination address is 0, the address is unicast, or is 1 , it is
multicast. The way the bits are transmitted, the unicast/multicast bit is the first bit which is transmitted or
received. The broadcast address is a special case of the multicast address: the recipients are all the stations on
the LAN. A broadcast destination address is forty-eight 1s.
Access Method
The network that uses the standard Ethernet protocol is a broadcast network. The standard Ethernet chose
CSMA/CD with 1-persistent method; let us use a scenario to see how this method works for the Ethernet
protocol.
➢Assume station A has a frame to send to station D as shown in 2.37 a. Station A first should check whether any
other station is sending (carrier sense). Station A measures the level of energy on the medium (for a short period
of time, normally less than 100µs).
If there is no signal energy on the medium, it means that no station is sending (or the signal has not
reached station A). Station A interprets this situation as idle medium. It starts sending its frame.
29
If the signal energy level is not zero, it means that the medium is being used by another station. Station
A continuously monitors the medium until it becomes idle for 100µs. It then starts sending the frame. Station A
needs to keep a copy of the frame in its buffer until it is sure that there is no collision.
➢ The medium sensing does not stop after station A has started sending the frame. Station A needs to send and
receive continuously. Two cases may occur:
(a) Station A has sent 512 bits and no collision is sensed, then the station is sure that the frame will go through
and stops sensing the medium. If a collision were to occur, it should occur by the time the sender has sent out
512 bits (worst case) and the first bit has made a round trip of 5120 meters, if the collision happens in the middle
of the cable, not at the end, station A hears the collision earlier and aborts the transmission. The above
assumption is that the length of the cable is 5120 meters. The designer of the standard Ethernet put a
restriction of 2500 meters because we need to consider the delays encountered throughout the journey.
The whole idea is that if station A does not sense the collision before sending 512 bits, there must have
been no collision, because during this time, the first bit has reached the end of the line and all other stations
know that a station is sending and refrain from sending. The restriction of 512 bits helps the sending station: The
sending station is certain that no collision will occur if it is not heard during the first 512 bits, so it can discard the
copy of the frame in its buffer.
(b) Station A has sensed a collision before sending 512 bits. This means that one of the previous bits has collided
with a bit sent by another station. In this case both stations should refrain from sending and keep the frame in
their buffer for resending when the line becomes available.
To inform other stations that there is a collision in the network, the station sends a 48-bit jam signal. The
jam signal is to create enough signal to alert other stations about the collision.
After sending the jam signal, the stations need to increment the value of K (number of attempts). If after
increment K = 15, the experience has shown that the network is too busy, the station needs to abort its effort and
try again. If K < 15, the station can wait a backoff time (TB) and restart the process.
The station creates a random number between 0 and 2K − 1, which means each time the collision occurs,
the range of the random number increases exponentially. After the first collision (K =1) the random number is in
the range (0, 1). After the second collision (K = 2) it is in the range (0, 1, 2, 3). After the third collision (K = 3) it is in
the range (0, 1, 2, 3, 4, 5, 6, 7).
So, after each collision, the probability increases that the backoff time becomes longer. This is due to
the fact that if the collision happens even after the third or fourth attempt, it means that the network is really
busy , a longer backoff time is needed.
30
The efficiency of the Ethernet is defined as the ratio of the time used by a station to send data to the time the
medium is occupied by this station.
Efficiency = 1/(1+6.4xa)
Where, a= the number of frames that can fit on the medium. a= (Propagation delay)/ (Transmission delay)
The transmission delay is the time it takes a frame of average size to be sent out and the propagation
delay is the time it takes to reach the end of the medium. As the value of parameter decreases, the efficiency
increases. This means that if the length of the media is shorter or the frame size longer, the efficiency increases.
In the ideal case, = 0 and the efficiency is 1.
Implementation
The Standard Ethernet defined several implementations, but only four of them became popular.
31
10Base-T: Twisted-Pair
Ethernet The third implementation is called 10Base-T or twisted-pair Ethernet.
Uses a physical star topology. The stations are connected to a hub via two pairs of twisted cable,
Two pairs of twisted cable create two paths (one for sending and one for receiving) between the station
and the hub.
Any collision here happens in the hub.
The maximum length of the twisted cable here is defined as 100 m, to minimize the effect of attenuation
in the twisted cable.
32
WIRELESS LANS
Wireless communication is one of the fastest-growing technologies. The demand for connecting devices
without the use of cables is increasing everywhere. Wireless LANs can be found on college campuses, in office
buildings, and in many public areas.
Architectural Comparison
1. Medium: In a wireless LAN, the medium is air, the signal is generally broadcast. When hosts in a
wireless LAN communicate with each other, they are sharing the same medium (multiple access).
2. Hosts: In a wired LAN, a host is always connected to its network at a point with a fixed link layer
address related to its network interface card (NIC). A host can move from one point in the Internet to another
point, its link-layer address remains the same, but its network-layer address will change. Before the host can use
the services of the Internet, it needs to be physically connected to the Internet. In a wireless LAN, a host is not
physically connected to the network, it can move freely and can use the services provided by the network.
3. Isolated LANs: A wired isolated LAN is a set of hosts connected via a link-layer switch. A wireless
isolated LAN, called an ad hoc network in wireless LAN terminology, is a set of hosts that communicate freely
with each other. The concept of a link-layer switch does not exist in wireless LANs.
33
Figure 2.45 Connection of a wired LAN and a wireless LAN to other Networks
4. Connection to Other Networks: A wired LAN can be connected to another network or an internetwork
such as the Internet using a router. A wireless LAN may be connected to a wired infrastructure network, to a
wireless infrastructure network, or to another wireless LAN.
5. Moving between Environments: In order to move from the wired environment to a wireless
environment, need to change the network interface cards designed for wired environments to the ones designed
for wireless environments. Replace the link-layer switch with an access point. The link-layer addresses will change
but the network-layer addresses (IP addresses) will remain the same in the movement from wired links to
wireless links.
Access Control
The most important issue in a wireless LAN is access control. The CSMA/CD algorithm does not work in
wireless LANs for three reasons:
1. To detect a collision, a host needs to send and receive at the same time (sending the frame and
receiving the collision signal), which means the host needs to work in a duplex mode. Wireless hosts do not have
enough power to do so (the power is supplied by batteries). They can only send or receive at one time.
2. Hidden station problem, a station may not be aware of another station’s transmission due to some
obstacles or range problems, collision may occur but not be detected. Hidden stations can reduce the capacity of
the network because of the possibility of collision.
3. The distance between stations can be long. Signal fading could prevent a station at one end from
hearing a collision at the other end.
To overcome the above three problems, Carrier Sense Multiple Access with Collision Avoidance
(CSMA/CA) was invented for wireless LANs.
34