|
Quick Public Links
DEGAS Member Links
People
Sponsors
|
|
QualNet Exercises:
Chapter 5. Link Layer and Local Area Networks*
Objective
This exercise is designed to gain a close view of Ethernet's multiple
access protocol -- CSMA/CD. Basic concepts and working details of
carrier sense and collision detection are examined through
implementations and simulations in QualNet simulator.
Overview
First, you will review the main concepts of medium access control (MAC)
and the CSMA/CD protocol specified by IEEE 802.3 standard, including
carrier sense, collision detection, jam sequence transmission, and
exponential back off. Based on these ideas,
you will implement several fuctionalities of the CSMA/CD protocol, starting
with a provided skeleton code for QualNet. Finally, you will run and
test the operations of the CSMA/CD protocol in QualNet.
Procedure
Part 1. Concepts review
.
- Medium Access Control (MAC)
Under the IEEE 802 series of standards, the data link layer of the OSI
Reference Model is subdivided into two sublayers: Logical Link Control
(LLC) and the Medium Access Control (MAC). The MAC sublayer is
responsible for checking the channel and transmitting data if the
channel is idle, checking for occurrence of a collision, and taking a
series of predefined steps if a collision is detected. The MAC layer is
an interface between user data and the physical placement and retrieval
of data on the network.
This exercise focuses on one major
function performed by the MAC sublayer -- transmission medium access
management.
The activities associated with this functionality are:
- Defer transmission if the medium is busy.
- Delay transmission for a specified interframe gap period.
- Present a serial bit stream to the physical layer for transmission.
- Halt transmission when a collision is detected.
- Transmit a jam signal to ensure that the news of a collision propagates
throughout the network.
- Reschedule retransmission after a collision until successful, or until a
specified retry limit is reached.
- Carrier sense
CSMA/CD can be described as a listen-before-speaking multiple access
method. Thus, the first function associated with transmission
media access management is to find out whether any data is
already being transmitted on the network and, if so, to defer
transmission. During the listening process, each station attempts
to sense the carrier signal on the bus, hence the name carrier
sense (CS) is used for this access method.
Under Manchester encoding, a transition occurs in the middle of
each bit period. The binary bit 1 is represented by a high-to-low
transition, while the binary bit 0 is represented by a low-to-high
voltage transition. Thus, an examination of the voltage on the
medium of a base-band network enables a station to determine
whether a carrier is present. If a carrier signal is found, the
station with data to transmit will continue to monitor the
channel.
- Waiting time
If the medium is busy, the station waits until it goes idle;
otherwise it transmits immediately. If two or more stations
simultaneously begin transmitting on an idle cable, they will
collide. All colliding stations then terminate their
transmission, wait for a random time, and repeat the whole process
all over again.
- Collision detection
A transmitting station keeps listening to the channel to check for
collisions while it is sending. Since IEEE 802.3 Manchester encoded
signals have a 1 volt average DC voltage level, a collision
results at an average DC level of 2 volts. Thus, a tranceiver or
network interface card can detect collision by monitoring the
voltage level of the Manchester line signal.
- Jam sequence
If a collision is detected during transmission, the transmitting
station will cease transmitting of data and initiate transmitting
of a jam pattern. The jam pattern consists of 32 ~ 48 bits.
These bits can have any value other than the CRC value that
corresponds to the partial frame transmitted before the jam. The
transmission of the jam pattern ensures that the collision lasts
long enough to be detected by all stations on the network.
- Collision backoff and retransmission
Once a collision is detected, the transmitting station waits for a
random number of time slots before attempting to retransmit. The
term "time slot" represents the time required to transmit 512 bits
on the network. The actual number of time slots the station
waits is selected by a randomization process, formaly known as
"truncated binary exponential backoff". Under this randomization
process, a randomly selected integer r defines the number
of time slots the station must wait before listening again to determine
whether the channel is clear.
The number of time slots to delay before the n-th
retransmission attempt is chosen as a uniformly distributed
random integer r in the range between 0 and
(2^k)-1 , where k=min(n,10). After the backoff, the station
begins to retransmit the frame when it senses the channel to
be free, while listening for another
collision. After a user-defined
maximum number of attempts, the MAC entity assumes that some
problem exists, gives up sending, and reports failure to LLC.
Part 2. Implementation and simulation
In this part, you will fill in codes for the following three
functions in the skeleton QualNet file mac_802_3.cpp
provided below. Please refer to the partial or pseudo codes for these functions
within the file. You do not need to modify
any other functions.
- Mac802_3Layer() : This function handles various messages
received such as MSG_MAC_StartTransmission (which indicates
that some other node has started to send a frame) and
MSG_MAC_TransmissionFinished (which indicates that a frame has
come up to this node), etc.
- Mac802_3SendJamSequence(): This function
creats and broadcasts a jam sequence to inform all nodes
of the collision.
- Mac802_3HandleBackOffSituation(): This function
checks the collision counter. If excessive number of
collisions occured then it rejects the frame. Otherwise, it
schedules a message for future retransmission.
Here are the steps to follow in part 2:
- Download the compressed tar file here, including the skeleton
file (mac_802_3.cpp) to complete and configuration
files (mac_exercise.config and mac_exercise.app) to run.
- Backup the original source file mac_802_3.cpp in QualNet directory
$QUALNET_HOME/libraries/developer/src by renaming it to mac_802_3.original.cpp.
- Copy the downloaded file mac_802_3.cpp into the directory
$QUALNET_HOME/libraries/developer/src and all other files into the
directory $QUALNET_HOME/bin.
- Study the files mac_802_3.original.cpp, mac_802_3.h (in the same directory), and
mac.cpp (in $QUALNET_HOME/main), if needed.
- Fill in the missing codes for above three functions to
complete the skeleton file mac_802_3.cpp,
basesd on the provided inline pseudo codes and comments.
- Re-compile QualNet and run simulation using the configuration file
mac_exercise.config.
Questions
- What happens after a sending station detects a collision ?
- Why does a sending station continue to transmit for some time even
after it detects a collision?
- What is the purpose of the minimum frame size?
How is it computed?
- What is the length of jam sequence in mac_802_3.cpp?
- Submit the generated statistics file (mac_exercise.stat)
and do the following:
- Specify the name(s) of MAC layer statistics related
to collision;
- Point out the instance(s) where frame loss happens due to
collisions, if any;
- Point out the instance(s) where all frames are transmitted
successfully in their first tries, if any.
References and Further Readings
- Sections 5.3.2 and 5.5.2 of the textbook.
- Section 4.5.5 of the QualNet 5.0 Programmer's Guide.
* This exercise is adapted from "Laboratories for Data Communications and
Computer Networking" - Raj Jain, Ohio State University.
DEGAS networking group |
CIS
(302) 831-1951/1131, Newark, DE.
© 2005, DEGAS networking group. All rights reserved.
|