diff --git a/bindings/python/ns3_module_helper.py b/bindings/python/ns3_module_helper.py index 4f4540086..3497c187c 100644 --- a/bindings/python/ns3_module_helper.py +++ b/bindings/python/ns3_module_helper.py @@ -41,6 +41,12 @@ def register_types(module): module.add_class('UdpEchoServerHelper', allow_subclassing=False) ## wifi-helper.h: ns3::WifiHelper [class] module.add_class('WifiHelper', allow_subclassing=False) + ## wifi-helper.h: ns3::WifiPhyHelper [class] + module.add_class('WifiPhyHelper', allow_subclassing=False) + ## yans-wifi-phy-helper.h: ns3::YansWifiChannelHelper [class] + module.add_class('YansWifiChannelHelper', allow_subclassing=False) + ## yans-wifi-phy-helper.h: ns3::YansWifiPhyHelper [class] + module.add_class('YansWifiPhyHelper', allow_subclassing=False, parent=root_module['ns3::WifiPhyHelper']) ## Register a nested module for the namespace internal @@ -102,6 +108,9 @@ def register_methods(root_module): register_Ns3UdpEchoClientHelper_methods(root_module, root_module['ns3::UdpEchoClientHelper']) register_Ns3UdpEchoServerHelper_methods(root_module, root_module['ns3::UdpEchoServerHelper']) register_Ns3WifiHelper_methods(root_module, root_module['ns3::WifiHelper']) + register_Ns3WifiPhyHelper_methods(root_module, root_module['ns3::WifiPhyHelper']) + register_Ns3YansWifiChannelHelper_methods(root_module, root_module['ns3::YansWifiChannelHelper']) + register_Ns3YansWifiPhyHelper_methods(root_module, root_module['ns3::YansWifiPhyHelper']) return def register_Ns3ApplicationContainer_methods(root_module, cls): @@ -672,6 +681,11 @@ def register_Ns3WifiHelper_methods(root_module, cls): cls.add_constructor([param('ns3::WifiHelper const &', 'arg0')]) ## wifi-helper.h: ns3::WifiHelper::WifiHelper() [constructor] cls.add_constructor([]) + ## wifi-helper.h: static ns3::WifiHelper ns3::WifiHelper::Default() [member function] + cls.add_method('Default', + 'ns3::WifiHelper', + [], + is_static=True) ## wifi-helper.h: void ns3::WifiHelper::SetRemoteStationManager(std::string type, std::string n0="", ns3::AttributeValue const & v0=ns3::EmptyAttributeValue(), std::string n1="", ns3::AttributeValue const & v1=ns3::EmptyAttributeValue(), std::string n2="", ns3::AttributeValue const & v2=ns3::EmptyAttributeValue(), std::string n3="", ns3::AttributeValue const & v3=ns3::EmptyAttributeValue(), std::string n4="", ns3::AttributeValue const & v4=ns3::EmptyAttributeValue(), std::string n5="", ns3::AttributeValue const & v5=ns3::EmptyAttributeValue(), std::string n6="", ns3::AttributeValue const & v6=ns3::EmptyAttributeValue(), std::string n7="", ns3::AttributeValue const & v7=ns3::EmptyAttributeValue()) [member function] cls.add_method('SetRemoteStationManager', 'void', @@ -680,60 +694,117 @@ def register_Ns3WifiHelper_methods(root_module, cls): cls.add_method('SetMac', 'void', [param('std::string', 'type'), param('std::string', 'n0', default_value='""'), param('ns3::AttributeValue const &', 'v0', default_value='ns3::EmptyAttributeValue()'), param('std::string', 'n1', default_value='""'), param('ns3::AttributeValue const &', 'v1', default_value='ns3::EmptyAttributeValue()'), param('std::string', 'n2', default_value='""'), param('ns3::AttributeValue const &', 'v2', default_value='ns3::EmptyAttributeValue()'), param('std::string', 'n3', default_value='""'), param('ns3::AttributeValue const &', 'v3', default_value='ns3::EmptyAttributeValue()'), param('std::string', 'n4', default_value='""'), param('ns3::AttributeValue const &', 'v4', default_value='ns3::EmptyAttributeValue()'), param('std::string', 'n5', default_value='""'), param('ns3::AttributeValue const &', 'v5', default_value='ns3::EmptyAttributeValue()'), param('std::string', 'n6', default_value='""'), param('ns3::AttributeValue const &', 'v6', default_value='ns3::EmptyAttributeValue()'), param('std::string', 'n7', default_value='""'), param('ns3::AttributeValue const &', 'v7', default_value='ns3::EmptyAttributeValue()')]) - ## wifi-helper.h: void ns3::WifiHelper::SetPhyAttribute(std::string n0, ns3::AttributeValue const & v0) [member function] - cls.add_method('SetPhyAttribute', + ## wifi-helper.h: ns3::NetDeviceContainer ns3::WifiHelper::Install(ns3::WifiPhyHelper const & phy, ns3::NodeContainer c) const [member function] + cls.add_method('Install', + 'ns3::NetDeviceContainer', + [param('ns3::WifiPhyHelper const &', 'phy'), param('ns3::NodeContainer', 'c')], + is_const=True) + return + +def register_Ns3WifiPhyHelper_methods(root_module, cls): + ## wifi-helper.h: ns3::WifiPhyHelper::WifiPhyHelper(ns3::WifiPhyHelper const & arg0) [copy constructor] + cls.add_constructor([param('ns3::WifiPhyHelper const &', 'arg0')]) + ## wifi-helper.h: ns3::WifiPhyHelper::WifiPhyHelper() [constructor] + cls.add_constructor([]) + ## wifi-helper.h: ns3::Ptr ns3::WifiPhyHelper::Create(ns3::Ptr node, ns3::Ptr device) const [member function] + cls.add_method('Create', + 'ns3::Ptr< ns3::WifiPhy >', + [param('ns3::Ptr< ns3::Node >', 'node'), param('ns3::Ptr< ns3::WifiNetDevice >', 'device')], + is_pure_virtual=True, is_const=True, is_virtual=True) + return + +def register_Ns3YansWifiChannelHelper_methods(root_module, cls): + ## yans-wifi-phy-helper.h: ns3::YansWifiChannelHelper::YansWifiChannelHelper(ns3::YansWifiChannelHelper const & arg0) [copy constructor] + cls.add_constructor([param('ns3::YansWifiChannelHelper const &', 'arg0')]) + ## yans-wifi-phy-helper.h: ns3::YansWifiChannelHelper::YansWifiChannelHelper() [constructor] + cls.add_constructor([]) + ## yans-wifi-phy-helper.h: static ns3::YansWifiChannelHelper ns3::YansWifiChannelHelper::Default() [member function] + cls.add_method('Default', + 'ns3::YansWifiChannelHelper', + [], + is_static=True) + ## yans-wifi-phy-helper.h: void ns3::YansWifiChannelHelper::AddPropagationLoss(std::string name, std::string n0="", ns3::AttributeValue const & v0=ns3::EmptyAttributeValue(), std::string n1="", ns3::AttributeValue const & v1=ns3::EmptyAttributeValue(), std::string n2="", ns3::AttributeValue const & v2=ns3::EmptyAttributeValue(), std::string n3="", ns3::AttributeValue const & v3=ns3::EmptyAttributeValue(), std::string n4="", ns3::AttributeValue const & v4=ns3::EmptyAttributeValue(), std::string n5="", ns3::AttributeValue const & v5=ns3::EmptyAttributeValue(), std::string n6="", ns3::AttributeValue const & v6=ns3::EmptyAttributeValue(), std::string n7="", ns3::AttributeValue const & v7=ns3::EmptyAttributeValue()) [member function] + cls.add_method('AddPropagationLoss', 'void', - [param('std::string', 'n0'), param('ns3::AttributeValue const &', 'v0')]) - ## wifi-helper.h: static void ns3::WifiHelper::EnablePcap(std::string filename, uint32_t nodeid, uint32_t deviceid) [member function] + [param('std::string', 'name'), param('std::string', 'n0', default_value='""'), param('ns3::AttributeValue const &', 'v0', default_value='ns3::EmptyAttributeValue()'), param('std::string', 'n1', default_value='""'), param('ns3::AttributeValue const &', 'v1', default_value='ns3::EmptyAttributeValue()'), param('std::string', 'n2', default_value='""'), param('ns3::AttributeValue const &', 'v2', default_value='ns3::EmptyAttributeValue()'), param('std::string', 'n3', default_value='""'), param('ns3::AttributeValue const &', 'v3', default_value='ns3::EmptyAttributeValue()'), param('std::string', 'n4', default_value='""'), param('ns3::AttributeValue const &', 'v4', default_value='ns3::EmptyAttributeValue()'), param('std::string', 'n5', default_value='""'), param('ns3::AttributeValue const &', 'v5', default_value='ns3::EmptyAttributeValue()'), param('std::string', 'n6', default_value='""'), param('ns3::AttributeValue const &', 'v6', default_value='ns3::EmptyAttributeValue()'), param('std::string', 'n7', default_value='""'), param('ns3::AttributeValue const &', 'v7', default_value='ns3::EmptyAttributeValue()')]) + ## yans-wifi-phy-helper.h: void ns3::YansWifiChannelHelper::SetPropagationDelay(std::string name, std::string n0="", ns3::AttributeValue const & v0=ns3::EmptyAttributeValue(), std::string n1="", ns3::AttributeValue const & v1=ns3::EmptyAttributeValue(), std::string n2="", ns3::AttributeValue const & v2=ns3::EmptyAttributeValue(), std::string n3="", ns3::AttributeValue const & v3=ns3::EmptyAttributeValue(), std::string n4="", ns3::AttributeValue const & v4=ns3::EmptyAttributeValue(), std::string n5="", ns3::AttributeValue const & v5=ns3::EmptyAttributeValue(), std::string n6="", ns3::AttributeValue const & v6=ns3::EmptyAttributeValue(), std::string n7="", ns3::AttributeValue const & v7=ns3::EmptyAttributeValue()) [member function] + cls.add_method('SetPropagationDelay', + 'void', + [param('std::string', 'name'), param('std::string', 'n0', default_value='""'), param('ns3::AttributeValue const &', 'v0', default_value='ns3::EmptyAttributeValue()'), param('std::string', 'n1', default_value='""'), param('ns3::AttributeValue const &', 'v1', default_value='ns3::EmptyAttributeValue()'), param('std::string', 'n2', default_value='""'), param('ns3::AttributeValue const &', 'v2', default_value='ns3::EmptyAttributeValue()'), param('std::string', 'n3', default_value='""'), param('ns3::AttributeValue const &', 'v3', default_value='ns3::EmptyAttributeValue()'), param('std::string', 'n4', default_value='""'), param('ns3::AttributeValue const &', 'v4', default_value='ns3::EmptyAttributeValue()'), param('std::string', 'n5', default_value='""'), param('ns3::AttributeValue const &', 'v5', default_value='ns3::EmptyAttributeValue()'), param('std::string', 'n6', default_value='""'), param('ns3::AttributeValue const &', 'v6', default_value='ns3::EmptyAttributeValue()'), param('std::string', 'n7', default_value='""'), param('ns3::AttributeValue const &', 'v7', default_value='ns3::EmptyAttributeValue()')]) + ## yans-wifi-phy-helper.h: ns3::Ptr ns3::YansWifiChannelHelper::Create() const [member function] + cls.add_method('Create', + 'ns3::Ptr< ns3::YansWifiChannel >', + [], + is_const=True) + return + +def register_Ns3YansWifiPhyHelper_methods(root_module, cls): + ## yans-wifi-phy-helper.h: ns3::YansWifiPhyHelper::YansWifiPhyHelper(ns3::YansWifiPhyHelper const & arg0) [copy constructor] + cls.add_constructor([param('ns3::YansWifiPhyHelper const &', 'arg0')]) + ## yans-wifi-phy-helper.h: ns3::YansWifiPhyHelper::YansWifiPhyHelper() [constructor] + cls.add_constructor([]) + ## yans-wifi-phy-helper.h: static ns3::YansWifiPhyHelper ns3::YansWifiPhyHelper::Default() [member function] + cls.add_method('Default', + 'ns3::YansWifiPhyHelper', + [], + is_static=True) + ## yans-wifi-phy-helper.h: void ns3::YansWifiPhyHelper::SetChannel(ns3::Ptr channel) [member function] + cls.add_method('SetChannel', + 'void', + [param('ns3::Ptr< ns3::YansWifiChannel >', 'channel')]) + ## yans-wifi-phy-helper.h: void ns3::YansWifiPhyHelper::Set(std::string name, ns3::AttributeValue const & v) [member function] + cls.add_method('Set', + 'void', + [param('std::string', 'name'), param('ns3::AttributeValue const &', 'v')]) + ## yans-wifi-phy-helper.h: void ns3::YansWifiPhyHelper::SetErrorRateModel(std::string name, std::string n0="", ns3::AttributeValue const & v0=ns3::EmptyAttributeValue(), std::string n1="", ns3::AttributeValue const & v1=ns3::EmptyAttributeValue(), std::string n2="", ns3::AttributeValue const & v2=ns3::EmptyAttributeValue(), std::string n3="", ns3::AttributeValue const & v3=ns3::EmptyAttributeValue(), std::string n4="", ns3::AttributeValue const & v4=ns3::EmptyAttributeValue(), std::string n5="", ns3::AttributeValue const & v5=ns3::EmptyAttributeValue(), std::string n6="", ns3::AttributeValue const & v6=ns3::EmptyAttributeValue(), std::string n7="", ns3::AttributeValue const & v7=ns3::EmptyAttributeValue()) [member function] + cls.add_method('SetErrorRateModel', + 'void', + [param('std::string', 'name'), param('std::string', 'n0', default_value='""'), param('ns3::AttributeValue const &', 'v0', default_value='ns3::EmptyAttributeValue()'), param('std::string', 'n1', default_value='""'), param('ns3::AttributeValue const &', 'v1', default_value='ns3::EmptyAttributeValue()'), param('std::string', 'n2', default_value='""'), param('ns3::AttributeValue const &', 'v2', default_value='ns3::EmptyAttributeValue()'), param('std::string', 'n3', default_value='""'), param('ns3::AttributeValue const &', 'v3', default_value='ns3::EmptyAttributeValue()'), param('std::string', 'n4', default_value='""'), param('ns3::AttributeValue const &', 'v4', default_value='ns3::EmptyAttributeValue()'), param('std::string', 'n5', default_value='""'), param('ns3::AttributeValue const &', 'v5', default_value='ns3::EmptyAttributeValue()'), param('std::string', 'n6', default_value='""'), param('ns3::AttributeValue const &', 'v6', default_value='ns3::EmptyAttributeValue()'), param('std::string', 'n7', default_value='""'), param('ns3::AttributeValue const &', 'v7', default_value='ns3::EmptyAttributeValue()')]) + ## yans-wifi-phy-helper.h: ns3::Ptr ns3::YansWifiPhyHelper::Create(ns3::Ptr node, ns3::Ptr device) const [member function] + cls.add_method('Create', + 'ns3::Ptr< ns3::WifiPhy >', + [param('ns3::Ptr< ns3::Node >', 'node'), param('ns3::Ptr< ns3::WifiNetDevice >', 'device')], + is_const=True, is_virtual=True) + ## yans-wifi-phy-helper.h: static void ns3::YansWifiPhyHelper::EnablePcap(std::string filename, uint32_t nodeid, uint32_t deviceid) [member function] cls.add_method('EnablePcap', 'void', [param('std::string', 'filename'), param('uint32_t', 'nodeid'), param('uint32_t', 'deviceid')], is_static=True) - ## wifi-helper.h: static void ns3::WifiHelper::EnablePcap(std::string filename, ns3::NetDeviceContainer d) [member function] + ## yans-wifi-phy-helper.h: static void ns3::YansWifiPhyHelper::EnablePcap(std::string filename, ns3::NetDeviceContainer d) [member function] cls.add_method('EnablePcap', 'void', [param('std::string', 'filename'), param('ns3::NetDeviceContainer', 'd')], is_static=True) - ## wifi-helper.h: static void ns3::WifiHelper::EnablePcap(std::string filename, ns3::NodeContainer n) [member function] + ## yans-wifi-phy-helper.h: static void ns3::YansWifiPhyHelper::EnablePcap(std::string filename, ns3::NodeContainer n) [member function] cls.add_method('EnablePcap', 'void', [param('std::string', 'filename'), param('ns3::NodeContainer', 'n')], is_static=True) - ## wifi-helper.h: static void ns3::WifiHelper::EnablePcapAll(std::string filename) [member function] + ## yans-wifi-phy-helper.h: static void ns3::YansWifiPhyHelper::EnablePcapAll(std::string filename) [member function] cls.add_method('EnablePcapAll', 'void', [param('std::string', 'filename')], is_static=True) - ## wifi-helper.h: static void ns3::WifiHelper::EnableAscii(std::ostream & os, uint32_t nodeid, uint32_t deviceid) [member function] + ## yans-wifi-phy-helper.h: static void ns3::YansWifiPhyHelper::EnableAscii(std::ostream & os, uint32_t nodeid, uint32_t deviceid) [member function] cls.add_method('EnableAscii', 'void', [param('std::ostream &', 'os'), param('uint32_t', 'nodeid'), param('uint32_t', 'deviceid')], is_static=True) - ## wifi-helper.h: static void ns3::WifiHelper::EnableAscii(std::ostream & os, ns3::NetDeviceContainer d) [member function] + ## yans-wifi-phy-helper.h: static void ns3::YansWifiPhyHelper::EnableAscii(std::ostream & os, ns3::NetDeviceContainer d) [member function] cls.add_method('EnableAscii', 'void', [param('std::ostream &', 'os'), param('ns3::NetDeviceContainer', 'd')], is_static=True) - ## wifi-helper.h: static void ns3::WifiHelper::EnableAscii(std::ostream & os, ns3::NodeContainer n) [member function] + ## yans-wifi-phy-helper.h: static void ns3::YansWifiPhyHelper::EnableAscii(std::ostream & os, ns3::NodeContainer n) [member function] cls.add_method('EnableAscii', 'void', [param('std::ostream &', 'os'), param('ns3::NodeContainer', 'n')], is_static=True) - ## wifi-helper.h: static void ns3::WifiHelper::EnableAsciiAll(std::ostream & os) [member function] + ## yans-wifi-phy-helper.h: static void ns3::YansWifiPhyHelper::EnableAsciiAll(std::ostream & os) [member function] cls.add_method('EnableAsciiAll', 'void', [param('std::ostream &', 'os')], is_static=True) - ## wifi-helper.h: ns3::NetDeviceContainer ns3::WifiHelper::Install(ns3::NodeContainer c) const [member function] - cls.add_method('Install', - 'ns3::NetDeviceContainer', - [param('ns3::NodeContainer', 'c')], - is_const=True) - ## wifi-helper.h: ns3::NetDeviceContainer ns3::WifiHelper::Install(ns3::NodeContainer c, ns3::Ptr channel) const [member function] - cls.add_method('Install', - 'ns3::NetDeviceContainer', - [param('ns3::NodeContainer', 'c'), param('ns3::Ptr< ns3::WifiChannel >', 'channel')], - is_const=True) return def register_functions(root_module): diff --git a/bindings/python/ns3_module_wifi.py b/bindings/python/ns3_module_wifi.py index fb851c258..4b4b2e4c8 100644 --- a/bindings/python/ns3_module_wifi.py +++ b/bindings/python/ns3_module_wifi.py @@ -77,6 +77,8 @@ def register_types(module): module.add_class('ConstantRateWifiManager', parent=root_module['ns3::WifiRemoteStationManager']) ## propagation-delay-model.h: ns3::ConstantSpeedPropagationDelayModel [class] module.add_class('ConstantSpeedPropagationDelayModel', parent=root_module['ns3::PropagationDelayModel']) + ## error-rate-model.h: ns3::ErrorRateModel [class] + module.add_class('ErrorRateModel', parent=root_module['ns3::Object']) ## propagation-loss-model.h: ns3::FriisPropagationLossModel [class] module.add_class('FriisPropagationLossModel', parent=root_module['ns3::PropagationLossModel']) ## ideal-wifi-manager.h: ns3::IdealWifiManager [class] @@ -176,6 +178,7 @@ def register_methods(root_module): register_Ns3ArfWifiManager_methods(root_module, root_module['ns3::ArfWifiManager']) register_Ns3ConstantRateWifiManager_methods(root_module, root_module['ns3::ConstantRateWifiManager']) register_Ns3ConstantSpeedPropagationDelayModel_methods(root_module, root_module['ns3::ConstantSpeedPropagationDelayModel']) + register_Ns3ErrorRateModel_methods(root_module, root_module['ns3::ErrorRateModel']) register_Ns3FriisPropagationLossModel_methods(root_module, root_module['ns3::FriisPropagationLossModel']) register_Ns3IdealWifiManager_methods(root_module, root_module['ns3::IdealWifiManager']) register_Ns3JakesPropagationLossModel_methods(root_module, root_module['ns3::JakesPropagationLossModel']) @@ -1647,6 +1650,14 @@ def register_Ns3YansWifiPhy_methods(root_module, cls): cls.add_method('SetErrorRateModel', 'void', [param('ns3::Ptr< ns3::ErrorRateModel >', 'rate')]) + ## yans-wifi-phy.h: void ns3::YansWifiPhy::SetDevice(ns3::Ptr device) [member function] + cls.add_method('SetDevice', + 'void', + [param('ns3::Ptr< ns3::Object >', 'device')]) + ## yans-wifi-phy.h: void ns3::YansWifiPhy::SetMobility(ns3::Ptr mobility) [member function] + 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', 'double', @@ -1677,6 +1688,15 @@ def register_Ns3YansWifiPhy_methods(root_module, cls): 'ns3::Ptr< ns3::ErrorRateModel >', [], is_const=True) + ## yans-wifi-phy.h: ns3::Ptr ns3::YansWifiPhy::GetDevice() const [member function] + cls.add_method('GetDevice', + 'ns3::Ptr< ns3::Object >', + [], + is_const=True) + ## yans-wifi-phy.h: ns3::Ptr ns3::YansWifiPhy::GetMobility() [member function] + cls.add_method('GetMobility', + 'ns3::Ptr< ns3::Object >', + []) ## yans-wifi-phy.h: double ns3::YansWifiPhy::GetTxPowerStart() const [member function] cls.add_method('GetTxPowerStart', 'double', @@ -2028,6 +2048,28 @@ def register_Ns3ConstantSpeedPropagationDelayModel_methods(root_module, cls): is_const=True) return +def register_Ns3ErrorRateModel_methods(root_module, cls): + ## error-rate-model.h: ns3::ErrorRateModel::ErrorRateModel(ns3::ErrorRateModel const & arg0) [copy constructor] + cls.add_constructor([param('ns3::ErrorRateModel const &', 'arg0')]) + ## error-rate-model.h: static ns3::TypeId ns3::ErrorRateModel::GetTypeId() [member function] + cls.add_method('GetTypeId', + 'ns3::TypeId', + [], + is_static=True) + ## error-rate-model.h: ns3::ErrorRateModel::ErrorRateModel() [constructor] + cls.add_constructor([]) + ## error-rate-model.h: double ns3::ErrorRateModel::CalculateSnr(ns3::WifiMode txMode, double ber) const [member function] + cls.add_method('CalculateSnr', + 'double', + [param('ns3::WifiMode', 'txMode'), param('double', 'ber')], + is_const=True) + ## error-rate-model.h: double ns3::ErrorRateModel::GetChunkSuccessRate(ns3::WifiMode mode, double snr, uint32_t nbits) const [member function] + cls.add_method('GetChunkSuccessRate', + 'double', + [param('ns3::WifiMode', 'mode'), param('double', 'snr'), param('uint32_t', 'nbits')], + is_const=True) + return + def register_Ns3FriisPropagationLossModel_methods(root_module, cls): ## propagation-loss-model.h: static ns3::TypeId ns3::FriisPropagationLossModel::GetTypeId() [member function] cls.add_method('GetTypeId', @@ -2145,14 +2187,10 @@ def register_Ns3LogDistancePropagationLossModel_methods(root_module, cls): 'double', [], is_const=True) - ## propagation-loss-model.h: void ns3::LogDistancePropagationLossModel::SetReferenceModel(ns3::Ptr model) [member function] - cls.add_method('SetReferenceModel', + ## propagation-loss-model.h: void ns3::LogDistancePropagationLossModel::SetReference(double referenceDistance, double referenceLoss) [member function] + cls.add_method('SetReference', 'void', - [param('ns3::Ptr< ns3::PropagationLossModel >', 'model')]) - ## propagation-loss-model.h: void ns3::LogDistancePropagationLossModel::SetReferenceDistance(double referenceDistance) [member function] - cls.add_method('SetReferenceDistance', - 'void', - [param('double', 'referenceDistance')]) + [param('double', 'referenceDistance'), param('double', 'referenceLoss')]) ## propagation-loss-model.h: double ns3::LogDistancePropagationLossModel::DoGetLoss(ns3::Ptr a, ns3::Ptr b) const [member function] cls.add_method('DoGetLoss', 'double', @@ -2527,11 +2565,6 @@ def register_Ns3WifiChannel_methods(root_module, cls): 'ns3::TypeId', [], is_static=True) - ## wifi-channel.h: ns3::Ptr ns3::WifiChannel::CreatePhy(ns3::Ptr device, ns3::Ptr mobility, ns3::UnsafeAttributeList list) [member function] - cls.add_method('CreatePhy', - 'ns3::Ptr< ns3::WifiPhy >', - [param('ns3::Ptr< ns3::WifiNetDevice >', 'device'), param('ns3::Ptr< ns3::Object >', 'mobility'), param('ns3::UnsafeAttributeList', 'list')], - is_pure_virtual=True, is_virtual=True) return def register_Ns3WifiNetDevice_methods(root_module, cls): @@ -2556,10 +2589,6 @@ def register_Ns3WifiNetDevice_methods(root_module, cls): cls.add_method('SetRemoteStationManager', 'void', [param('ns3::Ptr< ns3::WifiRemoteStationManager >', 'manager')]) - ## wifi-net-device.h: void ns3::WifiNetDevice::SetChannel(ns3::Ptr channel) [member function] - cls.add_method('SetChannel', - 'void', - [param('ns3::Ptr< ns3::WifiChannel >', 'channel')]) ## wifi-net-device.h: ns3::Ptr ns3::WifiNetDevice::GetMac() const [member function] cls.add_method('GetMac', 'ns3::Ptr< ns3::WifiMac >', @@ -2722,11 +2751,10 @@ def register_Ns3YansWifiChannel_methods(root_module, cls): 'ns3::Ptr< ns3::NetDevice >', [param('uint32_t', 'i')], is_const=True, is_virtual=True) - ## yans-wifi-channel.h: ns3::Ptr ns3::YansWifiChannel::CreatePhy(ns3::Ptr device, ns3::Ptr mobility, ns3::UnsafeAttributeList list) [member function] - cls.add_method('CreatePhy', - 'ns3::Ptr< ns3::WifiPhy >', - [param('ns3::Ptr< ns3::WifiNetDevice >', 'device'), param('ns3::Ptr< ns3::Object >', 'mobility'), param('ns3::UnsafeAttributeList', 'list')], - is_virtual=True) + ## yans-wifi-channel.h: void ns3::YansWifiChannel::Add(ns3::Ptr phy) [member function] + cls.add_method('Add', + 'void', + [param('ns3::Ptr< ns3::YansWifiPhy >', 'phy')]) ## yans-wifi-channel.h: void ns3::YansWifiChannel::SetPropagationLossModel(ns3::Ptr loss) [member function] cls.add_method('SetPropagationLossModel', 'void', diff --git a/examples/mixed-wireless.cc b/examples/mixed-wireless.cc index 3b1be7a05..944dd63c5 100644 --- a/examples/mixed-wireless.cc +++ b/examples/mixed-wireless.cc @@ -132,9 +132,12 @@ main (int argc, char *argv[]) // Create the backbone wifi net devices and install them into the nodes in // our container // + YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default (); + YansWifiChannelHelper wifiChannel = YansWifiChannelHelper::Default (); + wifiPhy.SetChannel (wifiChannel.Create ()); WifiHelper wifi; wifi.SetMac ("ns3::AdhocWifiMac"); - NetDeviceContainer backboneDevices = wifi.Install (backbone); + NetDeviceContainer backboneDevices = wifi.Install (wifiPhy, backbone); // // Add the IPv4 protocol stack to the nodes in our container // @@ -243,7 +246,8 @@ main (int argc, char *argv[]) // WifiHelper wifiInfra; wifiInfra.SetMac ("ns3::AdhocWifiMac"); - NetDeviceContainer infraDevices = wifiInfra.Install (infra); + wifiPhy.SetChannel (wifiChannel.Create ()); + NetDeviceContainer infraDevices = wifiInfra.Install (wifiPhy, infra); // Add the IPv4 protocol stack to the nodes in our container // @@ -330,14 +334,14 @@ main (int argc, char *argv[]) // std::ofstream ascii; ascii.open ("mixed-wireless.tr"); - WifiHelper::EnableAsciiAll (ascii); + YansWifiPhyHelper::EnableAsciiAll (ascii); CsmaHelper::EnableAsciiAll (ascii); // Look at nodes 11, 13 only //WifiHelper::EnableAscii (ascii, 11, 0); //WifiHelper::EnableAscii (ascii, 13, 0); // Let's do a pcap trace on the backbone devices - WifiHelper::EnablePcap ("mixed-wireless", backboneDevices); + YansWifiPhyHelper::EnablePcap ("mixed-wireless", backboneDevices); // Let's additionally trace the application Sink, ifIndex 0 CsmaHelper::EnablePcap ("mixed-wireless", appSink->GetId (), 0); diff --git a/examples/stats/wifi-example-sim.cc b/examples/stats/wifi-example-sim.cc index 07b951ce8..70ade7115 100644 --- a/examples/stats/wifi-example-sim.cc +++ b/examples/stats/wifi-example-sim.cc @@ -129,7 +129,10 @@ int main(int argc, char *argv[]) { NS_LOG_INFO("Installing WiFi and Internet stack."); WifiHelper wifi; wifi.SetMac("ns3::AdhocWifiMac"); - NetDeviceContainer nodeDevices = wifi.Install(nodes); + YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default (); + YansWifiChannelHelper wifiChannel = YansWifiChannelHelper::Default (); + wifiPhy.SetChannel (wifiChannel.Create ()); + NetDeviceContainer nodeDevices = wifi.Install(wifiPhy, nodes); InternetStackHelper internet; internet.Install(nodes); diff --git a/examples/wifi-adhoc.cc b/examples/wifi-adhoc.cc index aedeacf1c..13045424a 100644 --- a/examples/wifi-adhoc.cc +++ b/examples/wifi-adhoc.cc @@ -36,7 +36,7 @@ class Experiment public: Experiment (); Experiment (std::string name); - GnuplotDataset Run (const WifiHelper &wifi); + GnuplotDataset Run (const WifiHelper &wifi, const YansWifiPhyHelper &wifiPhy, const YansWifiChannelHelper &wifiChannel); private: void ReceivePacket (Ptr socket); void SetPosition (Ptr node, Vector position); @@ -110,7 +110,7 @@ Experiment::SetupPacketReceive (Ptr node) } GnuplotDataset -Experiment::Run (const WifiHelper &wifi) +Experiment::Run (const WifiHelper &wifi, const YansWifiPhyHelper &wifiPhy, const YansWifiChannelHelper &wifiChannel) { m_bytesTotal = 0; @@ -120,7 +120,9 @@ Experiment::Run (const WifiHelper &wifi) PacketSocketHelper packetSocket; packetSocket.Install (c); - NetDeviceContainer devices = wifi.Install (c); + YansWifiPhyHelper phy = wifiPhy; + phy.SetChannel (wifiChannel.Create ()); + NetDeviceContainer devices = wifi.Install (phy, c); MobilityHelper mobility; Ptr positionAlloc = CreateObject (); @@ -168,7 +170,9 @@ int main (int argc, char *argv[]) Gnuplot gnuplot = Gnuplot ("reference-rates.png"); Experiment experiment; - WifiHelper wifi; + WifiHelper wifi = WifiHelper::Default (); + YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default (); + YansWifiChannelHelper wifiChannel = YansWifiChannelHelper::Default (); GnuplotDataset dataset; wifi.SetMac ("ns3::AdhocWifiMac"); @@ -177,56 +181,56 @@ int main (int argc, char *argv[]) experiment = Experiment ("54mb"); wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager", "DataMode", StringValue ("wifia-54mbs")); - dataset = experiment.Run (wifi); + dataset = experiment.Run (wifi, wifiPhy, wifiChannel); gnuplot.AddDataset (dataset); NS_LOG_DEBUG ("48"); experiment = Experiment ("48mb"); wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager", "DataMode", StringValue ("wifia-48mbs")); - dataset = experiment.Run (wifi); + dataset = experiment.Run (wifi, wifiPhy, wifiChannel); gnuplot.AddDataset (dataset); NS_LOG_DEBUG ("36"); experiment = Experiment ("36mb"); wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager", "DataMode", StringValue ("wifia-36mbs")); - dataset = experiment.Run (wifi); + dataset = experiment.Run (wifi, wifiPhy, wifiChannel); gnuplot.AddDataset (dataset); NS_LOG_DEBUG ("24"); experiment = Experiment ("24mb"); wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager", "DataMode", StringValue ("wifia-24mbs")); - dataset = experiment.Run (wifi); + dataset = experiment.Run (wifi, wifiPhy, wifiChannel); gnuplot.AddDataset (dataset); NS_LOG_DEBUG ("18"); experiment = Experiment ("18mb"); wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager", "DataMode", StringValue ("wifia-18mbs")); - dataset = experiment.Run (wifi); + dataset = experiment.Run (wifi, wifiPhy, wifiChannel); gnuplot.AddDataset (dataset); NS_LOG_DEBUG ("12"); experiment = Experiment ("12mb"); wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager", "DataMode", StringValue ("wifia-12mbs")); - dataset = experiment.Run (wifi); + dataset = experiment.Run (wifi, wifiPhy, wifiChannel); gnuplot.AddDataset (dataset); NS_LOG_DEBUG ("9"); experiment = Experiment ("9mb"); wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager", "DataMode", StringValue ("wifia-9mbs")); - dataset = experiment.Run (wifi); + dataset = experiment.Run (wifi, wifiPhy, wifiChannel); gnuplot.AddDataset (dataset); NS_LOG_DEBUG ("6"); experiment = Experiment ("6mb"); wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager", "DataMode", StringValue ("wifia-6mbs")); - dataset = experiment.Run (wifi); + dataset = experiment.Run (wifi, wifiPhy, wifiChannel); gnuplot.AddDataset (dataset); gnuplot.GenerateOutput (std::cout); @@ -239,19 +243,19 @@ int main (int argc, char *argv[]) NS_LOG_DEBUG ("arf"); experiment = Experiment ("arf"); wifi.SetRemoteStationManager ("ns3::ArfWifiManager"); - dataset = experiment.Run (wifi); + dataset = experiment.Run (wifi, wifiPhy, wifiChannel); gnuplot.AddDataset (dataset); NS_LOG_DEBUG ("aarf"); experiment = Experiment ("aarf"); wifi.SetRemoteStationManager ("ns3::AarfWifiManager"); - dataset = experiment.Run (wifi); + dataset = experiment.Run (wifi, wifiPhy, wifiChannel); gnuplot.AddDataset (dataset); NS_LOG_DEBUG ("ideal"); experiment = Experiment ("ideal"); wifi.SetRemoteStationManager ("ns3::IdealWifiManager"); - dataset = experiment.Run (wifi); + dataset = experiment.Run (wifi, wifiPhy, wifiChannel); gnuplot.AddDataset (dataset); gnuplot.GenerateOutput (std::cout); diff --git a/examples/wifi-ap.cc b/examples/wifi-ap.cc index e1e327de4..6bd6c74d1 100644 --- a/examples/wifi-ap.cc +++ b/examples/wifi-ap.cc @@ -117,7 +117,7 @@ int main (int argc, char *argv[]) // disable fragmentation Config::SetDefault ("ns3::WifiRemoteStationManager::FragmentationThreshold", StringValue ("2200")); - WifiHelper wifi; + WifiHelper wifi = WifiHelper::Default (); MobilityHelper mobility; NodeContainer stas; NodeContainer ap; @@ -131,23 +131,21 @@ int main (int argc, char *argv[]) packetSocket.Install (stas); packetSocket.Install (ap); - Ptr channel = CreateObject (); - channel->SetPropagationDelayModel (CreateObject ()); - Ptr log = CreateObject (); - channel->SetPropagationLossModel (log); - + YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default (); + YansWifiChannelHelper wifiChannel = YansWifiChannelHelper::Default (); + wifiPhy.SetChannel (wifiChannel.Create ()); Ssid ssid = Ssid ("wifi-default"); wifi.SetRemoteStationManager ("ns3::ArfWifiManager"); // setup stas. wifi.SetMac ("ns3::NqstaWifiMac", "Ssid", SsidValue (ssid), "ActiveProbing", BooleanValue (false)); - staDevs = wifi.Install (stas, channel); + staDevs = wifi.Install (wifiPhy, stas); // setup ap. wifi.SetMac ("ns3::NqapWifiMac", "Ssid", SsidValue (ssid), "BeaconGeneration", BooleanValue (true), "BeaconInterval", TimeValue (Seconds (2.5))); - wifi.Install (ap, channel); + wifi.Install (wifiPhy, ap); // mobility. mobility.Install (stas); diff --git a/examples/wifi-wired-bridging.cc b/examples/wifi-wired-bridging.cc index 9a8b690c9..2852ae9b6 100644 --- a/examples/wifi-wired-bridging.cc +++ b/examples/wifi-wired-bridging.cc @@ -14,16 +14,6 @@ using namespace ns3; -Ptr -CreateChannel (void) -{ - Ptr channel = CreateObject (); - channel->SetPropagationDelayModel (CreateObject ()); - Ptr log = CreateObject (); - channel->SetPropagationLossModel (log); - return channel; -} - int main (int argc, char *argv[]) { uint32_t nWifis = 2; @@ -73,11 +63,12 @@ int main (int argc, char *argv[]) Ipv4InterfaceContainer apInterface; MobilityHelper mobility; BridgeHelper bridge; - WifiHelper wifi; - Ptr channel; + WifiHelper wifi = WifiHelper::Default (); + YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default (); + YansWifiChannelHelper wifiChannel = YansWifiChannelHelper::Default (); + wifiPhy.SetChannel (wifiChannel.Create ()); sta.Create (nStas); - channel = CreateChannel (); ip.NewNetwork (); mobility.SetPositionAllocator ("ns3::GridPositionAllocator", "MinX", DoubleValue (wifiX), @@ -95,7 +86,7 @@ int main (int argc, char *argv[]) "Ssid", SsidValue (ssid), "BeaconGeneration", BooleanValue (true), "BeaconInterval", TimeValue (Seconds (2.5))); - apDev = wifi.Install (backboneNodes.Get (i), channel); + apDev = wifi.Install (wifiPhy, backboneNodes.Get (i)); apInterface = ip.Assign (apDev); bridge.Install (backboneNodes.Get (i), NetDeviceContainer (apDev, backboneDevices.Get (i))); @@ -110,7 +101,7 @@ int main (int argc, char *argv[]) wifi.SetMac ("ns3::NqstaWifiMac", "Ssid", SsidValue (ssid), "ActiveProbing", BooleanValue (false)); - staDev = wifi.Install (sta, channel); + staDev = wifi.Install (wifiPhy, sta); staInterface = ip.Assign (staDev); // save everything in containers. @@ -149,8 +140,8 @@ int main (int argc, char *argv[]) apps.Stop (Seconds (3.0)); - WifiHelper::EnablePcap ("wifi-wire-bridging", staNodes[1].Get (1)); - WifiHelper::EnablePcap ("wifi-wire-bridging", staNodes[0].Get (0)); + YansWifiPhyHelper::EnablePcap ("wifi-wire-bridging", staNodes[1].Get (1)); + YansWifiPhyHelper::EnablePcap ("wifi-wire-bridging", staNodes[0].Get (0)); std::ofstream os; os.open ("wifi-wire-bridging.mob"); MobilityHelper::EnableAsciiAll (os); diff --git a/src/devices/wifi/interference-helper.cc b/src/devices/wifi/interference-helper.cc index 3f6ddb42b..2cb95fef2 100644 --- a/src/devices/wifi/interference-helper.cc +++ b/src/devices/wifi/interference-helper.cc @@ -104,10 +104,9 @@ InterferenceHelper::NiChange::operator < (InterferenceHelper::NiChange const &o) ****************************************************************/ InterferenceHelper::InterferenceHelper () - : m_80211a (false) -{ - m_errorRateModel = Create (); -} + : m_80211a (false), + m_errorRateModel (0) +{} InterferenceHelper::~InterferenceHelper () { m_errorRateModel = 0; diff --git a/src/devices/wifi/wifi-channel.h b/src/devices/wifi/wifi-channel.h index 3b8ccce56..0e1e901bd 100644 --- a/src/devices/wifi/wifi-channel.h +++ b/src/devices/wifi/wifi-channel.h @@ -43,10 +43,6 @@ class WifiChannel : public Channel { public: static TypeId GetTypeId (void); - - virtual Ptr CreatePhy (Ptr device, - Ptr mobility, - UnsafeAttributeList list) = 0; }; } // namespace ns3 diff --git a/src/devices/wifi/wifi-net-device.cc b/src/devices/wifi/wifi-net-device.cc index a02cd4549..6dbaf85cc 100644 --- a/src/devices/wifi/wifi-net-device.cc +++ b/src/devices/wifi/wifi-net-device.cc @@ -40,8 +40,7 @@ WifiNetDevice::GetTypeId (void) .SetParent () .AddAttribute ("Channel", "The channel attached to this device", PointerValue (), - MakePointerAccessor (&WifiNetDevice::DoGetChannel, - &WifiNetDevice::SetChannel), + MakePointerAccessor (&WifiNetDevice::DoGetChannel), MakePointerChecker ()) .AddAttribute ("Phy", "The PHY layer attached to this device.", PointerValue (), @@ -67,7 +66,8 @@ WifiNetDevice::GetTypeId (void) } WifiNetDevice::WifiNetDevice () - : m_mtu (0) + : m_mtu (0), + m_configComplete (false) {} WifiNetDevice::~WifiNetDevice () {} @@ -81,67 +81,48 @@ WifiNetDevice::DoDispose (void) m_stationManager->Dispose (); m_mac = 0; m_phy = 0; - m_channel = 0; m_stationManager = 0; // chain up. NetDevice::DoDispose (); } + +void +WifiNetDevice::CompleteConfig (void) +{ + if (m_mac == 0 || + m_phy == 0 || + m_stationManager == 0 || + m_node == 0 || + m_configComplete) + { + return; + } + m_mac->SetWifiRemoteStationManager (m_stationManager); + m_mac->SetWifiPhy (m_phy); + m_mac->SetForwardUpCallback (MakeCallback (&WifiNetDevice::ForwardUp, this)); + m_mac->SetLinkUpCallback (MakeCallback (&WifiNetDevice::LinkUp, this)); + m_mac->SetLinkDownCallback (MakeCallback (&WifiNetDevice::LinkDown, this)); + m_stationManager->SetupPhy (m_phy); + m_configComplete = true; +} void WifiNetDevice::SetMac (Ptr mac) { m_mac = mac; - if (m_mac != 0) - { - if (m_stationManager != 0) - { - m_mac->SetWifiRemoteStationManager (m_stationManager); - } - if (m_phy != 0) - { - m_mac->SetWifiPhy (m_phy); - } - m_mac->SetForwardUpCallback (MakeCallback (&WifiNetDevice::ForwardUp, this)); - m_mac->SetLinkUpCallback (MakeCallback (&WifiNetDevice::LinkUp, this)); - m_mac->SetLinkDownCallback (MakeCallback (&WifiNetDevice::LinkDown, this)); - } + CompleteConfig (); } void WifiNetDevice::SetPhy (Ptr phy) { m_phy = phy; - if (m_phy != 0) - { - if (m_stationManager != 0) - { - m_stationManager->SetupPhy (m_phy); - } - if (m_mac != 0) - { - m_mac->SetWifiPhy (m_phy); - } - } + CompleteConfig (); } void WifiNetDevice::SetRemoteStationManager (Ptr manager) { m_stationManager = manager; - if (m_stationManager != 0) - { - if (m_phy != 0) - { - m_stationManager->SetupPhy (m_phy); - } - if (m_mac != 0) - { - m_mac->SetWifiRemoteStationManager (m_stationManager); - } - } -} -void -WifiNetDevice::SetChannel (Ptr channel) -{ - m_channel = channel; + CompleteConfig (); } Ptr WifiNetDevice::GetMac (void) const @@ -182,12 +163,12 @@ WifiNetDevice::GetIfIndex(void) const Ptr WifiNetDevice::GetChannel (void) const { - return m_channel; + return m_phy->GetChannel (); } Ptr WifiNetDevice::DoGetChannel (void) const { - return m_channel; + return m_phy->GetChannel (); } Address WifiNetDevice::GetAddress (void) const @@ -282,6 +263,7 @@ void WifiNetDevice::SetNode (Ptr node) { m_node = node; + CompleteConfig (); } bool WifiNetDevice::NeedsArp (void) const diff --git a/src/devices/wifi/wifi-net-device.h b/src/devices/wifi/wifi-net-device.h index 556ddde15..3585705d8 100644 --- a/src/devices/wifi/wifi-net-device.h +++ b/src/devices/wifi/wifi-net-device.h @@ -60,10 +60,6 @@ public: * \param manager the manager to use. */ void SetRemoteStationManager (Ptr manager); - /** - * \param channel the channel to connect to. - */ - void SetChannel (Ptr channel); /** * \returns the mac we are currently using. */ @@ -112,9 +108,10 @@ private: void LinkDown (void); void Setup (void); Ptr DoGetChannel (void) const; + void CompleteConfig (void); + Ptr m_node; Ptr m_phy; - Ptr m_channel; Ptr m_mac; Ptr m_stationManager; NetDevice::ReceiveCallback m_forwardUp; @@ -126,6 +123,7 @@ private: bool m_linkUp; Callback m_linkChange; mutable uint16_t m_mtu; + bool m_configComplete; }; } // namespace ns3 diff --git a/src/devices/wifi/wifi-phy-test.cc b/src/devices/wifi/wifi-phy-test.cc index e3ea52fbb..5904c13f3 100644 --- a/src/devices/wifi/wifi-phy-test.cc +++ b/src/devices/wifi/wifi-phy-test.cc @@ -3,6 +3,7 @@ #include "yans-wifi-phy.h" #include "propagation-loss-model.h" #include "propagation-delay-model.h" +#include "error-rate-model.h" #include "ns3/ptr.h" #include "ns3/mobility-model.h" #include "ns3/static-mobility-model.h" @@ -83,8 +84,16 @@ PsrExperiment::Run (struct PsrExperiment::Input input) Ptr log = CreateObject (); channel->SetPropagationLossModel (log); - Ptr tx = channel->CreatePhy (0, posTx, UnsafeAttributeList ()); - Ptr rx = channel->CreatePhy (0, posRx, UnsafeAttributeList ()); + Ptr tx = CreateObject (); + Ptr rx = CreateObject (); + Ptr error = CreateObject (); + tx->SetErrorRateModel (error); + rx->SetErrorRateModel (error); + tx->SetChannel (channel); + rx->SetChannel (channel); + tx->SetMobility (posTx); + rx->SetMobility (posRx); + rx->SetReceiveOkCallback (MakeCallback (&PsrExperiment::Receive, this)); for (uint32_t i = 0; i < m_input.nPackets; ++i) @@ -204,9 +213,22 @@ CollisionExperiment::Run (struct CollisionExperiment::Input input) Ptr posRx = CreateObject (); posRx->SetPosition (Vector (0, 0.0, 0.0)); - Ptr txA = channel->CreatePhy (0, posTxA, UnsafeAttributeList ()); - Ptr txB = channel->CreatePhy (0, posTxB, UnsafeAttributeList ()); - Ptr rx = channel->CreatePhy (0, posRx, UnsafeAttributeList ()); + Ptr txA = CreateObject (); + Ptr txB = CreateObject (); + Ptr rx = CreateObject (); + + Ptr error = CreateObject (); + txA->SetErrorRateModel (error); + txB->SetErrorRateModel (error); + rx->SetErrorRateModel (error); + txA->SetChannel (channel); + txB->SetChannel (channel); + rx->SetChannel (channel); + txA->SetMobility (posTxA); + txB->SetMobility (posTxB); + rx->SetMobility (posRx); + + rx->SetReceiveOkCallback (MakeCallback (&CollisionExperiment::Receive, this)); for (uint32_t i = 0; i < m_input.nPackets; ++i) diff --git a/src/devices/wifi/wifi-phy.h b/src/devices/wifi/wifi-phy.h index 89dd95fc2..58c2cdbc4 100644 --- a/src/devices/wifi/wifi-phy.h +++ b/src/devices/wifi/wifi-phy.h @@ -35,6 +35,7 @@ namespace ns3 { class WifiChannel; +class NetDevice; /** * \brief receive notifications about phy events. @@ -231,12 +232,11 @@ public: * \returns the mode whose index is specified. */ virtual WifiMode GetMode (uint32_t mode) const = 0; - /* return snr: W/W */ /** * \param txMode the transmission mode * \param ber the probability of bit error rate * \returns the minimum snr which is required to achieve - * the requested ber for the specified transmission mode. + * the requested ber for the specified transmission mode. (W/W) */ virtual double CalculateSnr (WifiMode txMode, double ber) const = 0; diff --git a/src/devices/wifi/wifi-test.cc b/src/devices/wifi/wifi-test.cc index be74753b9..f13b68a00 100644 --- a/src/devices/wifi/wifi-test.cc +++ b/src/devices/wifi/wifi-test.cc @@ -7,6 +7,7 @@ #include "arf-wifi-manager.h" #include "propagation-delay-model.h" #include "propagation-loss-model.h" +#include "error-rate-model.h" #include "ns3/static-mobility-model.h" #include "ns3/node.h" #include "ns3/simulator.h" @@ -23,7 +24,7 @@ public: virtual bool RunTests (void); private: void RunOne (void); - void CreateOne (Vector pos, Ptr channel); + void CreateOne (Vector pos, Ptr channel); void SendOnePacket (Ptr dev); ObjectFactory m_manager; @@ -43,14 +44,19 @@ WifiTest::SendOnePacket (Ptr dev) } void -WifiTest::CreateOne (Vector pos, Ptr channel) +WifiTest::CreateOne (Vector pos, Ptr channel) { Ptr node = CreateObject (); Ptr dev = CreateObject (); Ptr mac = m_mac.Create (); Ptr mobility = CreateObject (); - Ptr phy = channel->CreatePhy (dev, mobility, UnsafeAttributeList ()); + Ptr phy = CreateObject (); + Ptr error = CreateObject (); + phy->SetErrorRateModel (error); + phy->SetChannel (channel); + phy->SetDevice (dev); + phy->SetMobility (node); Ptr manager = m_manager.Create (); mobility->SetPosition (pos); @@ -59,7 +65,6 @@ WifiTest::CreateOne (Vector pos, Ptr channel) dev->SetMac (mac); dev->SetPhy (phy); dev->SetRemoteStationManager (manager); - dev->SetChannel (channel); node->AddDevice (dev); Simulator::Schedule (Seconds (1.0), &WifiTest::SendOnePacket, this, dev); diff --git a/src/devices/wifi/wscript b/src/devices/wifi/wscript index 94cdd75b4..b01ac49e0 100644 --- a/src/devices/wifi/wscript +++ b/src/devices/wifi/wscript @@ -74,6 +74,7 @@ def build(bld): 'nqap-wifi-mac.h', 'wifi-phy.h', 'supported-rates.h', + 'error-rate-model.h', ] obj = bld.create_ns3_program('wifi-phy-test', diff --git a/src/devices/wifi/yans-wifi-channel.cc b/src/devices/wifi/yans-wifi-channel.cc index 086b5807f..1c7022752 100644 --- a/src/devices/wifi/yans-wifi-channel.cc +++ b/src/devices/wifi/yans-wifi-channel.cc @@ -27,7 +27,6 @@ #include "ns3/object-factory.h" #include "yans-wifi-channel.h" #include "yans-wifi-phy.h" -#include "wifi-net-device.h" #include "propagation-loss-model.h" #include "propagation-delay-model.h" @@ -57,7 +56,7 @@ YansWifiChannel::YansWifiChannel () {} YansWifiChannel::~YansWifiChannel () { - m_deviceList.clear (); + m_phyList.clear (); } void @@ -75,22 +74,14 @@ void YansWifiChannel::Send (Ptr sender, Ptr packet, double txPowerDbm, WifiMode wifiMode, WifiPreamble preamble) const { - Ptr senderMobility = 0; - for (DeviceList::const_iterator i = m_deviceList.begin (); i != m_deviceList.end (); i++) - { - if (sender == i->phy) - { - senderMobility = i->mobility->GetObject (); - break; - } - } + Ptr senderMobility = sender->GetMobility ()->GetObject (); NS_ASSERT (senderMobility != 0); uint32_t j = 0; - for (DeviceList::const_iterator i = m_deviceList.begin (); i != m_deviceList.end (); i++) + for (PhyList::const_iterator i = m_phyList.begin (); i != m_phyList.end (); i++) { - if (sender != i->phy) + if (sender != (*i)) { - Ptr receiverMobility = i->mobility->GetObject (); + Ptr receiverMobility = (*i)->GetMobility ()->GetObject (); Time delay = m_delay->GetDelay (senderMobility, receiverMobility); double rxPowerDbm = txPowerDbm + m_loss->GetLoss (senderMobility, receiverMobility); NS_LOG_DEBUG ("propagation: txPower="< sender, Ptr packet, double void YansWifiChannel::Receive (uint32_t i, Ptr packet, double rxPowerDbm, - WifiMode txMode, WifiPreamble preamble) const + WifiMode txMode, WifiPreamble preamble) const { - m_deviceList[i].phy->StartReceivePacket (packet, rxPowerDbm, txMode, preamble); + m_phyList[i]->StartReceivePacket (packet, rxPowerDbm, txMode, preamble); } uint32_t YansWifiChannel::GetNDevices (void) const { - return m_deviceList.size (); + return m_phyList.size (); } Ptr YansWifiChannel::GetDevice (uint32_t i) const { - return m_deviceList[i].device; + return m_phyList[i]->GetDevice ()->GetObject (); } -Ptr -YansWifiChannel::CreatePhy (Ptr device, - Ptr mobility, - UnsafeAttributeList list) +void +YansWifiChannel::Add (Ptr phy) { - ObjectFactory factory; - factory.SetTypeId ("ns3::YansWifiPhy"); - factory.Set (list.GetSafe ("ns3::YansWifiPhy")); - Ptr phy = factory.Create (); - phy->SetChannel (this); - struct Item item; - item.device = device; - item.phy = phy; - item.mobility = mobility; - m_deviceList.push_back (item); - return phy; + m_phyList.push_back (phy); } } // namespace ns3 diff --git a/src/devices/wifi/yans-wifi-channel.h b/src/devices/wifi/yans-wifi-channel.h index b34c2c7e8..6bd05c4e0 100644 --- a/src/devices/wifi/yans-wifi-channel.h +++ b/src/devices/wifi/yans-wifi-channel.h @@ -30,7 +30,6 @@ namespace ns3 { class NetDevice; -class WifiNetDevice; class PropagationLossModel; class PropagationDelayModel; class YansWifiPhy; @@ -58,10 +57,7 @@ public: virtual uint32_t GetNDevices (void) const; virtual Ptr GetDevice (uint32_t i) const; - // inherited from WifiChannel - virtual Ptr CreatePhy (Ptr device, - Ptr mobility, - UnsafeAttributeList list); + void Add (Ptr phy); /** * \param loss the new propagation loss model. @@ -86,17 +82,12 @@ public: WifiMode wifiMode, WifiPreamble preamble) const; private: - struct Item { - Ptr device; - Ptr phy; - Ptr mobility; - }; - typedef std::vector DeviceList; + typedef std::vector > PhyList; void Receive (uint32_t i, Ptr packet, double rxPowerDbm, WifiMode txMode, WifiPreamble preamble) const; - DeviceList m_deviceList; + PhyList m_phyList; Ptr m_loss; Ptr m_delay; }; diff --git a/src/devices/wifi/yans-wifi-phy.cc b/src/devices/wifi/yans-wifi-phy.cc index af7a6aae8..ee79c8d44 100644 --- a/src/devices/wifi/yans-wifi-phy.cc +++ b/src/devices/wifi/yans-wifi-phy.cc @@ -33,6 +33,7 @@ #include "ns3/uinteger.h" #include "ns3/enum.h" #include "ns3/pointer.h" +#include "ns3/net-device.h" #include NS_LOG_COMPONENT_DEFINE ("YansWifiPhy"); @@ -130,6 +131,7 @@ YansWifiPhy::DoDispose (void) NS_LOG_FUNCTION (this); m_channel = 0; m_modes.clear (); + m_device = 0; } void @@ -204,6 +206,17 @@ YansWifiPhy::SetErrorRateModel (Ptr rate) { m_interference.SetErrorRateModel (rate); } +void +YansWifiPhy::SetDevice (Ptr device) +{ + m_device = device; +} +void +YansWifiPhy::SetMobility (Ptr mobility) +{ + m_mobility = mobility; +} + double YansWifiPhy::GetRxNoise (void) const { @@ -247,6 +260,16 @@ YansWifiPhy::GetErrorRateModel (void) const { return m_interference.GetErrorRateModel (); } +Ptr +YansWifiPhy::GetDevice (void) const +{ + return m_device; +} +Ptr +YansWifiPhy::GetMobility (void) +{ + return m_mobility; +} double YansWifiPhy::CalculateSnr (WifiMode txMode, double ber) const @@ -259,11 +282,11 @@ YansWifiPhy::GetChannel (void) const { return m_channel; } - void YansWifiPhy::SetChannel (Ptr channel) { m_channel = channel; + m_channel->Add (this); } void diff --git a/src/devices/wifi/yans-wifi-phy.h b/src/devices/wifi/yans-wifi-phy.h index bfeb4d74e..cdd65eae1 100644 --- a/src/devices/wifi/yans-wifi-phy.h +++ b/src/devices/wifi/yans-wifi-phy.h @@ -84,12 +84,16 @@ public: void SetEdThreshold (double threshold); void SetCcaMode1Threshold (double threshold); void SetErrorRateModel (Ptr rate); + void SetDevice (Ptr device); + void SetMobility (Ptr mobility); double GetRxNoise (void) const; double GetTxGain (void) const; double GetRxGain (void) const; double GetEdThreshold (void) const; double GetCcaMode1Threshold (void) const; Ptr GetErrorRateModel (void) const; + Ptr GetDevice (void) const; + Ptr GetMobility (void); virtual double GetTxPowerStart (void) const; @@ -139,6 +143,8 @@ private: uint32_t m_nTxPower; Ptr m_channel; + Ptr m_device; + Ptr m_mobility; Modes m_modes; EventId m_endSyncEvent; UniformVariable m_random; diff --git a/src/helper/wifi-helper.cc b/src/helper/wifi-helper.cc index cbc8ad7ae..ad1064567 100644 --- a/src/helper/wifi-helper.cc +++ b/src/helper/wifi-helper.cc @@ -29,8 +29,6 @@ #include "ns3/mobility-model.h" #include "ns3/log.h" #include "ns3/pcap-writer.h" -#include "ns3/wifi-mode.h" -#include "ns3/wifi-preamble.h" #include "ns3/config.h" #include "ns3/simulator.h" @@ -40,40 +38,20 @@ NS_LOG_COMPONENT_DEFINE ("WifiHelper"); namespace ns3 { -static void PcapPhyTxEvent (Ptr writer, Ptr packet, - WifiMode mode, WifiPreamble preamble, - uint8_t txLevel) -{ - writer->WritePacket (packet); -} - -static void PcapPhyRxEvent (Ptr writer, - Ptr packet, double snr, WifiMode mode, - enum WifiPreamble preamble) -{ - writer->WritePacket (packet); -} - -static void AsciiPhyTxEvent (std::ostream *os, std::string context, - Ptr packet, - WifiMode mode, WifiPreamble preamble, - uint8_t txLevel) -{ - *os << "+ " << Simulator::Now () << " " << context << " " << *packet << std::endl; -} - -static void AsciiPhyRxOkEvent (std::ostream *os, std::string context, - Ptr packet, double snr, WifiMode mode, - enum WifiPreamble preamble) -{ - *os << "r " << Simulator::Now () << " " << context << " " << *packet << std::endl; -} +WifiPhyHelper::~WifiPhyHelper () +{} WifiHelper::WifiHelper () +{} + +WifiHelper +WifiHelper::Default (void) { - m_stationManager.SetTypeId ("ns3::ArfWifiManager"); - m_mac.SetTypeId ("ns3::AdhocWifiMac"); + WifiHelper helper; + helper.SetRemoteStationManager ("ns3::ArfWifiManager"); + helper.SetMac ("ns3::AdhocWifiMac"); + return helper; } void @@ -122,130 +100,21 @@ WifiHelper::SetMac (std::string type, m_mac.Set (n7, v7); } -void -WifiHelper::SetPhyAttribute (std::string name, const AttributeValue &value) -{ - m_phyAttributes.Set (name, value); -} - -void -WifiHelper::EnablePcap (std::string filename, uint32_t nodeid, uint32_t deviceid) -{ - std::ostringstream oss; - oss << "/NodeList/" << nodeid << "/DeviceList/" << deviceid << "/$ns3::WifiNetDevice/Phy/"; - Config::MatchContainer matches = Config::LookupMatches (oss.str ()); - if (matches.GetN () == 0) - { - return; - } - oss.str (""); - oss << filename << "-" << nodeid << "-" << deviceid << ".pcap"; - Ptr pcap = Create (); - pcap->Open (oss.str ()); - pcap->WriteWifiHeader (); - oss.str (""); - oss << "/NodeList/" << nodeid << "/DeviceList/" << deviceid << "/$ns3::WifiNetDevice/Phy/State/Tx"; - Config::ConnectWithoutContext (oss.str (), MakeBoundCallback (&PcapPhyTxEvent, pcap)); - oss.str (""); - oss << "/NodeList/" << nodeid << "/DeviceList/" << deviceid << "/$ns3::WifiNetDevice/Phy/State/RxOk"; - Config::ConnectWithoutContext (oss.str (), MakeBoundCallback (&PcapPhyRxEvent, pcap)); -} -void -WifiHelper::EnablePcap (std::string filename, NetDeviceContainer d) -{ - for (NetDeviceContainer::Iterator i = d.Begin (); i != d.End (); ++i) - { - Ptr dev = *i; - EnablePcap (filename, dev->GetNode ()->GetId (), dev->GetIfIndex ()); - } -} -void -WifiHelper::EnablePcap (std::string filename, NodeContainer n) -{ - NetDeviceContainer devs; - for (NodeContainer::Iterator i = n.Begin (); i != n.End (); ++i) - { - Ptr node = *i; - for (uint32_t j = 0; j < node->GetNDevices (); ++j) - { - devs.Add (node->GetDevice (j)); - } - } - EnablePcap (filename, devs); -} - -void -WifiHelper::EnablePcapAll (std::string filename) -{ - EnablePcap (filename, NodeContainer::GetGlobal ()); -} - -void -WifiHelper::EnableAscii (std::ostream &os, uint32_t nodeid, uint32_t deviceid) -{ - Packet::EnablePrinting (); - std::ostringstream oss; - oss << "/NodeList/" << nodeid << "/DeviceList/" << deviceid << "/$ns3::WifiNetDevice/Phy/State/RxOk"; - Config::Connect (oss.str (), MakeBoundCallback (&AsciiPhyRxOkEvent, &os)); - oss.str (""); - oss << "/NodeList/" << nodeid << "/DeviceList/" << deviceid << "/$ns3::WifiNetDevice/Phy/State/Tx"; - Config::Connect (oss.str (), MakeBoundCallback (&AsciiPhyTxEvent, &os)); -} -void -WifiHelper::EnableAscii (std::ostream &os, NetDeviceContainer d) -{ - for (NetDeviceContainer::Iterator i = d.Begin (); i != d.End (); ++i) - { - Ptr dev = *i; - EnableAscii (os, dev->GetNode ()->GetId (), dev->GetIfIndex ()); - } -} -void -WifiHelper::EnableAscii (std::ostream &os, NodeContainer n) -{ - NetDeviceContainer devs; - for (NodeContainer::Iterator i = n.Begin (); i != n.End (); ++i) - { - Ptr node = *i; - for (uint32_t j = 0; j < node->GetNDevices (); ++j) - { - devs.Add (node->GetDevice (j)); - } - } - EnableAscii (os, devs); -} - -void -WifiHelper::EnableAsciiAll (std::ostream &os) -{ - EnableAscii (os, NodeContainer::GetGlobal ()); -} - -NetDeviceContainer -WifiHelper::Install (NodeContainer c) const -{ - Ptr channel = CreateObject (); - channel->SetPropagationDelayModel (CreateObject ()); - Ptr log = CreateObject (); - channel->SetPropagationLossModel (log); - return Install (c, channel); -} -NetDeviceContainer -WifiHelper::Install (NodeContainer c, Ptr channel) const +NetDeviceContainer +WifiHelper::Install (const WifiPhyHelper &phyHelper, NodeContainer c) const { NetDeviceContainer devices; - for (NodeContainer::Iterator i = c.Begin (); i != c.End (); i++) + for (NodeContainer::Iterator i = c.Begin (); i != c.End (); ++i) { Ptr node = *i; Ptr device = CreateObject (); Ptr manager = m_stationManager.Create (); Ptr mac = m_mac.Create (); - Ptr phy = channel->CreatePhy (device, node, m_phyAttributes); + Ptr phy = phyHelper.Create (node, device); mac->SetAddress (Mac48Address::Allocate ()); device->SetMac (mac); device->SetPhy (phy); device->SetRemoteStationManager (manager); - device->SetChannel (channel); node->AddDevice (device); devices.Add (device); NS_LOG_DEBUG ("node="< channel) const; + NetDeviceContainer Install (const WifiPhyHelper &phy, NodeContainer c) const; private: ObjectFactory m_stationManager; ObjectFactory m_mac; - UnsafeAttributeList m_phyAttributes; }; } // namespace ns3 diff --git a/src/helper/wscript b/src/helper/wscript index c638e84f0..d420c5557 100644 --- a/src/helper/wscript +++ b/src/helper/wscript @@ -21,6 +21,7 @@ def build(bld): 'ipv4-interface-container.cc', 'udp-echo-helper.cc', 'bridge-helper.cc', + 'yans-wifi-phy-helper.cc', ] headers = bld.create_obj('ns3header') @@ -44,4 +45,5 @@ def build(bld): 'ipv4-interface-container.h', 'udp-echo-helper.h', 'bridge-helper.h', + 'yans-wifi-phy-helper.h', ] diff --git a/src/helper/yans-wifi-phy-helper.cc b/src/helper/yans-wifi-phy-helper.cc new file mode 100644 index 000000000..9781aafd9 --- /dev/null +++ b/src/helper/yans-wifi-phy-helper.cc @@ -0,0 +1,305 @@ +/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ +/* + * Copyright (c) 2008 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 "yans-wifi-phy-helper.h" +#include "ns3/error-rate-model.h" +#include "ns3/propagation-loss-model.h" +#include "ns3/propagation-delay-model.h" +#include "ns3/yans-wifi-channel.h" +#include "ns3/yans-wifi-phy.h" +#include "ns3/wifi-net-device.h" +#include "ns3/pcap-writer.h" +#include "ns3/simulator.h" +#include "ns3/config.h" + +namespace ns3 { + +static void PcapPhyTxEvent (Ptr writer, Ptr packet, + WifiMode mode, WifiPreamble preamble, + uint8_t txLevel) +{ + writer->WritePacket (packet); +} + +static void PcapPhyRxEvent (Ptr writer, + Ptr packet, double snr, WifiMode mode, + enum WifiPreamble preamble) +{ + writer->WritePacket (packet); +} + +static void AsciiPhyTxEvent (std::ostream *os, std::string context, + Ptr packet, + WifiMode mode, WifiPreamble preamble, + uint8_t txLevel) +{ + *os << "+ " << Simulator::Now () << " " << context << " " << *packet << std::endl; +} + +static void AsciiPhyRxOkEvent (std::ostream *os, std::string context, + Ptr packet, double snr, WifiMode mode, + enum WifiPreamble preamble) +{ + *os << "r " << Simulator::Now () << " " << context << " " << *packet << std::endl; +} + + +YansWifiChannelHelper::YansWifiChannelHelper () +{} + +YansWifiChannelHelper +YansWifiChannelHelper::Default (void) +{ + YansWifiChannelHelper helper; + helper.SetPropagationDelay ("ns3::ConstantSpeedPropagationDelayModel"); + helper.AddPropagationLoss ("ns3::LogDistancePropagationLossModel"); + return helper; +} + +void +YansWifiChannelHelper::AddPropagationLoss (std::string type, + std::string n0, const AttributeValue &v0, + std::string n1, const AttributeValue &v1, + std::string n2, const AttributeValue &v2, + std::string n3, const AttributeValue &v3, + std::string n4, const AttributeValue &v4, + std::string n5, const AttributeValue &v5, + std::string n6, const AttributeValue &v6, + std::string n7, const AttributeValue &v7) +{ + ObjectFactory factory; + factory.SetTypeId (type); + factory.Set (n0, v0); + factory.Set (n1, v1); + factory.Set (n2, v2); + factory.Set (n3, v3); + factory.Set (n4, v4); + factory.Set (n5, v5); + factory.Set (n6, v6); + factory.Set (n7, v7); + m_propagationLoss.push_back (factory); +} + +void +YansWifiChannelHelper::SetPropagationDelay (std::string type, + std::string n0, const AttributeValue &v0, + std::string n1, const AttributeValue &v1, + std::string n2, const AttributeValue &v2, + std::string n3, const AttributeValue &v3, + std::string n4, const AttributeValue &v4, + std::string n5, const AttributeValue &v5, + std::string n6, const AttributeValue &v6, + std::string n7, const AttributeValue &v7) +{ + ObjectFactory factory; + factory.SetTypeId (type); + factory.Set (n0, v0); + factory.Set (n1, v1); + factory.Set (n2, v2); + factory.Set (n3, v3); + factory.Set (n4, v4); + factory.Set (n5, v5); + factory.Set (n6, v6); + factory.Set (n7, v7); + m_propagationDelay = factory; +} + +Ptr +YansWifiChannelHelper::Create (void) const +{ + Ptr channel = CreateObject (); + Ptr prev = 0; + for (std::vector::const_iterator i = m_propagationLoss.begin (); i != m_propagationLoss.end (); ++i) + { + Ptr cur = (*i).Create (); + if (prev != 0) + { + prev->SetNext (cur); + prev = cur; + } + if (m_propagationLoss.begin () == i) + { + channel->SetPropagationLossModel (cur); + } + } + Ptr delay = m_propagationDelay.Create (); + channel->SetPropagationDelayModel (delay); + return channel; +} + + +YansWifiPhyHelper::YansWifiPhyHelper () + : m_channel (0) +{ + m_phy.SetTypeId ("ns3::YansWifiPhy"); +} + +YansWifiPhyHelper +YansWifiPhyHelper::Default (void) +{ + YansWifiPhyHelper helper; + helper.SetErrorRateModel ("ns3::ErrorRateModel"); + return helper; +} + +void +YansWifiPhyHelper::SetChannel (Ptr channel) +{ + m_channel = channel; +} +void +YansWifiPhyHelper::Set (std::string name, const AttributeValue &v) +{ + m_phy.Set (name, v); +} + +void +YansWifiPhyHelper::SetErrorRateModel (std::string name, + std::string n0, const AttributeValue &v0, + std::string n1, const AttributeValue &v1, + std::string n2, const AttributeValue &v2, + std::string n3, const AttributeValue &v3, + std::string n4, const AttributeValue &v4, + std::string n5, const AttributeValue &v5, + std::string n6, const AttributeValue &v6, + std::string n7, const AttributeValue &v7) +{ + m_errorRateModel = ObjectFactory (); + m_errorRateModel.SetTypeId (name); + m_errorRateModel.Set (n0, v0); + m_errorRateModel.Set (n1, v1); + m_errorRateModel.Set (n2, v2); + m_errorRateModel.Set (n3, v3); + m_errorRateModel.Set (n4, v4); + m_errorRateModel.Set (n5, v5); + m_errorRateModel.Set (n6, v6); + m_errorRateModel.Set (n7, v7); +} + + +Ptr +YansWifiPhyHelper::Create (Ptr node, Ptr device) const +{ + Ptr phy = m_phy.Create (); + Ptr error = m_errorRateModel.Create (); + phy->SetErrorRateModel (error); + phy->SetChannel (m_channel); + phy->SetMobility (node); + phy->SetDevice (device); + return phy; +} + +void +YansWifiPhyHelper::EnablePcap (std::string filename, uint32_t nodeid, uint32_t deviceid) +{ + std::ostringstream oss; + oss << "/NodeList/" << nodeid << "/DeviceList/" << deviceid << "/$ns3::WifiNetDevice/Phy/"; + Config::MatchContainer matches = Config::LookupMatches (oss.str ()); + if (matches.GetN () == 0) + { + return; + } + oss.str (""); + oss << filename << "-" << nodeid << "-" << deviceid << ".pcap"; + // we must fully-qualify the call to Create below because it conflicts + // with the locally-defined WifiPhyHelper::Create method. + Ptr pcap = ::ns3::Create (); + pcap->Open (oss.str ()); + pcap->WriteWifiHeader (); + oss.str (""); + oss << "/NodeList/" << nodeid << "/DeviceList/" << deviceid << "/$ns3::WifiNetDevice/Phy/State/Tx"; + Config::ConnectWithoutContext (oss.str (), MakeBoundCallback (&PcapPhyTxEvent, pcap)); + oss.str (""); + oss << "/NodeList/" << nodeid << "/DeviceList/" << deviceid << "/$ns3::WifiNetDevice/Phy/State/RxOk"; + Config::ConnectWithoutContext (oss.str (), MakeBoundCallback (&PcapPhyRxEvent, pcap)); +} +void +YansWifiPhyHelper::EnablePcap (std::string filename, NetDeviceContainer d) +{ + for (NetDeviceContainer::Iterator i = d.Begin (); i != d.End (); ++i) + { + Ptr dev = *i; + EnablePcap (filename, dev->GetNode ()->GetId (), dev->GetIfIndex ()); + } +} +void +YansWifiPhyHelper::EnablePcap (std::string filename, NodeContainer n) +{ + NetDeviceContainer devs; + for (NodeContainer::Iterator i = n.Begin (); i != n.End (); ++i) + { + Ptr node = *i; + for (uint32_t j = 0; j < node->GetNDevices (); ++j) + { + devs.Add (node->GetDevice (j)); + } + } + EnablePcap (filename, devs); +} + +void +YansWifiPhyHelper::EnablePcapAll (std::string filename) +{ + EnablePcap (filename, NodeContainer::GetGlobal ()); +} + +void +YansWifiPhyHelper::EnableAscii (std::ostream &os, uint32_t nodeid, uint32_t deviceid) +{ + Packet::EnablePrinting (); + std::ostringstream oss; + oss << "/NodeList/" << nodeid << "/DeviceList/" << deviceid << "/$ns3::WifiNetDevice/Phy/State/RxOk"; + Config::Connect (oss.str (), MakeBoundCallback (&AsciiPhyRxOkEvent, &os)); + oss.str (""); + oss << "/NodeList/" << nodeid << "/DeviceList/" << deviceid << "/$ns3::WifiNetDevice/Phy/State/Tx"; + Config::Connect (oss.str (), MakeBoundCallback (&AsciiPhyTxEvent, &os)); +} +void +YansWifiPhyHelper::EnableAscii (std::ostream &os, NetDeviceContainer d) +{ + for (NetDeviceContainer::Iterator i = d.Begin (); i != d.End (); ++i) + { + Ptr dev = *i; + EnableAscii (os, dev->GetNode ()->GetId (), dev->GetIfIndex ()); + } +} +void +YansWifiPhyHelper::EnableAscii (std::ostream &os, NodeContainer n) +{ + NetDeviceContainer devs; + for (NodeContainer::Iterator i = n.Begin (); i != n.End (); ++i) + { + Ptr node = *i; + for (uint32_t j = 0; j < node->GetNDevices (); ++j) + { + devs.Add (node->GetDevice (j)); + } + } + EnableAscii (os, devs); +} + +void +YansWifiPhyHelper::EnableAsciiAll (std::ostream &os) +{ + EnableAscii (os, NodeContainer::GetGlobal ()); +} + + + +} // namespace ns3 diff --git a/src/helper/yans-wifi-phy-helper.h b/src/helper/yans-wifi-phy-helper.h new file mode 100644 index 000000000..3cbad0488 --- /dev/null +++ b/src/helper/yans-wifi-phy-helper.h @@ -0,0 +1,167 @@ +/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ +/* + * Copyright (c) 2008 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 YANS_WIFI_PHY_HELPER_H +#define YANS_WIFI_PHY_HELPER_H + +#include "wifi-helper.h" +#include "ns3/yans-wifi-channel.h" + +namespace ns3 { + +class YansWifiChannelHelper +{ +public: + YansWifiChannelHelper (); + + static YansWifiChannelHelper Default (void); + + void AddPropagationLoss (std::string name, + std::string n0 = "", const AttributeValue &v0 = EmptyAttributeValue (), + std::string n1 = "", const AttributeValue &v1 = EmptyAttributeValue (), + std::string n2 = "", const AttributeValue &v2 = EmptyAttributeValue (), + std::string n3 = "", const AttributeValue &v3 = EmptyAttributeValue (), + std::string n4 = "", const AttributeValue &v4 = EmptyAttributeValue (), + std::string n5 = "", const AttributeValue &v5 = EmptyAttributeValue (), + std::string n6 = "", const AttributeValue &v6 = EmptyAttributeValue (), + std::string n7 = "", const AttributeValue &v7 = EmptyAttributeValue ()); + void SetPropagationDelay (std::string name, + std::string n0 = "", const AttributeValue &v0 = EmptyAttributeValue (), + std::string n1 = "", const AttributeValue &v1 = EmptyAttributeValue (), + std::string n2 = "", const AttributeValue &v2 = EmptyAttributeValue (), + std::string n3 = "", const AttributeValue &v3 = EmptyAttributeValue (), + std::string n4 = "", const AttributeValue &v4 = EmptyAttributeValue (), + std::string n5 = "", const AttributeValue &v5 = EmptyAttributeValue (), + std::string n6 = "", const AttributeValue &v6 = EmptyAttributeValue (), + std::string n7 = "", const AttributeValue &v7 = EmptyAttributeValue ()); + + Ptr Create (void) const; + +private: + std::vector m_propagationLoss; + ObjectFactory m_propagationDelay; +}; + +class YansWifiPhyHelper : public WifiPhyHelper +{ +public: + YansWifiPhyHelper (); + + static YansWifiPhyHelper Default (void); + + void SetChannel (Ptr channel); + void Set (std::string name, const AttributeValue &v); + void SetErrorRateModel (std::string name, + std::string n0 = "", const AttributeValue &v0 = EmptyAttributeValue (), + std::string n1 = "", const AttributeValue &v1 = EmptyAttributeValue (), + std::string n2 = "", const AttributeValue &v2 = EmptyAttributeValue (), + std::string n3 = "", const AttributeValue &v3 = EmptyAttributeValue (), + std::string n4 = "", const AttributeValue &v4 = EmptyAttributeValue (), + std::string n5 = "", const AttributeValue &v5 = EmptyAttributeValue (), + std::string n6 = "", const AttributeValue &v6 = EmptyAttributeValue (), + std::string n7 = "", const AttributeValue &v7 = EmptyAttributeValue ()); + + virtual Ptr Create (Ptr node, Ptr device) const; + + /** + * \param filename filename prefix to use for pcap files. + * \param nodeid the id of the node to generate pcap output for. + * \param deviceid the id of the device to generate pcap output for. + * + * Generate a pcap file which contains the link-level data observed + * by the specified deviceid within the specified nodeid. The pcap + * data is stored in the file prefix-nodeid-deviceid.pcap. + * + * This method should be invoked after the network topology has + * been fully constructed. + */ + static void EnablePcap (std::string filename, uint32_t nodeid, uint32_t deviceid); + /** + * \param filename filename prefix to use for pcap files. + * \param d container of devices of type ns3::WifiNetDevice + * + * Enable pcap output on each input device which is of the + * ns3::WifiNetDevice type. + */ + static void EnablePcap (std::string filename, NetDeviceContainer d); + /** + * \param filename filename prefix to use for pcap files. + * \param n container of nodes. + * + * Enable pcap output on each device which is of the + * ns3::WifiNetDevice type and which is located in one of the + * input nodes. + */ + static void EnablePcap (std::string filename, NodeContainer n); + /** + * \param filename filename prefix to use for pcap files. + * + * Enable pcap output on each device which is of the + * ns3::WifiNetDevice type + */ + static void EnablePcapAll (std::string filename); + + /** + * \param os output stream + * \param nodeid the id of the node to generate ascii output for. + * \param deviceid the id of the device to generate ascii output for. + * + * Enable ascii output on the specified deviceid within the + * specified nodeid if it is of type ns3::WifiNetDevice and dump + * that to the specified stdc++ output stream. + */ + static void EnableAscii (std::ostream &os, uint32_t nodeid, uint32_t deviceid); + /** + * \param os output stream + * \param d device container + * + * Enable ascii output on each device which is of the + * ns3::WifiNetDevice type and which is located in the input + * device container and dump that to the specified + * stdc++ output stream. + */ + static void EnableAscii (std::ostream &os, NetDeviceContainer d); + /** + * \param os output stream + * \param n node container + * + * Enable ascii output on each device which is of the + * ns3::WifiNetDevice type and which is located in one + * of the input node and dump that to the specified + * stdc++ output stream. + */ + static void EnableAscii (std::ostream &os, NodeContainer n); + /** + * \param os output stream + * + * Enable ascii output on each device which is of the + * ns3::WifiNetDevice type and dump that to the specified + * stdc++ output stream. + */ + static void EnableAsciiAll (std::ostream &os); + +private: + ObjectFactory m_phy; + ObjectFactory m_errorRateModel; + Ptr m_channel; +}; + +} // namespace ns3 + +#endif /* YANS_WIFI_PHY_HELPER_H */