[Ns-developers] static InterferenceHelper::CalculateTxDuration()

Nicola Baldo nbaldo at cttc.es
Tue Jul 14 09:23:55 PDT 2009


Hi all,

I was trying to simulate a scenario with 802.11b using short preamble, 
and I realized that frame durations were not calculated appropriately. 
Thinking about how to fix this issue, it emerged that there are actually 
several other associated issues.

In the end, I prepared a patch that does following things to address the 
whole problem:

1) make InterferenceHelper::CalculateTxDuration() a static method.
Currently, InterferenceHelper has several member variables which store 
PHY related parameters such as the standard being used and the duration 
of the PLCP preamble. This information is used to calculate the duration 
of received frames. This makes it not feasible to simulate scenarios in 
which several configurations co-exist in the same channel (e.g., a BSS 
using short preamble and another BSS using long preamble).

2) add several convenience methods:
   static WifiMode GetPlcpHeaderMode (WifiMode, WifiPreamble);
   static uint32_t GetPlcpHeaderDurationMicroSeconds (WifiMode, 
WifiPreamble);
   static uint32_t GetPlcpPreambleDurationMicroSeconds (WifiMode, 
WifiPreamble);
   static uint32_t GetPayloadDurationMicroSeconds (size, WifiMode);
the introduction of the above methods makes IMHO the code more readable 
and makes it possible to remove several switch statements (there were 
many of them for calculating preamble durations at different locations).
Particular care was taken in making all calculations according to the 
standard. I put comments referring to specific sections in the IEEE Std. 
802.11-2007 for the majority of these calculations, in the hope that it 
is easier for everybody to check that the code does the right thing.

3) (I'm sure I'll have to fight to get this one accepted ;-) )
Added a WifiPhyStandard member variable to WifiMode.
I think from a logical perspective it makes sense, since there is a 
1-to-1 relationship between a WifiMode and a WifiPhyStandard. Even if, 
for example, 802.11a and 802.11g modes are very similar, the standard 
makes an explicit distinction between them (OFDM at 5Hz vs ERP-OFDM and 
DSSS-OFDM at 2.4Ghz), and the duration of their frames would differ due 
to different PLCP.

4) added a unit test (interference-helper-tx-duration-test) which makes 
sure that the code calculating frame durations returns the correct value 
for some known cases. I've added a lot of cases for 802.11b; for 802.11a 
there are only 3 test cases, if somebody could provide more it would be 
great.

5) let m_maxPacketDuration be set automatically based on received 
packets. This makes it possible for a device using a "fast" standard to 
use the correct interference duration when other devices using "slow" 
standard are present in the same channel. Conceptually, this issue is 
similar to issue 1), and this is the reason why it is included in the 
same patch.

6) in InterferenceHelper, I removed several member variables which 
became unused, and removed as well all 
InterferenceHelper::Configure80211*Parameters() methods, which were not 
needed any more.


The patch is here for review:
http://codereview.appspot.com/91110

as a final note, I would like to say that the patch passes regression 
tests, so even though most of the CalculateTxDuration code was 
re-implemented the result is consistent at least in a few cases.

That's all! I am looking forward to seeing your comments...

Regards,

Nicola





More information about the Ns-developers mailing list