--- a/bindings/python/ns3_module_bridge.py Mon Apr 13 23:10:37 2009 +0100
+++ b/bindings/python/ns3_module_bridge.py Thu Apr 16 11:02:11 2009 +0100
@@ -103,16 +103,6 @@
'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',
--- a/bindings/python/ns3_module_core.py Mon Apr 13 23:10:37 2009 +0100
+++ b/bindings/python/ns3_module_core.py Thu Apr 16 11:02:11 2009 +0100
@@ -115,8 +115,12 @@
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 @@
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 @@
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 @@
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 @@
cls.add_method('ConnectWithoutContext',
'void',
[param('ns3::CallbackBase const &', 'cb')])
- ## traced-value.h: void ns3::TracedValue<unsigned int>::Connect(ns3::CallbackBase const & cb, std::basic_string<char,std::char_traits<char>,std::allocator<char> > path) [member function]
+ ## traced-value.h: void ns3::TracedValue<unsigned int>::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 @@
cls.add_method('DisconnectWithoutContext',
'void',
[param('ns3::CallbackBase const &', 'cb')])
- ## traced-value.h: void ns3::TracedValue<unsigned int>::Disconnect(ns3::CallbackBase const & cb, std::basic_string<char,std::char_traits<char>,std::allocator<char> > path) [member function]
+ ## traced-value.h: void ns3::TracedValue<unsigned int>::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 @@
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 @@
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',
--- a/bindings/python/ns3_module_csma.py Mon Apr 13 23:10:37 2009 +0100
+++ b/bindings/python/ns3_module_csma.py Thu Apr 16 11:02:11 2009 +0100
@@ -273,16 +273,6 @@
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',
--- a/bindings/python/ns3_module_emu.py Mon Apr 13 23:10:37 2009 +0100
+++ b/bindings/python/ns3_module_emu.py Thu Apr 16 11:02:11 2009 +0100
@@ -80,16 +80,6 @@
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',
--- a/bindings/python/ns3_module_node.py Mon Apr 13 23:10:37 2009 +0100
+++ b/bindings/python/ns3_module_node.py Thu Apr 16 11:02:11 2009 +0100
@@ -2310,16 +2310,6 @@
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 @@
'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 @@
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',
--- a/bindings/python/ns3_module_point_to_point.py Mon Apr 13 23:10:37 2009 +0100
+++ b/bindings/python/ns3_module_point_to_point.py Thu Apr 16 11:02:11 2009 +0100
@@ -175,16 +175,6 @@
'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',
--- a/bindings/python/ns3_module_tap_bridge.py Mon Apr 13 23:10:37 2009 +0100
+++ b/bindings/python/ns3_module_tap_bridge.py Thu Apr 16 11:02:11 2009 +0100
@@ -86,16 +86,6 @@
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',
--- a/bindings/python/ns3_module_wifi.py Mon Apr 13 23:10:37 2009 +0100
+++ b/bindings/python/ns3_module_wifi.py Thu Apr 16 11:02:11 2009 +0100
@@ -228,8 +228,8 @@
'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 @@
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 @@
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 @@
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 @@
'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',
--- a/examples/wifi-ap.cc Mon Apr 13 23:10:37 2009 +0100
+++ b/examples/wifi-ap.cc Thu Apr 16 11:02:11 2009 +0100
@@ -32,14 +32,14 @@
using namespace ns3;
void
-DevTxTrace (std::string context, Ptr<const Packet> p, Mac48Address address)
+DevTxTrace (std::string context, Ptr<const Packet> p)
{
- std::cout << " TX to=" << address << " p: " << *p << std::endl;
+ std::cout << " TX p: " << *p << std::endl;
}
void
-DevRxTrace (std::string context, Ptr<const Packet> p, Mac48Address address)
+DevRxTrace (std::string context, Ptr<const Packet> p)
{
- std::cout << " RX from=" << address << " p: " << *p << std::endl;
+ std::cout << " RX p: " << *p << std::endl;
}
void
PhyRxOkTrace (std::string context, Ptr<const Packet> packet, double snr, WifiMode mode, enum WifiPreamble preamble)
@@ -168,8 +168,8 @@
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));
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/samples/main-random-variable.cc Thu Apr 16 11:02:11 2009 +0100
@@ -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 <timo.bingmann@student.kit.edu>
+ */
+#include "ns3/random-variable.h"
+#include "ns3/gnuplot.h"
+#include <map>
+#include <cmath>
+
+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<double, unsigned int> 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;
+}
--- a/samples/wscript Mon Apr 13 23:10:37 2009 +0100
+++ b/samples/wscript Thu Apr 16 11:02:11 2009 +0100
@@ -10,6 +10,9 @@
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'
--- a/src/core/random-variable.cc Mon Apr 13 23:10:37 2009 +0100
+++ b/src/core/random-variable.cc Thu Apr 16 11:02:11 2009 +0100
@@ -1220,6 +1220,230 @@
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
+// 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
class TriangularVariableImpl : public RandomVariableBase {
public:
--- a/src/core/random-variable.h Mon Apr 13 23:10:37 2009 +0100
+++ b/src/core/random-variable.h Thu Apr 16 11:02:11 2009 +0100
@@ -36,7 +36,7 @@
*
*/
-namespace ns3{
+namespace ns3 {
class RandomVariableBase;
@@ -422,7 +422,7 @@
* 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 @@
explicit DeterministicVariable(double* d, uint32_t c);
};
-
/**
* \brief Log-normal Distributed random var
* \ingroup randomvariable
@@ -594,6 +593,108 @@
};
/**
+ * \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
*
--- a/src/core/type-id.cc Mon Apr 13 23:10:37 2009 +0100
+++ b/src/core/type-id.cc Thu Apr 16 11:02:11 2009 +0100
@@ -71,6 +71,9 @@
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 @@
return i + 1;
}
+bool
+IidManager::HasAttribute (uint16_t uid,
+ std::string name)
+{
+ struct IidInformation *information = LookupInformation (uid);
+ while (true)
+ {
+ for (std::vector<struct AttributeInformation>::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 @@
ns3::Ptr<const ns3::AttributeChecker> checker)
{
struct IidInformation *information = LookupInformation (uid);
- for (std::vector<struct AttributeInformation>::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<<"\" in TypeId=\""<<information->name<<"\"");
- return;
- }
+ NS_FATAL_ERROR ("Attribute \"" << name << "\" already registered on tid=\"" <<
+ information->name << "\"");
}
struct AttributeInformation param;
param.name = name;
@@ -310,6 +336,33 @@
return information->attributes[i].checker;
}
+bool
+IidManager::HasTraceSource (uint16_t uid,
+ std::string name)
+{
+ struct IidInformation *information = LookupInformation (uid);
+ while (true)
+ {
+ for (std::vector<struct TraceSourceInformation>::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 @@
ns3::Ptr<const ns3::TraceSourceAccessor> 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;
--- a/src/devices/bridge/bridge-channel.cc Mon Apr 13 23:10:37 2009 +0100
+++ b/src/devices/bridge/bridge-channel.cc Thu Apr 16 11:02:11 2009 +0100
@@ -34,7 +34,7 @@
}
BridgeChannel::BridgeChannel ()
- : Channel ("BridgeChannel")
+ : Channel ()
{
NS_LOG_FUNCTION_NOARGS ();
}
--- a/src/devices/bridge/bridge-net-device.cc Mon Apr 13 23:10:37 2009 +0100
+++ b/src/devices/bridge/bridge-net-device.cc Thu Apr 16 11:02:11 2009 +0100
@@ -53,7 +53,6 @@
BridgeNetDevice::BridgeNetDevice ()
: m_node (0),
- m_name (""),
m_ifIndex (0),
m_mtu (0xffff)
{
@@ -128,7 +127,7 @@
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="<<protocol
<< ", src=" << src << ", dst=" << dst << ")");
@@ -136,7 +135,7 @@
Ptr<NetDevice> 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 @@
Ptr<NetDevice> 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 @@
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="<<protocol
<< ", src=" << src << ", dst=" << dst << ")");
Learn (src, incomingPort);
@@ -173,8 +173,9 @@
Ptr<NetDevice> 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,7 +250,7 @@
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);
@@ -257,20 +258,6 @@
}
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)
{
NS_LOG_FUNCTION_NOARGS ();
--- a/src/devices/bridge/bridge-net-device.h Mon Apr 13 23:10:37 2009 +0100
+++ b/src/devices/bridge/bridge-net-device.h Thu Apr 16 11:02:11 2009 +0100
@@ -88,8 +88,6 @@
Ptr<NetDevice> 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<Channel> GetChannel (void) const;
@@ -140,7 +138,6 @@
std::map<Mac48Address, LearnedState> m_learnState;
Ptr<Node> m_node;
Ptr<BridgeChannel> m_channel;
- std::string m_name;
std::vector< Ptr<NetDevice> > m_ports;
uint32_t m_ifIndex;
uint16_t m_mtu;
--- a/src/devices/csma/csma-channel.cc Mon Apr 13 23:10:37 2009 +0100
+++ b/src/devices/csma/csma-channel.cc Thu Apr 16 11:02:11 2009 +0100
@@ -51,7 +51,7 @@
CsmaChannel::CsmaChannel ()
:
- Channel ("Csma Channel")
+ Channel ()
{
NS_LOG_FUNCTION_NOARGS ();
m_state = IDLE;
--- a/src/devices/csma/csma-net-device.cc Mon Apr 13 23:10:37 2009 +0100
+++ b/src/devices/csma/csma-net-device.cc Thu Apr 16 11:02:11 2009 +0100
@@ -154,8 +154,7 @@
}
CsmaNetDevice::CsmaNetDevice ()
- : m_name (""),
- m_linkUp (false)
+ : m_linkUp (false)
{
NS_LOG_FUNCTION (this);
m_txMachineState = READY;
@@ -874,20 +873,6 @@
}
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)
{
NS_LOG_FUNCTION (index);
@@ -1054,25 +1039,6 @@
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<NetDevice> dev = node->GetDevice (i);
- if (dynamic_cast<CsmaNetDevice*> (PeekPointer (dev)))
- {
- count++;
- if (dev == this)
- {
- break;
- }
- }
- }
- std::ostringstream s;
- s << "eth" << count;
- m_name = s.str ();
- }
}
bool
--- a/src/devices/csma/csma-net-device.h Mon Apr 13 23:10:37 2009 +0100
+++ b/src/devices/csma/csma-net-device.h Thu Apr 16 11:02:11 2009 +0100
@@ -305,8 +305,6 @@
//
// 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<Channel> GetChannel (void) const;
@@ -808,11 +806,6 @@
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.
*/
--- a/src/devices/emu/emu-net-device.cc Mon Apr 13 23:10:37 2009 +0100
+++ b/src/devices/emu/emu-net-device.cc Thu Apr 16 11:02:11 2009 +0100
@@ -68,11 +68,6 @@
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 @@
m_sock (-1),
m_readThread (0),
m_ifIndex (std::numeric_limits<uint32_t>::max ()), // absurdly large value
- m_sll_ifindex (-1),
- m_name ("Emu NetDevice")
+ m_sll_ifindex (-1)
{
NS_LOG_FUNCTION (this);
Start (m_tStart);
@@ -844,18 +838,6 @@
}
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)
{
m_ifIndex = index;
--- a/src/devices/emu/emu-net-device.h Mon Apr 13 23:10:37 2009 +0100
+++ b/src/devices/emu/emu-net-device.h Thu Apr 16 11:02:11 2009 +0100
@@ -105,9 +105,6 @@
//
// 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;
@@ -450,11 +447,6 @@
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.
*/
--- a/src/devices/point-to-point/point-to-point-channel.cc Mon Apr 13 23:10:37 2009 +0100
+++ b/src/devices/point-to-point/point-to-point-channel.cc Thu Apr 16 11:02:11 2009 +0100
@@ -43,11 +43,11 @@
}
//
-// 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)
{
--- a/src/devices/point-to-point/point-to-point-channel.h Mon Apr 13 23:10:37 2009 +0100
+++ b/src/devices/point-to-point/point-to-point-channel.h Thu Apr 16 11:02:11 2009 +0100
@@ -50,7 +50,7 @@
/**
* \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 ();
--- a/src/devices/point-to-point/point-to-point-net-device.cc Mon Apr 13 23:10:37 2009 +0100
+++ b/src/devices/point-to-point/point-to-point-net-device.cc Thu Apr 16 11:02:11 2009 +0100
@@ -148,7 +148,6 @@
:
m_txMachineState (READY),
m_channel (0),
- m_name (""),
m_linkUp (false),
m_currentPkt (0)
{
@@ -374,18 +373,6 @@
}
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)
{
m_ifIndex = index;
--- a/src/devices/point-to-point/point-to-point-net-device.h Mon Apr 13 23:10:37 2009 +0100
+++ b/src/devices/point-to-point/point-to-point-net-device.h Thu Apr 16 11:02:11 2009 +0100
@@ -226,12 +226,6 @@
*/
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 @@
NetDevice::ReceiveCallback m_rxCallback;
NetDevice::PromiscReceiveCallback m_promiscCallback;
uint32_t m_ifIndex;
- std::string m_name;
bool m_linkUp;
Callback<void> m_linkChangeCallback;
--- a/src/devices/tap-bridge/tap-bridge.cc Mon Apr 13 23:10:37 2009 +0100
+++ b/src/devices/tap-bridge/tap-bridge.cc Thu Apr 16 11:02:11 2009 +0100
@@ -958,20 +958,6 @@
}
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)
{
NS_LOG_FUNCTION_NOARGS ();
--- a/src/devices/tap-bridge/tap-bridge.h Mon Apr 13 23:10:37 2009 +0100
+++ b/src/devices/tap-bridge/tap-bridge.h Thu Apr 16 11:02:11 2009 +0100
@@ -173,8 +173,6 @@
// 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<Channel> GetChannel (void) const;
@@ -318,12 +316,6 @@
*/
Ptr<Node> m_node;
- /**
- * \internal
- *
- * A possible name for the (ghost) Node to which we are connected.
- */
- std::string m_name;
/**
* \internal
--- a/src/devices/wifi/dcf-manager-test.cc Mon Apr 13 23:10:37 2009 +0100
+++ b/src/devices/wifi/dcf-manager-test.cc Thu Apr 16 11:02:11 2009 +0100
@@ -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 <mathieu.lacage@sophia.inria.fr>
+ */
#ifdef RUN_SELF_TESTS
#include "ns3/test.h"
--- a/src/devices/wifi/dcf-manager.cc Mon Apr 13 23:10:37 2009 +0100
+++ b/src/devices/wifi/dcf-manager.cc Thu Apr 16 11:02:11 2009 +0100
@@ -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 <mathieu.lacage@sophia.inria.fr>
+ */
#include "ns3/assert.h"
#include "ns3/log.h"
--- a/src/devices/wifi/interference-helper.cc Mon Apr 13 23:10:37 2009 +0100
+++ b/src/devices/wifi/interference-helper.cc Thu Apr 16 11:02:11 2009 +0100
@@ -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 <mathieu.lacage@sophia.inria.fr>
+ */
#include "interference-helper.h"
#include "wifi-phy.h"
#include "error-rate-model.h"
@@ -137,15 +156,15 @@
}
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 @@
{
// 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;
--- a/src/devices/wifi/interference-helper.h Mon Apr 13 23:10:37 2009 +0100
+++ b/src/devices/wifi/interference-helper.h Thu Apr 16 11:02:11 2009 +0100
@@ -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 <mathieu.lacage@sophia.inria.fr>
+ */
#ifndef INTERFERENCE_HELPER_H
#define INTERFERENCE_HELPER_H
@@ -50,10 +69,10 @@
~InterferenceHelper ();
void Configure80211aParameters (void);
- void SetNoiseFloorW (double noiseFloor);
+ void SetNoiseFigure (double value);
void SetErrorRateModel (Ptr<ErrorRateModel> rate);
- double GetNoiseFloorW (void) const;
+ double GetNoiseFigure (void) const;
Ptr<ErrorRateModel> GetErrorRateModel (void) const;
@@ -99,7 +118,7 @@
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<ErrorRateModel> m_errorRateModel;
--- a/src/devices/wifi/wifi-net-device.cc Mon Apr 13 23:10:37 2009 +0100
+++ b/src/devices/wifi/wifi-net-device.cc Thu Apr 16 11:02:11 2009 +0100
@@ -137,16 +137,6 @@
}
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)
{
m_ifIndex = index;
--- a/src/devices/wifi/wifi-net-device.h Mon Apr 13 23:10:37 2009 +0100
+++ b/src/devices/wifi/wifi-net-device.h Thu Apr 16 11:02:11 2009 +0100
@@ -75,8 +75,6 @@
// 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<Channel> GetChannel (void) const;
@@ -123,7 +121,6 @@
TracedCallback<Ptr<const Packet>, Mac48Address> m_txLogger;
uint32_t m_ifIndex;
- std::string m_name;
bool m_linkUp;
Callback<void> m_linkChange;
mutable uint16_t m_mtu;
--- a/src/devices/wifi/wifi-phy-test.cc Mon Apr 13 23:10:37 2009 +0100
+++ b/src/devices/wifi/wifi-phy-test.cc Thu Apr 16 11:02:11 2009 +0100
@@ -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 <mathieu.lacage@sophia.inria.fr>
+ */
#include "wifi-net-device.h"
#include "yans-wifi-channel.h"
#include "yans-wifi-phy.h"
--- a/src/devices/wifi/wifi-remote-station-manager.cc Mon Apr 13 23:10:37 2009 +0100
+++ b/src/devices/wifi/wifi-remote-station-manager.cc Thu Apr 16 11:02:11 2009 +0100
@@ -97,7 +97,7 @@
WifiMode
NonUnicastWifiRemoteStation::DoGetDataMode (uint32_t size)
{
- WifiMode mode = m_stations->GetBasicMode (0);
+ WifiMode mode = m_stations->GetNonUnicastMode ();
NS_LOG_DEBUG ("non-unicast size="<<size<<", mode="<<mode);
return mode;
}
@@ -155,6 +155,10 @@
UintegerValue (1500),
MakeUintegerAccessor (&WifiRemoteStationManager::m_fragmentationThreshold),
MakeUintegerChecker<uint32_t> ())
+ .AddAttribute ("NonUnicastMode", "Wifi mode used for non-unicast transmissions.",
+ WifiModeValue (),
+ MakeWifiModeAccessor (&WifiRemoteStationManager::m_nonUnicastMode),
+ MakeWifiModeChecker ())
;
return tid;
}
@@ -305,6 +309,14 @@
{
return m_isLowLatency;
}
+WifiMode
+WifiRemoteStationManager::GetNonUnicastMode (void) const
+{
+ if (m_nonUnicastMode == WifiMode ())
+ return GetBasicMode(0);
+ else
+ return m_nonUnicastMode;
+}
} // namespace ns3
--- a/src/devices/wifi/wifi-remote-station-manager.h Mon Apr 13 23:10:37 2009 +0100
+++ b/src/devices/wifi/wifi-remote-station-manager.h Thu Apr 16 11:02:11 2009 +0100
@@ -80,6 +80,8 @@
bool IsLowLatency (void) const;
+ WifiMode GetNonUnicastMode (void) const;
+
WifiRemoteStation *Lookup (Mac48Address address);
WifiRemoteStation *LookupNonUnicast (void);
protected:
@@ -97,6 +99,7 @@
uint32_t m_maxSlrc;
uint32_t m_rtsCtsThreshold;
uint32_t m_fragmentationThreshold;
+ WifiMode m_nonUnicastMode;
};
} // namespace ns3
--- a/src/devices/wifi/wifi-test.cc Mon Apr 13 23:10:37 2009 +0100
+++ b/src/devices/wifi/wifi-test.cc Thu Apr 16 11:02:11 2009 +0100
@@ -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 <mathieu.lacage@sophia.inria.fr>
+ */
#ifdef RUN_SELF_TESTS
#include "wifi-net-device.h"
--- a/src/devices/wifi/yans-wifi-phy.cc Mon Apr 13 23:10:37 2009 +0100
+++ b/src/devices/wifi/yans-wifi-phy.cc Thu Apr 16 11:02:11 2009 +0100
@@ -93,11 +93,17 @@
MakeDoubleAccessor (&YansWifiPhy::SetTxPowerStart,
&YansWifiPhy::GetTxPowerStart),
MakeDoubleChecker<double> ())
- .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<double> ())
.AddAttribute ("Standard", "The standard chosen configures a set of transmission modes"
" and some PHY-specific constants.",
@@ -155,10 +161,10 @@
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 @@
}
double
-YansWifiPhy::GetRxNoise (void) const
+YansWifiPhy::GetRxNoiseFigure (void) const
{
- return RatioToDb (m_interference.GetNoiseFloorW ());
+ return RatioToDb (m_interference.GetNoiseFigure ());
}
double
YansWifiPhy::GetTxPowerStart (void) const
--- a/src/devices/wifi/yans-wifi-phy.h Mon Apr 13 23:10:37 2009 +0100
+++ b/src/devices/wifi/yans-wifi-phy.h Thu Apr 16 11:02:11 2009 +0100
@@ -75,7 +75,7 @@
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 @@
void SetErrorRateModel (Ptr<ErrorRateModel> rate);
void SetDevice (Ptr<Object> device);
void SetMobility (Ptr<Object> mobility);
- double GetRxNoise (void) const;
+ double GetRxNoiseFigure (void) const;
double GetTxGain (void) const;
double GetRxGain (void) const;
double GetEdThreshold (void) const;
--- a/src/mobility/random-waypoint-mobility-model.cc Mon Apr 13 23:10:37 2009 +0100
+++ b/src/mobility/random-waypoint-mobility-model.cc Thu Apr 16 11:02:11 2009 +0100
@@ -45,7 +45,7 @@
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),
--- a/src/node/channel.cc Mon Apr 13 23:10:37 2009 +0100
+++ b/src/node/channel.cc Thu Apr 16 11:02:11 2009 +0100
@@ -35,34 +35,14 @@
}
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
--- a/src/node/channel.h Mon Apr 13 23:10:37 2009 +0100
+++ b/src/node/channel.h Thu Apr 16 11:02:11 2009 +0100
@@ -43,12 +43,8 @@
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 @@
*/
virtual Ptr<NetDevice> GetDevice (uint32_t i) const = 0;
-private:
- std::string m_name;
};
-}; // namespace ns3
+} // namespace ns3
#endif /* NS3_CHANNEL_H */
--- a/src/node/net-device.h Mon Apr 13 23:10:37 2009 +0100
+++ b/src/node/net-device.h Thu Apr 16 11:02:11 2009 +0100
@@ -68,14 +68,6 @@
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
*/
virtual void SetIfIndex(const uint32_t index) = 0;
--- a/src/node/node.cc Mon Apr 13 23:10:37 2009 +0100
+++ b/src/node/node.cc Thu Apr 16 11:02:11 2009 +0100
@@ -225,7 +225,7 @@
Node::PromiscReceiveFromDevice (Ptr<NetDevice> device, Ptr<const Packet> 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 @@
Node::NonPromiscReceiveFromDevice (Ptr<NetDevice> device, Ptr<const Packet> 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 @@
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;
--- a/src/node/simple-net-device.cc Mon Apr 13 23:10:37 2009 +0100
+++ b/src/node/simple-net-device.cc Thu Apr 16 11:02:11 2009 +0100
@@ -38,7 +38,6 @@
: m_channel (0),
m_node (0),
m_mtu (0xffff),
- m_name (""),
m_ifIndex (0)
{}
@@ -84,16 +83,6 @@
}
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)
{
m_ifIndex = index;
--- a/src/node/simple-net-device.h Mon Apr 13 23:10:37 2009 +0100
+++ b/src/node/simple-net-device.h Thu Apr 16 11:02:11 2009 +0100
@@ -46,8 +46,6 @@
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<Channel> GetChannel (void) const;
@@ -82,7 +80,6 @@
NetDevice::PromiscReceiveCallback m_promiscCallback;
Ptr<Node> m_node;
uint16_t m_mtu;
- std::string m_name;
uint32_t m_ifIndex;
Mac48Address m_address;
};
--- a/utils/python-unit-tests.py Mon Apr 13 23:10:37 2009 +0100
+++ b/utils/python-unit-tests.py Thu Apr 16 11:02:11 2009 +0100
@@ -97,14 +97,14 @@
## -- 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):