0% found this document useful (0 votes)
72 views5 pages

Lab #2: Contention-Aware Scheduling To in Wireless Networks

This document describes Lab #2 for a computer networks course. The goal is to investigate whether a contention-aware scheduling algorithm can improve throughput in a multi-hop wireless network simulated using ns-2. Part 1 involves demonstrating throughput loss due to contention at node B. Part 2 involves developing a scheduling algorithm that aborts transmissions after a few retries and schedules other packets, to improve throughput for nodes C and D without reducing throughput for node B. Modifications to ns-2 source code are required to implement the new scheduling algorithm.

Uploaded by

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

Lab #2: Contention-Aware Scheduling To in Wireless Networks

This document describes Lab #2 for a computer networks course. The goal is to investigate whether a contention-aware scheduling algorithm can improve throughput in a multi-hop wireless network simulated using ns-2. Part 1 involves demonstrating throughput loss due to contention at node B. Part 2 involves developing a scheduling algorithm that aborts transmissions after a few retries and schedules other packets, to improve throughput for nodes C and D without reducing throughput for node B. Modifications to ns-2 source code are required to implement the new scheduling algorithm.

Uploaded by

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

CS 660 Computer Networks : Assignments : Lab #2

Page 1 of 5

Lab #2: Contention-Aware Scheduling to in Wireless Networks


Overview
The main goal of this assignment is to determine whether it is possible to improve throughput
in a multi-hop wireless network by using a contention-aware scheduling algorithm. Additional
goals for this assignment include: (1) to familiarize yourself with the ns network simulator, (2)
to understand the process of conducting a simulation and evaluating the simulation data, and
(3) to learn how to clearly present your work to others.
Consider the following network:

In this network, node A has three separate TCP flows from itself to nodes B, C, and D. Nodes C
and D are in areas where there is no other traffic, s othey are ready to receive data at any time.
Node B, however, is within the interference range of nodes X and Y, causing it to be periodically
unable to exchange data with A, due to interference that interferes with its ability to contend for
the wireless medium.
Typically, node A will have a queue of frames to send to nodes B, C, and D, and it will schedule
them in first-come-first-served order. Every time it tries to send a frame to B, if B is unable to
respond, it will time out after 7 tries to send an RTS message and then drop the frame. The
routing protocol will then assume the route is broken and try to find a new route. Both the
inability to send to B and the extra routing traffic will interfere with the throughput of the flows
to nodes C and D.
In this assignment, we will investigate whether a different scheduling algorithm at node A can
improve throughput for nodes C and D, without seriously affecting node B's throughput. The
basic idea is to schedule packets to nodes C and D while B is busy or is suffering from
interference.
The ns2 simulator
For this assignment, we will be using the ns2 network simulator. This is the most commonly
used software in the Internet research community, and because of this popularity there are
many protocols written for it. Most TCP research uses ns, so it has a large set of TCP variants.
ns2 is an event-driven, packet-level simulator. This means that the simulator steps through a
series of events using a simulated notion of time, and it simulates each packet in a connection.
As a result, ns2 is very effective at simulating the detailed behavior of a single TCP connection,
but it is somewhat harder to use it to study a very large number of connections with a peer-topeer protocol.
Using ns-2
To run ns-2, you call a Tcl script to create a network topology; define which applications will be

file://D:\011208\CS 660 Computer Networks Assignments Lab #2.htm

12/3/2008

CS 660 Computer Networks : Assignments : Lab #2

Page 2 of 5

running, what transport protocol the applications will use, and where the senders and receivers
are located; and configure a series of events. The file oneflow-wireless.tcl lists an example ns-2
Tcl script for a wireless environment. This script sets up the following topology:

The first part of the script:


set ns [new Simulator]
creates a new instance of the simulator and sets it equal to a variable so that we can reference
this in later steps.
Next the script opens a file and tells ns to store all trace output in this file. Note that the script
issues a command to use a new trace format.
set f [open distant.tr w]
$ns trace-all $f
$ns use-newtrace
This will record all packet events in the listed file, including every time a packet is queued,
dequeued, or dropped at a router and every time a packet is received by a host.
Next the script establishes wireless parameters:
set
set
set
set
set
set
set
set
set
set
set
set

val(chan)
val(prop)
val(netif)
val(mac)
val(ifq)
val(ll)
val(ant)
val(ifqlen)
val(rp)
val(x)
val(y)
val(nn)

Channel/WirelessChannel
Propagation/TwoRayGround
Phy/WirelessPhy
Mac/802_11
Queue/DropTail/PriQueue
LL
Antenna/OmniAntenna
10
DSR
1500
200
4

;#
;#
;#
;#
;#
;#
;#
;#
;#
;#
;#
;#

channel type
radio-propagation model
network interface type
MAC type
interface queue type
link layer type
antenna model
max packet in ifq
routing protocol
X dimension of topography
Y dimension of topography
number of mobile nodes

These will be used later. Next it creates the network area:


set topo [new Topography]
$topo load_flatgrid $val(x) $val(y)
Mobile nodes, since they move around, must be constrined to a certain area. In wireless
simulations it is also useful to have an entity that can see everything that happens, so it can
calulate interference, cause collisions, etc. The script does this here:
create-god $val(nn)
Next the script creates a wireless channel:
set chan_1_ [new $val(chan)]

file://D:\011208\CS 660 Computer Networks Assignments Lab #2.htm

12/3/2008

CS 660 Computer Networks : Assignments : Lab #2

Page 3 of 5

and configures various wireless parameters with the simulation object:


$ns node-config -adhocRouting $val(rp)

-llType $val(ll)

-macType $v

Next the script creates the nodes and establishes a TCP connection between them. First it
creates the nodes and their positions in the field:
set n0 [$ns node]
set n1 [$ns node]
$n0 set X_ 100
$n0 set Y_ 100
$n0 set Z_ 0
$n1 set X_ 300
$n1 set Y_ 100
$n1 set Z_ 0
Then it creates a TCP source and destination (a one-way flow):
set src1 [new Agent/TCP/Sack1]
set dst1 [new Agent/TCPSink]
and attaches them to the two nodes:
$ns attach-agent $n0 $src1
$ns attach-agent $n1 $dst1
$ns connect $src1 $dst1
Third, it establishes a traffic generation model, in this case an FTP application with an unlimited
stream of data to be sent:
set ftp1 [new Application/FTP]
$ftp1 attach-agent $src1
The final steps are to create the events the simulation needs to run. The script starts the FTP
flow at the beginning of virtual time, time 0:
$ns at 0.00 "$ftp1 start"
and ends the simulation by calling the finish method after 5 simulated minutes:
$ns at 300.0 "finish"
proc finish {} {
global ns
$ns flush-trace
exit 0
}
It then runs the script, which will generate data in the trace file:
$ns run
ns2 Traces
The script uses a new trace format that is documented in the ns-2 manual on page 159.
Additional References

file://D:\011208\CS 660 Computer Networks Assignments Lab #2.htm

12/3/2008

CS 660 Computer Networks : Assignments : Lab #2

Page 4 of 5

To complete this assignment, you should rely on the extensive documentation on the ns web
site. In particular, look at the ns manual, ns for Beginners, and these papers.
Part 1: Loss Due to Contention
Your goal is to setup a topology like the one shown in the overview, so that you can
demonstrate that contention with node B negatively impacts throughput for nodes C and D.
You should run this script both with and without the traffic between nodes X and Y, and then
report the total number of bytes transferred in each case. You should also show plots of TCP
throughput over time -- the throughput at time t should be averaged over the previous 10
packets. Finally, you should show an event graph for node A to demonstrate that failed frame
transmissions are occuring.
To generate an event graph, plot time on the X axis and node number on the Y axis. Then,
designate a symbol for each type of event and plot the symbol at the time the event occurs. For
example, if a circle represents an RTS frame being sent, then show that node A sends seven
RTS frames to node B at some time, while X is sending frames to Y. You can likewise show any
CTS, DATA, and ACK frames that get through.
These graphs can form the basis for demonstrating that a scheduling problem is occuring, which
you will try to fix in the next section.
Part 2: Content-Aware Scheduling
Your goal is to develop a scheduling algorithm for the MAC layer that will abort transmissions to
any node if the RTS message fails 3 times. Instead of notifying the routing protocol, the
scheduler should save this frame for retransmission later and try sending a frame to a different
destination. The scheduler should try to send the postponed frame again after it tries one other
frame. If the scheduler tries three separate times to send the same frame to a destination that
doesn't respond, then it will assume the destination has moved and will notify the routing
protocol to try to find a new route.
Test this new scheduling algorithm by repeating the tests and measurements of Part I,
observing whether throughput is improved for nodes C and D, without decreasing throughput
for node B. You should see no differences if nodes X and Y are not communicating.
The first file you will need to modify is mac/mac-802_11.cc, which handles much of the IEEE
802.11 protocol functionality. Start with the method Mac802_11::RetransmitRTS(), which
will abort the frame transmission if it has tried sending the RTS a certain number of times. You
need to have this method set a condition after three tries, and it should not discard the packet
in this case. Next, modify the method Mac802_11::tx_resume(), which gets called from
Mac802_11::send_timer() after RetransmitRTS() returns. Modify this method so that if the
RTS has failed after three times it calls the callback method with the original packet that was
being sent. This will be a signal to the frame scheduler that this packet needs to be retried
later.
The bulk of you work will then involve creating a new queue class that inherits from the Queue
in queue/queue.h. This queue handler should have a handle() method that is supplied as the
callback to the MAC layer. The handle() method will take the failed frame, save it for later, and
then call the resume() method. It will then need a modified deque() method that can retry the
saved frame at some later point. The handle() method will also need to keep track of the
number of times a frame has been tried and then, if the maximum number of tries is exceeded,
assume the route is broken and call the routing protocol to recompute a route.
Lab Report
Write a report describing the results of your experiments. Your audience for your report is your
fellow students and other networking researchers -- you can assume that they know about

file://D:\011208\CS 660 Computer Networks Assignments Lab #2.htm

12/3/2008

CS 660 Computer Networks : Assignments : Lab #2

Page 5 of 5

networking in general but don't know about the exact topic you have studied. The style of the
report should be a formal paper, as if you were submitting it to a conference.
The report should contain the following sections:
1. Introduction: Describe the purpose of your project and summarize your important results.
2. Part I: Demonstrate that contention for one node can reduce throughput for other nodes.
Describe the purpose of these experiments, your methodology, and the data you
collected. You methodology should include everything a fellow student would need to
replicate your results, including the topologies, workload, and metrics. Then show your
results. Emphasize the most important things and provide a logical structure for your
results. You do not need to include every graph you produced. Instead, include only
those graphs where you see something significant. If several graphs all show the same
thing, then show one graph and summarize the other results.
3. Part II: Demonstrate whether a contention-aware scheduling algorithm can improve
throughput. Describe the purpose of these experiments, your methodology, and the data
you collected. Then show your results.
4. Conclusions: Discuss any conclusions you have drawn from your study and any areas for
future work that this project has inspired.
5. References: List references for related work, if any These should be complete references,
including at a minimum the full names of the authors, the title of the paper, the
conference or journal in which it was published, and the date of publication.
Your paper can be any length, as long as you thoroughly describe your project and results. The
paper must use 11 point type, single spacing, and one column per page. The paper must be
written using LaTeX and the IEEE articleand bibliography These styles are typically used for
submission to many IEEE conferences; there are others for ACM conferences. These files
include documentation on how to use them, and you can see me for any help you need. LaTeX
is a useful publishing tool in the academic work, as it automatically formats in many commonlyused styles. I also find it helps me to focus on content, rather than style, when I am writing a
paper. To help you learn LaTeX, I am including a LaTeX tutorial I wrote, complete with tables,
figures, and bibliography.
Where they are helpful, you are encouraged to include your own figures in your paper. I
suggest using biggles , RPy, or gnuplot.
If you need to draw figures for inclusion in your report (e.g. to diagram the topologies), I
suggest using Inkscape or a similar vector drawing program.

file://D:\011208\CS 660 Computer Networks Assignments Lab #2.htm

12/3/2008

You might also like