The goal of this exercise is to investigate the impact of contention window size on the performance of the IEEE 802.11 MAC protocol. IEEE 802.11 specification requires all nodes to choose a random back off interval between zero and CW (contention window), and wait for the chosen number of slot times before trying to access the channel. Initially, CW is set to CWMin (minimum contention window size). However, when there is a collision, the contention window size is doubled, until a maximum value: CWMax. This technique of randomization and scaling the contention window size is used to reduce collisions. In our study however, we will consider a variant of 802.11 where the contention window size is fixed, i.e., CWMin=CWmax=CW. We will not scale the contention window, but still use randomization.
We will need a topology under which to study the effect of contention window sizes. For this, let us choose a single hop network where all nodes are in range of each other. Specifically we consider a 150m X 150m area. All nodes are involved in two Constant Bit Rate (CBR) conversations: one as source, and one as destination.
$val(mac) set CWMin_ 31 $val(mac) set CWMax_ 31
In the lines above, CWMin and CWMax have been set to 31. You will manually change these values when asked to do so, using a text editor of your choice.
ns cwsim.tcl -rlen 2
To calculate PDR, you will need to know the number of packets sent and number of packets received. In this example, to get the number of packets sent, you can use the following command:
grep AGT cwsim.tr |grep ^s |grep cbr|wc -l
The number reported above is the number of packets sent by all nodes. To get the number of packets received, you can use a similar command:
grep AGT cwsim.tr |grep ^r |grep cbr|wc -l
The reported number above is the number of packets received (should be less than equal to the number of packets sent). The ratio of [Packets Received] / [Packets Sent] is the PDR.
To get the throughput, since all flows are a CBR, with a constant packet size of 512 bytes, just multiply number of packets received with 512 x 8 and divide by total simulation time (25 seconds for this example), i.e, Throughput in bits/second = 512 x 8 x [Packets Received] / 25 .
To understand more about the trace file and what it contains, refer to sections 16.1.6 and 16.1.7 of the ns2 manual.
This assignment lets you
correlate the CW size and network size/density. The trend may or may
not be very clear due to factors like interference with increase in
density etc. Try to answer following questions with respect to the
graph obtained above-
1. What trends do you observe? Do you observe any optimal CW size for each network population?
2. If yes, does the optimal window size exhibit any particular relationship with the network population?
3. Can you predict what would happen if you try to run this script for rlen = 6? Explain.
4. Could you explain what the grep command does to extract information from the trace file?
1. What is contention window?
2. Overview of IEEE 802.11
3. Know ns2