diff --git a/bindings/python/ns3_module_bridge.py b/bindings/python/ns3_module_bridge.py index 013863812..647193174 100644 --- a/bindings/python/ns3_module_bridge.py +++ b/bindings/python/ns3_module_bridge.py @@ -103,16 +103,6 @@ def register_Ns3BridgeNetDevice_methods(root_module, cls): 'ns3::Ptr< ns3::NetDevice >', [param('uint32_t', 'n')], is_const=True) - ## bridge-net-device.h: void ns3::BridgeNetDevice::SetName(std::string const name) [member function] - cls.add_method('SetName', - 'void', - [param('std::string const', 'name')], - is_virtual=True) - ## bridge-net-device.h: std::string ns3::BridgeNetDevice::GetName() const [member function] - cls.add_method('GetName', - 'std::string', - [], - is_const=True, is_virtual=True) ## bridge-net-device.h: void ns3::BridgeNetDevice::SetIfIndex(uint32_t const index) [member function] cls.add_method('SetIfIndex', 'void', diff --git a/bindings/python/ns3_module_core.py b/bindings/python/ns3_module_core.py index 71322205c..e108eba13 100644 --- a/bindings/python/ns3_module_core.py +++ b/bindings/python/ns3_module_core.py @@ -115,8 +115,12 @@ def register_types(module): module.add_class('EnumChecker', parent=root_module['ns3::AttributeChecker']) ## enum.h: ns3::EnumValue [class] module.add_class('EnumValue', parent=root_module['ns3::AttributeValue']) + ## random-variable.h: ns3::ErlangVariable [class] + module.add_class('ErlangVariable', parent=root_module['ns3::RandomVariable']) ## random-variable.h: ns3::ExponentialVariable [class] module.add_class('ExponentialVariable', parent=root_module['ns3::RandomVariable']) + ## random-variable.h: ns3::GammaVariable [class] + module.add_class('GammaVariable', parent=root_module['ns3::RandomVariable']) ## random-variable.h: ns3::IntEmpiricalVariable [class] module.add_class('IntEmpiricalVariable', parent=root_module['ns3::EmpiricalVariable']) ## integer.h: ns3::IntegerValue [class] @@ -261,7 +265,9 @@ def register_methods(root_module): register_Ns3EmptyAttributeValue_methods(root_module, root_module['ns3::EmptyAttributeValue']) register_Ns3EnumChecker_methods(root_module, root_module['ns3::EnumChecker']) register_Ns3EnumValue_methods(root_module, root_module['ns3::EnumValue']) + register_Ns3ErlangVariable_methods(root_module, root_module['ns3::ErlangVariable']) register_Ns3ExponentialVariable_methods(root_module, root_module['ns3::ExponentialVariable']) + register_Ns3GammaVariable_methods(root_module, root_module['ns3::GammaVariable']) register_Ns3IntEmpiricalVariable_methods(root_module, root_module['ns3::IntEmpiricalVariable']) register_Ns3IntegerValue_methods(root_module, root_module['ns3::IntegerValue']) register_Ns3LogNormalVariable_methods(root_module, root_module['ns3::LogNormalVariable']) @@ -1497,6 +1503,25 @@ def register_Ns3EnumValue_methods(root_module, cls): is_virtual=True) return +def register_Ns3ErlangVariable_methods(root_module, cls): + ## random-variable.h: ns3::ErlangVariable::ErlangVariable(ns3::ErlangVariable const & arg0) [copy constructor] + cls.add_constructor([param('ns3::ErlangVariable const &', 'arg0')]) + ## random-variable.h: ns3::ErlangVariable::ErlangVariable() [constructor] + cls.add_constructor([]) + ## random-variable.h: ns3::ErlangVariable::ErlangVariable(unsigned int k, double lambda) [constructor] + cls.add_constructor([param('unsigned int', 'k'), param('double', 'lambda')]) + ## random-variable.h: double ns3::ErlangVariable::GetValue() const [member function] + cls.add_method('GetValue', + 'double', + [], + is_const=True) + ## random-variable.h: double ns3::ErlangVariable::GetValue(unsigned int k, double lambda) const [member function] + cls.add_method('GetValue', + 'double', + [param('unsigned int', 'k'), param('double', 'lambda')], + is_const=True) + return + def register_Ns3ExponentialVariable_methods(root_module, cls): ## random-variable.h: ns3::ExponentialVariable::ExponentialVariable(ns3::ExponentialVariable const & arg0) [copy constructor] cls.add_constructor([param('ns3::ExponentialVariable const &', 'arg0')]) @@ -1508,6 +1533,25 @@ def register_Ns3ExponentialVariable_methods(root_module, cls): cls.add_constructor([param('double', 'm'), param('double', 'b')]) return +def register_Ns3GammaVariable_methods(root_module, cls): + ## random-variable.h: ns3::GammaVariable::GammaVariable(ns3::GammaVariable const & arg0) [copy constructor] + cls.add_constructor([param('ns3::GammaVariable const &', 'arg0')]) + ## random-variable.h: ns3::GammaVariable::GammaVariable() [constructor] + cls.add_constructor([]) + ## random-variable.h: ns3::GammaVariable::GammaVariable(double alpha, double beta) [constructor] + cls.add_constructor([param('double', 'alpha'), param('double', 'beta')]) + ## random-variable.h: double ns3::GammaVariable::GetValue() const [member function] + cls.add_method('GetValue', + 'double', + [], + is_const=True) + ## random-variable.h: double ns3::GammaVariable::GetValue(double alpha, double beta) const [member function] + cls.add_method('GetValue', + 'double', + [param('double', 'alpha'), param('double', 'beta')], + is_const=True) + return + def register_Ns3IntEmpiricalVariable_methods(root_module, cls): ## random-variable.h: ns3::IntEmpiricalVariable::IntEmpiricalVariable(ns3::IntEmpiricalVariable const & arg0) [copy constructor] cls.add_constructor([param('ns3::IntEmpiricalVariable const &', 'arg0')]) @@ -1984,7 +2028,7 @@ def register_Ns3TracedValue__Unsigned_int_methods(root_module, cls): cls.add_method('ConnectWithoutContext', 'void', [param('ns3::CallbackBase const &', 'cb')]) - ## traced-value.h: void ns3::TracedValue::Connect(ns3::CallbackBase const & cb, std::basic_string,std::allocator > path) [member function] + ## traced-value.h: void ns3::TracedValue::Connect(ns3::CallbackBase const & cb, std::string path) [member function] cls.add_method('Connect', 'void', [param('ns3::CallbackBase const &', 'cb'), param('std::string', 'path')]) @@ -1992,7 +2036,7 @@ def register_Ns3TracedValue__Unsigned_int_methods(root_module, cls): cls.add_method('DisconnectWithoutContext', 'void', [param('ns3::CallbackBase const &', 'cb')]) - ## traced-value.h: void ns3::TracedValue::Disconnect(ns3::CallbackBase const & cb, std::basic_string,std::allocator > path) [member function] + ## traced-value.h: void ns3::TracedValue::Disconnect(ns3::CallbackBase const & cb, std::string path) [member function] cls.add_method('Disconnect', 'void', [param('ns3::CallbackBase const &', 'cb'), param('std::string', 'path')]) @@ -2140,7 +2184,7 @@ def register_functions(root_module): module.add_function('TypeNameGet', 'std::string', [], - template_parameters=['long']) + template_parameters=['long long']) ## type-name.h: extern std::string ns3::TypeNameGet() [free function] module.add_function('TypeNameGet', 'std::string', @@ -2160,7 +2204,7 @@ def register_functions(root_module): module.add_function('TypeNameGet', 'std::string', [], - template_parameters=['unsigned long']) + template_parameters=['unsigned long long']) ## type-name.h: extern std::string ns3::TypeNameGet() [free function] module.add_function('TypeNameGet', 'std::string', diff --git a/bindings/python/ns3_module_csma.py b/bindings/python/ns3_module_csma.py index 17494ae9e..d7e8e9b4f 100644 --- a/bindings/python/ns3_module_csma.py +++ b/bindings/python/ns3_module_csma.py @@ -273,16 +273,6 @@ def register_Ns3CsmaNetDevice_methods(root_module, cls): cls.add_method('GetEncapsulationMode', 'ns3::CsmaNetDevice::EncapsulationMode', []) - ## csma-net-device.h: void ns3::CsmaNetDevice::SetName(std::string const name) [member function] - cls.add_method('SetName', - 'void', - [param('std::string const', 'name')], - is_virtual=True) - ## csma-net-device.h: std::string ns3::CsmaNetDevice::GetName() const [member function] - cls.add_method('GetName', - 'std::string', - [], - is_const=True, is_virtual=True) ## csma-net-device.h: void ns3::CsmaNetDevice::SetIfIndex(uint32_t const index) [member function] cls.add_method('SetIfIndex', 'void', diff --git a/bindings/python/ns3_module_emu.py b/bindings/python/ns3_module_emu.py index 54ffede89..4fa5d12a1 100644 --- a/bindings/python/ns3_module_emu.py +++ b/bindings/python/ns3_module_emu.py @@ -80,16 +80,6 @@ def register_Ns3EmuNetDevice_methods(root_module, cls): cls.add_method('SetAddress', 'void', [param('ns3::Mac48Address', 'addr')]) - ## emu-net-device.h: void ns3::EmuNetDevice::SetName(std::string const name) [member function] - cls.add_method('SetName', - 'void', - [param('std::string const', 'name')], - is_virtual=True) - ## emu-net-device.h: std::string ns3::EmuNetDevice::GetName() const [member function] - cls.add_method('GetName', - 'std::string', - [], - is_const=True, is_virtual=True) ## emu-net-device.h: void ns3::EmuNetDevice::SetIfIndex(uint32_t const index) [member function] cls.add_method('SetIfIndex', 'void', diff --git a/bindings/python/ns3_module_node.py b/bindings/python/ns3_module_node.py index b214fcda6..d1421012f 100644 --- a/bindings/python/ns3_module_node.py +++ b/bindings/python/ns3_module_node.py @@ -2310,16 +2310,6 @@ def register_Ns3Channel_methods(root_module, cls): is_static=True) ## channel.h: ns3::Channel::Channel() [constructor] cls.add_constructor([]) - ## channel.h: ns3::Channel::Channel(std::string name) [constructor] - cls.add_constructor([param('std::string', 'name')]) - ## channel.h: void ns3::Channel::SetName(std::string arg0) [member function] - cls.add_method('SetName', - 'void', - [param('std::string', 'arg0')]) - ## channel.h: std::string ns3::Channel::GetName() [member function] - cls.add_method('GetName', - 'std::string', - []) ## channel.h: uint32_t ns3::Channel::GetNDevices() const [member function] cls.add_method('GetNDevices', 'uint32_t', @@ -2749,16 +2739,6 @@ def register_Ns3NetDevice_methods(root_module, cls): 'ns3::TypeId', [], is_static=True) - ## net-device.h: void ns3::NetDevice::SetName(std::string const name) [member function] - cls.add_method('SetName', - 'void', - [param('std::string const', 'name')], - is_pure_virtual=True, is_virtual=True) - ## net-device.h: std::string ns3::NetDevice::GetName() const [member function] - cls.add_method('GetName', - 'std::string', - [], - is_pure_virtual=True, is_const=True, is_virtual=True) ## net-device.h: void ns3::NetDevice::SetIfIndex(uint32_t const index) [member function] cls.add_method('SetIfIndex', 'void', @@ -3015,16 +2995,6 @@ def register_Ns3SimpleNetDevice_methods(root_module, cls): cls.add_method('SetAddress', 'void', [param('ns3::Mac48Address', 'address')]) - ## simple-net-device.h: void ns3::SimpleNetDevice::SetName(std::string const name) [member function] - cls.add_method('SetName', - 'void', - [param('std::string const', 'name')], - is_virtual=True) - ## simple-net-device.h: std::string ns3::SimpleNetDevice::GetName() const [member function] - cls.add_method('GetName', - 'std::string', - [], - is_const=True, is_virtual=True) ## simple-net-device.h: void ns3::SimpleNetDevice::SetIfIndex(uint32_t const index) [member function] cls.add_method('SetIfIndex', 'void', diff --git a/bindings/python/ns3_module_point_to_point.py b/bindings/python/ns3_module_point_to_point.py index 1541d7d25..2360f1f62 100644 --- a/bindings/python/ns3_module_point_to_point.py +++ b/bindings/python/ns3_module_point_to_point.py @@ -175,16 +175,6 @@ def register_Ns3PointToPointNetDevice_methods(root_module, cls): 'uint16_t', [], is_const=True) - ## point-to-point-net-device.h: void ns3::PointToPointNetDevice::SetName(std::string const name) [member function] - cls.add_method('SetName', - 'void', - [param('std::string const', 'name')], - is_virtual=True) - ## point-to-point-net-device.h: std::string ns3::PointToPointNetDevice::GetName() const [member function] - cls.add_method('GetName', - 'std::string', - [], - is_const=True, is_virtual=True) ## point-to-point-net-device.h: void ns3::PointToPointNetDevice::SetIfIndex(uint32_t const index) [member function] cls.add_method('SetIfIndex', 'void', diff --git a/bindings/python/ns3_module_tap_bridge.py b/bindings/python/ns3_module_tap_bridge.py index 49b6e651f..060f909a6 100644 --- a/bindings/python/ns3_module_tap_bridge.py +++ b/bindings/python/ns3_module_tap_bridge.py @@ -86,16 +86,6 @@ def register_Ns3TapBridge_methods(root_module, cls): cls.add_method('GetMode', 'ns3::TapBridge::Mode', []) - ## tap-bridge.h: void ns3::TapBridge::SetName(std::string const name) [member function] - cls.add_method('SetName', - 'void', - [param('std::string const', 'name')], - is_virtual=True) - ## tap-bridge.h: std::string ns3::TapBridge::GetName() const [member function] - cls.add_method('GetName', - 'std::string', - [], - is_const=True, is_virtual=True) ## tap-bridge.h: void ns3::TapBridge::SetIfIndex(uint32_t const index) [member function] cls.add_method('SetIfIndex', 'void', diff --git a/bindings/python/ns3_module_wifi.py b/bindings/python/ns3_module_wifi.py index 564128159..f4c2301e5 100644 --- a/bindings/python/ns3_module_wifi.py +++ b/bindings/python/ns3_module_wifi.py @@ -228,8 +228,8 @@ def register_Ns3InterferenceHelper_methods(root_module, cls): 'ns3::Ptr< ns3::ErrorRateModel >', [], is_const=True) - ## interference-helper.h: double ns3::InterferenceHelper::GetNoiseFloorW() const [member function] - cls.add_method('GetNoiseFloorW', + ## interference-helper.h: double ns3::InterferenceHelper::GetNoiseFigure() const [member function] + cls.add_method('GetNoiseFigure', 'double', [], is_const=True) @@ -237,10 +237,10 @@ def register_Ns3InterferenceHelper_methods(root_module, cls): cls.add_method('SetErrorRateModel', 'void', [param('ns3::Ptr< ns3::ErrorRateModel >', 'rate')]) - ## interference-helper.h: void ns3::InterferenceHelper::SetNoiseFloorW(double noiseFloor) [member function] - cls.add_method('SetNoiseFloorW', + ## interference-helper.h: void ns3::InterferenceHelper::SetNoiseFigure(double value) [member function] + cls.add_method('SetNoiseFigure', 'void', - [param('double', 'noiseFloor')]) + [param('double', 'value')]) return def register_Ns3InterferenceHelperSnrPer_methods(root_module, cls): @@ -1707,10 +1707,10 @@ def register_Ns3YansWifiPhy_methods(root_module, cls): cls.add_method('SetStandard', 'void', [param('ns3::WifiPhyStandard', 'standard')]) - ## yans-wifi-phy.h: void ns3::YansWifiPhy::SetRxNoise(double ratio) [member function] - cls.add_method('SetRxNoise', + ## yans-wifi-phy.h: void ns3::YansWifiPhy::SetRxNoiseFigure(double noiseFigureDb) [member function] + cls.add_method('SetRxNoiseFigure', 'void', - [param('double', 'ratio')]) + [param('double', 'noiseFigureDb')]) ## yans-wifi-phy.h: void ns3::YansWifiPhy::SetTxPowerStart(double start) [member function] cls.add_method('SetTxPowerStart', 'void', @@ -1751,8 +1751,8 @@ def register_Ns3YansWifiPhy_methods(root_module, cls): cls.add_method('SetMobility', 'void', [param('ns3::Ptr< ns3::Object >', 'mobility')]) - ## yans-wifi-phy.h: double ns3::YansWifiPhy::GetRxNoise() const [member function] - cls.add_method('GetRxNoise', + ## yans-wifi-phy.h: double ns3::YansWifiPhy::GetRxNoiseFigure() const [member function] + cls.add_method('GetRxNoiseFigure', 'double', [], is_const=True) @@ -2697,16 +2697,6 @@ def register_Ns3WifiNetDevice_methods(root_module, cls): 'ns3::Ptr< ns3::WifiRemoteStationManager >', [], is_const=True) - ## wifi-net-device.h: void ns3::WifiNetDevice::SetName(std::string const name) [member function] - cls.add_method('SetName', - 'void', - [param('std::string const', 'name')], - is_virtual=True) - ## wifi-net-device.h: std::string ns3::WifiNetDevice::GetName() const [member function] - cls.add_method('GetName', - 'std::string', - [], - is_const=True, is_virtual=True) ## wifi-net-device.h: void ns3::WifiNetDevice::SetIfIndex(uint32_t const index) [member function] cls.add_method('SetIfIndex', 'void', diff --git a/examples/wifi-ap.cc b/examples/wifi-ap.cc index 6bd6c74d1..e5cc5d84e 100644 --- a/examples/wifi-ap.cc +++ b/examples/wifi-ap.cc @@ -32,14 +32,14 @@ using namespace ns3; void -DevTxTrace (std::string context, Ptr p, Mac48Address address) +DevTxTrace (std::string context, Ptr p) { - std::cout << " TX to=" << address << " p: " << *p << std::endl; + std::cout << " TX p: " << *p << std::endl; } void -DevRxTrace (std::string context, Ptr p, Mac48Address address) +DevRxTrace (std::string context, Ptr p) { - std::cout << " RX from=" << address << " p: " << *p << std::endl; + std::cout << " RX p: " << *p << std::endl; } void PhyRxOkTrace (std::string context, Ptr packet, double snr, WifiMode mode, enum WifiPreamble preamble) @@ -168,8 +168,8 @@ int main (int argc, char *argv[]) Simulator::Stop (Seconds (44.0)); - Config::Connect ("/NodeList/*/DeviceList/*/Tx", MakeCallback (&DevTxTrace)); - Config::Connect ("/NodeList/*/DeviceList/*/Rx", MakeCallback (&DevRxTrace)); + Config::Connect ("/NodeList/*/DeviceList/*/Mac/MacTx", MakeCallback (&DevTxTrace)); + Config::Connect ("/NodeList/*/DeviceList/*/Mac/MacRx", MakeCallback (&DevRxTrace)); Config::Connect ("/NodeList/*/DeviceList/*/Phy/State/RxOk", MakeCallback (&PhyRxOkTrace)); Config::Connect ("/NodeList/*/DeviceList/*/Phy/State/RxError", MakeCallback (&PhyRxErrorTrace)); Config::Connect ("/NodeList/*/DeviceList/*/Phy/State/Tx", MakeCallback (&PhyTxTrace)); diff --git a/samples/main-random-variable.cc b/samples/main-random-variable.cc new file mode 100644 index 000000000..de16cd6da --- /dev/null +++ b/samples/main-random-variable.cc @@ -0,0 +1,377 @@ +/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ +/* + * Copyright (c) 2008 Timo Bingmann + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation; + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Author: Timo Bingmann + */ +#include "ns3/random-variable.h" +#include "ns3/gnuplot.h" +#include +#include + +using namespace ns3; + +/// Round a double number to the given precision. e.g. dround(0.234, 0.1) = 0.2 +/// and dround(0.257, 0.1) = 0.3 +double dround(double number, double precision) +{ + number /= precision; + if (number >= 0) + number = std::floor(number + 0.5); + else + number = std::ceil(number - 0.5); + number *= precision; + return number; +} + +static GnuplotDataset +Histogramm (RandomVariable rndvar, unsigned int probes, double precision, const std::string& title, bool notcontinous = false) +{ + typedef std::map histogramm_maptype; + histogramm_maptype histogramm; + + for(unsigned int i = 0; i < probes; ++i) + { + double val = dround( rndvar.GetValue(), precision ); + + ++histogramm[val]; + } + + Gnuplot2dDataset data; + data.SetTitle(title); + + if (notcontinous) + { + data.SetStyle(Gnuplot2dDataset::IMPULSES); + } + + for(histogramm_maptype::const_iterator hi = histogramm.begin(); + hi != histogramm.end(); ++hi) + { + data.Add(hi->first, (double)hi->second / (double)probes / precision); + } + + return data; +} + +int main (int argc, char *argv[]) +{ + unsigned int probes = 1000000; + double precision = 0.01; + + GnuplotCollection gnuplots("main-random-variables.pdf"); + gnuplots.SetTerminal("pdf enhanced"); + + { + Gnuplot plot; + plot.SetTitle("UniformVariable"); + plot.AppendExtra("set yrange [0:]"); + + plot.AddDataset( Histogramm(UniformVariable(0.0, 1.0), probes, precision, + "UniformVariable [0.0 .. 1.0)") ); + + plot.AddDataset( Gnuplot2dFunction("0.1", + "0 <= x && x <= 1 ? 1.0 : 0") ); + + gnuplots.AddPlot(plot); + } + + { + Gnuplot plot; + plot.SetTitle("ExponentialVariable"); + plot.AppendExtra("set xrange [0:8]"); + plot.AppendExtra("ExpDist(x,l) = 1/l * exp(-1/l * x)"); + + plot.AddDataset( Histogramm(ExponentialVariable(0.5), probes, precision, + "ExponentialVariable m=0.5") ); + + plot.AddDataset( Gnuplot2dFunction("ExponentialDistribution mean 0.5", + "ExpDist(x, 0.5)") ); + + plot.AddDataset( Histogramm(ExponentialVariable(1.0), probes, precision, + "ExponentialVariable m=1") ); + + plot.AddDataset( Gnuplot2dFunction("ExponentialDistribution mean 1.0", + "ExpDist(x, 1.0)") ); + + plot.AddDataset( Histogramm(ExponentialVariable(1.5), probes, precision, + "ExponentialVariable m=1.5") ); + + plot.AddDataset( Gnuplot2dFunction("ExponentialDistribution mean 1.5", + "ExpDist(x, 1.5)") ); + + gnuplots.AddPlot(plot); + } + + { + Gnuplot plot; + plot.SetTitle("ParetoVariable"); + plot.AppendExtra("set xrange [0:2]"); + + plot.AddDataset( Histogramm(ParetoVariable(1.0, 1.5), probes, precision, + "ParetoVariable m=1.0 s=1.5") ); + + plot.AddDataset( Histogramm(ParetoVariable(1.0, 2.0), probes, precision, + "ParetoVariable m=1.0 s=2.0") ); + + plot.AddDataset( Histogramm(ParetoVariable(1.0, 2.5), probes, precision, + "ParetoVariable m=1.0 s=2.5") ); + + gnuplots.AddPlot(plot); + } + + { + Gnuplot plot; + plot.SetTitle("WeibullVariable"); + plot.AppendExtra("set xrange [0:3]"); + + plot.AddDataset( Histogramm(WeibullVariable(1.0, 1.0), probes, precision, + "WeibullVariable m=1.0 s=1.0") ); + + plot.AddDataset( Histogramm(WeibullVariable(1.0, 2.0), probes, precision, + "WeibullVariable m=1.0 s=2.0") ); + + plot.AddDataset( Histogramm(WeibullVariable(1.0, 3.0), probes, precision, + "WeibullVariable m=1.0 s=3.0") ); + + gnuplots.AddPlot(plot); + } + + { + Gnuplot plot; + plot.SetTitle("NormalVariable"); + plot.AppendExtra("set xrange [-3:3]"); + plot.AppendExtra("NormalDist(x,m,s) = 1 / (s * sqrt(2*pi)) * exp(-1.0 / 2.0 * ((x-m) / s)**2)"); + + plot.AddDataset( Histogramm(NormalVariable(0.0, 1.0), probes, precision, + "NormalVariable m=0.0 v=1.0") ); + + plot.AddDataset( Gnuplot2dFunction("NormalDist {/Symbol m}=0.0 {/Symbol s}=1.0", + "NormalDist(x,0.0,1.0)") ); + + plot.AddDataset( Histogramm(NormalVariable(0.0, 2.0), probes, precision, + "NormalVariable m=0.0 v=2.0") ); + + plot.AddDataset( Gnuplot2dFunction("NormalDist {/Symbol m}=0.0 {/Symbol s}=sqrt(2.0)", + "NormalDist(x,0.0,sqrt(2.0))") ); + + plot.AddDataset( Histogramm(NormalVariable(0.0, 3.0), probes, precision, + "NormalVariable m=0.0 v=3.0") ); + + plot.AddDataset( Gnuplot2dFunction("NormalDist {/Symbol m}=0.0 {/Symbol s}=sqrt(3.0)", + "NormalDist(x,0.0,sqrt(3.0))") ); + + gnuplots.AddPlot(plot); + } + + { + Gnuplot plot; + plot.SetTitle("EmpiricalVariable"); + plot.AppendExtra("set xrange [*:*]"); + + EmpiricalVariable emp1; + emp1.CDF(0.0, 0.0 / 15.0); + emp1.CDF(0.2, 1.0 / 15.0); + emp1.CDF(0.4, 3.0 / 15.0); + emp1.CDF(0.6, 6.0 / 15.0); + emp1.CDF(0.8, 10.0 / 15.0); + emp1.CDF(1.0, 15.0 / 15.0); + + plot.AddDataset( Histogramm(emp1, probes, precision, + "EmpiricalVariable (Stairs)") ); + + gnuplots.AddPlot(plot); + } + + { + Gnuplot plot; + plot.SetTitle("DeterministicVariable"); + plot.AppendExtra("set xrange [*:*]"); + + double values[] = { 0.0, 0.2, 0.2, 0.4, 0.2, 0.6, 0.8, 0.8, 1.0 }; + DeterministicVariable det1 (values, sizeof(values) / sizeof(values[0])); + + plot.AddDataset( Histogramm(det1, probes, precision, + "DeterministicVariable", true) ); + + gnuplots.AddPlot(plot); + } + + { + Gnuplot plot; + plot.SetTitle("LogNormalVariable"); + plot.AppendExtra("set xrange [0:3]"); + + plot.AppendExtra("LogNormalDist(x,m,s) = 1.0/x * NormalDist(log(x), m, s)"); + + plot.AddDataset( Histogramm(LogNormalVariable(0.0, 1.0), probes, precision, + "LogNormalVariable m=0.0 s=1.0") ); + + plot.AddDataset( Gnuplot2dFunction("LogNormalDist(x, 0.0, 1.0)", + "LogNormalDist(x, 0.0, 1.0)") ); + + plot.AddDataset( Histogramm(LogNormalVariable(0.0, 0.5), probes, precision, + "LogNormalVariable m=0.0 s=0.5") ); + + plot.AddDataset( Histogramm(LogNormalVariable(0.0, 0.25), probes, precision, + "LogNormalVariable m=0.0 s=0.25") ); + + plot.AddDataset( Gnuplot2dFunction("LogNormalDist(x, 0.0, 0.25)", + "LogNormalDist(x, 0.0, 0.25)") ); + + plot.AddDataset( Histogramm(LogNormalVariable(0.0, 0.125), probes, precision, + "LogNormalVariable m=0.0 s=0.125") ); + + plot.AddDataset( Histogramm(LogNormalVariable(0.0, 2.0), probes, precision, + "LogNormalVariable m=0.0 s=2.0") ); + + plot.AddDataset( Gnuplot2dFunction("LogNormalDist(x, 0.0, 2.0)", + "LogNormalDist(x, 0.0, 2.0)") ); + + plot.AddDataset( Histogramm(LogNormalVariable(0.0, 2.5), probes, precision, + "LogNormalVariable m=0.0 s=2.5") ); + + gnuplots.AddPlot(plot); + } + + { + Gnuplot plot; + plot.SetTitle("TriangularVariable"); + plot.AppendExtra("set xrange [*:*]"); + + plot.AddDataset( Histogramm(TriangularVariable(0.0, 1.0, 0.5), probes, precision, + "TriangularVariable [0.0 .. 1.0) m=0.5") ); + + plot.AddDataset( Histogramm(TriangularVariable(0.0, 1.0, 0.4), probes, precision, + "TriangularVariable [0.0 .. 1.0) m=0.4") ); + + plot.AddDataset( Histogramm(TriangularVariable(0.0, 1.0, 0.65), probes, precision, + "TriangularVariable [0.0 .. 1.0) m=0.65") ); + + gnuplots.AddPlot(plot); + } + + { + Gnuplot plot; + plot.SetTitle("GammaVariable"); + plot.AppendExtra("set xrange [0:10]"); + plot.AppendExtra("set yrange [0:1]"); + plot.AppendExtra("GammaDist(x,a,b) = x**(a-1) * 1/b**a * exp(-x/b) / gamma(a)"); + + plot.AppendExtra("set label 1 '{/Symbol g}(x,{/Symbol a},{/Symbol b}) = x^{/Symbol a-1} e^{-x {/Symbol b}^{-1}} ( {/Symbol b}^{/Symbol a} {/Symbol G}({/Symbol a}) )^{-1}' at 0.7, 0.9"); + + plot.AddDataset( Histogramm(GammaVariable(1.0, 1.0), probes, precision, + "GammaVariable a=1.0 b=1.0") ); + + plot.AddDataset( Gnuplot2dFunction("{/Symbol g}(x, 1.0, 1.0)", + "GammaDist(x, 1.0, 1.0)") ); + + plot.AddDataset( Histogramm(GammaVariable(1.5, 1.0), probes, precision, + "GammaVariable a=1.5 b=1.0") ); + + plot.AddDataset( Gnuplot2dFunction("{/Symbol g}(x, 1.5, 1.0)", + "GammaDist(x, 1.5, 1.0)") ); + + plot.AddDataset( Histogramm(GammaVariable(2.0, 1.0), probes, precision, + "GammaVariable a=2.0 b=1.0") ); + + plot.AddDataset( Gnuplot2dFunction("{/Symbol g}(x, 2.0, 1.0)", + "GammaDist(x, 2.0, 1.0)") ); + + plot.AddDataset( Histogramm(GammaVariable(4.0, 1.0), probes, precision, + "GammaVariable a=4.0 b=1.0") ); + + plot.AddDataset( Gnuplot2dFunction("{/Symbol g}(x, 4.0, 1.0)", + "GammaDist(x, 4.0, 1.0)") ); + + plot.AddDataset( Histogramm(GammaVariable(2.0, 2.0), probes, precision, + "GammaVariable a=2.0 b=2.0") ); + + plot.AddDataset( Gnuplot2dFunction("{/Symbol g}(x, 2.0, 2.0)", + "GammaDist(x, 2.0, 2.0)") ); + + plot.AddDataset( Histogramm(GammaVariable(2.5, 3.0), probes, precision, + "GammaVariable a=2.5 b=3.0") ); + + plot.AddDataset( Gnuplot2dFunction("{/Symbol g}(x, 2.5, 3.0)", + "GammaDist(x, 2.5, 3.0)") ); + + plot.AddDataset( Histogramm(GammaVariable(2.5, 4.5), probes, precision, + "GammaVariable a=2.5 b=4.5") ); + + plot.AddDataset( Gnuplot2dFunction("{/Symbol g}(x, 2.5, 4.5)", + "GammaDist(x, 2.5, 4.5)") ); + + gnuplots.AddPlot(plot); + } + + { + Gnuplot plot; + plot.SetTitle("ErlangVariable"); + plot.AppendExtra("set xrange [0:10]"); + plot.AppendExtra("ErlangDist(x,k,l) = x**(k-1) * 1/l**k * exp(-x/l) / (k-1)!"); + + plot.AppendExtra("set label 1 'Erlang(x,k,{/Symbol l}) = x^{k-1} e^{-x {/Symbol l}^{-1}} ( {/Symbol l}^k (k-1)! )^{-1}' at 0.7, 0.9"); + + plot.AddDataset( Histogramm(ErlangVariable(1, 1.0), probes, precision, + "ErlangVariable k=1 {/Symbol l}=1.0") ); + + plot.AddDataset( Gnuplot2dFunction("Erlang(x, 1, 1.0)", + "ErlangDist(x, 1, 1.0)") ); + + plot.AddDataset( Histogramm(ErlangVariable(2, 1.0), probes, precision, + "ErlangVariable k=2 {/Symbol l}=1.0") ); + + plot.AddDataset( Gnuplot2dFunction("Erlang(x, 2, 1.0)", + "ErlangDist(x, 2, 1.0)") ); + + plot.AddDataset( Histogramm(ErlangVariable(3, 1.0), probes, precision, + "ErlangVariable k=3 {/Symbol l}=1.0") ); + + plot.AddDataset( Gnuplot2dFunction("Erlang(x, 3, 1.0)", + "ErlangDist(x, 3, 1.0)") ); + + plot.AddDataset( Histogramm(ErlangVariable(5, 1.0), probes, precision, + "ErlangVariable k=5 {/Symbol l}=1.0") ); + + plot.AddDataset( Gnuplot2dFunction("Erlang(x, 5, 1.0)", + "ErlangDist(x, 5, 1.0)") ); + + plot.AddDataset( Histogramm(ErlangVariable(2, 2.0), probes, precision, + "ErlangVariable k=2 {/Symbol l}=2.0") ); + + plot.AddDataset( Gnuplot2dFunction("Erlang(x, 2, 2.0)", + "ErlangDist(x, 2, 2.0)") ); + + plot.AddDataset( Histogramm(ErlangVariable(2, 3.0), probes, precision, + "ErlangVariable k=2 {/Symbol l}=3.0") ); + + plot.AddDataset( Gnuplot2dFunction("Erlang(x, 2, 3.0)", + "ErlangDist(x, 2, 3.0)") ); + + plot.AddDataset( Histogramm(ErlangVariable(2, 5.0), probes, precision, + "ErlangVariable k=2 {/Symbol l}=5.0") ); + + plot.AddDataset( Gnuplot2dFunction("Erlang(x, 2, 5.0)", + "ErlangDist(x, 2, 5.0)") ); + + gnuplots.AddPlot(plot); + } + + gnuplots.GenerateOutput(std::cout); + + return 0; +} diff --git a/samples/wscript b/samples/wscript index deba5598e..0c081ee80 100644 --- a/samples/wscript +++ b/samples/wscript @@ -10,6 +10,9 @@ def build(bld): obj = bld.create_ns3_program('main-simulator') obj.source = 'main-simulator.cc' + obj = bld.create_ns3_program('main-random-variable') + obj.source = 'main-random-variable.cc' + obj = bld.create_ns3_program('main-packet-header', ['common', 'simulator']) obj.source = 'main-packet-header.cc' diff --git a/src/core/random-variable.cc b/src/core/random-variable.cc index 70be8a201..c8989d223 100644 --- a/src/core/random-variable.cc +++ b/src/core/random-variable.cc @@ -1218,6 +1218,230 @@ LogNormalVariable::LogNormalVariable (double mu, double sigma) : RandomVariable (LogNormalVariableImpl (mu, sigma)) {} +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +// GammaVariableImpl +class GammaVariableImpl : public RandomVariableBase +{ +public: + /** + * \param alpha alpha parameter of the gamma distribution + * \param beta beta parameter of the gamma distribution + */ + GammaVariableImpl (double alpha, double beta); + + /** + * \return A random value from this distribution + */ + virtual double GetValue (); + + /** + * \return A random value from the gamma distribution with parameters alpha + * and beta + */ + double GetValue(double alpha, double beta); + + virtual RandomVariableBase* Copy(void) const; + +private: + double m_alpha; + double m_beta; + NormalVariable m_normal; +}; + + +RandomVariableBase* GammaVariableImpl::Copy () const +{ + return new GammaVariableImpl (m_alpha, m_beta); +} + +GammaVariableImpl::GammaVariableImpl (double alpha, double beta) + : m_alpha(alpha), m_beta(beta) +{ +} + +double +GammaVariableImpl::GetValue () +{ + return GetValue(m_alpha, m_beta); +} + +/* + The code for the following generator functions was adapted from ns-2 + tools/ranvar.cc + + Originally the algorithm was devised by Marsaglia in 2000: + G. Marsaglia, W. W. Tsang: A simple method for gereating Gamma variables + ACM Transactions on mathematical software, Vol. 26, No. 3, Sept. 2000 + + The Gamma distribution density function has the form + + x^(alpha-1) * exp(-x/beta) + p(x; alpha, beta) = ---------------------------- + beta^alpha * Gamma(alpha) + + for x > 0. +*/ +double +GammaVariableImpl::GetValue (double alpha, double beta) +{ + if(!m_generator) + { + m_generator = new RngStream(); + } + + if (alpha < 1) + { + double u = m_generator->RandU01 (); + return GetValue(1.0 + alpha, beta) * pow (u, 1.0 / alpha); + } + + double x, v, u; + double d = alpha - 1.0 / 3.0; + double c = (1.0 / 3.0) / sqrt (d); + + while (1) + { + do + { + x = m_normal.GetValue (); + v = 1.0 + c * x; + } while (v <= 0); + + v = v * v * v; + u = m_generator->RandU01 (); + if (u < 1 - 0.0331 * x * x * x * x) + { + break; + } + if (log (u) < 0.5 * x * x + d * (1 - v + log (v))) + { + break; + } + } + + return beta * d * v; +} + +GammaVariable::GammaVariable () + : RandomVariable (GammaVariableImpl (1.0, 1.0)) +{ +} + +GammaVariable::GammaVariable (double alpha, double beta) + : RandomVariable (GammaVariableImpl (alpha, beta)) +{ +} + +double GammaVariable::GetValue(void) const +{ + return this->RandomVariable::GetValue (); +} + +double GammaVariable::GetValue(double alpha, double beta) const +{ + return ((GammaVariableImpl*)Peek())->GetValue(alpha, beta); +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +// ErlangVariableImpl + +class ErlangVariableImpl : public RandomVariableBase +{ +public: + /** + * \param k k parameter of the Erlang distribution + * \param lambda lambda parameter of the Erlang distribution + */ + ErlangVariableImpl (unsigned int k, double lambda); + + /** + * \return A random value from this distribution + */ + virtual double GetValue (); + + /** + * \return A random value from the Erlang distribution with parameters k and + * lambda. + */ + double GetValue(unsigned int k, double lambda); + + virtual RandomVariableBase* Copy(void) const; + +private: + unsigned int m_k; + double m_lambda; +}; + + +RandomVariableBase* ErlangVariableImpl::Copy () const +{ + return new ErlangVariableImpl (m_k, m_lambda); +} + +ErlangVariableImpl::ErlangVariableImpl (unsigned int k, double lambda) + : m_k(k), m_lambda(lambda) +{ +} + +double +ErlangVariableImpl::GetValue () +{ + return GetValue(m_k, m_lambda); +} + +/* + The code for the following generator functions was adapted from ns-2 + tools/ranvar.cc + + The Erlang distribution density function has the form + + x^(k-1) * exp(-x/lambda) + p(x; k, lambda) = --------------------------- + lambda^k * (k-1)! + + for x > 0. +*/ +double +ErlangVariableImpl::GetValue (unsigned int k, double lambda) +{ + if(!m_generator) + { + m_generator = new RngStream(); + } + + ExponentialVariable exponential(lambda); + + double result = 0; + for (unsigned int i = 0; i < k; ++i) + { + result += exponential.GetValue(); + } + + return result; +} + +ErlangVariable::ErlangVariable () + : RandomVariable (ErlangVariableImpl (1, 1.0)) +{ +} + +ErlangVariable::ErlangVariable (unsigned int k, double lambda) + : RandomVariable (ErlangVariableImpl (k, lambda)) +{ +} + +double ErlangVariable::GetValue(void) const +{ + return this->RandomVariable::GetValue (); +} + +double ErlangVariable::GetValue(unsigned int k, double lambda) const +{ + return ((ErlangVariableImpl*)Peek())->GetValue(k, lambda); +} + //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- // TriangularVariableImpl methods diff --git a/src/core/random-variable.h b/src/core/random-variable.h index fc48ddf7a..a637726d4 100644 --- a/src/core/random-variable.h +++ b/src/core/random-variable.h @@ -36,7 +36,7 @@ * */ -namespace ns3{ +namespace ns3 { class RandomVariableBase; @@ -422,7 +422,7 @@ public: * value and a shape (alpha) parameter of 1.5. * \param m mean value of the distribution */ - WeibullVariable(double m) ; + WeibullVariable(double m) ; /** * Constructs a weibull random variable with the specified mean @@ -560,7 +560,6 @@ public: explicit DeterministicVariable(double* d, uint32_t c); }; - /** * \brief Log-normal Distributed random var * \ingroup randomvariable @@ -593,6 +592,108 @@ public: LogNormalVariable (double mu, double sigma); }; +/** + * \brief Gamma Distributed Random Variable + * \ingroup randomvariable + * + * GammaVariable defines a random variable with gamma distribution. + * + * This class supports the creation of objects that return random numbers + * from a fixed gamma distribution. It also supports the generation of + * single random numbers from various gamma distributions. + * + * The probability density function is defined over the interval [0,+inf) as: + * \f$ x^{\alpha-1} \frac{e^{-\frac{x}{\beta}}}{\beta^\alpha \Gamma(\alpha)}\f$ + * where \f$ mean = \alpha\beta \f$ and + * \f$ variance = \alpha \beta^2\f$ + */ +class GammaVariable : public RandomVariable +{ +public: + /** + * Constructs a gamma random variable with alpha = 1.0 and beta = 1.0 + */ + GammaVariable (); + + /** + * \param alpha alpha parameter of the gamma distribution + * \param beta beta parameter of the gamma distribution + */ + GammaVariable (double alpha, double beta); + + /** + * \brief call RandomVariable::GetValue + * \return A floating point random value + * + * Note: we have to re-implement this method here because the method is + * overloaded below for the two-argument variant and the c++ name resolution + * rules don't work well with overloads split between parent and child + * classes. + */ + double GetValue (void) const; + + /** + * \brief Returns a gamma random distributed double with parameters alpha and beta. + * \param alpha alpha parameter of the gamma distribution + * \param beta beta parameter of the gamma distribution + * \return A floating point random value + */ + double GetValue(double alpha, double beta) const; +}; + +/** + * \brief Erlang Distributed Random Variable + * \ingroup randomvariable + * + * ErlangVariable defines a random variable with Erlang distribution. + * + * The Erlang distribution is a special case of the Gamma distribution where k + * (= alpha) is a non-negative integer. Erlang distributed variables can be + * generated using a much faster algorithm than gamma variables. + * + * This class supports the creation of objects that return random numbers from + * a fixed Erlang distribution. It also supports the generation of single + * random numbers from various Erlang distributions. + * + * The probability density function is defined over the interval [0,+inf) as: + * \f$ \frac{x^{k-1} e^{-\frac{x}{\lambda}}}{\lambda^k (k-1)!}\f$ + * where \f$ mean = k \lambda \f$ and + * \f$ variance = k \lambda^2\f$ + */ +class ErlangVariable : public RandomVariable +{ +public: + /** + * Constructs an Erlang random variable with k = 1 and lambda = 1.0 + */ + ErlangVariable (); + + /** + * \param k k parameter of the Erlang distribution. Must be a non-negative integer. + * \param lambda lambda parameter of the Erlang distribution + */ + ErlangVariable (unsigned int k, double lambda); + + /** + * \brief call RandomVariable::GetValue + * \return A floating point random value + * + * Note: we have to re-implement this method here because the method is + * overloaded below for the two-argument variant and the c++ name resolution + * rules don't work well with overloads split between parent and child + * classes. + */ + double GetValue (void) const; + + /** + * \brief Returns an Erlang random distributed double with parameters k and lambda. + * \param k k parameter of the Erlang distribution. Must be a non-negative integer. + * \param lambda lambda parameter of the Erlang distribution + * \return A floating point random value + */ + double GetValue(unsigned int k, double lambda) const; +}; + /** * \brief Triangularly Distributed random var * \ingroup randomvariable diff --git a/src/core/type-id.cc b/src/core/type-id.cc index 90d400c05..dcab76ecb 100644 --- a/src/core/type-id.cc +++ b/src/core/type-id.cc @@ -71,6 +71,9 @@ public: bool MustHideFromDocumentation (uint16_t uid) const; private: + bool HasTraceSource (uint16_t uid, std::string name); + bool HasAttribute (uint16_t uid, std::string name); + struct AttributeInformation { std::string name; std::string help; @@ -231,6 +234,33 @@ IidManager::GetRegistered (uint32_t i) const return i + 1; } +bool +IidManager::HasAttribute (uint16_t uid, + std::string name) +{ + struct IidInformation *information = LookupInformation (uid); + while (true) + { + for (std::vector::const_iterator i = information->attributes.begin (); + i != information->attributes.end (); ++i) + { + if (i->name == name) + { + return true; + } + } + struct IidInformation *parent = LookupInformation (information->parent); + if (parent == information) + { + // top of inheritance tree + return false; + } + // check parent + information = parent; + } + return false; +} + void IidManager::AddAttribute (uint16_t uid, std::string name, @@ -241,14 +271,10 @@ IidManager::AddAttribute (uint16_t uid, ns3::Ptr checker) { struct IidInformation *information = LookupInformation (uid); - for (std::vector::const_iterator j = information->attributes.begin (); - j != information->attributes.end (); j++) + if (HasAttribute (uid, name)) { - if (j->name == name) - { - NS_FATAL_ERROR ("Registered the same attribute twice name=\""<name<<"\""); - return; - } + NS_FATAL_ERROR ("Attribute \"" << name << "\" already registered on tid=\"" << + information->name << "\""); } struct AttributeInformation param; param.name = name; @@ -310,6 +336,33 @@ IidManager::GetAttributeChecker (uint16_t uid, uint32_t i) const return information->attributes[i].checker; } +bool +IidManager::HasTraceSource (uint16_t uid, + std::string name) +{ + struct IidInformation *information = LookupInformation (uid); + while (true) + { + for (std::vector::const_iterator i = information->traceSources.begin (); + i != information->traceSources.end (); ++i) + { + if (i->name == name) + { + return true; + } + } + struct IidInformation *parent = LookupInformation (information->parent); + if (parent == information) + { + // top of inheritance tree + return false; + } + // check parent + information = parent; + } + return false; +} + void IidManager::AddTraceSource (uint16_t uid, std::string name, @@ -317,6 +370,11 @@ IidManager::AddTraceSource (uint16_t uid, ns3::Ptr accessor) { struct IidInformation *information = LookupInformation (uid); + if (HasTraceSource (uid, name)) + { + NS_FATAL_ERROR ("Trace source \"" << name << "\" already registered on tid=\"" << + information->name << "\""); + } struct TraceSourceInformation source; source.name = name; source.help = help; diff --git a/src/devices/bridge/bridge-channel.cc b/src/devices/bridge/bridge-channel.cc index e5eac7a54..b8b8b6bca 100644 --- a/src/devices/bridge/bridge-channel.cc +++ b/src/devices/bridge/bridge-channel.cc @@ -34,7 +34,7 @@ BridgeChannel::GetTypeId (void) } BridgeChannel::BridgeChannel () - : Channel ("BridgeChannel") + : Channel () { NS_LOG_FUNCTION_NOARGS (); } diff --git a/src/devices/bridge/bridge-net-device.cc b/src/devices/bridge/bridge-net-device.cc index b4a376b8c..03d7778eb 100644 --- a/src/devices/bridge/bridge-net-device.cc +++ b/src/devices/bridge/bridge-net-device.cc @@ -53,7 +53,6 @@ BridgeNetDevice::GetTypeId (void) BridgeNetDevice::BridgeNetDevice () : m_node (0), - m_name (""), m_ifIndex (0), m_mtu (0xffff) { @@ -128,7 +127,7 @@ BridgeNetDevice::ForwardUnicast (Ptr incomingPort, Ptr uint16_t protocol, Mac48Address src, Mac48Address dst) { NS_LOG_FUNCTION_NOARGS (); - NS_LOG_DEBUG ("LearningBridgeForward (incomingPort=" << incomingPort->GetName () + NS_LOG_DEBUG ("LearningBridgeForward (incomingPort=" << incomingPort->GetInstanceTypeId ().GetName () << ", packet=" << packet << ", protocol="< incomingPort, Ptr Ptr outPort = GetLearnedState (dst); if (outPort != NULL && outPort != incomingPort) { - NS_LOG_LOGIC ("Learning bridge state says to use port `" << outPort->GetName () << "'"); + NS_LOG_LOGIC ("Learning bridge state says to use port `" << outPort->GetInstanceTypeId ().GetName () << "'"); outPort->SendFrom (packet->Copy (), src, dst, protocol); } else @@ -148,8 +147,9 @@ BridgeNetDevice::ForwardUnicast (Ptr incomingPort, Ptr Ptr port = *iter; if (port != incomingPort) { - NS_LOG_LOGIC ("LearningBridgeForward (" << src << " => " << dst << "): " << incomingPort->GetName () - << " --> " << port->GetName () + NS_LOG_LOGIC ("LearningBridgeForward (" << src << " => " << dst << "): " + << incomingPort->GetInstanceTypeId ().GetName () + << " --> " << port->GetInstanceTypeId ().GetName () << " (UID " << packet->GetUid () << ")."); port->SendFrom (packet->Copy (), src, dst, protocol); } @@ -162,7 +162,7 @@ BridgeNetDevice::ForwardBroadcast (Ptr incomingPort, Ptr incomingPort, Ptr port = *iter; if (port != incomingPort) { - NS_LOG_LOGIC ("LearningBridgeForward (" << src << " => " << dst << "): " << incomingPort->GetName () - << " --> " << port->GetName () + NS_LOG_LOGIC ("LearningBridgeForward (" << src << " => " << dst << "): " + << incomingPort->GetInstanceTypeId ().GetName () + << " --> " << port->GetInstanceTypeId ().GetName () << " (UID " << packet->GetUid () << ")."); port->SendFrom (packet->Copy (), src, dst, protocol); } @@ -249,27 +250,13 @@ BridgeNetDevice::AddBridgePort (Ptr bridgePort) m_address = Mac48Address::ConvertFrom (bridgePort->GetAddress ()); } - NS_LOG_DEBUG ("RegisterProtocolHandler for " << bridgePort->GetName ()); + NS_LOG_DEBUG ("RegisterProtocolHandler for " << bridgePort->GetInstanceTypeId ().GetName ()); m_node->RegisterProtocolHandler (MakeCallback (&BridgeNetDevice::ReceiveFromDevice, this), 0, bridgePort, true); m_ports.push_back (bridgePort); m_channel->AddChannel (bridgePort->GetChannel ()); } -void -BridgeNetDevice::SetName(const std::string name) -{ - NS_LOG_FUNCTION_NOARGS (); - m_name = name; -} - -std::string -BridgeNetDevice::GetName(void) const -{ - NS_LOG_FUNCTION_NOARGS (); - return m_name; -} - void BridgeNetDevice::SetIfIndex(const uint32_t index) { diff --git a/src/devices/bridge/bridge-net-device.h b/src/devices/bridge/bridge-net-device.h index 4af590c97..02be49f37 100644 --- a/src/devices/bridge/bridge-net-device.h +++ b/src/devices/bridge/bridge-net-device.h @@ -88,8 +88,6 @@ public: Ptr GetBridgePort (uint32_t n) const; // inherited from NetDevice base class. - virtual void SetName(const std::string name); - virtual std::string GetName(void) const; virtual void SetIfIndex(const uint32_t index); virtual uint32_t GetIfIndex(void) const; virtual Ptr GetChannel (void) const; @@ -140,7 +138,6 @@ private: std::map m_learnState; Ptr m_node; Ptr m_channel; - std::string m_name; std::vector< Ptr > m_ports; uint32_t m_ifIndex; uint16_t m_mtu; diff --git a/src/devices/csma/csma-channel.cc b/src/devices/csma/csma-channel.cc index ab2a83bf3..20b870db1 100644 --- a/src/devices/csma/csma-channel.cc +++ b/src/devices/csma/csma-channel.cc @@ -51,7 +51,7 @@ CsmaChannel::GetTypeId (void) CsmaChannel::CsmaChannel () : - Channel ("Csma Channel") + Channel () { NS_LOG_FUNCTION_NOARGS (); m_state = IDLE; diff --git a/src/devices/csma/csma-net-device.cc b/src/devices/csma/csma-net-device.cc index f9742c649..dc953e7b6 100644 --- a/src/devices/csma/csma-net-device.cc +++ b/src/devices/csma/csma-net-device.cc @@ -154,8 +154,7 @@ CsmaNetDevice::GetTypeId (void) } CsmaNetDevice::CsmaNetDevice () - : m_name (""), - m_linkUp (false) + : m_linkUp (false) { NS_LOG_FUNCTION (this); m_txMachineState = READY; @@ -873,20 +872,6 @@ CsmaNetDevice::NotifyLinkUp (void) } } - void -CsmaNetDevice::SetName (const std::string name) -{ - NS_LOG_FUNCTION (name); - m_name = name; -} - - std::string -CsmaNetDevice::GetName (void) const -{ - NS_LOG_FUNCTION_NOARGS (); - return m_name; -} - void CsmaNetDevice::SetIfIndex (const uint32_t index) { @@ -1054,25 +1039,6 @@ CsmaNetDevice::SetNode (Ptr node) NS_LOG_FUNCTION (node); m_node = node; - int count = -1; - if (m_name.size () == 0) - { - for (uint32_t i = 0; i < node->GetNDevices (); i++) - { - Ptr dev = node->GetDevice (i); - if (dynamic_cast (PeekPointer (dev))) - { - count++; - if (dev == this) - { - break; - } - } - } - std::ostringstream s; - s << "eth" << count; - m_name = s.str (); - } } bool diff --git a/src/devices/csma/csma-net-device.h b/src/devices/csma/csma-net-device.h index 2213e1390..7dc1f9c55 100644 --- a/src/devices/csma/csma-net-device.h +++ b/src/devices/csma/csma-net-device.h @@ -305,8 +305,6 @@ public: // // The following methods are inherited from NetDevice base class. // - virtual void SetName (const std::string name); - virtual std::string GetName (void) const; virtual void SetIfIndex (const uint32_t index); virtual uint32_t GetIfIndex (void) const; virtual Ptr GetChannel (void) const; @@ -807,11 +805,6 @@ private: */ uint32_t m_ifIndex; - /** - * The human readable name of this device. - */ - std::string m_name; - /** * Flag indicating whether or not the link is up. In this case, * whether or not the device is connected to a channel. diff --git a/src/devices/emu/emu-net-device.cc b/src/devices/emu/emu-net-device.cc index 0a987850e..7d3e451eb 100644 --- a/src/devices/emu/emu-net-device.cc +++ b/src/devices/emu/emu-net-device.cc @@ -68,11 +68,6 @@ EmuNetDevice::GetTypeId (void) Mac48AddressValue (Mac48Address ("ff:ff:ff:ff:ff:ff")), MakeMac48AddressAccessor (&EmuNetDevice::m_address), MakeMac48AddressChecker ()) - .AddAttribute ("DeviceName", - "The name of the underlying real device (e.g. eth1).", - StringValue ("eth1"), - MakeStringAccessor (&EmuNetDevice::m_deviceName), - MakeStringChecker ()) .AddAttribute ("Start", "The simulation time at which to spin up the device thread.", TimeValue (Seconds (0.)), @@ -173,8 +168,7 @@ EmuNetDevice::EmuNetDevice () m_sock (-1), m_readThread (0), m_ifIndex (std::numeric_limits::max ()), // absurdly large value - m_sll_ifindex (-1), - m_name ("Emu NetDevice") + m_sll_ifindex (-1) { NS_LOG_FUNCTION (this); Start (m_tStart); @@ -843,18 +837,6 @@ EmuNetDevice::NotifyLinkUp (void) } } -void -EmuNetDevice::SetName(const std::string name) -{ - m_name = name; -} - -std::string -EmuNetDevice::GetName(void) const -{ - return m_name; -} - void EmuNetDevice::SetIfIndex(const uint32_t index) { diff --git a/src/devices/emu/emu-net-device.h b/src/devices/emu/emu-net-device.h index 02947cb53..189a81833 100644 --- a/src/devices/emu/emu-net-device.h +++ b/src/devices/emu/emu-net-device.h @@ -105,9 +105,6 @@ public: // // Pure virtual methods inherited from NetDevice we must implement. // - virtual void SetName(const std::string name); - virtual std::string GetName(void) const; - virtual void SetIfIndex(const uint32_t index); virtual uint32_t GetIfIndex(void) const; @@ -449,11 +446,6 @@ private: */ int32_t m_sll_ifindex; - /** - * The human readable name of this device. - */ - std::string m_name; - /** * Flag indicating whether or not the link is up. In this case, * whether or not the device is connected to a channel. diff --git a/src/devices/point-to-point/point-to-point-channel.cc b/src/devices/point-to-point/point-to-point-channel.cc index b94add35c..6fa1b7bee 100644 --- a/src/devices/point-to-point/point-to-point-channel.cc +++ b/src/devices/point-to-point/point-to-point-channel.cc @@ -43,11 +43,11 @@ PointToPointChannel::GetTypeId (void) } // -// By default, you get a channel with the name "PointToPoint Channel" that +// By default, you get a channel that // has an "infitely" fast transmission speed and zero delay. PointToPointChannel::PointToPointChannel() : - Channel ("PointToPoint Channel"), + Channel (), m_delay (Seconds (0.)), m_nDevices (0) { diff --git a/src/devices/point-to-point/point-to-point-channel.h b/src/devices/point-to-point/point-to-point-channel.h index b31a37ae7..9830e048f 100644 --- a/src/devices/point-to-point/point-to-point-channel.h +++ b/src/devices/point-to-point/point-to-point-channel.h @@ -50,7 +50,7 @@ public: /** * \brief Create a PointToPointChannel * - * By default, you get a channel with the name "PointToPoint Channel" that + * By default, you get a channel that * has zero transmission delay. */ PointToPointChannel (); diff --git a/src/devices/point-to-point/point-to-point-net-device.cc b/src/devices/point-to-point/point-to-point-net-device.cc index 856ba6852..609441cad 100644 --- a/src/devices/point-to-point/point-to-point-net-device.cc +++ b/src/devices/point-to-point/point-to-point-net-device.cc @@ -148,7 +148,6 @@ PointToPointNetDevice::PointToPointNetDevice () : m_txMachineState (READY), m_channel (0), - m_name (""), m_linkUp (false), m_currentPkt (0) { @@ -373,18 +372,6 @@ PointToPointNetDevice::NotifyLinkUp (void) } } - void -PointToPointNetDevice::SetName(const std::string name) -{ - m_name = name; -} - - std::string -PointToPointNetDevice::GetName(void) const -{ - return m_name; -} - void PointToPointNetDevice::SetIfIndex(const uint32_t index) { diff --git a/src/devices/point-to-point/point-to-point-net-device.h b/src/devices/point-to-point/point-to-point-net-device.h index 5af6c9c66..956b6a356 100644 --- a/src/devices/point-to-point/point-to-point-net-device.h +++ b/src/devices/point-to-point/point-to-point-net-device.h @@ -226,12 +226,6 @@ public: */ uint16_t GetFrameSize (void) const; -// -// Pure virtual methods inherited from NetDevice we must implement. -// - virtual void SetName(const std::string name); - virtual std::string GetName(void) const; - virtual void SetIfIndex(const uint32_t index); virtual uint32_t GetIfIndex(void) const; @@ -531,7 +525,6 @@ private: NetDevice::ReceiveCallback m_rxCallback; NetDevice::PromiscReceiveCallback m_promiscCallback; uint32_t m_ifIndex; - std::string m_name; bool m_linkUp; Callback m_linkChangeCallback; diff --git a/src/devices/tap-bridge/tap-bridge.cc b/src/devices/tap-bridge/tap-bridge.cc index fa14796a9..9c99c21fb 100644 --- a/src/devices/tap-bridge/tap-bridge.cc +++ b/src/devices/tap-bridge/tap-bridge.cc @@ -957,20 +957,6 @@ TapBridge::ReceiveFromBridgedDevice ( NS_ABORT_MSG_IF (bytesWritten != p->GetSize (), "TapBridge::ReceiveFromBridgedDevice(): Write error."); } -void -TapBridge::SetName(const std::string name) -{ - NS_LOG_FUNCTION_NOARGS (); - m_name = name; -} - -std::string -TapBridge::GetName(void) const -{ - NS_LOG_FUNCTION_NOARGS (); - return m_name; -} - void TapBridge::SetIfIndex(const uint32_t index) { diff --git a/src/devices/tap-bridge/tap-bridge.h b/src/devices/tap-bridge/tap-bridge.h index 62d6a1350..ac2fb2a2d 100644 --- a/src/devices/tap-bridge/tap-bridge.h +++ b/src/devices/tap-bridge/tap-bridge.h @@ -173,8 +173,6 @@ public: // The following methods are inherited from NetDevice base class and are // documented there. // - virtual void SetName(const std::string name); - virtual std::string GetName(void) const; virtual void SetIfIndex(const uint32_t index); virtual uint32_t GetIfIndex(void) const; virtual Ptr GetChannel (void) const; @@ -318,12 +316,6 @@ private: */ Ptr m_node; - /** - * \internal - * - * A possible name for the (ghost) Node to which we are connected. - */ - std::string m_name; /** * \internal diff --git a/src/devices/wifi/dcf-manager-test.cc b/src/devices/wifi/dcf-manager-test.cc index 18787ab57..01cf118b2 100644 --- a/src/devices/wifi/dcf-manager-test.cc +++ b/src/devices/wifi/dcf-manager-test.cc @@ -1,4 +1,22 @@ /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ +/* + * Copyright (c) 2005,2006 INRIA + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation; + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Author: Mathieu Lacage + */ #ifdef RUN_SELF_TESTS #include "ns3/test.h" diff --git a/src/devices/wifi/dcf-manager.cc b/src/devices/wifi/dcf-manager.cc index c2dbc9e63..6dd69b31f 100644 --- a/src/devices/wifi/dcf-manager.cc +++ b/src/devices/wifi/dcf-manager.cc @@ -1,4 +1,22 @@ /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ +/* + * Copyright (c) 2005,2006 INRIA + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation; + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Author: Mathieu Lacage + */ #include "ns3/assert.h" #include "ns3/log.h" diff --git a/src/devices/wifi/interference-helper.cc b/src/devices/wifi/interference-helper.cc index fa50b5674..dff6c5eb9 100644 --- a/src/devices/wifi/interference-helper.cc +++ b/src/devices/wifi/interference-helper.cc @@ -1,3 +1,22 @@ +/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ +/* + * Copyright (c) 2005,2006 INRIA + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation; + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Author: Mathieu Lacage + */ #include "interference-helper.h" #include "wifi-phy.h" #include "error-rate-model.h" @@ -137,15 +156,15 @@ InterferenceHelper::GetMaxPacketDuration (void) const } void -InterferenceHelper::SetNoiseFloorW (double noiseFloor) +InterferenceHelper::SetNoiseFigure (double value) { - m_noiseFloorW = noiseFloor; + m_noiseFigure = value; } double -InterferenceHelper::GetNoiseFloorW (void) const +InterferenceHelper::GetNoiseFigure (void) const { - return m_noiseFloorW; + return m_noiseFigure; } void @@ -260,9 +279,10 @@ InterferenceHelper::CalculateSnr (double signal, double noiseInterference, WifiM { // thermal noise at 290K in J/s = W static const double BOLTZMANN = 1.3803e-23; + // Nt is the power of thermal noise in W double Nt = BOLTZMANN * 290.0 * mode.GetBandwidth (); - // receiver noise Floor (W) - double noiseFloor = m_noiseFloorW * Nt; + // receiver noise Floor (W) which accounts for thermal noise and non-idealities of the receiver + double noiseFloor = m_noiseFigure * Nt; double noise = noiseFloor + noiseInterference; double snr = signal / noise; return snr; diff --git a/src/devices/wifi/interference-helper.h b/src/devices/wifi/interference-helper.h index 29d284501..0b40e239d 100644 --- a/src/devices/wifi/interference-helper.h +++ b/src/devices/wifi/interference-helper.h @@ -1,3 +1,22 @@ +/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ +/* + * Copyright (c) 2005,2006 INRIA + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation; + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Author: Mathieu Lacage + */ #ifndef INTERFERENCE_HELPER_H #define INTERFERENCE_HELPER_H @@ -50,10 +69,10 @@ public: ~InterferenceHelper (); void Configure80211aParameters (void); - void SetNoiseFloorW (double noiseFloor); + void SetNoiseFigure (double value); void SetErrorRateModel (Ptr rate); - double GetNoiseFloorW (void) const; + double GetNoiseFigure (void) const; Ptr GetErrorRateModel (void) const; @@ -99,7 +118,7 @@ private: WifiMode m_shortPlcpHeaderMode; uint32_t m_plcpHeaderLength; Time m_maxPacketDuration; - double m_noiseFloorW; + double m_noiseFigure; /**< noise figure (linear) */ Events m_events; bool m_80211a; Ptr m_errorRateModel; diff --git a/src/devices/wifi/wifi-net-device.cc b/src/devices/wifi/wifi-net-device.cc index 5f67c2224..d7dccc85d 100644 --- a/src/devices/wifi/wifi-net-device.cc +++ b/src/devices/wifi/wifi-net-device.cc @@ -136,16 +136,6 @@ WifiNetDevice::GetRemoteStationManager (void) const return m_stationManager; } -void -WifiNetDevice::SetName(const std::string name) -{ - m_name = name; -} -std::string -WifiNetDevice::GetName(void) const -{ - return m_name; -} void WifiNetDevice::SetIfIndex(const uint32_t index) { diff --git a/src/devices/wifi/wifi-net-device.h b/src/devices/wifi/wifi-net-device.h index 2bee1d2f9..d5aae5797 100644 --- a/src/devices/wifi/wifi-net-device.h +++ b/src/devices/wifi/wifi-net-device.h @@ -75,8 +75,6 @@ public: // inherited from NetDevice base class. - virtual void SetName(const std::string name); - virtual std::string GetName(void) const; virtual void SetIfIndex(const uint32_t index); virtual uint32_t GetIfIndex(void) const; virtual Ptr GetChannel (void) const; @@ -123,7 +121,6 @@ private: TracedCallback, Mac48Address> m_txLogger; uint32_t m_ifIndex; - std::string m_name; bool m_linkUp; Callback m_linkChange; mutable uint16_t m_mtu; diff --git a/src/devices/wifi/wifi-phy-test.cc b/src/devices/wifi/wifi-phy-test.cc index d1ee08880..9f4444416 100644 --- a/src/devices/wifi/wifi-phy-test.cc +++ b/src/devices/wifi/wifi-phy-test.cc @@ -1,3 +1,22 @@ +/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ +/* + * Copyright (c) 2005,2006 INRIA + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation; + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Author: Mathieu Lacage + */ #include "wifi-net-device.h" #include "yans-wifi-channel.h" #include "yans-wifi-phy.h" diff --git a/src/devices/wifi/wifi-remote-station-manager.cc b/src/devices/wifi/wifi-remote-station-manager.cc index 296a28e7b..b4626b78a 100644 --- a/src/devices/wifi/wifi-remote-station-manager.cc +++ b/src/devices/wifi/wifi-remote-station-manager.cc @@ -97,7 +97,7 @@ NonUnicastWifiRemoteStation::DoReportFinalDataFailed (void) WifiMode NonUnicastWifiRemoteStation::DoGetDataMode (uint32_t size) { - WifiMode mode = m_stations->GetBasicMode (0); + WifiMode mode = m_stations->GetNonUnicastMode (); NS_LOG_DEBUG ("non-unicast size="< + */ #ifdef RUN_SELF_TESTS #include "wifi-net-device.h" diff --git a/src/devices/wifi/yans-wifi-phy.cc b/src/devices/wifi/yans-wifi-phy.cc index 369bb589f..f57ebdfaf 100644 --- a/src/devices/wifi/yans-wifi-phy.cc +++ b/src/devices/wifi/yans-wifi-phy.cc @@ -93,11 +93,17 @@ YansWifiPhy::GetTypeId (void) MakeDoubleAccessor (&YansWifiPhy::SetTxPowerStart, &YansWifiPhy::GetTxPowerStart), MakeDoubleChecker ()) - .AddAttribute ("RxNoise", - "Ratio of energy lost by receiver (dB).", + .AddAttribute ("RxNoiseFigure", + "Loss (dB) in the Signal-to-Noise-Ratio due to non-idealities in the receiver." + " According to Wikipedia (http://en.wikipedia.org/wiki/Noise_figure), this is " + "\"the difference in decibels (dB) between" + " the noise output of the actual receiver to the noise output of an " + " ideal receiver with the same overall gain and bandwidth when the receivers " + " are connected to sources at the standard noise temperature T0 (usually 290 K)\"." + " For", DoubleValue (7), - MakeDoubleAccessor (&YansWifiPhy::SetRxNoise, - &YansWifiPhy::GetRxNoise), + MakeDoubleAccessor (&YansWifiPhy::SetRxNoiseFigure, + &YansWifiPhy::GetRxNoiseFigure), MakeDoubleChecker ()) .AddAttribute ("Standard", "The standard chosen configures a set of transmission modes" " and some PHY-specific constants.", @@ -155,10 +161,10 @@ YansWifiPhy::SetStandard (enum WifiPhyStandard standard) void -YansWifiPhy::SetRxNoise (double db) +YansWifiPhy::SetRxNoiseFigure (double noiseFigureDb) { - NS_LOG_FUNCTION (this << db); - m_interference.SetNoiseFloorW (DbToRatio (db)); + NS_LOG_FUNCTION (this << noiseFigureDb); + m_interference.SetNoiseFigure (DbToRatio (noiseFigureDb)); } void YansWifiPhy::SetTxPowerStart (double start) @@ -219,9 +225,9 @@ YansWifiPhy::SetMobility (Ptr mobility) } double -YansWifiPhy::GetRxNoise (void) const +YansWifiPhy::GetRxNoiseFigure (void) const { - return RatioToDb (m_interference.GetNoiseFloorW ()); + return RatioToDb (m_interference.GetNoiseFigure ()); } double YansWifiPhy::GetTxPowerStart (void) const diff --git a/src/devices/wifi/yans-wifi-phy.h b/src/devices/wifi/yans-wifi-phy.h index faf6e85c4..49d5c2d85 100644 --- a/src/devices/wifi/yans-wifi-phy.h +++ b/src/devices/wifi/yans-wifi-phy.h @@ -75,7 +75,7 @@ public: WifiPreamble preamble); void SetStandard (enum WifiPhyStandard standard); - void SetRxNoise (double ratio); + void SetRxNoiseFigure (double noiseFigureDb); void SetTxPowerStart (double start); void SetTxPowerEnd (double end); void SetNTxPower (uint32_t n); @@ -86,7 +86,7 @@ public: void SetErrorRateModel (Ptr rate); void SetDevice (Ptr device); void SetMobility (Ptr mobility); - double GetRxNoise (void) const; + double GetRxNoiseFigure (void) const; double GetTxGain (void) const; double GetRxGain (void) const; double GetEdThreshold (void) const; diff --git a/src/mobility/random-waypoint-mobility-model.cc b/src/mobility/random-waypoint-mobility-model.cc index 5188fff82..bff248676 100644 --- a/src/mobility/random-waypoint-mobility-model.cc +++ b/src/mobility/random-waypoint-mobility-model.cc @@ -45,7 +45,7 @@ RandomWaypointMobilityModel::GetTypeId (void) RandomVariableValue (ConstantVariable (2.0)), MakeRandomVariableAccessor (&RandomWaypointMobilityModel::m_pause), MakeRandomVariableChecker ()) - .AddAttribute ("Position", + .AddAttribute ("PositionAllocator", "The position model used to pick a destination point.", PointerValue (), MakePointerAccessor (&RandomWaypointMobilityModel::m_position), diff --git a/src/node/channel.cc b/src/node/channel.cc index 6f23bad49..e85503c66 100644 --- a/src/node/channel.cc +++ b/src/node/channel.cc @@ -35,34 +35,14 @@ Channel::GetTypeId (void) } Channel::Channel () - : m_name("Channel") { NS_LOG_FUNCTION_NOARGS (); } -Channel::Channel (std::string name) - : m_name(name) -{ - NS_LOG_FUNCTION (this << name); -} Channel::~Channel () { NS_LOG_FUNCTION_NOARGS (); } - void -Channel::SetName(std::string name) -{ - NS_LOG_FUNCTION (this << name); - m_name = name; -} - - std::string -Channel::GetName(void) -{ - NS_LOG_FUNCTION_NOARGS (); - return m_name; -} - } // namespace ns3 diff --git a/src/node/channel.h b/src/node/channel.h index 1e4a0cd6a..68f8d3175 100644 --- a/src/node/channel.h +++ b/src/node/channel.h @@ -43,12 +43,8 @@ public: static TypeId GetTypeId (void); Channel (); - Channel (std::string name); virtual ~Channel (); - void SetName(std::string); - std::string GetName(void); - /** * \returns the number of NetDevices connected to this Channel. * @@ -63,10 +59,8 @@ public: */ virtual Ptr GetDevice (uint32_t i) const = 0; -private: - std::string m_name; }; -}; // namespace ns3 +} // namespace ns3 #endif /* NS3_CHANNEL_H */ diff --git a/src/node/net-device.h b/src/node/net-device.h index ced6c9dff..dcdaa6d75 100644 --- a/src/node/net-device.h +++ b/src/node/net-device.h @@ -67,14 +67,6 @@ public: static TypeId GetTypeId (void); virtual ~NetDevice(); - /** - * \param name name of the device (e.g. "eth0") - */ - virtual void SetName(const std::string name) = 0; - /** - * \return name name of the device (e.g. "eth0") - */ - virtual std::string GetName(void) const = 0; /** * \param index ifIndex of the device */ diff --git a/src/node/node.cc b/src/node/node.cc index 9cecbab14..199490484 100644 --- a/src/node/node.cc +++ b/src/node/node.cc @@ -225,7 +225,7 @@ bool Node::PromiscReceiveFromDevice (Ptr device, Ptr packet, uint16_t protocol, const Address &from, const Address &to, NetDevice::PacketType packetType) { - NS_LOG_FUNCTION(device->GetName ()); + NS_LOG_FUNCTION(this); return ReceiveFromDevice (device, packet, protocol, from, to, packetType, true); } @@ -233,7 +233,7 @@ bool Node::NonPromiscReceiveFromDevice (Ptr device, Ptr packet, uint16_t protocol, const Address &from) { - NS_LOG_FUNCTION(device->GetName ()); + NS_LOG_FUNCTION(this); return ReceiveFromDevice (device, packet, protocol, from, from, NetDevice::PacketType (0), false); } @@ -242,8 +242,7 @@ Node::ReceiveFromDevice (Ptr device, Ptr packet, uint16 const Address &from, const Address &to, NetDevice::PacketType packetType, bool promiscuous) { NS_LOG_DEBUG("Node " << GetId () << " ReceiveFromDevice: dev " - << device->GetIfIndex () << " (" - << device->GetName () << " type " << device->GetInstanceTypeId ().GetName () + << device->GetIfIndex () << " (type=" << device->GetInstanceTypeId ().GetName () << ") Packet UID " << packet->GetUid ()); bool found = false; diff --git a/src/node/simple-net-device.cc b/src/node/simple-net-device.cc index d13bd53fe..d996d5341 100644 --- a/src/node/simple-net-device.cc +++ b/src/node/simple-net-device.cc @@ -38,7 +38,6 @@ SimpleNetDevice::SimpleNetDevice () : m_channel (0), m_node (0), m_mtu (0xffff), - m_name (""), m_ifIndex (0) {} @@ -83,16 +82,6 @@ SimpleNetDevice::SetAddress (Mac48Address address) m_address = address; } -void -SimpleNetDevice::SetName(const std::string name) -{ - m_name = name; -} -std::string -SimpleNetDevice::GetName(void) const -{ - return m_name; -} void SimpleNetDevice::SetIfIndex(const uint32_t index) { diff --git a/src/node/simple-net-device.h b/src/node/simple-net-device.h index 1e1f15323..7840887cf 100644 --- a/src/node/simple-net-device.h +++ b/src/node/simple-net-device.h @@ -46,8 +46,6 @@ public: void SetAddress (Mac48Address address); // inherited from NetDevice base class. - virtual void SetName(const std::string name); - virtual std::string GetName(void) const; virtual void SetIfIndex(const uint32_t index); virtual uint32_t GetIfIndex(void) const; virtual Ptr GetChannel (void) const; @@ -82,7 +80,6 @@ private: NetDevice::PromiscReceiveCallback m_promiscCallback; Ptr m_node; uint16_t m_mtu; - std::string m_name; uint32_t m_ifIndex; Mac48Address m_address; }; diff --git a/utils/python-unit-tests.py b/utils/python-unit-tests.py index 00713e8d9..a08f668fe 100644 --- a/utils/python-unit-tests.py +++ b/utils/python-unit-tests.py @@ -97,14 +97,14 @@ class TestSimulator(unittest.TestCase): ## -- object pointer values mobility = ns3.RandomWaypointMobilityModel() ptr = ns3.PointerValue() - mobility.GetAttribute("Position", ptr) + mobility.GetAttribute("PositionAllocator", ptr) self.assertEqual(ptr.GetObject(), None) pos = ns3.ListPositionAllocator() - mobility.SetAttribute("Position", ns3.PointerValue(pos)) + mobility.SetAttribute("PositionAllocator", ns3.PointerValue(pos)) ptr = ns3.PointerValue() - mobility.GetAttribute("Position", ptr) + mobility.GetAttribute("PositionAllocator", ptr) self.assert_(ptr.GetObject() is not None) def testIdentity(self):