The goal of part I 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.
The goal of part II of this exercise is to see the effect of RTS/CTS, or virtual carrier sending. When RTS/CTS is enabled and a node has a packet to send, the node will first send out an RTS, or a Request-to-Send packet. If the receiving node receives that RTS error-free and the channel is idle, then the receiving node will respond with a CTS, or Clear-to-Send message. This tells the transmitter node that it is OK to send. This method is particularly useful when the transmitter sees the channel as idle, but the receiver does not.
For our simulation, we will use the same topology as in case 1, but we will not vary the CW size. We will vary the number of nodes (rlen), packet size, and turn RTS on and off and record the aggregate throughput.
$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 -rts on -ps 512
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.
$cbr_($i) set packetSize_ $val(ps) $udp_($i) set packetSize_ $val(ps)
In the lines above, the packet size is set to the command line argument -ps. You can set the packet size to 512, for example by using "-ps 512". See part I for an entire command line example.
(PART I)This part 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?
(PART II)This part lets you
correlate the packet size and the throughput, for RTS on and off. 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? What is happening as the packet size increases? What is happening as rlen increases?
2. Is RTS more helpful when the packet size is small or large? Try to explain.
3. Explain how RTS is helpful to battle the hidden node problem? (i.e. where the receiver senses the channel is busy, but the transmitter cannot sense anything.)
1. What is contention window?
2. Overview of IEEE 802.11
3. Know ns2