Introduction
The goal of this exercise is to understand the concept of Carrier-Sensing in IEEE 802.11 standard and compare Physical Carrier Sense and Virtual Carrier Sense mechanisms.
Recall that when Physical Carrier Sense is used, a node seeking to transmit first assesses the channel. if the energy detected on the channel is above a certain threshold (caller carrier sense threshold), the channel is deemed busy, and the node must wait. Otherwise, the channel is assumed idle, and the node is free to transmit.
On the contrary, Virtual Carrier Sense involves use of a special handshake to "reserve" the channel. The RTS/CTS mechanism in 802.11 is a Virtual Carrier Sense mechanism. To briefly summarize 802.11 RTS/CTS, the sender first sends an RTS message, and the destination replies with a CTS. Only then does the actual DATA/ACK exchange happen. Neighboring nodes that receive either the RTS or CTS set their Network Allocation Vector (NAV) so as to reserve the channel for the impending DATA/ACK transmission.
We consider the following topology:
Node A is transmitting CBR packets to node B, and node C is transmitting CBR packets to node D.
ns2 Instructions
1. Get the tcl script from here.
2. A script "csense.tcl" is provided. This script takes three command-line arguments: RTSthresh, CSthresh, and the value of x. Script usage is : ns csense.tcl -RTSthresh {RTS_Threshold} -CSthresh {carrier-sense threshold} -dist {x}
3. By setting RTSthresh to some absurdly high value (e.g. above 10000), you can effectively shut down RTS/CTS. Similarly, by setting CSthresh to the value of RXThresh, you can get "close" to removing carrier-sensing (this is due to a peculiarity of the ns2 implementation; otherwise one would expect that CSthresh be set to some absurdly large value; resultantly CSThresh must always be less than or equal to RXThresh in ns2). Supplying a negative argument causes the default ns2 value to be used.
4. Obtain the CSThresh value needed to have a carrier-sense range of 250m, 300m, 400m, 500m. This may be done by using the "threshold" utility provided with ns2 (assume TwoRayGround propagation model, and keep all other parameters at their default value).
5.For each value of CSThresh, run the simulation by shutting down RTS/CTS and for values of x=100m, 200m, 300m. Also run the simulation for each value of x using the default RTS-threshold but shutting down carrier-sense.
6. Obtain the CBR throughput in both cases.(To calculate throughput, you need to calculate [num of received packets/num of sent packets]. Go through the sections 16.1.6 and 16.1.7 of the ns2 manual for understanding and using trace files. For this particular assignment, use the commands 'grep "^s" {trace file name} | wc -l' and 'grep "^r" {trace file name} | wc -l' to get the number of sent and received packets respectively.)
7. Also examine the number of MAC collisions recorded in the trace, and the type of packet involved (CBR/non-CBR).
8. Plot the overall throughput for each run as a bar-graph. Also plot the number of CBR and non-CBR packets dropped due to collision.
Analysis
IEEE 802.11 MAC mainly relies on two techniques to combat interference: physical carrier sensing and RTS/CTS handshake (also known as �virtual carrier sensing�). Ideally, the RTS/CTS handshake can eliminate most interference. However, the effectiveness of RTS/CTS is still based on certain assumptions. This assignment should help students to understand their significance and efficacy.
Try to answer following questions-
1. Briefly discuss and what you observe from the graphs, try to explain why, and state what you conclude about the efficacy of physical and virtual CS?
2. Now consider the following topology:

The distances AB, BC, AC, and CD are all 200m.
However, now there is an obstacle between A and C that does not permit RF propagation. Do you expect that the trends seen in your simulation would continue to hold for this topology? Briefly discuss which scheme you think would perform better?
以上是实验的全部内容介绍。
这里我制作了throughput的问题。
根据上面介绍至少有两种方法,第一种是执行ns csense.tcl之后生成了csense.tr文件。然后在命令行输入:
$ grep "^s" csense.tr | wc -l
18963
就可以得到发送的数据包量
输入:$ grep "^r" csense.tr | wc -l
18959
就可以得到接受的数据包量。
有了它们的比值就可以计算吞吐量。
还有一种方法就是用gawk.
写一个简单的awk脚本:
至于还有好多个问题,比如Mac collision,以及计算出CBR和NON-CBR数据包丢失量并绘图。我还不清楚如何在新版本的trace文件中提取那些是cbr那些不是,以及那些是mac collision.
r -t 0.002992251 -Hs 0 -Hd -2 -Ni 0 -Nx 50.00 -Ny 0.00 -Nz 0.00 -Ne -1.000000 -Nl RTR -Nw --- -Ma 0 -Md 0 -Ms 0 -Mt 0 -Is 0.0 -Id 1.0 -It cbr -Il 1024 -If 0 -Ii 4 -Iv 32 -Pn cbr -Pi 3 -Pf 0 -Po 0
这是其中一行。如果你晓得,帮忙先,我先放着...