mac layer
mac layer
Throughput
• Let us call G the average number of frames generated by the system during one frame
transmission time.
• Then it can be proven that the average number of successfully transmitted frames for pure
ALOHA is S = G × e-2G.
• The maximum throughput Smax is 0.184, for G = 1/2. (We can find it by setting the
derivative of S with respect to G to 0.)
• In other words, if one-half a frame is generated during one frame
transmission time (one frame during two frame transmission times),
then 18.4 percent of these frames reach their destination successfully.
• We expect G = 1/2 to produce the maximum throughput because the
vulnerable time is 2 times the frame transmission time.
• Therefore, if a station generates only one frame in this vulnerable time
(and no other stations generate a frame during this time), the frame
will reach its destination successfully.
• The throughput for pure ALOHA is S = G × e−2G.
• The maximum throughput Smax = 1/(2e) = 0.184 when G = 1/2.
Example A pure ALOHA network transmits 200-bit frames on a shared
channel of 200 kbps. Find the throughput for each of the following
frames per second produced by the system.
• a. 1000
• b. 500
• c. 250
Solution
• The frame transmission time is 200/200 kbps or 1 ms.
a. If the system creates 1000 frames per second, or 1 frame per
millisecond, then G = 1. In this case, S = G × e−2G = 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.
b. If the system creates 500 frames per second, or 1/2 frame per
millisecond, then G = 1/2. In this case, S = G × e−2G = 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, or 1/4 frame per
millisecond, then G = 1/4. In this case, S = G × e−2G = 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
• 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.
• Figure shows an example of frame collisions in slotted ALOHA.
• Because a station is allowed to send only at the beginning
of the synchronized time slot, if a station misses this
moment, it must wait until the beginning of the next time
slot.
• This means that the station that started at the beginning of
this slot has already finished sending its frame.
• Of course, there is still the possibility of collision if two
stations try to send at the beginning of the same time slot.
• However, the vulnerable time is now reduced to one-half,
equal to Tfr. Figure shows this situation.
• Throughput
• It can be proven that the average number of successful transmissions for slotted
ALOHA is S = G × e−G.
• The maximum throughput Smax is 0.368, when G = 1.
• In other words, if one frame is generated during one frame transmission time,
then 36.8 percent of these frames reach their destination successfully.
• We expect G = 1 to produce maximum throughput because the vulnerable time
is equal to the frame transmission time.
• Slotted ALOHA vulnerable time = Tfr
• Therefore, if a station generates only one frame in this vulnerable time
(and no other station generates a frame during this time), the frame will
reach its destination successfully.
• The throughput for slotted ALOHA is S = G × e−G.
• The maximum throughput Smax = 0.368 when G = 1.
• Example
• A slotted ALOHA network transmits 200-bit frames
using a shared channel with a 200-kbps bandwidth.
Find the throughput for each of the following frames
per second produced by the system (all stations
together).
a. 1000
b. 500
c. 250
• Solution
• The frame transmission time is 200/200 kbps or 1 ms.
a. In this case G is 1. So S = G × e−G = 0.368 (36.8 percent). This
means that the throughput is 1000 × 0.0368 = 368 frames. Only 368 out of
1000 frames will probably survive. Note that this is the maximum throughput
case, percentage wise.
b. Here G is 1/2. In this case S = G × e−G = 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. Now G is 1/4. In this case S = G × e−G = 0.195 (19.5 percent). This
means that the throughput is 250 × 0.195 = 49. Only 49 frames out of 250
will probably survive.
Carrier Sense Multiple Access (CSMA)
• 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.
• In other words, 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, a space and time model of a
CSMA network.
• Stations are connected to a shared channel (usually a dedicated medium).
• 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.
• In other words, 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 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.
Vulnerable time in CSMA
• Persistence Methods
• What should a station do if the channel is busy?
• What should a station do if the channel is idle?
• Three methods have been devised to answer these
questions:
• 1- persistent method,
• nonpersistent method, and
• p-persistent method.
• Figure shows the behavior of these three persistence
methods when a station finds a channel busy.
• 1-Persistent
• The 1-persistent method is simple and straightforward.
• In this method, after the station finds the line idle, it sends its frame immediately (with probability 1).
• This method has the highest chance of collision because two or more stations may find the line idle and
send their frames immediately.
• Nonpersistent
• In the nonpersistent method, a station that has a frame to send senses the line.
• If the line is idle, it sends immediately.
• If the line is not idle, it waits a random amount of time and then senses the line again.
• The nonpersistent approach reduces the chance of collision because it is unlikely that two or more stations
will wait the same amount of time and retry to send simultaneously.
• However, this method reduces the efficiency of the network because the medium remains idle when there
may be stations with frames to send.
• p-Persistent
• 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.
• 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:
1. With probability p, the station sends its frame.
2. With probability q = 1 − p, the station waits for
the beginning of the next time slot and checks the
line again.
a. If the line is idle, it goes to step 1.
b. If the line is busy, it acts as though a collision has
occurred and uses the backoff procedure.
• CSMA/CD
• The CSMA method does not specify the procedure following a collision.
• Carrier sense multiple access with collision detection (CSMA/CD)
augments the algorithm to handle the collision.
• In this method, a station monitors the medium after it sends a frame to
see if the transmission was successful.
• If so, the station is finished.
• If, however, there is a collision, the frame is sent again.
• To better understand CSMA/CD, let us look at the first bits transmitted
by the two stations involved in the collision.
• Although each station continues to send bits in the frame until it detects
the collision, we show what happens as the first bits collide.
• In Figure, stations A and C are involved in the collision.
• 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 (or after a short time, but we assume immediately) aborts
transmission.
• Station A detects a collision at time t4 when it receives the first bit of C’s frame; it also
immediately aborts transmission.
• Looking at the above Figure, we see that A transmits for the duration t4 − t1; C transmits
for the duration t3 − t2.
• Now that we know the time durations for the two transmissions, we can show a more
complete graph in Figure.
• Minimum Frame Size
• For CSMA/CD to work, we need a restriction on the frame size.
• Before sending the last bit of the frame, the sending station must detect a
collision, if any, and abort the transmission.
• This is so because the station, once the entire frame is sent, 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 2 times the
maximum propagation time Tp.
• To understand the reason, let us think about the worst-case scenario.
• 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.
• Example
• 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) is 25.6 μs, what is
the minimum size of the frame?
• Solution
• The minimum 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.
• Procedure
• Now let us look at the flow diagram for CSMA/CD in Figure.
• It is similar to the one for the ALOHA protocol, but there are
differences.
• The first difference is the addition of the persistence process.
• We need to sense the channel before we start sending the frame
by using one of the persistence processes we discussed
previously (nonpersistent, 1-persistent, or p-persistent).
• The corresponding box can be replaced by one of the
persistence processes shown in Figure (Flow diagram for three
persistence methods 3.32).
• The second difference is the frame transmission.
• In ALOHA, we first transmit the entire frame and then wait for an acknowledgment.
• In CSMA/CD, transmission and collision detection is a continuous process.
• We do not send the entire frame and then look for a collision.
• The station transmits and receives continuously and simultaneously (using two different
ports or a bidirectional port).
• We use a loop to show that transmission is a continuous process.
• We constantly monitor to detect one of two conditions: Either transmission is finished,
or a collision is detected.
• Either event stops transmission.
• When we come 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.
• The third difference is the sending of a short jamming signal to make sure that all other
stations become aware of the collision.
• Energy Level
• We can say that the level of energy in a channel can have
three values: zero, normal, and abnormal.
• At the zero level, the channel is idle.
• At the normal level, a station has successfully captured the
channel and is sending its frame.
• At the abnormal level, there is a collision and the level of
the energy is twice the normal level.
• 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.
• Figure shows the situation.
• 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 nonpersistent method, the maximum
throughput can go up to 90 percent when G is between
3 and 8.
• Traditional Ethernet
• One of the LAN protocols that used CSMA/CD is the traditional
Ethernet with the data rate of 10 Mbps.
• It is good to know that the traditional Ethernet was a broadcast LAN
that used 1-persistence method to control access to the common
media.
• CSMA/CA
• A variation of the CSMA method is Carrier Sense Multiple Access
with Collision Avoidance (CSMA/CA), which is used in wireless
LANs.
• 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 controlled-access methods: reservation, polling, and token
passing.
• Reservation
• Reservation access method
• Polling
• Polling works with topologies in which one device is designated as a
primary station and the other devices are secondary stations.
• All data exchanges must be made through the primary device even
when the ultimate destination is a secondary device.
• The primary device controls the link; the secondary devices follow its
instructions.
• It is up to the primary device to determine which device is allowed to
use the channel at a given time.
• The primary device, therefore, is always the initiator of a session (see
Figure).
• This method uses poll and select functions to prevent collisions.
• However, the drawback is if the primary station fails, the system goes
down.
• Select
• The select function is used whenever the primary device has
something to send.
• Remember that the primary controls the link.
• If the primary is neither sending nor receiving data, it knows the
link is available.
• If it has something to send, the primary device sends it.
• What it does not know, however, is whether the target device is
prepared to receive.
• So the primary must alert the secondary to the upcoming
transmission and wait for an acknowledgment of the secondary’s
ready status.
• Before sending data, the primary creates and transmits a select
(SEL) frame, one field of which includes the address of the
intended secondary.
• Poll
• The poll function is used by the primary device to solicit
transmissions from the secondary devices.
• When the primary is ready to receive data, it must ask (poll)
each device in turn if it has anything to send.
• When the first secondary is approached, it responds either
with a NAK frame if it has nothing to send or with data (in
the form of a data frame) if it does.
• If the response is negative (a NAK frame), then the primary
polls the next secondary in the same manner until it finds
one with data to send.
• When the response is positive (a data frame), the primary
reads the frame and returns an acknowledgment (ACK
frame) verifying its receipt.
• Token Passing
• In the token-passing method, the stations in a network are organized
in a logical ring.
• In other words, for each station, there is a predecessor and a
successor.
• The predecessor is the station that is logically before the station in the
ring; the successor is the station that is after the station in the ring.
• The current station is the one that is accessing the channel now.
• The right to this access has been passed from the predecessor to the
current station.
• The right will be passed to the successor when the current station has
no more data to send.
• But how is the right to access the channel passed from one station to
another?
• In this method, a special packet called a token circulates
through the ring.
• The possession of the token gives the station the right to access
the channel and send its data.
• When a station has some data to send, it waits until it receives
the token from its predecessor.
• It then holds the token and sends its data.
• When the station has no more data to send, it releases the
token, passing it to the next logical station in the ring.
• The station cannot send data until it receives the token again in
the next round.
• In this process, when a station receives the token and has no
data to send, it just passes the data to the next station.
• Token management is needed for this access method.
• Stations must be limited in the time they can have possession
of the token.
• The token must be monitored to ensure it has not been lost or
destroyed.
• For example, if a station that is holding the token fails, the
token will disappear from the network.
• Another function of token management is to assign priorities
to the stations and to the types of data being transmitted.
• And finally, token management is needed to make low-priority
stations release the token to high-priority stations.
• Logical Ring
• In a token-passing network, stations do not have to be physically
connected in a ring; the ring can be a logical one.
• Figure shows four different physical topologies that can create a
logical ring.
• In the physical ring topology, when a station sends the token to its
successor, the token cannot be seen by other stations; the successor
is the next one in line.
• This means that the token does not need to have the address of the
next successor.
• The problem with this topology is that if one of the links—the
medium between two adjacent stations—fails, the whole system
fails.
• The dual-ring topology uses a second (auxiliary) ring that operates in the
reverse direction compared with the main ring.
• The second ring is for emergencies only (such as a spare tire for a car).
• If one of the links in the main ring fails, the system automatically
combines the two rings to form a temporary ring.
• After the failed link is restored, the auxiliary ring becomes idle again.
• Note that for this topology to work, each station needs to have two
transmitter ports and two receiver ports.
• The high speed Token Ring networks called FDDI (Fiber Distributed Data
Interface) and CDDI (Copper Distributed Data Interface) use this
topology.
• In the bus ring topology, also called a token bus, the stations are connected to a single cable
called a bus.
• They, however, make a logical ring, because each station knows the address of its successor
(and also pedecessor for token management purposes).
• When a station has finished sending its data, it releases the token and inserts the address of its
successor in the token.
• Only the station with the address matching the destination address of the token gets the token
to access the shared media.
• The Token Bus LAN, standardized by IEEE, uses this topology.
• In a star ring topology, the physical topology is a star.
• There is a hub, however, that acts as the connector.
• The wiring inside the hub makes the ring; the stations are connected to this ring through the
two wire connections.
• This topology makes the network less prone to failure because if a link goes down, it will be
bypassed by the hub and the rest of the stations can operate.
• Also adding and removing stations from the ring is easier.
• This topology is still used in the Token Ring LAN designed by IBM.
• LINK-LAYER ADDRESSING
• The next issue we discuss about the data-link layer is the link-layer
addresses.
• IP addresses are the identifiers at the network layer that define
exact points in the Internet where the source and destination hosts
are connected.
• However, 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.
• Therefore we need another addressing mechanism in a connectionless
internetwork: the link-layer addresses of the two nodes.
• A link-layer address is sometimes called a link address, sometimes a
physical address, and sometimes a MAC address.
• We use these terms interchangeably.
• Because 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.
• In above Figure, we have three links and two routers.
• We also have shown only two hosts: Alice (source) and Bob (destination).
• For each host, we have shown two addresses, the IP addresses (N) and the link-
layer addresses (L).
• Note that a router has as many pairs of addresses as the number of links the
router is connected to.
• We have shown three frames, one in each link.
• Each frame carries the same datagram with the same source and destination
addresses (N1 and N8), but the link-layer addresses of the frame change from
link to link. In link 1, the link-layer addresses are L1 and L2. In link 2, they are
L4 and L5. In link 3, they are L7 and L8.
• Note that the IP addresses and the link-layer addresses are not in the same
order.
• For IP addresses, the source address comes before the destination address; for
link-layer addresses, the destination address comes before the source.
• The datagrams and frames are designed in this way, and we follow the design.
• We may raise several questions:
• 1. If the IP address of a router does not appear in any datagram sent from a
source to a destination, why do we need to assign an IP address to the
router?
• The answer is that in some protocols a router may act as a sender or receiver
of a datagram. For example, in the routing protocols, a router is a sender or
a receiver of a message. The communications in these protocols are between
routers.
• 2. Why do we need more than one IP address in a router? Do we need one
for each interface?
• The answer is that an interface is a connection of a router to a link. We will
see that an IP address defines a point in the Internet at which a device is
connected. A router with n interfaces is connected to the Internet at n points.
This is like the situation where a house is at the corner of a street with two
gates; each gate has the address related to the corresponding street.
• 3. How are the source and destination IP addresses in a packet determined?
• The answer is that the host should know its own IP address, which becomes
the source IP address in the packet. The application layer uses the services
of the DNS to find the destination address of the packet and passes it to the
network layer to be inserted in the packet.
• 4. How are the source and destination link-layer addresses determined for
each link?
• Again, each hop (router or host) should know its own link-layer address.
The destination link-layer address is determined by using the Address
Resolution Protocol.
• 5. What is the size of link-layer addresses?
• The answer is that it depends on the protocol used by the link. Although we
have only one IP protocol for the whole Internet, we may be using different
data-link protocols in different links. This means that we can define the size
of the address when we discuss different link layer protocols.
• Three Types of Addresses
• Some link-layer protocols define three types of addresses: unicast, multicast, and broadcast.
• 1. 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.
• The unicast link-layer addresses in the most common LAN, the Ethernet, are 48 bits (6 bytes) that are
presented as 12 hexadecimal digits separated by colons; for example, the following is a link-layer
address of a computer. A2:34:45:11:92:F1
• 2. Multicast Address
• Some link-layer protocols define multicast addresses. Multicasting means one-to many
communication. However, the jurisdiction is local (inside the link).
• The multicast link-layer addresses in the most common LAN, the Ethernet, are 48 bits (6 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.
• The broadcast link-layer addresses in the most common LAN, the Ethernet, are 48 bits that are all 1s
and presented as 12 hexadecimal digits separated by colons. The following shows a broadcast address:
FF:FF:FF:FF:FF:FF