[Ns-developers] [all versions] definition of power values in Tcl scripts
antoine.trux@nokia.com
antoine.trux at nokia.com
Tue Jun 17 05:28:00 PDT 2008
Hi,
Power values are often conveniently expressed in dBm units, but most
(all?) Tcl variables that hold power values are expressed in watts. For
example, in ns-2.33/tcl/lib/ns-default.tcl:
Phy/WirelessPhyExt set noise_floor_ 7.96159e-14 ;#-101
dBm
Why not instead use a conversion function? Something like this:
# Return the value in watts that corresponds to `dBm_value'.
proc dBmsToWatts {dBm_value} {
return [expr 0.001 * pow(10, $dBm_value / 10.0)]
}
[...]
Phy/WirelessPhyExt set noise_floor_ [dBmsToWatts -101.0]
This would result in easier-to-maintain code and more precise results.
Antoine Trux
Nokia Research Center
More information about the Ns-developers
mailing list