From d2d081606fdbc0619b4cbddce7e41a89c8340402 Mon Sep 17 00:00:00 2001 From: Faker Moatamri Date: Thu, 12 Nov 2009 10:20:26 +0100 Subject: [PATCH 01/29] Rescan python bindings --- .../apidefs/gcc-ILP32/ns3_module_common.py | 5 + .../apidefs/gcc-ILP32/ns3_module_core.py | 82 +- .../apidefs/gcc-ILP32/ns3_module_mobility.py | 120 +++ .../gcc-ILP32/ns3_module_point_to_point.py | 8 + .../apidefs/gcc-ILP32/ns3_module_stats.py | 115 +-- .../gcc-ILP32/ns3modulegen_generated.py | 780 +++++++++--------- .../apidefs/gcc-LP64/ns3_module_common.py | 5 + .../apidefs/gcc-LP64/ns3_module_core.py | 82 +- .../apidefs/gcc-LP64/ns3_module_mobility.py | 120 +++ .../gcc-LP64/ns3_module_point_to_point.py | 8 + .../apidefs/gcc-LP64/ns3_module_stats.py | 115 +-- .../gcc-LP64/ns3modulegen_generated.py | 780 +++++++++--------- 12 files changed, 1340 insertions(+), 880 deletions(-) diff --git a/bindings/python/apidefs/gcc-ILP32/ns3_module_common.py b/bindings/python/apidefs/gcc-ILP32/ns3_module_common.py index a7a0c4975..2d1c570f5 100644 --- a/bindings/python/apidefs/gcc-ILP32/ns3_module_common.py +++ b/bindings/python/apidefs/gcc-ILP32/ns3_module_common.py @@ -903,6 +903,11 @@ def register_Ns3PcapFile_methods(root_module, cls): cls.add_method('Close', 'void', []) + ## pcap-file.h: static bool ns3::PcapFile::Diff(std::string const & f1, std::string const & f2, uint32_t & sec, uint32_t & usec, uint32_t snapLen=ns3::PcapFile::SNAPLEN_DEFAULT) [member function] + cls.add_method('Diff', + 'bool', + [param('std::string const &', 'f1'), param('std::string const &', 'f2'), param('uint32_t &', 'sec'), param('uint32_t &', 'usec'), param('uint32_t', 'snapLen', default_value='ns3::PcapFile::SNAPLEN_DEFAULT')], + is_static=True) ## pcap-file.h: uint32_t ns3::PcapFile::GetDataLinkType() [member function] cls.add_method('GetDataLinkType', 'uint32_t', diff --git a/bindings/python/apidefs/gcc-ILP32/ns3_module_core.py b/bindings/python/apidefs/gcc-ILP32/ns3_module_core.py index 9fcae109a..ce5c5d700 100644 --- a/bindings/python/apidefs/gcc-ILP32/ns3_module_core.py +++ b/bindings/python/apidefs/gcc-ILP32/ns3_module_core.py @@ -51,6 +51,8 @@ def register_types(module): module.add_class('ObjectBase', allow_subclassing=True) ## object-factory.h: ns3::ObjectFactory [class] module.add_class('ObjectFactory') + ## object-ref-count.h: ns3::ObjectRefCount [class] + module.add_class('ObjectRefCount', template_parameters=['ns3::Object', 'ns3::ObjectBase'], parent=root_module['ns3::ObjectBase']) ## random-variable.h: ns3::RandomVariable [class] module.add_class('RandomVariable') ## ref-count-base.h: ns3::RefCountBase [class] @@ -144,7 +146,7 @@ def register_types(module): ## random-variable.h: ns3::NormalVariable [class] module.add_class('NormalVariable', parent=root_module['ns3::RandomVariable']) ## object.h: ns3::Object [class] - module.add_class('Object', automatic_type_narrowing=True, parent=root_module['ns3::ObjectBase'], memory_policy=cppclass.ReferenceCountingMethodsPolicy(incref_method='Ref', decref_method='Unref', peekref_method='GetReferenceCount')) + module.add_class('Object', automatic_type_narrowing=True, parent=root_module['ns3::ObjectRefCount< ns3::Object, ns3::ObjectBase >'], memory_policy=cppclass.ReferenceCountingMethodsPolicy(incref_method='Ref', decref_method='Unref', peekref_method='GetReferenceCount')) ## object.h: ns3::Object::AggregateIterator [class] module.add_class('AggregateIterator', outer_class=root_module['ns3::Object']) ## object-factory.h: ns3::ObjectFactoryChecker [class] @@ -304,6 +306,7 @@ def register_methods(root_module): register_Ns3Names_methods(root_module, root_module['ns3::Names']) register_Ns3ObjectBase_methods(root_module, root_module['ns3::ObjectBase']) register_Ns3ObjectFactory_methods(root_module, root_module['ns3::ObjectFactory']) + register_Ns3ObjectRefCount__Ns3Object_Ns3ObjectBase_methods(root_module, root_module['ns3::ObjectRefCount< ns3::Object, ns3::ObjectBase >']) register_Ns3RandomVariable_methods(root_module, root_module['ns3::RandomVariable']) register_Ns3RefCountBase_methods(root_module, root_module['ns3::RefCountBase']) register_Ns3RngStream_methods(root_module, root_module['ns3::RngStream']) @@ -721,6 +724,43 @@ def register_Ns3ObjectFactory_methods(root_module, cls): [param('std::string', 'tid')]) return +def register_Ns3ObjectRefCount__Ns3Object_Ns3ObjectBase_methods(root_module, cls): + ## object-ref-count.h: ns3::ObjectRefCount::ObjectRefCount() [constructor] + cls.add_constructor([]) + ## object-ref-count.h: ns3::ObjectRefCount::ObjectRefCount(ns3::ObjectRefCount const & o) [copy constructor] + cls.add_constructor([param('ns3::ObjectRefCount< ns3::Object, ns3::ObjectBase > const &', 'o')]) + ## object-ref-count.h: int ns3::ObjectRefCount::GetReferenceCount() const [member function] + cls.add_method('GetReferenceCount', + 'int', + [], + is_const=True) + ## object-ref-count.h: void ns3::ObjectRefCount::Ref() const [member function] + cls.add_method('Ref', + 'void', + [], + is_const=True) + ## object-ref-count.h: void ns3::ObjectRefCount::Unref() const [member function] + cls.add_method('Unref', + 'void', + [], + is_const=True) + ## object-ref-count.h: int * ns3::ObjectRefCount::PeekCountPtr() const [member function] + cls.add_method('PeekCountPtr', + 'int *', + [], + is_const=True, visibility='protected') + ## object-ref-count.h: void ns3::ObjectRefCount::ShareCount(ns3::ObjectRefCount * other) [member function] + cls.add_method('ShareCount', + 'void', + [param('ns3::ObjectRefCount< ns3::Object, ns3::ObjectBase > *', 'other')], + visibility='protected') + ## object-ref-count.h: void ns3::ObjectRefCount::DoDelete() [member function] + cls.add_method('DoDelete', + 'void', + [], + is_pure_virtual=True, visibility='private', is_virtual=True) + return + def register_Ns3RandomVariable_methods(root_module, cls): cls.add_output_stream_operator() ## random-variable.h: ns3::RandomVariable::RandomVariable() [constructor] @@ -962,10 +1002,25 @@ def register_Ns3SystemWallClockMs_methods(root_module, cls): cls.add_constructor([param('ns3::SystemWallClockMs const &', 'arg0')]) ## system-wall-clock-ms.h: ns3::SystemWallClockMs::SystemWallClockMs() [constructor] cls.add_constructor([]) - ## system-wall-clock-ms.h: long long unsigned int ns3::SystemWallClockMs::End() [member function] + ## system-wall-clock-ms.h: int64_t ns3::SystemWallClockMs::End() [member function] cls.add_method('End', - 'long long unsigned int', + 'int64_t', []) + ## system-wall-clock-ms.h: int64_t ns3::SystemWallClockMs::GetElapsedReal() const [member function] + cls.add_method('GetElapsedReal', + 'int64_t', + [], + is_const=True) + ## system-wall-clock-ms.h: int64_t ns3::SystemWallClockMs::GetElapsedSystem() const [member function] + cls.add_method('GetElapsedSystem', + 'int64_t', + [], + is_const=True) + ## system-wall-clock-ms.h: int64_t ns3::SystemWallClockMs::GetElapsedUser() const [member function] + cls.add_method('GetElapsedUser', + 'int64_t', + [], + is_const=True) ## system-wall-clock-ms.h: void ns3::SystemWallClockMs::Start() [member function] cls.add_method('Start', 'void', @@ -1003,6 +1058,14 @@ def register_Ns3TestCase_methods(root_module, cls): cls.add_method('GetBaseDir', 'std::string', []) + ## test.h: void ns3::TestCase::SetTempDir(std::string dir) [member function] + cls.add_method('SetTempDir', + 'void', + [param('std::string', 'dir')]) + ## test.h: std::string ns3::TestCase::GetTempDir() [member function] + cls.add_method('GetTempDir', + 'std::string', + []) ## test.h: std::string ns3::TestCase::GetSourceDir(std::string file) [member function] cls.add_method('GetSourceDir', 'std::string', @@ -1162,6 +1225,14 @@ def register_Ns3TestSuite_methods(root_module, cls): cls.add_method('GetBaseDir', 'std::string', []) + ## test.h: void ns3::TestSuite::SetTempDir(std::string dir) [member function] + cls.add_method('SetTempDir', + 'void', + [param('std::string', 'dir')]) + ## test.h: std::string ns3::TestSuite::GetTempDir() [member function] + cls.add_method('GetTempDir', + 'std::string', + []) ## test.h: void ns3::TestSuite::SetStream(std::ofstream * ofs) [member function] cls.add_method('SetStream', 'void', @@ -2046,6 +2117,11 @@ def register_Ns3Object_methods(root_module, cls): 'void', [], visibility='protected', is_virtual=True) + ## object.h: void ns3::Object::DoDelete() [member function] + cls.add_method('DoDelete', + 'void', + [], + visibility='private', is_virtual=True) return def register_Ns3ObjectAggregateIterator_methods(root_module, cls): diff --git a/bindings/python/apidefs/gcc-ILP32/ns3_module_mobility.py b/bindings/python/apidefs/gcc-ILP32/ns3_module_mobility.py index b7556135d..37f4e096e 100644 --- a/bindings/python/apidefs/gcc-ILP32/ns3_module_mobility.py +++ b/bindings/python/apidefs/gcc-ILP32/ns3_module_mobility.py @@ -9,6 +9,8 @@ def register_types(module): module.add_class('Rectangle') ## rectangle.h: ns3::Rectangle::Side [enumeration] module.add_enum('Side', ['RIGHT', 'LEFT', 'TOP', 'BOTTOM'], outer_class=root_module['ns3::Rectangle']) + ## waypoint.h: ns3::Waypoint [class] + module.add_class('Waypoint') ## position-allocator.h: ns3::PositionAllocator [class] module.add_class('PositionAllocator', parent=root_module['ns3::Object']) ## position-allocator.h: ns3::RandomDiscPositionAllocator [class] @@ -19,6 +21,10 @@ def register_types(module): module.add_class('RectangleChecker', parent=root_module['ns3::AttributeChecker']) ## rectangle.h: ns3::RectangleValue [class] module.add_class('RectangleValue', parent=root_module['ns3::AttributeValue']) + ## waypoint.h: ns3::WaypointChecker [class] + module.add_class('WaypointChecker', parent=root_module['ns3::AttributeChecker']) + ## waypoint.h: ns3::WaypointValue [class] + module.add_class('WaypointValue', parent=root_module['ns3::AttributeValue']) ## position-allocator.h: ns3::GridPositionAllocator [class] module.add_class('GridPositionAllocator', parent=root_module['ns3::PositionAllocator']) ## position-allocator.h: ns3::GridPositionAllocator::LayoutType [enumeration] @@ -35,6 +41,8 @@ def register_types(module): module.add_enum('Mode', ['MODE_DISTANCE', 'MODE_TIME'], outer_class=root_module['ns3::RandomWalk2dMobilityModel']) ## random-waypoint-mobility-model.h: ns3::RandomWaypointMobilityModel [class] module.add_class('RandomWaypointMobilityModel', parent=root_module['ns3::MobilityModel']) + ## waypoint-mobility-model.h: ns3::WaypointMobilityModel [class] + module.add_class('WaypointMobilityModel', parent=root_module['ns3::MobilityModel']) ## constant-acceleration-mobility-model.h: ns3::ConstantAccelerationMobilityModel [class] module.add_class('ConstantAccelerationMobilityModel', parent=root_module['ns3::MobilityModel']) ## constant-position-mobility-model.h: ns3::ConstantPositionMobilityModel [class] @@ -117,17 +125,21 @@ def register_types_ns3_olsr(module): def register_methods(root_module): register_Ns3ConstantVelocityHelper_methods(root_module, root_module['ns3::ConstantVelocityHelper']) register_Ns3Rectangle_methods(root_module, root_module['ns3::Rectangle']) + register_Ns3Waypoint_methods(root_module, root_module['ns3::Waypoint']) register_Ns3PositionAllocator_methods(root_module, root_module['ns3::PositionAllocator']) register_Ns3RandomDiscPositionAllocator_methods(root_module, root_module['ns3::RandomDiscPositionAllocator']) register_Ns3RandomRectanglePositionAllocator_methods(root_module, root_module['ns3::RandomRectanglePositionAllocator']) register_Ns3RectangleChecker_methods(root_module, root_module['ns3::RectangleChecker']) register_Ns3RectangleValue_methods(root_module, root_module['ns3::RectangleValue']) + register_Ns3WaypointChecker_methods(root_module, root_module['ns3::WaypointChecker']) + register_Ns3WaypointValue_methods(root_module, root_module['ns3::WaypointValue']) register_Ns3GridPositionAllocator_methods(root_module, root_module['ns3::GridPositionAllocator']) register_Ns3ListPositionAllocator_methods(root_module, root_module['ns3::ListPositionAllocator']) register_Ns3MobilityModel_methods(root_module, root_module['ns3::MobilityModel']) register_Ns3RandomDirection2dMobilityModel_methods(root_module, root_module['ns3::RandomDirection2dMobilityModel']) register_Ns3RandomWalk2dMobilityModel_methods(root_module, root_module['ns3::RandomWalk2dMobilityModel']) register_Ns3RandomWaypointMobilityModel_methods(root_module, root_module['ns3::RandomWaypointMobilityModel']) + register_Ns3WaypointMobilityModel_methods(root_module, root_module['ns3::WaypointMobilityModel']) register_Ns3ConstantAccelerationMobilityModel_methods(root_module, root_module['ns3::ConstantAccelerationMobilityModel']) register_Ns3ConstantPositionMobilityModel_methods(root_module, root_module['ns3::ConstantPositionMobilityModel']) register_Ns3ConstantVelocityMobilityModel_methods(root_module, root_module['ns3::ConstantVelocityMobilityModel']) @@ -214,6 +226,20 @@ def register_Ns3Rectangle_methods(root_module, cls): cls.add_instance_attribute('yMin', 'double', is_const=False) return +def register_Ns3Waypoint_methods(root_module, cls): + cls.add_output_stream_operator() + ## waypoint.h: ns3::Waypoint::Waypoint(ns3::Waypoint const & arg0) [copy constructor] + cls.add_constructor([param('ns3::Waypoint const &', 'arg0')]) + ## waypoint.h: ns3::Waypoint::Waypoint(ns3::Time const & waypointTime, ns3::Vector const & waypointPosition) [constructor] + cls.add_constructor([param('ns3::Time const &', 'waypointTime'), param('ns3::Vector const &', 'waypointPosition')]) + ## waypoint.h: ns3::Waypoint::Waypoint() [constructor] + cls.add_constructor([]) + ## waypoint.h: ns3::Waypoint::position [variable] + cls.add_instance_attribute('position', 'ns3::Vector', is_const=False) + ## waypoint.h: ns3::Waypoint::time [variable] + cls.add_instance_attribute('time', 'ns3::Time', is_const=False) + return + def register_Ns3PositionAllocator_methods(root_module, cls): ## position-allocator.h: ns3::PositionAllocator::PositionAllocator(ns3::PositionAllocator const & arg0) [copy constructor] cls.add_constructor([param('ns3::PositionAllocator const &', 'arg0')]) @@ -329,6 +355,46 @@ def register_Ns3RectangleValue_methods(root_module, cls): [param('ns3::Rectangle const &', 'value')]) return +def register_Ns3WaypointChecker_methods(root_module, cls): + ## waypoint.h: ns3::WaypointChecker::WaypointChecker() [constructor] + cls.add_constructor([]) + ## waypoint.h: ns3::WaypointChecker::WaypointChecker(ns3::WaypointChecker const & arg0) [copy constructor] + cls.add_constructor([param('ns3::WaypointChecker const &', 'arg0')]) + return + +def register_Ns3WaypointValue_methods(root_module, cls): + ## waypoint.h: ns3::WaypointValue::WaypointValue() [constructor] + cls.add_constructor([]) + ## waypoint.h: ns3::WaypointValue::WaypointValue(ns3::WaypointValue const & arg0) [copy constructor] + cls.add_constructor([param('ns3::WaypointValue const &', 'arg0')]) + ## waypoint.h: ns3::WaypointValue::WaypointValue(ns3::Waypoint const & value) [constructor] + cls.add_constructor([param('ns3::Waypoint const &', 'value')]) + ## waypoint.h: ns3::Ptr ns3::WaypointValue::Copy() const [member function] + cls.add_method('Copy', + 'ns3::Ptr< ns3::AttributeValue >', + [], + is_const=True, is_virtual=True) + ## waypoint.h: bool ns3::WaypointValue::DeserializeFromString(std::string value, ns3::Ptr checker) [member function] + cls.add_method('DeserializeFromString', + 'bool', + [param('std::string', 'value'), param('ns3::Ptr< ns3::AttributeChecker const >', 'checker')], + is_virtual=True) + ## waypoint.h: ns3::Waypoint ns3::WaypointValue::Get() const [member function] + cls.add_method('Get', + 'ns3::Waypoint', + [], + is_const=True) + ## waypoint.h: std::string ns3::WaypointValue::SerializeToString(ns3::Ptr checker) const [member function] + cls.add_method('SerializeToString', + 'std::string', + [param('ns3::Ptr< ns3::AttributeChecker const >', 'checker')], + is_const=True, is_virtual=True) + ## waypoint.h: void ns3::WaypointValue::Set(ns3::Waypoint const & value) [member function] + cls.add_method('Set', + 'void', + [param('ns3::Waypoint const &', 'value')]) + return + def register_Ns3GridPositionAllocator_methods(root_module, cls): ## position-allocator.h: ns3::GridPositionAllocator::GridPositionAllocator(ns3::GridPositionAllocator const & arg0) [copy constructor] cls.add_constructor([param('ns3::GridPositionAllocator const &', 'arg0')]) @@ -563,6 +629,56 @@ def register_Ns3RandomWaypointMobilityModel_methods(root_module, cls): visibility='private', is_virtual=True) return +def register_Ns3WaypointMobilityModel_methods(root_module, cls): + ## waypoint-mobility-model.h: ns3::WaypointMobilityModel::WaypointMobilityModel(ns3::WaypointMobilityModel const & arg0) [copy constructor] + cls.add_constructor([param('ns3::WaypointMobilityModel const &', 'arg0')]) + ## waypoint-mobility-model.h: ns3::WaypointMobilityModel::WaypointMobilityModel() [constructor] + cls.add_constructor([]) + ## waypoint-mobility-model.h: void ns3::WaypointMobilityModel::AddWaypoint(ns3::Waypoint const & waypoint) [member function] + cls.add_method('AddWaypoint', + 'void', + [param('ns3::Waypoint const &', 'waypoint')]) + ## waypoint-mobility-model.h: void ns3::WaypointMobilityModel::EndMobility() [member function] + cls.add_method('EndMobility', + 'void', + []) + ## waypoint-mobility-model.h: ns3::Waypoint ns3::WaypointMobilityModel::GetNextWaypoint() const [member function] + cls.add_method('GetNextWaypoint', + 'ns3::Waypoint', + [], + is_const=True) + ## waypoint-mobility-model.h: static ns3::TypeId ns3::WaypointMobilityModel::GetTypeId() [member function] + cls.add_method('GetTypeId', + 'ns3::TypeId', + [], + is_static=True) + ## waypoint-mobility-model.h: uint32_t ns3::WaypointMobilityModel::WaypointsLeft() const [member function] + cls.add_method('WaypointsLeft', + 'uint32_t', + [], + is_const=True) + ## waypoint-mobility-model.h: void ns3::WaypointMobilityModel::DoDispose() [member function] + cls.add_method('DoDispose', + 'void', + [], + visibility='private', is_virtual=True) + ## waypoint-mobility-model.h: ns3::Vector ns3::WaypointMobilityModel::DoGetPosition() const [member function] + cls.add_method('DoGetPosition', + 'ns3::Vector', + [], + is_const=True, visibility='private', is_virtual=True) + ## waypoint-mobility-model.h: ns3::Vector ns3::WaypointMobilityModel::DoGetVelocity() const [member function] + cls.add_method('DoGetVelocity', + 'ns3::Vector', + [], + is_const=True, visibility='private', is_virtual=True) + ## waypoint-mobility-model.h: void ns3::WaypointMobilityModel::DoSetPosition(ns3::Vector const & position) [member function] + cls.add_method('DoSetPosition', + 'void', + [param('ns3::Vector const &', 'position')], + visibility='private', is_virtual=True) + return + def register_Ns3ConstantAccelerationMobilityModel_methods(root_module, cls): ## constant-acceleration-mobility-model.h: ns3::ConstantAccelerationMobilityModel::ConstantAccelerationMobilityModel(ns3::ConstantAccelerationMobilityModel const & arg0) [copy constructor] cls.add_constructor([param('ns3::ConstantAccelerationMobilityModel const &', 'arg0')]) @@ -703,6 +819,10 @@ def register_functions(root_module): module.add_function('MakeRectangleChecker', 'ns3::Ptr< ns3::AttributeChecker const >', []) + ## waypoint.h: extern ns3::Ptr ns3::MakeWaypointChecker() [free function] + module.add_function('MakeWaypointChecker', + 'ns3::Ptr< ns3::AttributeChecker const >', + []) register_functions_ns3_Config(module.get_submodule('Config'), root_module) register_functions_ns3_TimeStepPrecision(module.get_submodule('TimeStepPrecision'), root_module) register_functions_ns3_addressUtils(module.get_submodule('addressUtils'), root_module) diff --git a/bindings/python/apidefs/gcc-ILP32/ns3_module_point_to_point.py b/bindings/python/apidefs/gcc-ILP32/ns3_module_point_to_point.py index 817a3baac..72d3e567e 100644 --- a/bindings/python/apidefs/gcc-ILP32/ns3_module_point_to_point.py +++ b/bindings/python/apidefs/gcc-ILP32/ns3_module_point_to_point.py @@ -101,6 +101,10 @@ def register_Ns3PppHeader_methods(root_module, cls): 'ns3::TypeId', [], is_const=True, is_virtual=True) + ## ppp-header.h: uint16_t ns3::PppHeader::GetProtocol() [member function] + cls.add_method('GetProtocol', + 'uint16_t', + []) ## ppp-header.h: uint32_t ns3::PppHeader::GetSerializedSize() const [member function] cls.add_method('GetSerializedSize', 'uint32_t', @@ -121,6 +125,10 @@ def register_Ns3PppHeader_methods(root_module, cls): 'void', [param('ns3::Buffer::Iterator', 'start')], is_const=True, is_virtual=True) + ## ppp-header.h: void ns3::PppHeader::SetProtocol(uint16_t protocol) [member function] + cls.add_method('SetProtocol', + 'void', + [param('uint16_t', 'protocol')]) return def register_Ns3PointToPointChannel_methods(root_module, cls): diff --git a/bindings/python/apidefs/gcc-ILP32/ns3_module_stats.py b/bindings/python/apidefs/gcc-ILP32/ns3_module_stats.py index 610739ccc..bfd42eb05 100644 --- a/bindings/python/apidefs/gcc-ILP32/ns3_module_stats.py +++ b/bindings/python/apidefs/gcc-ILP32/ns3_module_stats.py @@ -5,18 +5,16 @@ def register_types(module): ## data-output-interface.h: ns3::DataOutputCallback [class] module.add_class('DataOutputCallback', allow_subclassing=True) + ## data-calculator.h: ns3::StatisticalSummary [class] + module.add_class('StatisticalSummary', allow_subclassing=True) ## data-calculator.h: ns3::DataCalculator [class] module.add_class('DataCalculator', parent=root_module['ns3::Object']) ## data-collector.h: ns3::DataCollector [class] module.add_class('DataCollector', parent=root_module['ns3::Object']) ## data-output-interface.h: ns3::DataOutputInterface [class] module.add_class('DataOutputInterface', parent=root_module['ns3::Object']) - ## basic-data-calculators.h: ns3::MinMaxAvgTotalCalculator [class] - module.add_class('MinMaxAvgTotalCalculator', template_parameters=['unsigned int'], parent=root_module['ns3::DataCalculator']) ## omnet-data-output.h: ns3::OmnetDataOutput [class] module.add_class('OmnetDataOutput', parent=root_module['ns3::DataOutputInterface']) - ## packet-data-calculators.h: ns3::PacketSizeMinMaxAvgTotalCalculator [class] - module.add_class('PacketSizeMinMaxAvgTotalCalculator', parent=root_module['ns3::MinMaxAvgTotalCalculator< unsigned int >']) ## sqlite-data-output.h: ns3::SqliteDataOutput [class] module.add_class('SqliteDataOutput', parent=root_module['ns3::DataOutputInterface']) ## time-data-calculators.h: ns3::TimeMinMaxAvgTotalCalculator [class] @@ -104,12 +102,11 @@ def register_types_ns3_olsr(module): def register_methods(root_module): register_Ns3DataOutputCallback_methods(root_module, root_module['ns3::DataOutputCallback']) + register_Ns3StatisticalSummary_methods(root_module, root_module['ns3::StatisticalSummary']) register_Ns3DataCalculator_methods(root_module, root_module['ns3::DataCalculator']) register_Ns3DataCollector_methods(root_module, root_module['ns3::DataCollector']) register_Ns3DataOutputInterface_methods(root_module, root_module['ns3::DataOutputInterface']) - register_Ns3MinMaxAvgTotalCalculator__Unsigned_int_methods(root_module, root_module['ns3::MinMaxAvgTotalCalculator< unsigned int >']) register_Ns3OmnetDataOutput_methods(root_module, root_module['ns3::OmnetDataOutput']) - register_Ns3PacketSizeMinMaxAvgTotalCalculator_methods(root_module, root_module['ns3::PacketSizeMinMaxAvgTotalCalculator']) register_Ns3SqliteDataOutput_methods(root_module, root_module['ns3::SqliteDataOutput']) register_Ns3TimeMinMaxAvgTotalCalculator_methods(root_module, root_module['ns3::TimeMinMaxAvgTotalCalculator']) register_Ns3CounterCalculator__Unsigned_int_methods(root_module, root_module['ns3::CounterCalculator< unsigned int >']) @@ -146,6 +143,58 @@ def register_Ns3DataOutputCallback_methods(root_module, cls): 'void', [param('std::string', 'key'), param('std::string', 'variable'), param('ns3::Time', 'val')], is_pure_virtual=True, is_virtual=True) + ## data-output-interface.h: void ns3::DataOutputCallback::OutputStatistic(std::string key, std::string variable, ns3::StatisticalSummary const * statSum) [member function] + cls.add_method('OutputStatistic', + 'void', + [param('std::string', 'key'), param('std::string', 'variable'), param('ns3::StatisticalSummary const *', 'statSum')], + is_pure_virtual=True, is_virtual=True) + return + +def register_Ns3StatisticalSummary_methods(root_module, cls): + ## data-calculator.h: ns3::StatisticalSummary::StatisticalSummary() [constructor] + cls.add_constructor([]) + ## data-calculator.h: ns3::StatisticalSummary::StatisticalSummary(ns3::StatisticalSummary const & arg0) [copy constructor] + cls.add_constructor([param('ns3::StatisticalSummary const &', 'arg0')]) + ## data-calculator.h: long int ns3::StatisticalSummary::getCount() const [member function] + cls.add_method('getCount', + 'long int', + [], + is_pure_virtual=True, is_const=True, is_virtual=True) + ## data-calculator.h: double ns3::StatisticalSummary::getMax() const [member function] + cls.add_method('getMax', + 'double', + [], + is_pure_virtual=True, is_const=True, is_virtual=True) + ## data-calculator.h: double ns3::StatisticalSummary::getMean() const [member function] + cls.add_method('getMean', + 'double', + [], + is_pure_virtual=True, is_const=True, is_virtual=True) + ## data-calculator.h: double ns3::StatisticalSummary::getMin() const [member function] + cls.add_method('getMin', + 'double', + [], + is_pure_virtual=True, is_const=True, is_virtual=True) + ## data-calculator.h: double ns3::StatisticalSummary::getSqrSum() const [member function] + cls.add_method('getSqrSum', + 'double', + [], + is_pure_virtual=True, is_const=True, is_virtual=True) + ## data-calculator.h: double ns3::StatisticalSummary::getStddev() const [member function] + cls.add_method('getStddev', + 'double', + [], + is_pure_virtual=True, is_const=True, is_virtual=True) + ## data-calculator.h: double ns3::StatisticalSummary::getSum() const [member function] + cls.add_method('getSum', + 'double', + [], + is_pure_virtual=True, is_const=True, is_virtual=True) + ## data-calculator.h: double ns3::StatisticalSummary::getVariance() const [member function] + cls.add_method('getVariance', + 'double', + [], + is_pure_virtual=True, is_const=True, is_virtual=True) return def register_Ns3DataCalculator_methods(root_module, cls): @@ -161,6 +210,11 @@ def register_Ns3DataCalculator_methods(root_module, cls): cls.add_method('Enable', 'void', []) + ## data-calculator.h: std::string ns3::DataCalculator::GetContext() const [member function] + cls.add_method('GetContext', + 'std::string', + [], + is_const=True) ## data-calculator.h: bool ns3::DataCalculator::GetEnabled() const [member function] cls.add_method('GetEnabled', 'bool', @@ -176,6 +230,10 @@ def register_Ns3DataCalculator_methods(root_module, cls): 'void', [param('ns3::DataOutputCallback &', 'callback')], is_pure_virtual=True, is_const=True, is_virtual=True) + ## data-calculator.h: void ns3::DataCalculator::SetContext(std::string const context) [member function] + cls.add_method('SetContext', + 'void', + [param('std::string const', 'context')]) ## data-calculator.h: void ns3::DataCalculator::SetKey(std::string const key) [member function] cls.add_method('SetKey', 'void', @@ -296,27 +354,6 @@ def register_Ns3DataOutputInterface_methods(root_module, cls): visibility='protected', is_virtual=True) return -def register_Ns3MinMaxAvgTotalCalculator__Unsigned_int_methods(root_module, cls): - ## basic-data-calculators.h: ns3::MinMaxAvgTotalCalculator::MinMaxAvgTotalCalculator(ns3::MinMaxAvgTotalCalculator const & arg0) [copy constructor] - cls.add_constructor([param('ns3::MinMaxAvgTotalCalculator< unsigned int > const &', 'arg0')]) - ## basic-data-calculators.h: ns3::MinMaxAvgTotalCalculator::MinMaxAvgTotalCalculator() [constructor] - cls.add_constructor([]) - ## basic-data-calculators.h: void ns3::MinMaxAvgTotalCalculator::Output(ns3::DataOutputCallback & callback) const [member function] - cls.add_method('Output', - 'void', - [param('ns3::DataOutputCallback &', 'callback')], - is_const=True, is_virtual=True) - ## basic-data-calculators.h: void ns3::MinMaxAvgTotalCalculator::Update(unsigned int const i) [member function] - cls.add_method('Update', - 'void', - [param('unsigned int const', 'i')]) - ## basic-data-calculators.h: void ns3::MinMaxAvgTotalCalculator::DoDispose() [member function] - cls.add_method('DoDispose', - 'void', - [], - visibility='protected', is_virtual=True) - return - def register_Ns3OmnetDataOutput_methods(root_module, cls): ## omnet-data-output.h: ns3::OmnetDataOutput::OmnetDataOutput(ns3::OmnetDataOutput const & arg0) [copy constructor] cls.add_constructor([param('ns3::OmnetDataOutput const &', 'arg0')]) @@ -334,26 +371,6 @@ def register_Ns3OmnetDataOutput_methods(root_module, cls): visibility='protected', is_virtual=True) return -def register_Ns3PacketSizeMinMaxAvgTotalCalculator_methods(root_module, cls): - ## packet-data-calculators.h: ns3::PacketSizeMinMaxAvgTotalCalculator::PacketSizeMinMaxAvgTotalCalculator(ns3::PacketSizeMinMaxAvgTotalCalculator const & arg0) [copy constructor] - cls.add_constructor([param('ns3::PacketSizeMinMaxAvgTotalCalculator const &', 'arg0')]) - ## packet-data-calculators.h: ns3::PacketSizeMinMaxAvgTotalCalculator::PacketSizeMinMaxAvgTotalCalculator() [constructor] - cls.add_constructor([]) - ## packet-data-calculators.h: void ns3::PacketSizeMinMaxAvgTotalCalculator::FrameUpdate(std::string path, ns3::Ptr packet, ns3::Mac48Address realto) [member function] - cls.add_method('FrameUpdate', - 'void', - [param('std::string', 'path'), param('ns3::Ptr< ns3::Packet const >', 'packet'), param('ns3::Mac48Address', 'realto')]) - ## packet-data-calculators.h: void ns3::PacketSizeMinMaxAvgTotalCalculator::PacketUpdate(std::string path, ns3::Ptr packet) [member function] - cls.add_method('PacketUpdate', - 'void', - [param('std::string', 'path'), param('ns3::Ptr< ns3::Packet const >', 'packet')]) - ## packet-data-calculators.h: void ns3::PacketSizeMinMaxAvgTotalCalculator::DoDispose() [member function] - cls.add_method('DoDispose', - 'void', - [], - visibility='protected', is_virtual=True) - return - def register_Ns3SqliteDataOutput_methods(root_module, cls): ## sqlite-data-output.h: ns3::SqliteDataOutput::SqliteDataOutput(ns3::SqliteDataOutput const & arg0) [copy constructor] cls.add_constructor([param('ns3::SqliteDataOutput const &', 'arg0')]) @@ -444,6 +461,10 @@ def register_Ns3PacketCounterCalculator_methods(root_module, cls): def register_functions(root_module): module = root_module + ## data-calculator.h: bool ns3::isNaN(double x) [free function] + module.add_function('isNaN', + 'bool', + [param('double', 'x')]) register_functions_ns3_Config(module.get_submodule('Config'), root_module) register_functions_ns3_TimeStepPrecision(module.get_submodule('TimeStepPrecision'), root_module) register_functions_ns3_addressUtils(module.get_submodule('addressUtils'), root_module) diff --git a/bindings/python/apidefs/gcc-ILP32/ns3modulegen_generated.py b/bindings/python/apidefs/gcc-ILP32/ns3modulegen_generated.py index f016d9880..62dac471f 100644 --- a/bindings/python/apidefs/gcc-ILP32/ns3modulegen_generated.py +++ b/bindings/python/apidefs/gcc-ILP32/ns3modulegen_generated.py @@ -17,29 +17,29 @@ import ns3_module_simulator import ns3_module_test import ns3_module_mobility import ns3_module_common -import ns3_module_node import ns3_module_contrib +import ns3_module_node +import ns3_module_tap_bridge +import ns3_module_v4ping +import ns3_module_static_routing +import ns3_module_packet_sink +import ns3_module_stats +import ns3_module_onoff import ns3_module_point_to_point import ns3_module_internet_stack -import ns3_module_tap_bridge import ns3_module_csma -import ns3_module_wifi -import ns3_module_static_routing -import ns3_module_v4ping -import ns3_module_virtual_net_device -import ns3_module_packet_sink -import ns3_module_global_routing -import ns3_module_stats import ns3_module_list_routing +import ns3_module_virtual_net_device +import ns3_module_wifi import ns3_module_emu import ns3_module_bridge -import ns3_module_onoff +import ns3_module_global_routing import ns3_module_udp_echo -import ns3_module_ping6 import ns3_module_nix_vector_routing import ns3_module_olsr -import ns3_module_flow_monitor import ns3_module_radvd +import ns3_module_ping6 +import ns3_module_flow_monitor import ns3_module_mesh import ns3_module_helper import ns3_module_dot11s @@ -107,17 +107,6 @@ def register_types(module): ns3_module_common__local.register_types(module) root_module.end_section('ns3_module_common') - root_module.begin_section('ns3_module_node') - ns3_module_node.register_types(module) - - try: - import ns3_module_node__local - except ImportError: - pass - else: - ns3_module_node__local.register_types(module) - - root_module.end_section('ns3_module_node') root_module.begin_section('ns3_module_contrib') ns3_module_contrib.register_types(module) @@ -129,6 +118,83 @@ def register_types(module): ns3_module_contrib__local.register_types(module) root_module.end_section('ns3_module_contrib') + root_module.begin_section('ns3_module_node') + ns3_module_node.register_types(module) + + try: + import ns3_module_node__local + except ImportError: + pass + else: + ns3_module_node__local.register_types(module) + + root_module.end_section('ns3_module_node') + root_module.begin_section('ns3_module_tap_bridge') + ns3_module_tap_bridge.register_types(module) + + try: + import ns3_module_tap_bridge__local + except ImportError: + pass + else: + ns3_module_tap_bridge__local.register_types(module) + + root_module.end_section('ns3_module_tap_bridge') + root_module.begin_section('ns3_module_v4ping') + ns3_module_v4ping.register_types(module) + + try: + import ns3_module_v4ping__local + except ImportError: + pass + else: + ns3_module_v4ping__local.register_types(module) + + root_module.end_section('ns3_module_v4ping') + root_module.begin_section('ns3_module_static_routing') + ns3_module_static_routing.register_types(module) + + try: + import ns3_module_static_routing__local + except ImportError: + pass + else: + ns3_module_static_routing__local.register_types(module) + + root_module.end_section('ns3_module_static_routing') + root_module.begin_section('ns3_module_packet_sink') + ns3_module_packet_sink.register_types(module) + + try: + import ns3_module_packet_sink__local + except ImportError: + pass + else: + ns3_module_packet_sink__local.register_types(module) + + root_module.end_section('ns3_module_packet_sink') + root_module.begin_section('ns3_module_stats') + ns3_module_stats.register_types(module) + + try: + import ns3_module_stats__local + except ImportError: + pass + else: + ns3_module_stats__local.register_types(module) + + root_module.end_section('ns3_module_stats') + root_module.begin_section('ns3_module_onoff') + ns3_module_onoff.register_types(module) + + try: + import ns3_module_onoff__local + except ImportError: + pass + else: + ns3_module_onoff__local.register_types(module) + + root_module.end_section('ns3_module_onoff') root_module.begin_section('ns3_module_point_to_point') ns3_module_point_to_point.register_types(module) @@ -151,17 +217,6 @@ def register_types(module): ns3_module_internet_stack__local.register_types(module) root_module.end_section('ns3_module_internet_stack') - root_module.begin_section('ns3_module_tap_bridge') - ns3_module_tap_bridge.register_types(module) - - try: - import ns3_module_tap_bridge__local - except ImportError: - pass - else: - ns3_module_tap_bridge__local.register_types(module) - - root_module.end_section('ns3_module_tap_bridge') root_module.begin_section('ns3_module_csma') ns3_module_csma.register_types(module) @@ -173,83 +228,6 @@ def register_types(module): ns3_module_csma__local.register_types(module) root_module.end_section('ns3_module_csma') - root_module.begin_section('ns3_module_wifi') - ns3_module_wifi.register_types(module) - - try: - import ns3_module_wifi__local - except ImportError: - pass - else: - ns3_module_wifi__local.register_types(module) - - root_module.end_section('ns3_module_wifi') - root_module.begin_section('ns3_module_static_routing') - ns3_module_static_routing.register_types(module) - - try: - import ns3_module_static_routing__local - except ImportError: - pass - else: - ns3_module_static_routing__local.register_types(module) - - root_module.end_section('ns3_module_static_routing') - root_module.begin_section('ns3_module_v4ping') - ns3_module_v4ping.register_types(module) - - try: - import ns3_module_v4ping__local - except ImportError: - pass - else: - ns3_module_v4ping__local.register_types(module) - - root_module.end_section('ns3_module_v4ping') - root_module.begin_section('ns3_module_virtual_net_device') - ns3_module_virtual_net_device.register_types(module) - - try: - import ns3_module_virtual_net_device__local - except ImportError: - pass - else: - ns3_module_virtual_net_device__local.register_types(module) - - root_module.end_section('ns3_module_virtual_net_device') - root_module.begin_section('ns3_module_packet_sink') - ns3_module_packet_sink.register_types(module) - - try: - import ns3_module_packet_sink__local - except ImportError: - pass - else: - ns3_module_packet_sink__local.register_types(module) - - root_module.end_section('ns3_module_packet_sink') - root_module.begin_section('ns3_module_global_routing') - ns3_module_global_routing.register_types(module) - - try: - import ns3_module_global_routing__local - except ImportError: - pass - else: - ns3_module_global_routing__local.register_types(module) - - root_module.end_section('ns3_module_global_routing') - root_module.begin_section('ns3_module_stats') - ns3_module_stats.register_types(module) - - try: - import ns3_module_stats__local - except ImportError: - pass - else: - ns3_module_stats__local.register_types(module) - - root_module.end_section('ns3_module_stats') root_module.begin_section('ns3_module_list_routing') ns3_module_list_routing.register_types(module) @@ -261,6 +239,28 @@ def register_types(module): ns3_module_list_routing__local.register_types(module) root_module.end_section('ns3_module_list_routing') + root_module.begin_section('ns3_module_virtual_net_device') + ns3_module_virtual_net_device.register_types(module) + + try: + import ns3_module_virtual_net_device__local + except ImportError: + pass + else: + ns3_module_virtual_net_device__local.register_types(module) + + root_module.end_section('ns3_module_virtual_net_device') + root_module.begin_section('ns3_module_wifi') + ns3_module_wifi.register_types(module) + + try: + import ns3_module_wifi__local + except ImportError: + pass + else: + ns3_module_wifi__local.register_types(module) + + root_module.end_section('ns3_module_wifi') root_module.begin_section('ns3_module_emu') ns3_module_emu.register_types(module) @@ -283,17 +283,17 @@ def register_types(module): ns3_module_bridge__local.register_types(module) root_module.end_section('ns3_module_bridge') - root_module.begin_section('ns3_module_onoff') - ns3_module_onoff.register_types(module) + root_module.begin_section('ns3_module_global_routing') + ns3_module_global_routing.register_types(module) try: - import ns3_module_onoff__local + import ns3_module_global_routing__local except ImportError: pass else: - ns3_module_onoff__local.register_types(module) + ns3_module_global_routing__local.register_types(module) - root_module.end_section('ns3_module_onoff') + root_module.end_section('ns3_module_global_routing') root_module.begin_section('ns3_module_udp_echo') ns3_module_udp_echo.register_types(module) @@ -305,17 +305,6 @@ def register_types(module): ns3_module_udp_echo__local.register_types(module) root_module.end_section('ns3_module_udp_echo') - root_module.begin_section('ns3_module_ping6') - ns3_module_ping6.register_types(module) - - try: - import ns3_module_ping6__local - except ImportError: - pass - else: - ns3_module_ping6__local.register_types(module) - - root_module.end_section('ns3_module_ping6') root_module.begin_section('ns3_module_nix_vector_routing') ns3_module_nix_vector_routing.register_types(module) @@ -338,17 +327,6 @@ def register_types(module): ns3_module_olsr__local.register_types(module) root_module.end_section('ns3_module_olsr') - root_module.begin_section('ns3_module_flow_monitor') - ns3_module_flow_monitor.register_types(module) - - try: - import ns3_module_flow_monitor__local - except ImportError: - pass - else: - ns3_module_flow_monitor__local.register_types(module) - - root_module.end_section('ns3_module_flow_monitor') root_module.begin_section('ns3_module_radvd') ns3_module_radvd.register_types(module) @@ -360,6 +338,28 @@ def register_types(module): ns3_module_radvd__local.register_types(module) root_module.end_section('ns3_module_radvd') + root_module.begin_section('ns3_module_ping6') + ns3_module_ping6.register_types(module) + + try: + import ns3_module_ping6__local + except ImportError: + pass + else: + ns3_module_ping6__local.register_types(module) + + root_module.end_section('ns3_module_ping6') + root_module.begin_section('ns3_module_flow_monitor') + ns3_module_flow_monitor.register_types(module) + + try: + import ns3_module_flow_monitor__local + except ImportError: + pass + else: + ns3_module_flow_monitor__local.register_types(module) + + root_module.end_section('ns3_module_flow_monitor') root_module.begin_section('ns3_module_mesh') ns3_module_mesh.register_types(module) @@ -549,17 +549,6 @@ def register_methods(root_module): ns3_module_common__local.register_methods(root_module) root_module.end_section('ns3_module_common') - root_module.begin_section('ns3_module_node') - ns3_module_node.register_methods(root_module) - - try: - import ns3_module_node__local - except ImportError: - pass - else: - ns3_module_node__local.register_methods(root_module) - - root_module.end_section('ns3_module_node') root_module.begin_section('ns3_module_contrib') ns3_module_contrib.register_methods(root_module) @@ -571,6 +560,83 @@ def register_methods(root_module): ns3_module_contrib__local.register_methods(root_module) root_module.end_section('ns3_module_contrib') + root_module.begin_section('ns3_module_node') + ns3_module_node.register_methods(root_module) + + try: + import ns3_module_node__local + except ImportError: + pass + else: + ns3_module_node__local.register_methods(root_module) + + root_module.end_section('ns3_module_node') + root_module.begin_section('ns3_module_tap_bridge') + ns3_module_tap_bridge.register_methods(root_module) + + try: + import ns3_module_tap_bridge__local + except ImportError: + pass + else: + ns3_module_tap_bridge__local.register_methods(root_module) + + root_module.end_section('ns3_module_tap_bridge') + root_module.begin_section('ns3_module_v4ping') + ns3_module_v4ping.register_methods(root_module) + + try: + import ns3_module_v4ping__local + except ImportError: + pass + else: + ns3_module_v4ping__local.register_methods(root_module) + + root_module.end_section('ns3_module_v4ping') + root_module.begin_section('ns3_module_static_routing') + ns3_module_static_routing.register_methods(root_module) + + try: + import ns3_module_static_routing__local + except ImportError: + pass + else: + ns3_module_static_routing__local.register_methods(root_module) + + root_module.end_section('ns3_module_static_routing') + root_module.begin_section('ns3_module_packet_sink') + ns3_module_packet_sink.register_methods(root_module) + + try: + import ns3_module_packet_sink__local + except ImportError: + pass + else: + ns3_module_packet_sink__local.register_methods(root_module) + + root_module.end_section('ns3_module_packet_sink') + root_module.begin_section('ns3_module_stats') + ns3_module_stats.register_methods(root_module) + + try: + import ns3_module_stats__local + except ImportError: + pass + else: + ns3_module_stats__local.register_methods(root_module) + + root_module.end_section('ns3_module_stats') + root_module.begin_section('ns3_module_onoff') + ns3_module_onoff.register_methods(root_module) + + try: + import ns3_module_onoff__local + except ImportError: + pass + else: + ns3_module_onoff__local.register_methods(root_module) + + root_module.end_section('ns3_module_onoff') root_module.begin_section('ns3_module_point_to_point') ns3_module_point_to_point.register_methods(root_module) @@ -593,17 +659,6 @@ def register_methods(root_module): ns3_module_internet_stack__local.register_methods(root_module) root_module.end_section('ns3_module_internet_stack') - root_module.begin_section('ns3_module_tap_bridge') - ns3_module_tap_bridge.register_methods(root_module) - - try: - import ns3_module_tap_bridge__local - except ImportError: - pass - else: - ns3_module_tap_bridge__local.register_methods(root_module) - - root_module.end_section('ns3_module_tap_bridge') root_module.begin_section('ns3_module_csma') ns3_module_csma.register_methods(root_module) @@ -615,83 +670,6 @@ def register_methods(root_module): ns3_module_csma__local.register_methods(root_module) root_module.end_section('ns3_module_csma') - root_module.begin_section('ns3_module_wifi') - ns3_module_wifi.register_methods(root_module) - - try: - import ns3_module_wifi__local - except ImportError: - pass - else: - ns3_module_wifi__local.register_methods(root_module) - - root_module.end_section('ns3_module_wifi') - root_module.begin_section('ns3_module_static_routing') - ns3_module_static_routing.register_methods(root_module) - - try: - import ns3_module_static_routing__local - except ImportError: - pass - else: - ns3_module_static_routing__local.register_methods(root_module) - - root_module.end_section('ns3_module_static_routing') - root_module.begin_section('ns3_module_v4ping') - ns3_module_v4ping.register_methods(root_module) - - try: - import ns3_module_v4ping__local - except ImportError: - pass - else: - ns3_module_v4ping__local.register_methods(root_module) - - root_module.end_section('ns3_module_v4ping') - root_module.begin_section('ns3_module_virtual_net_device') - ns3_module_virtual_net_device.register_methods(root_module) - - try: - import ns3_module_virtual_net_device__local - except ImportError: - pass - else: - ns3_module_virtual_net_device__local.register_methods(root_module) - - root_module.end_section('ns3_module_virtual_net_device') - root_module.begin_section('ns3_module_packet_sink') - ns3_module_packet_sink.register_methods(root_module) - - try: - import ns3_module_packet_sink__local - except ImportError: - pass - else: - ns3_module_packet_sink__local.register_methods(root_module) - - root_module.end_section('ns3_module_packet_sink') - root_module.begin_section('ns3_module_global_routing') - ns3_module_global_routing.register_methods(root_module) - - try: - import ns3_module_global_routing__local - except ImportError: - pass - else: - ns3_module_global_routing__local.register_methods(root_module) - - root_module.end_section('ns3_module_global_routing') - root_module.begin_section('ns3_module_stats') - ns3_module_stats.register_methods(root_module) - - try: - import ns3_module_stats__local - except ImportError: - pass - else: - ns3_module_stats__local.register_methods(root_module) - - root_module.end_section('ns3_module_stats') root_module.begin_section('ns3_module_list_routing') ns3_module_list_routing.register_methods(root_module) @@ -703,6 +681,28 @@ def register_methods(root_module): ns3_module_list_routing__local.register_methods(root_module) root_module.end_section('ns3_module_list_routing') + root_module.begin_section('ns3_module_virtual_net_device') + ns3_module_virtual_net_device.register_methods(root_module) + + try: + import ns3_module_virtual_net_device__local + except ImportError: + pass + else: + ns3_module_virtual_net_device__local.register_methods(root_module) + + root_module.end_section('ns3_module_virtual_net_device') + root_module.begin_section('ns3_module_wifi') + ns3_module_wifi.register_methods(root_module) + + try: + import ns3_module_wifi__local + except ImportError: + pass + else: + ns3_module_wifi__local.register_methods(root_module) + + root_module.end_section('ns3_module_wifi') root_module.begin_section('ns3_module_emu') ns3_module_emu.register_methods(root_module) @@ -725,17 +725,17 @@ def register_methods(root_module): ns3_module_bridge__local.register_methods(root_module) root_module.end_section('ns3_module_bridge') - root_module.begin_section('ns3_module_onoff') - ns3_module_onoff.register_methods(root_module) + root_module.begin_section('ns3_module_global_routing') + ns3_module_global_routing.register_methods(root_module) try: - import ns3_module_onoff__local + import ns3_module_global_routing__local except ImportError: pass else: - ns3_module_onoff__local.register_methods(root_module) + ns3_module_global_routing__local.register_methods(root_module) - root_module.end_section('ns3_module_onoff') + root_module.end_section('ns3_module_global_routing') root_module.begin_section('ns3_module_udp_echo') ns3_module_udp_echo.register_methods(root_module) @@ -747,17 +747,6 @@ def register_methods(root_module): ns3_module_udp_echo__local.register_methods(root_module) root_module.end_section('ns3_module_udp_echo') - root_module.begin_section('ns3_module_ping6') - ns3_module_ping6.register_methods(root_module) - - try: - import ns3_module_ping6__local - except ImportError: - pass - else: - ns3_module_ping6__local.register_methods(root_module) - - root_module.end_section('ns3_module_ping6') root_module.begin_section('ns3_module_nix_vector_routing') ns3_module_nix_vector_routing.register_methods(root_module) @@ -780,17 +769,6 @@ def register_methods(root_module): ns3_module_olsr__local.register_methods(root_module) root_module.end_section('ns3_module_olsr') - root_module.begin_section('ns3_module_flow_monitor') - ns3_module_flow_monitor.register_methods(root_module) - - try: - import ns3_module_flow_monitor__local - except ImportError: - pass - else: - ns3_module_flow_monitor__local.register_methods(root_module) - - root_module.end_section('ns3_module_flow_monitor') root_module.begin_section('ns3_module_radvd') ns3_module_radvd.register_methods(root_module) @@ -802,6 +780,28 @@ def register_methods(root_module): ns3_module_radvd__local.register_methods(root_module) root_module.end_section('ns3_module_radvd') + root_module.begin_section('ns3_module_ping6') + ns3_module_ping6.register_methods(root_module) + + try: + import ns3_module_ping6__local + except ImportError: + pass + else: + ns3_module_ping6__local.register_methods(root_module) + + root_module.end_section('ns3_module_ping6') + root_module.begin_section('ns3_module_flow_monitor') + ns3_module_flow_monitor.register_methods(root_module) + + try: + import ns3_module_flow_monitor__local + except ImportError: + pass + else: + ns3_module_flow_monitor__local.register_methods(root_module) + + root_module.end_section('ns3_module_flow_monitor') root_module.begin_section('ns3_module_mesh') ns3_module_mesh.register_methods(root_module) @@ -1039,17 +1039,6 @@ def register_functions(root_module): ns3_module_common__local.register_functions(root_module) root_module.end_section('ns3_module_common') - root_module.begin_section('ns3_module_node') - ns3_module_node.register_functions(root_module) - - try: - import ns3_module_node__local - except ImportError: - pass - else: - ns3_module_node__local.register_functions(root_module) - - root_module.end_section('ns3_module_node') root_module.begin_section('ns3_module_contrib') ns3_module_contrib.register_functions(root_module) @@ -1061,6 +1050,83 @@ def register_functions(root_module): ns3_module_contrib__local.register_functions(root_module) root_module.end_section('ns3_module_contrib') + root_module.begin_section('ns3_module_node') + ns3_module_node.register_functions(root_module) + + try: + import ns3_module_node__local + except ImportError: + pass + else: + ns3_module_node__local.register_functions(root_module) + + root_module.end_section('ns3_module_node') + root_module.begin_section('ns3_module_tap_bridge') + ns3_module_tap_bridge.register_functions(root_module) + + try: + import ns3_module_tap_bridge__local + except ImportError: + pass + else: + ns3_module_tap_bridge__local.register_functions(root_module) + + root_module.end_section('ns3_module_tap_bridge') + root_module.begin_section('ns3_module_v4ping') + ns3_module_v4ping.register_functions(root_module) + + try: + import ns3_module_v4ping__local + except ImportError: + pass + else: + ns3_module_v4ping__local.register_functions(root_module) + + root_module.end_section('ns3_module_v4ping') + root_module.begin_section('ns3_module_static_routing') + ns3_module_static_routing.register_functions(root_module) + + try: + import ns3_module_static_routing__local + except ImportError: + pass + else: + ns3_module_static_routing__local.register_functions(root_module) + + root_module.end_section('ns3_module_static_routing') + root_module.begin_section('ns3_module_packet_sink') + ns3_module_packet_sink.register_functions(root_module) + + try: + import ns3_module_packet_sink__local + except ImportError: + pass + else: + ns3_module_packet_sink__local.register_functions(root_module) + + root_module.end_section('ns3_module_packet_sink') + root_module.begin_section('ns3_module_stats') + ns3_module_stats.register_functions(root_module) + + try: + import ns3_module_stats__local + except ImportError: + pass + else: + ns3_module_stats__local.register_functions(root_module) + + root_module.end_section('ns3_module_stats') + root_module.begin_section('ns3_module_onoff') + ns3_module_onoff.register_functions(root_module) + + try: + import ns3_module_onoff__local + except ImportError: + pass + else: + ns3_module_onoff__local.register_functions(root_module) + + root_module.end_section('ns3_module_onoff') root_module.begin_section('ns3_module_point_to_point') ns3_module_point_to_point.register_functions(root_module) @@ -1083,17 +1149,6 @@ def register_functions(root_module): ns3_module_internet_stack__local.register_functions(root_module) root_module.end_section('ns3_module_internet_stack') - root_module.begin_section('ns3_module_tap_bridge') - ns3_module_tap_bridge.register_functions(root_module) - - try: - import ns3_module_tap_bridge__local - except ImportError: - pass - else: - ns3_module_tap_bridge__local.register_functions(root_module) - - root_module.end_section('ns3_module_tap_bridge') root_module.begin_section('ns3_module_csma') ns3_module_csma.register_functions(root_module) @@ -1105,83 +1160,6 @@ def register_functions(root_module): ns3_module_csma__local.register_functions(root_module) root_module.end_section('ns3_module_csma') - root_module.begin_section('ns3_module_wifi') - ns3_module_wifi.register_functions(root_module) - - try: - import ns3_module_wifi__local - except ImportError: - pass - else: - ns3_module_wifi__local.register_functions(root_module) - - root_module.end_section('ns3_module_wifi') - root_module.begin_section('ns3_module_static_routing') - ns3_module_static_routing.register_functions(root_module) - - try: - import ns3_module_static_routing__local - except ImportError: - pass - else: - ns3_module_static_routing__local.register_functions(root_module) - - root_module.end_section('ns3_module_static_routing') - root_module.begin_section('ns3_module_v4ping') - ns3_module_v4ping.register_functions(root_module) - - try: - import ns3_module_v4ping__local - except ImportError: - pass - else: - ns3_module_v4ping__local.register_functions(root_module) - - root_module.end_section('ns3_module_v4ping') - root_module.begin_section('ns3_module_virtual_net_device') - ns3_module_virtual_net_device.register_functions(root_module) - - try: - import ns3_module_virtual_net_device__local - except ImportError: - pass - else: - ns3_module_virtual_net_device__local.register_functions(root_module) - - root_module.end_section('ns3_module_virtual_net_device') - root_module.begin_section('ns3_module_packet_sink') - ns3_module_packet_sink.register_functions(root_module) - - try: - import ns3_module_packet_sink__local - except ImportError: - pass - else: - ns3_module_packet_sink__local.register_functions(root_module) - - root_module.end_section('ns3_module_packet_sink') - root_module.begin_section('ns3_module_global_routing') - ns3_module_global_routing.register_functions(root_module) - - try: - import ns3_module_global_routing__local - except ImportError: - pass - else: - ns3_module_global_routing__local.register_functions(root_module) - - root_module.end_section('ns3_module_global_routing') - root_module.begin_section('ns3_module_stats') - ns3_module_stats.register_functions(root_module) - - try: - import ns3_module_stats__local - except ImportError: - pass - else: - ns3_module_stats__local.register_functions(root_module) - - root_module.end_section('ns3_module_stats') root_module.begin_section('ns3_module_list_routing') ns3_module_list_routing.register_functions(root_module) @@ -1193,6 +1171,28 @@ def register_functions(root_module): ns3_module_list_routing__local.register_functions(root_module) root_module.end_section('ns3_module_list_routing') + root_module.begin_section('ns3_module_virtual_net_device') + ns3_module_virtual_net_device.register_functions(root_module) + + try: + import ns3_module_virtual_net_device__local + except ImportError: + pass + else: + ns3_module_virtual_net_device__local.register_functions(root_module) + + root_module.end_section('ns3_module_virtual_net_device') + root_module.begin_section('ns3_module_wifi') + ns3_module_wifi.register_functions(root_module) + + try: + import ns3_module_wifi__local + except ImportError: + pass + else: + ns3_module_wifi__local.register_functions(root_module) + + root_module.end_section('ns3_module_wifi') root_module.begin_section('ns3_module_emu') ns3_module_emu.register_functions(root_module) @@ -1215,17 +1215,17 @@ def register_functions(root_module): ns3_module_bridge__local.register_functions(root_module) root_module.end_section('ns3_module_bridge') - root_module.begin_section('ns3_module_onoff') - ns3_module_onoff.register_functions(root_module) + root_module.begin_section('ns3_module_global_routing') + ns3_module_global_routing.register_functions(root_module) try: - import ns3_module_onoff__local + import ns3_module_global_routing__local except ImportError: pass else: - ns3_module_onoff__local.register_functions(root_module) + ns3_module_global_routing__local.register_functions(root_module) - root_module.end_section('ns3_module_onoff') + root_module.end_section('ns3_module_global_routing') root_module.begin_section('ns3_module_udp_echo') ns3_module_udp_echo.register_functions(root_module) @@ -1237,17 +1237,6 @@ def register_functions(root_module): ns3_module_udp_echo__local.register_functions(root_module) root_module.end_section('ns3_module_udp_echo') - root_module.begin_section('ns3_module_ping6') - ns3_module_ping6.register_functions(root_module) - - try: - import ns3_module_ping6__local - except ImportError: - pass - else: - ns3_module_ping6__local.register_functions(root_module) - - root_module.end_section('ns3_module_ping6') root_module.begin_section('ns3_module_nix_vector_routing') ns3_module_nix_vector_routing.register_functions(root_module) @@ -1270,17 +1259,6 @@ def register_functions(root_module): ns3_module_olsr__local.register_functions(root_module) root_module.end_section('ns3_module_olsr') - root_module.begin_section('ns3_module_flow_monitor') - ns3_module_flow_monitor.register_functions(root_module) - - try: - import ns3_module_flow_monitor__local - except ImportError: - pass - else: - ns3_module_flow_monitor__local.register_functions(root_module) - - root_module.end_section('ns3_module_flow_monitor') root_module.begin_section('ns3_module_radvd') ns3_module_radvd.register_functions(root_module) @@ -1292,6 +1270,28 @@ def register_functions(root_module): ns3_module_radvd__local.register_functions(root_module) root_module.end_section('ns3_module_radvd') + root_module.begin_section('ns3_module_ping6') + ns3_module_ping6.register_functions(root_module) + + try: + import ns3_module_ping6__local + except ImportError: + pass + else: + ns3_module_ping6__local.register_functions(root_module) + + root_module.end_section('ns3_module_ping6') + root_module.begin_section('ns3_module_flow_monitor') + ns3_module_flow_monitor.register_functions(root_module) + + try: + import ns3_module_flow_monitor__local + except ImportError: + pass + else: + ns3_module_flow_monitor__local.register_functions(root_module) + + root_module.end_section('ns3_module_flow_monitor') root_module.begin_section('ns3_module_mesh') ns3_module_mesh.register_functions(root_module) diff --git a/bindings/python/apidefs/gcc-LP64/ns3_module_common.py b/bindings/python/apidefs/gcc-LP64/ns3_module_common.py index a7a0c4975..2d1c570f5 100644 --- a/bindings/python/apidefs/gcc-LP64/ns3_module_common.py +++ b/bindings/python/apidefs/gcc-LP64/ns3_module_common.py @@ -903,6 +903,11 @@ def register_Ns3PcapFile_methods(root_module, cls): cls.add_method('Close', 'void', []) + ## pcap-file.h: static bool ns3::PcapFile::Diff(std::string const & f1, std::string const & f2, uint32_t & sec, uint32_t & usec, uint32_t snapLen=ns3::PcapFile::SNAPLEN_DEFAULT) [member function] + cls.add_method('Diff', + 'bool', + [param('std::string const &', 'f1'), param('std::string const &', 'f2'), param('uint32_t &', 'sec'), param('uint32_t &', 'usec'), param('uint32_t', 'snapLen', default_value='ns3::PcapFile::SNAPLEN_DEFAULT')], + is_static=True) ## pcap-file.h: uint32_t ns3::PcapFile::GetDataLinkType() [member function] cls.add_method('GetDataLinkType', 'uint32_t', diff --git a/bindings/python/apidefs/gcc-LP64/ns3_module_core.py b/bindings/python/apidefs/gcc-LP64/ns3_module_core.py index e3c306bae..614bbc12f 100644 --- a/bindings/python/apidefs/gcc-LP64/ns3_module_core.py +++ b/bindings/python/apidefs/gcc-LP64/ns3_module_core.py @@ -51,6 +51,8 @@ def register_types(module): module.add_class('ObjectBase', allow_subclassing=True) ## object-factory.h: ns3::ObjectFactory [class] module.add_class('ObjectFactory') + ## object-ref-count.h: ns3::ObjectRefCount [class] + module.add_class('ObjectRefCount', template_parameters=['ns3::Object', 'ns3::ObjectBase'], parent=root_module['ns3::ObjectBase']) ## random-variable.h: ns3::RandomVariable [class] module.add_class('RandomVariable') ## ref-count-base.h: ns3::RefCountBase [class] @@ -144,7 +146,7 @@ def register_types(module): ## random-variable.h: ns3::NormalVariable [class] module.add_class('NormalVariable', parent=root_module['ns3::RandomVariable']) ## object.h: ns3::Object [class] - module.add_class('Object', automatic_type_narrowing=True, parent=root_module['ns3::ObjectBase'], memory_policy=cppclass.ReferenceCountingMethodsPolicy(incref_method='Ref', decref_method='Unref', peekref_method='GetReferenceCount')) + module.add_class('Object', automatic_type_narrowing=True, parent=root_module['ns3::ObjectRefCount< ns3::Object, ns3::ObjectBase >'], memory_policy=cppclass.ReferenceCountingMethodsPolicy(incref_method='Ref', decref_method='Unref', peekref_method='GetReferenceCount')) ## object.h: ns3::Object::AggregateIterator [class] module.add_class('AggregateIterator', outer_class=root_module['ns3::Object']) ## object-factory.h: ns3::ObjectFactoryChecker [class] @@ -304,6 +306,7 @@ def register_methods(root_module): register_Ns3Names_methods(root_module, root_module['ns3::Names']) register_Ns3ObjectBase_methods(root_module, root_module['ns3::ObjectBase']) register_Ns3ObjectFactory_methods(root_module, root_module['ns3::ObjectFactory']) + register_Ns3ObjectRefCount__Ns3Object_Ns3ObjectBase_methods(root_module, root_module['ns3::ObjectRefCount< ns3::Object, ns3::ObjectBase >']) register_Ns3RandomVariable_methods(root_module, root_module['ns3::RandomVariable']) register_Ns3RefCountBase_methods(root_module, root_module['ns3::RefCountBase']) register_Ns3RngStream_methods(root_module, root_module['ns3::RngStream']) @@ -721,6 +724,43 @@ def register_Ns3ObjectFactory_methods(root_module, cls): [param('std::string', 'tid')]) return +def register_Ns3ObjectRefCount__Ns3Object_Ns3ObjectBase_methods(root_module, cls): + ## object-ref-count.h: ns3::ObjectRefCount::ObjectRefCount() [constructor] + cls.add_constructor([]) + ## object-ref-count.h: ns3::ObjectRefCount::ObjectRefCount(ns3::ObjectRefCount const & o) [copy constructor] + cls.add_constructor([param('ns3::ObjectRefCount< ns3::Object, ns3::ObjectBase > const &', 'o')]) + ## object-ref-count.h: int ns3::ObjectRefCount::GetReferenceCount() const [member function] + cls.add_method('GetReferenceCount', + 'int', + [], + is_const=True) + ## object-ref-count.h: void ns3::ObjectRefCount::Ref() const [member function] + cls.add_method('Ref', + 'void', + [], + is_const=True) + ## object-ref-count.h: void ns3::ObjectRefCount::Unref() const [member function] + cls.add_method('Unref', + 'void', + [], + is_const=True) + ## object-ref-count.h: int * ns3::ObjectRefCount::PeekCountPtr() const [member function] + cls.add_method('PeekCountPtr', + 'int *', + [], + is_const=True, visibility='protected') + ## object-ref-count.h: void ns3::ObjectRefCount::ShareCount(ns3::ObjectRefCount * other) [member function] + cls.add_method('ShareCount', + 'void', + [param('ns3::ObjectRefCount< ns3::Object, ns3::ObjectBase > *', 'other')], + visibility='protected') + ## object-ref-count.h: void ns3::ObjectRefCount::DoDelete() [member function] + cls.add_method('DoDelete', + 'void', + [], + is_pure_virtual=True, visibility='private', is_virtual=True) + return + def register_Ns3RandomVariable_methods(root_module, cls): cls.add_output_stream_operator() ## random-variable.h: ns3::RandomVariable::RandomVariable() [constructor] @@ -962,10 +1002,25 @@ def register_Ns3SystemWallClockMs_methods(root_module, cls): cls.add_constructor([param('ns3::SystemWallClockMs const &', 'arg0')]) ## system-wall-clock-ms.h: ns3::SystemWallClockMs::SystemWallClockMs() [constructor] cls.add_constructor([]) - ## system-wall-clock-ms.h: long long unsigned int ns3::SystemWallClockMs::End() [member function] + ## system-wall-clock-ms.h: int64_t ns3::SystemWallClockMs::End() [member function] cls.add_method('End', - 'long long unsigned int', + 'int64_t', []) + ## system-wall-clock-ms.h: int64_t ns3::SystemWallClockMs::GetElapsedReal() const [member function] + cls.add_method('GetElapsedReal', + 'int64_t', + [], + is_const=True) + ## system-wall-clock-ms.h: int64_t ns3::SystemWallClockMs::GetElapsedSystem() const [member function] + cls.add_method('GetElapsedSystem', + 'int64_t', + [], + is_const=True) + ## system-wall-clock-ms.h: int64_t ns3::SystemWallClockMs::GetElapsedUser() const [member function] + cls.add_method('GetElapsedUser', + 'int64_t', + [], + is_const=True) ## system-wall-clock-ms.h: void ns3::SystemWallClockMs::Start() [member function] cls.add_method('Start', 'void', @@ -1003,6 +1058,14 @@ def register_Ns3TestCase_methods(root_module, cls): cls.add_method('GetBaseDir', 'std::string', []) + ## test.h: void ns3::TestCase::SetTempDir(std::string dir) [member function] + cls.add_method('SetTempDir', + 'void', + [param('std::string', 'dir')]) + ## test.h: std::string ns3::TestCase::GetTempDir() [member function] + cls.add_method('GetTempDir', + 'std::string', + []) ## test.h: std::string ns3::TestCase::GetSourceDir(std::string file) [member function] cls.add_method('GetSourceDir', 'std::string', @@ -1162,6 +1225,14 @@ def register_Ns3TestSuite_methods(root_module, cls): cls.add_method('GetBaseDir', 'std::string', []) + ## test.h: void ns3::TestSuite::SetTempDir(std::string dir) [member function] + cls.add_method('SetTempDir', + 'void', + [param('std::string', 'dir')]) + ## test.h: std::string ns3::TestSuite::GetTempDir() [member function] + cls.add_method('GetTempDir', + 'std::string', + []) ## test.h: void ns3::TestSuite::SetStream(std::ofstream * ofs) [member function] cls.add_method('SetStream', 'void', @@ -2046,6 +2117,11 @@ def register_Ns3Object_methods(root_module, cls): 'void', [], visibility='protected', is_virtual=True) + ## object.h: void ns3::Object::DoDelete() [member function] + cls.add_method('DoDelete', + 'void', + [], + visibility='private', is_virtual=True) return def register_Ns3ObjectAggregateIterator_methods(root_module, cls): diff --git a/bindings/python/apidefs/gcc-LP64/ns3_module_mobility.py b/bindings/python/apidefs/gcc-LP64/ns3_module_mobility.py index b7556135d..37f4e096e 100644 --- a/bindings/python/apidefs/gcc-LP64/ns3_module_mobility.py +++ b/bindings/python/apidefs/gcc-LP64/ns3_module_mobility.py @@ -9,6 +9,8 @@ def register_types(module): module.add_class('Rectangle') ## rectangle.h: ns3::Rectangle::Side [enumeration] module.add_enum('Side', ['RIGHT', 'LEFT', 'TOP', 'BOTTOM'], outer_class=root_module['ns3::Rectangle']) + ## waypoint.h: ns3::Waypoint [class] + module.add_class('Waypoint') ## position-allocator.h: ns3::PositionAllocator [class] module.add_class('PositionAllocator', parent=root_module['ns3::Object']) ## position-allocator.h: ns3::RandomDiscPositionAllocator [class] @@ -19,6 +21,10 @@ def register_types(module): module.add_class('RectangleChecker', parent=root_module['ns3::AttributeChecker']) ## rectangle.h: ns3::RectangleValue [class] module.add_class('RectangleValue', parent=root_module['ns3::AttributeValue']) + ## waypoint.h: ns3::WaypointChecker [class] + module.add_class('WaypointChecker', parent=root_module['ns3::AttributeChecker']) + ## waypoint.h: ns3::WaypointValue [class] + module.add_class('WaypointValue', parent=root_module['ns3::AttributeValue']) ## position-allocator.h: ns3::GridPositionAllocator [class] module.add_class('GridPositionAllocator', parent=root_module['ns3::PositionAllocator']) ## position-allocator.h: ns3::GridPositionAllocator::LayoutType [enumeration] @@ -35,6 +41,8 @@ def register_types(module): module.add_enum('Mode', ['MODE_DISTANCE', 'MODE_TIME'], outer_class=root_module['ns3::RandomWalk2dMobilityModel']) ## random-waypoint-mobility-model.h: ns3::RandomWaypointMobilityModel [class] module.add_class('RandomWaypointMobilityModel', parent=root_module['ns3::MobilityModel']) + ## waypoint-mobility-model.h: ns3::WaypointMobilityModel [class] + module.add_class('WaypointMobilityModel', parent=root_module['ns3::MobilityModel']) ## constant-acceleration-mobility-model.h: ns3::ConstantAccelerationMobilityModel [class] module.add_class('ConstantAccelerationMobilityModel', parent=root_module['ns3::MobilityModel']) ## constant-position-mobility-model.h: ns3::ConstantPositionMobilityModel [class] @@ -117,17 +125,21 @@ def register_types_ns3_olsr(module): def register_methods(root_module): register_Ns3ConstantVelocityHelper_methods(root_module, root_module['ns3::ConstantVelocityHelper']) register_Ns3Rectangle_methods(root_module, root_module['ns3::Rectangle']) + register_Ns3Waypoint_methods(root_module, root_module['ns3::Waypoint']) register_Ns3PositionAllocator_methods(root_module, root_module['ns3::PositionAllocator']) register_Ns3RandomDiscPositionAllocator_methods(root_module, root_module['ns3::RandomDiscPositionAllocator']) register_Ns3RandomRectanglePositionAllocator_methods(root_module, root_module['ns3::RandomRectanglePositionAllocator']) register_Ns3RectangleChecker_methods(root_module, root_module['ns3::RectangleChecker']) register_Ns3RectangleValue_methods(root_module, root_module['ns3::RectangleValue']) + register_Ns3WaypointChecker_methods(root_module, root_module['ns3::WaypointChecker']) + register_Ns3WaypointValue_methods(root_module, root_module['ns3::WaypointValue']) register_Ns3GridPositionAllocator_methods(root_module, root_module['ns3::GridPositionAllocator']) register_Ns3ListPositionAllocator_methods(root_module, root_module['ns3::ListPositionAllocator']) register_Ns3MobilityModel_methods(root_module, root_module['ns3::MobilityModel']) register_Ns3RandomDirection2dMobilityModel_methods(root_module, root_module['ns3::RandomDirection2dMobilityModel']) register_Ns3RandomWalk2dMobilityModel_methods(root_module, root_module['ns3::RandomWalk2dMobilityModel']) register_Ns3RandomWaypointMobilityModel_methods(root_module, root_module['ns3::RandomWaypointMobilityModel']) + register_Ns3WaypointMobilityModel_methods(root_module, root_module['ns3::WaypointMobilityModel']) register_Ns3ConstantAccelerationMobilityModel_methods(root_module, root_module['ns3::ConstantAccelerationMobilityModel']) register_Ns3ConstantPositionMobilityModel_methods(root_module, root_module['ns3::ConstantPositionMobilityModel']) register_Ns3ConstantVelocityMobilityModel_methods(root_module, root_module['ns3::ConstantVelocityMobilityModel']) @@ -214,6 +226,20 @@ def register_Ns3Rectangle_methods(root_module, cls): cls.add_instance_attribute('yMin', 'double', is_const=False) return +def register_Ns3Waypoint_methods(root_module, cls): + cls.add_output_stream_operator() + ## waypoint.h: ns3::Waypoint::Waypoint(ns3::Waypoint const & arg0) [copy constructor] + cls.add_constructor([param('ns3::Waypoint const &', 'arg0')]) + ## waypoint.h: ns3::Waypoint::Waypoint(ns3::Time const & waypointTime, ns3::Vector const & waypointPosition) [constructor] + cls.add_constructor([param('ns3::Time const &', 'waypointTime'), param('ns3::Vector const &', 'waypointPosition')]) + ## waypoint.h: ns3::Waypoint::Waypoint() [constructor] + cls.add_constructor([]) + ## waypoint.h: ns3::Waypoint::position [variable] + cls.add_instance_attribute('position', 'ns3::Vector', is_const=False) + ## waypoint.h: ns3::Waypoint::time [variable] + cls.add_instance_attribute('time', 'ns3::Time', is_const=False) + return + def register_Ns3PositionAllocator_methods(root_module, cls): ## position-allocator.h: ns3::PositionAllocator::PositionAllocator(ns3::PositionAllocator const & arg0) [copy constructor] cls.add_constructor([param('ns3::PositionAllocator const &', 'arg0')]) @@ -329,6 +355,46 @@ def register_Ns3RectangleValue_methods(root_module, cls): [param('ns3::Rectangle const &', 'value')]) return +def register_Ns3WaypointChecker_methods(root_module, cls): + ## waypoint.h: ns3::WaypointChecker::WaypointChecker() [constructor] + cls.add_constructor([]) + ## waypoint.h: ns3::WaypointChecker::WaypointChecker(ns3::WaypointChecker const & arg0) [copy constructor] + cls.add_constructor([param('ns3::WaypointChecker const &', 'arg0')]) + return + +def register_Ns3WaypointValue_methods(root_module, cls): + ## waypoint.h: ns3::WaypointValue::WaypointValue() [constructor] + cls.add_constructor([]) + ## waypoint.h: ns3::WaypointValue::WaypointValue(ns3::WaypointValue const & arg0) [copy constructor] + cls.add_constructor([param('ns3::WaypointValue const &', 'arg0')]) + ## waypoint.h: ns3::WaypointValue::WaypointValue(ns3::Waypoint const & value) [constructor] + cls.add_constructor([param('ns3::Waypoint const &', 'value')]) + ## waypoint.h: ns3::Ptr ns3::WaypointValue::Copy() const [member function] + cls.add_method('Copy', + 'ns3::Ptr< ns3::AttributeValue >', + [], + is_const=True, is_virtual=True) + ## waypoint.h: bool ns3::WaypointValue::DeserializeFromString(std::string value, ns3::Ptr checker) [member function] + cls.add_method('DeserializeFromString', + 'bool', + [param('std::string', 'value'), param('ns3::Ptr< ns3::AttributeChecker const >', 'checker')], + is_virtual=True) + ## waypoint.h: ns3::Waypoint ns3::WaypointValue::Get() const [member function] + cls.add_method('Get', + 'ns3::Waypoint', + [], + is_const=True) + ## waypoint.h: std::string ns3::WaypointValue::SerializeToString(ns3::Ptr checker) const [member function] + cls.add_method('SerializeToString', + 'std::string', + [param('ns3::Ptr< ns3::AttributeChecker const >', 'checker')], + is_const=True, is_virtual=True) + ## waypoint.h: void ns3::WaypointValue::Set(ns3::Waypoint const & value) [member function] + cls.add_method('Set', + 'void', + [param('ns3::Waypoint const &', 'value')]) + return + def register_Ns3GridPositionAllocator_methods(root_module, cls): ## position-allocator.h: ns3::GridPositionAllocator::GridPositionAllocator(ns3::GridPositionAllocator const & arg0) [copy constructor] cls.add_constructor([param('ns3::GridPositionAllocator const &', 'arg0')]) @@ -563,6 +629,56 @@ def register_Ns3RandomWaypointMobilityModel_methods(root_module, cls): visibility='private', is_virtual=True) return +def register_Ns3WaypointMobilityModel_methods(root_module, cls): + ## waypoint-mobility-model.h: ns3::WaypointMobilityModel::WaypointMobilityModel(ns3::WaypointMobilityModel const & arg0) [copy constructor] + cls.add_constructor([param('ns3::WaypointMobilityModel const &', 'arg0')]) + ## waypoint-mobility-model.h: ns3::WaypointMobilityModel::WaypointMobilityModel() [constructor] + cls.add_constructor([]) + ## waypoint-mobility-model.h: void ns3::WaypointMobilityModel::AddWaypoint(ns3::Waypoint const & waypoint) [member function] + cls.add_method('AddWaypoint', + 'void', + [param('ns3::Waypoint const &', 'waypoint')]) + ## waypoint-mobility-model.h: void ns3::WaypointMobilityModel::EndMobility() [member function] + cls.add_method('EndMobility', + 'void', + []) + ## waypoint-mobility-model.h: ns3::Waypoint ns3::WaypointMobilityModel::GetNextWaypoint() const [member function] + cls.add_method('GetNextWaypoint', + 'ns3::Waypoint', + [], + is_const=True) + ## waypoint-mobility-model.h: static ns3::TypeId ns3::WaypointMobilityModel::GetTypeId() [member function] + cls.add_method('GetTypeId', + 'ns3::TypeId', + [], + is_static=True) + ## waypoint-mobility-model.h: uint32_t ns3::WaypointMobilityModel::WaypointsLeft() const [member function] + cls.add_method('WaypointsLeft', + 'uint32_t', + [], + is_const=True) + ## waypoint-mobility-model.h: void ns3::WaypointMobilityModel::DoDispose() [member function] + cls.add_method('DoDispose', + 'void', + [], + visibility='private', is_virtual=True) + ## waypoint-mobility-model.h: ns3::Vector ns3::WaypointMobilityModel::DoGetPosition() const [member function] + cls.add_method('DoGetPosition', + 'ns3::Vector', + [], + is_const=True, visibility='private', is_virtual=True) + ## waypoint-mobility-model.h: ns3::Vector ns3::WaypointMobilityModel::DoGetVelocity() const [member function] + cls.add_method('DoGetVelocity', + 'ns3::Vector', + [], + is_const=True, visibility='private', is_virtual=True) + ## waypoint-mobility-model.h: void ns3::WaypointMobilityModel::DoSetPosition(ns3::Vector const & position) [member function] + cls.add_method('DoSetPosition', + 'void', + [param('ns3::Vector const &', 'position')], + visibility='private', is_virtual=True) + return + def register_Ns3ConstantAccelerationMobilityModel_methods(root_module, cls): ## constant-acceleration-mobility-model.h: ns3::ConstantAccelerationMobilityModel::ConstantAccelerationMobilityModel(ns3::ConstantAccelerationMobilityModel const & arg0) [copy constructor] cls.add_constructor([param('ns3::ConstantAccelerationMobilityModel const &', 'arg0')]) @@ -703,6 +819,10 @@ def register_functions(root_module): module.add_function('MakeRectangleChecker', 'ns3::Ptr< ns3::AttributeChecker const >', []) + ## waypoint.h: extern ns3::Ptr ns3::MakeWaypointChecker() [free function] + module.add_function('MakeWaypointChecker', + 'ns3::Ptr< ns3::AttributeChecker const >', + []) register_functions_ns3_Config(module.get_submodule('Config'), root_module) register_functions_ns3_TimeStepPrecision(module.get_submodule('TimeStepPrecision'), root_module) register_functions_ns3_addressUtils(module.get_submodule('addressUtils'), root_module) diff --git a/bindings/python/apidefs/gcc-LP64/ns3_module_point_to_point.py b/bindings/python/apidefs/gcc-LP64/ns3_module_point_to_point.py index 817a3baac..72d3e567e 100644 --- a/bindings/python/apidefs/gcc-LP64/ns3_module_point_to_point.py +++ b/bindings/python/apidefs/gcc-LP64/ns3_module_point_to_point.py @@ -101,6 +101,10 @@ def register_Ns3PppHeader_methods(root_module, cls): 'ns3::TypeId', [], is_const=True, is_virtual=True) + ## ppp-header.h: uint16_t ns3::PppHeader::GetProtocol() [member function] + cls.add_method('GetProtocol', + 'uint16_t', + []) ## ppp-header.h: uint32_t ns3::PppHeader::GetSerializedSize() const [member function] cls.add_method('GetSerializedSize', 'uint32_t', @@ -121,6 +125,10 @@ def register_Ns3PppHeader_methods(root_module, cls): 'void', [param('ns3::Buffer::Iterator', 'start')], is_const=True, is_virtual=True) + ## ppp-header.h: void ns3::PppHeader::SetProtocol(uint16_t protocol) [member function] + cls.add_method('SetProtocol', + 'void', + [param('uint16_t', 'protocol')]) return def register_Ns3PointToPointChannel_methods(root_module, cls): diff --git a/bindings/python/apidefs/gcc-LP64/ns3_module_stats.py b/bindings/python/apidefs/gcc-LP64/ns3_module_stats.py index 610739ccc..bfd42eb05 100644 --- a/bindings/python/apidefs/gcc-LP64/ns3_module_stats.py +++ b/bindings/python/apidefs/gcc-LP64/ns3_module_stats.py @@ -5,18 +5,16 @@ def register_types(module): ## data-output-interface.h: ns3::DataOutputCallback [class] module.add_class('DataOutputCallback', allow_subclassing=True) + ## data-calculator.h: ns3::StatisticalSummary [class] + module.add_class('StatisticalSummary', allow_subclassing=True) ## data-calculator.h: ns3::DataCalculator [class] module.add_class('DataCalculator', parent=root_module['ns3::Object']) ## data-collector.h: ns3::DataCollector [class] module.add_class('DataCollector', parent=root_module['ns3::Object']) ## data-output-interface.h: ns3::DataOutputInterface [class] module.add_class('DataOutputInterface', parent=root_module['ns3::Object']) - ## basic-data-calculators.h: ns3::MinMaxAvgTotalCalculator [class] - module.add_class('MinMaxAvgTotalCalculator', template_parameters=['unsigned int'], parent=root_module['ns3::DataCalculator']) ## omnet-data-output.h: ns3::OmnetDataOutput [class] module.add_class('OmnetDataOutput', parent=root_module['ns3::DataOutputInterface']) - ## packet-data-calculators.h: ns3::PacketSizeMinMaxAvgTotalCalculator [class] - module.add_class('PacketSizeMinMaxAvgTotalCalculator', parent=root_module['ns3::MinMaxAvgTotalCalculator< unsigned int >']) ## sqlite-data-output.h: ns3::SqliteDataOutput [class] module.add_class('SqliteDataOutput', parent=root_module['ns3::DataOutputInterface']) ## time-data-calculators.h: ns3::TimeMinMaxAvgTotalCalculator [class] @@ -104,12 +102,11 @@ def register_types_ns3_olsr(module): def register_methods(root_module): register_Ns3DataOutputCallback_methods(root_module, root_module['ns3::DataOutputCallback']) + register_Ns3StatisticalSummary_methods(root_module, root_module['ns3::StatisticalSummary']) register_Ns3DataCalculator_methods(root_module, root_module['ns3::DataCalculator']) register_Ns3DataCollector_methods(root_module, root_module['ns3::DataCollector']) register_Ns3DataOutputInterface_methods(root_module, root_module['ns3::DataOutputInterface']) - register_Ns3MinMaxAvgTotalCalculator__Unsigned_int_methods(root_module, root_module['ns3::MinMaxAvgTotalCalculator< unsigned int >']) register_Ns3OmnetDataOutput_methods(root_module, root_module['ns3::OmnetDataOutput']) - register_Ns3PacketSizeMinMaxAvgTotalCalculator_methods(root_module, root_module['ns3::PacketSizeMinMaxAvgTotalCalculator']) register_Ns3SqliteDataOutput_methods(root_module, root_module['ns3::SqliteDataOutput']) register_Ns3TimeMinMaxAvgTotalCalculator_methods(root_module, root_module['ns3::TimeMinMaxAvgTotalCalculator']) register_Ns3CounterCalculator__Unsigned_int_methods(root_module, root_module['ns3::CounterCalculator< unsigned int >']) @@ -146,6 +143,58 @@ def register_Ns3DataOutputCallback_methods(root_module, cls): 'void', [param('std::string', 'key'), param('std::string', 'variable'), param('ns3::Time', 'val')], is_pure_virtual=True, is_virtual=True) + ## data-output-interface.h: void ns3::DataOutputCallback::OutputStatistic(std::string key, std::string variable, ns3::StatisticalSummary const * statSum) [member function] + cls.add_method('OutputStatistic', + 'void', + [param('std::string', 'key'), param('std::string', 'variable'), param('ns3::StatisticalSummary const *', 'statSum')], + is_pure_virtual=True, is_virtual=True) + return + +def register_Ns3StatisticalSummary_methods(root_module, cls): + ## data-calculator.h: ns3::StatisticalSummary::StatisticalSummary() [constructor] + cls.add_constructor([]) + ## data-calculator.h: ns3::StatisticalSummary::StatisticalSummary(ns3::StatisticalSummary const & arg0) [copy constructor] + cls.add_constructor([param('ns3::StatisticalSummary const &', 'arg0')]) + ## data-calculator.h: long int ns3::StatisticalSummary::getCount() const [member function] + cls.add_method('getCount', + 'long int', + [], + is_pure_virtual=True, is_const=True, is_virtual=True) + ## data-calculator.h: double ns3::StatisticalSummary::getMax() const [member function] + cls.add_method('getMax', + 'double', + [], + is_pure_virtual=True, is_const=True, is_virtual=True) + ## data-calculator.h: double ns3::StatisticalSummary::getMean() const [member function] + cls.add_method('getMean', + 'double', + [], + is_pure_virtual=True, is_const=True, is_virtual=True) + ## data-calculator.h: double ns3::StatisticalSummary::getMin() const [member function] + cls.add_method('getMin', + 'double', + [], + is_pure_virtual=True, is_const=True, is_virtual=True) + ## data-calculator.h: double ns3::StatisticalSummary::getSqrSum() const [member function] + cls.add_method('getSqrSum', + 'double', + [], + is_pure_virtual=True, is_const=True, is_virtual=True) + ## data-calculator.h: double ns3::StatisticalSummary::getStddev() const [member function] + cls.add_method('getStddev', + 'double', + [], + is_pure_virtual=True, is_const=True, is_virtual=True) + ## data-calculator.h: double ns3::StatisticalSummary::getSum() const [member function] + cls.add_method('getSum', + 'double', + [], + is_pure_virtual=True, is_const=True, is_virtual=True) + ## data-calculator.h: double ns3::StatisticalSummary::getVariance() const [member function] + cls.add_method('getVariance', + 'double', + [], + is_pure_virtual=True, is_const=True, is_virtual=True) return def register_Ns3DataCalculator_methods(root_module, cls): @@ -161,6 +210,11 @@ def register_Ns3DataCalculator_methods(root_module, cls): cls.add_method('Enable', 'void', []) + ## data-calculator.h: std::string ns3::DataCalculator::GetContext() const [member function] + cls.add_method('GetContext', + 'std::string', + [], + is_const=True) ## data-calculator.h: bool ns3::DataCalculator::GetEnabled() const [member function] cls.add_method('GetEnabled', 'bool', @@ -176,6 +230,10 @@ def register_Ns3DataCalculator_methods(root_module, cls): 'void', [param('ns3::DataOutputCallback &', 'callback')], is_pure_virtual=True, is_const=True, is_virtual=True) + ## data-calculator.h: void ns3::DataCalculator::SetContext(std::string const context) [member function] + cls.add_method('SetContext', + 'void', + [param('std::string const', 'context')]) ## data-calculator.h: void ns3::DataCalculator::SetKey(std::string const key) [member function] cls.add_method('SetKey', 'void', @@ -296,27 +354,6 @@ def register_Ns3DataOutputInterface_methods(root_module, cls): visibility='protected', is_virtual=True) return -def register_Ns3MinMaxAvgTotalCalculator__Unsigned_int_methods(root_module, cls): - ## basic-data-calculators.h: ns3::MinMaxAvgTotalCalculator::MinMaxAvgTotalCalculator(ns3::MinMaxAvgTotalCalculator const & arg0) [copy constructor] - cls.add_constructor([param('ns3::MinMaxAvgTotalCalculator< unsigned int > const &', 'arg0')]) - ## basic-data-calculators.h: ns3::MinMaxAvgTotalCalculator::MinMaxAvgTotalCalculator() [constructor] - cls.add_constructor([]) - ## basic-data-calculators.h: void ns3::MinMaxAvgTotalCalculator::Output(ns3::DataOutputCallback & callback) const [member function] - cls.add_method('Output', - 'void', - [param('ns3::DataOutputCallback &', 'callback')], - is_const=True, is_virtual=True) - ## basic-data-calculators.h: void ns3::MinMaxAvgTotalCalculator::Update(unsigned int const i) [member function] - cls.add_method('Update', - 'void', - [param('unsigned int const', 'i')]) - ## basic-data-calculators.h: void ns3::MinMaxAvgTotalCalculator::DoDispose() [member function] - cls.add_method('DoDispose', - 'void', - [], - visibility='protected', is_virtual=True) - return - def register_Ns3OmnetDataOutput_methods(root_module, cls): ## omnet-data-output.h: ns3::OmnetDataOutput::OmnetDataOutput(ns3::OmnetDataOutput const & arg0) [copy constructor] cls.add_constructor([param('ns3::OmnetDataOutput const &', 'arg0')]) @@ -334,26 +371,6 @@ def register_Ns3OmnetDataOutput_methods(root_module, cls): visibility='protected', is_virtual=True) return -def register_Ns3PacketSizeMinMaxAvgTotalCalculator_methods(root_module, cls): - ## packet-data-calculators.h: ns3::PacketSizeMinMaxAvgTotalCalculator::PacketSizeMinMaxAvgTotalCalculator(ns3::PacketSizeMinMaxAvgTotalCalculator const & arg0) [copy constructor] - cls.add_constructor([param('ns3::PacketSizeMinMaxAvgTotalCalculator const &', 'arg0')]) - ## packet-data-calculators.h: ns3::PacketSizeMinMaxAvgTotalCalculator::PacketSizeMinMaxAvgTotalCalculator() [constructor] - cls.add_constructor([]) - ## packet-data-calculators.h: void ns3::PacketSizeMinMaxAvgTotalCalculator::FrameUpdate(std::string path, ns3::Ptr packet, ns3::Mac48Address realto) [member function] - cls.add_method('FrameUpdate', - 'void', - [param('std::string', 'path'), param('ns3::Ptr< ns3::Packet const >', 'packet'), param('ns3::Mac48Address', 'realto')]) - ## packet-data-calculators.h: void ns3::PacketSizeMinMaxAvgTotalCalculator::PacketUpdate(std::string path, ns3::Ptr packet) [member function] - cls.add_method('PacketUpdate', - 'void', - [param('std::string', 'path'), param('ns3::Ptr< ns3::Packet const >', 'packet')]) - ## packet-data-calculators.h: void ns3::PacketSizeMinMaxAvgTotalCalculator::DoDispose() [member function] - cls.add_method('DoDispose', - 'void', - [], - visibility='protected', is_virtual=True) - return - def register_Ns3SqliteDataOutput_methods(root_module, cls): ## sqlite-data-output.h: ns3::SqliteDataOutput::SqliteDataOutput(ns3::SqliteDataOutput const & arg0) [copy constructor] cls.add_constructor([param('ns3::SqliteDataOutput const &', 'arg0')]) @@ -444,6 +461,10 @@ def register_Ns3PacketCounterCalculator_methods(root_module, cls): def register_functions(root_module): module = root_module + ## data-calculator.h: bool ns3::isNaN(double x) [free function] + module.add_function('isNaN', + 'bool', + [param('double', 'x')]) register_functions_ns3_Config(module.get_submodule('Config'), root_module) register_functions_ns3_TimeStepPrecision(module.get_submodule('TimeStepPrecision'), root_module) register_functions_ns3_addressUtils(module.get_submodule('addressUtils'), root_module) diff --git a/bindings/python/apidefs/gcc-LP64/ns3modulegen_generated.py b/bindings/python/apidefs/gcc-LP64/ns3modulegen_generated.py index e24f8a588..a34101ded 100644 --- a/bindings/python/apidefs/gcc-LP64/ns3modulegen_generated.py +++ b/bindings/python/apidefs/gcc-LP64/ns3modulegen_generated.py @@ -17,29 +17,29 @@ import ns3_module_simulator import ns3_module_test import ns3_module_mobility import ns3_module_common -import ns3_module_node import ns3_module_contrib +import ns3_module_node +import ns3_module_tap_bridge +import ns3_module_v4ping +import ns3_module_static_routing +import ns3_module_packet_sink +import ns3_module_stats +import ns3_module_onoff import ns3_module_point_to_point import ns3_module_internet_stack -import ns3_module_tap_bridge import ns3_module_csma -import ns3_module_wifi -import ns3_module_static_routing -import ns3_module_v4ping -import ns3_module_virtual_net_device -import ns3_module_packet_sink -import ns3_module_global_routing -import ns3_module_stats import ns3_module_list_routing +import ns3_module_virtual_net_device +import ns3_module_wifi import ns3_module_emu import ns3_module_bridge -import ns3_module_onoff +import ns3_module_global_routing import ns3_module_udp_echo -import ns3_module_ping6 import ns3_module_nix_vector_routing import ns3_module_olsr -import ns3_module_flow_monitor import ns3_module_radvd +import ns3_module_ping6 +import ns3_module_flow_monitor import ns3_module_mesh import ns3_module_helper import ns3_module_dot11s @@ -107,17 +107,6 @@ def register_types(module): ns3_module_common__local.register_types(module) root_module.end_section('ns3_module_common') - root_module.begin_section('ns3_module_node') - ns3_module_node.register_types(module) - - try: - import ns3_module_node__local - except ImportError: - pass - else: - ns3_module_node__local.register_types(module) - - root_module.end_section('ns3_module_node') root_module.begin_section('ns3_module_contrib') ns3_module_contrib.register_types(module) @@ -129,6 +118,83 @@ def register_types(module): ns3_module_contrib__local.register_types(module) root_module.end_section('ns3_module_contrib') + root_module.begin_section('ns3_module_node') + ns3_module_node.register_types(module) + + try: + import ns3_module_node__local + except ImportError: + pass + else: + ns3_module_node__local.register_types(module) + + root_module.end_section('ns3_module_node') + root_module.begin_section('ns3_module_tap_bridge') + ns3_module_tap_bridge.register_types(module) + + try: + import ns3_module_tap_bridge__local + except ImportError: + pass + else: + ns3_module_tap_bridge__local.register_types(module) + + root_module.end_section('ns3_module_tap_bridge') + root_module.begin_section('ns3_module_v4ping') + ns3_module_v4ping.register_types(module) + + try: + import ns3_module_v4ping__local + except ImportError: + pass + else: + ns3_module_v4ping__local.register_types(module) + + root_module.end_section('ns3_module_v4ping') + root_module.begin_section('ns3_module_static_routing') + ns3_module_static_routing.register_types(module) + + try: + import ns3_module_static_routing__local + except ImportError: + pass + else: + ns3_module_static_routing__local.register_types(module) + + root_module.end_section('ns3_module_static_routing') + root_module.begin_section('ns3_module_packet_sink') + ns3_module_packet_sink.register_types(module) + + try: + import ns3_module_packet_sink__local + except ImportError: + pass + else: + ns3_module_packet_sink__local.register_types(module) + + root_module.end_section('ns3_module_packet_sink') + root_module.begin_section('ns3_module_stats') + ns3_module_stats.register_types(module) + + try: + import ns3_module_stats__local + except ImportError: + pass + else: + ns3_module_stats__local.register_types(module) + + root_module.end_section('ns3_module_stats') + root_module.begin_section('ns3_module_onoff') + ns3_module_onoff.register_types(module) + + try: + import ns3_module_onoff__local + except ImportError: + pass + else: + ns3_module_onoff__local.register_types(module) + + root_module.end_section('ns3_module_onoff') root_module.begin_section('ns3_module_point_to_point') ns3_module_point_to_point.register_types(module) @@ -151,17 +217,6 @@ def register_types(module): ns3_module_internet_stack__local.register_types(module) root_module.end_section('ns3_module_internet_stack') - root_module.begin_section('ns3_module_tap_bridge') - ns3_module_tap_bridge.register_types(module) - - try: - import ns3_module_tap_bridge__local - except ImportError: - pass - else: - ns3_module_tap_bridge__local.register_types(module) - - root_module.end_section('ns3_module_tap_bridge') root_module.begin_section('ns3_module_csma') ns3_module_csma.register_types(module) @@ -173,83 +228,6 @@ def register_types(module): ns3_module_csma__local.register_types(module) root_module.end_section('ns3_module_csma') - root_module.begin_section('ns3_module_wifi') - ns3_module_wifi.register_types(module) - - try: - import ns3_module_wifi__local - except ImportError: - pass - else: - ns3_module_wifi__local.register_types(module) - - root_module.end_section('ns3_module_wifi') - root_module.begin_section('ns3_module_static_routing') - ns3_module_static_routing.register_types(module) - - try: - import ns3_module_static_routing__local - except ImportError: - pass - else: - ns3_module_static_routing__local.register_types(module) - - root_module.end_section('ns3_module_static_routing') - root_module.begin_section('ns3_module_v4ping') - ns3_module_v4ping.register_types(module) - - try: - import ns3_module_v4ping__local - except ImportError: - pass - else: - ns3_module_v4ping__local.register_types(module) - - root_module.end_section('ns3_module_v4ping') - root_module.begin_section('ns3_module_virtual_net_device') - ns3_module_virtual_net_device.register_types(module) - - try: - import ns3_module_virtual_net_device__local - except ImportError: - pass - else: - ns3_module_virtual_net_device__local.register_types(module) - - root_module.end_section('ns3_module_virtual_net_device') - root_module.begin_section('ns3_module_packet_sink') - ns3_module_packet_sink.register_types(module) - - try: - import ns3_module_packet_sink__local - except ImportError: - pass - else: - ns3_module_packet_sink__local.register_types(module) - - root_module.end_section('ns3_module_packet_sink') - root_module.begin_section('ns3_module_global_routing') - ns3_module_global_routing.register_types(module) - - try: - import ns3_module_global_routing__local - except ImportError: - pass - else: - ns3_module_global_routing__local.register_types(module) - - root_module.end_section('ns3_module_global_routing') - root_module.begin_section('ns3_module_stats') - ns3_module_stats.register_types(module) - - try: - import ns3_module_stats__local - except ImportError: - pass - else: - ns3_module_stats__local.register_types(module) - - root_module.end_section('ns3_module_stats') root_module.begin_section('ns3_module_list_routing') ns3_module_list_routing.register_types(module) @@ -261,6 +239,28 @@ def register_types(module): ns3_module_list_routing__local.register_types(module) root_module.end_section('ns3_module_list_routing') + root_module.begin_section('ns3_module_virtual_net_device') + ns3_module_virtual_net_device.register_types(module) + + try: + import ns3_module_virtual_net_device__local + except ImportError: + pass + else: + ns3_module_virtual_net_device__local.register_types(module) + + root_module.end_section('ns3_module_virtual_net_device') + root_module.begin_section('ns3_module_wifi') + ns3_module_wifi.register_types(module) + + try: + import ns3_module_wifi__local + except ImportError: + pass + else: + ns3_module_wifi__local.register_types(module) + + root_module.end_section('ns3_module_wifi') root_module.begin_section('ns3_module_emu') ns3_module_emu.register_types(module) @@ -283,17 +283,17 @@ def register_types(module): ns3_module_bridge__local.register_types(module) root_module.end_section('ns3_module_bridge') - root_module.begin_section('ns3_module_onoff') - ns3_module_onoff.register_types(module) + root_module.begin_section('ns3_module_global_routing') + ns3_module_global_routing.register_types(module) try: - import ns3_module_onoff__local + import ns3_module_global_routing__local except ImportError: pass else: - ns3_module_onoff__local.register_types(module) + ns3_module_global_routing__local.register_types(module) - root_module.end_section('ns3_module_onoff') + root_module.end_section('ns3_module_global_routing') root_module.begin_section('ns3_module_udp_echo') ns3_module_udp_echo.register_types(module) @@ -305,17 +305,6 @@ def register_types(module): ns3_module_udp_echo__local.register_types(module) root_module.end_section('ns3_module_udp_echo') - root_module.begin_section('ns3_module_ping6') - ns3_module_ping6.register_types(module) - - try: - import ns3_module_ping6__local - except ImportError: - pass - else: - ns3_module_ping6__local.register_types(module) - - root_module.end_section('ns3_module_ping6') root_module.begin_section('ns3_module_nix_vector_routing') ns3_module_nix_vector_routing.register_types(module) @@ -338,17 +327,6 @@ def register_types(module): ns3_module_olsr__local.register_types(module) root_module.end_section('ns3_module_olsr') - root_module.begin_section('ns3_module_flow_monitor') - ns3_module_flow_monitor.register_types(module) - - try: - import ns3_module_flow_monitor__local - except ImportError: - pass - else: - ns3_module_flow_monitor__local.register_types(module) - - root_module.end_section('ns3_module_flow_monitor') root_module.begin_section('ns3_module_radvd') ns3_module_radvd.register_types(module) @@ -360,6 +338,28 @@ def register_types(module): ns3_module_radvd__local.register_types(module) root_module.end_section('ns3_module_radvd') + root_module.begin_section('ns3_module_ping6') + ns3_module_ping6.register_types(module) + + try: + import ns3_module_ping6__local + except ImportError: + pass + else: + ns3_module_ping6__local.register_types(module) + + root_module.end_section('ns3_module_ping6') + root_module.begin_section('ns3_module_flow_monitor') + ns3_module_flow_monitor.register_types(module) + + try: + import ns3_module_flow_monitor__local + except ImportError: + pass + else: + ns3_module_flow_monitor__local.register_types(module) + + root_module.end_section('ns3_module_flow_monitor') root_module.begin_section('ns3_module_mesh') ns3_module_mesh.register_types(module) @@ -549,17 +549,6 @@ def register_methods(root_module): ns3_module_common__local.register_methods(root_module) root_module.end_section('ns3_module_common') - root_module.begin_section('ns3_module_node') - ns3_module_node.register_methods(root_module) - - try: - import ns3_module_node__local - except ImportError: - pass - else: - ns3_module_node__local.register_methods(root_module) - - root_module.end_section('ns3_module_node') root_module.begin_section('ns3_module_contrib') ns3_module_contrib.register_methods(root_module) @@ -571,6 +560,83 @@ def register_methods(root_module): ns3_module_contrib__local.register_methods(root_module) root_module.end_section('ns3_module_contrib') + root_module.begin_section('ns3_module_node') + ns3_module_node.register_methods(root_module) + + try: + import ns3_module_node__local + except ImportError: + pass + else: + ns3_module_node__local.register_methods(root_module) + + root_module.end_section('ns3_module_node') + root_module.begin_section('ns3_module_tap_bridge') + ns3_module_tap_bridge.register_methods(root_module) + + try: + import ns3_module_tap_bridge__local + except ImportError: + pass + else: + ns3_module_tap_bridge__local.register_methods(root_module) + + root_module.end_section('ns3_module_tap_bridge') + root_module.begin_section('ns3_module_v4ping') + ns3_module_v4ping.register_methods(root_module) + + try: + import ns3_module_v4ping__local + except ImportError: + pass + else: + ns3_module_v4ping__local.register_methods(root_module) + + root_module.end_section('ns3_module_v4ping') + root_module.begin_section('ns3_module_static_routing') + ns3_module_static_routing.register_methods(root_module) + + try: + import ns3_module_static_routing__local + except ImportError: + pass + else: + ns3_module_static_routing__local.register_methods(root_module) + + root_module.end_section('ns3_module_static_routing') + root_module.begin_section('ns3_module_packet_sink') + ns3_module_packet_sink.register_methods(root_module) + + try: + import ns3_module_packet_sink__local + except ImportError: + pass + else: + ns3_module_packet_sink__local.register_methods(root_module) + + root_module.end_section('ns3_module_packet_sink') + root_module.begin_section('ns3_module_stats') + ns3_module_stats.register_methods(root_module) + + try: + import ns3_module_stats__local + except ImportError: + pass + else: + ns3_module_stats__local.register_methods(root_module) + + root_module.end_section('ns3_module_stats') + root_module.begin_section('ns3_module_onoff') + ns3_module_onoff.register_methods(root_module) + + try: + import ns3_module_onoff__local + except ImportError: + pass + else: + ns3_module_onoff__local.register_methods(root_module) + + root_module.end_section('ns3_module_onoff') root_module.begin_section('ns3_module_point_to_point') ns3_module_point_to_point.register_methods(root_module) @@ -593,17 +659,6 @@ def register_methods(root_module): ns3_module_internet_stack__local.register_methods(root_module) root_module.end_section('ns3_module_internet_stack') - root_module.begin_section('ns3_module_tap_bridge') - ns3_module_tap_bridge.register_methods(root_module) - - try: - import ns3_module_tap_bridge__local - except ImportError: - pass - else: - ns3_module_tap_bridge__local.register_methods(root_module) - - root_module.end_section('ns3_module_tap_bridge') root_module.begin_section('ns3_module_csma') ns3_module_csma.register_methods(root_module) @@ -615,83 +670,6 @@ def register_methods(root_module): ns3_module_csma__local.register_methods(root_module) root_module.end_section('ns3_module_csma') - root_module.begin_section('ns3_module_wifi') - ns3_module_wifi.register_methods(root_module) - - try: - import ns3_module_wifi__local - except ImportError: - pass - else: - ns3_module_wifi__local.register_methods(root_module) - - root_module.end_section('ns3_module_wifi') - root_module.begin_section('ns3_module_static_routing') - ns3_module_static_routing.register_methods(root_module) - - try: - import ns3_module_static_routing__local - except ImportError: - pass - else: - ns3_module_static_routing__local.register_methods(root_module) - - root_module.end_section('ns3_module_static_routing') - root_module.begin_section('ns3_module_v4ping') - ns3_module_v4ping.register_methods(root_module) - - try: - import ns3_module_v4ping__local - except ImportError: - pass - else: - ns3_module_v4ping__local.register_methods(root_module) - - root_module.end_section('ns3_module_v4ping') - root_module.begin_section('ns3_module_virtual_net_device') - ns3_module_virtual_net_device.register_methods(root_module) - - try: - import ns3_module_virtual_net_device__local - except ImportError: - pass - else: - ns3_module_virtual_net_device__local.register_methods(root_module) - - root_module.end_section('ns3_module_virtual_net_device') - root_module.begin_section('ns3_module_packet_sink') - ns3_module_packet_sink.register_methods(root_module) - - try: - import ns3_module_packet_sink__local - except ImportError: - pass - else: - ns3_module_packet_sink__local.register_methods(root_module) - - root_module.end_section('ns3_module_packet_sink') - root_module.begin_section('ns3_module_global_routing') - ns3_module_global_routing.register_methods(root_module) - - try: - import ns3_module_global_routing__local - except ImportError: - pass - else: - ns3_module_global_routing__local.register_methods(root_module) - - root_module.end_section('ns3_module_global_routing') - root_module.begin_section('ns3_module_stats') - ns3_module_stats.register_methods(root_module) - - try: - import ns3_module_stats__local - except ImportError: - pass - else: - ns3_module_stats__local.register_methods(root_module) - - root_module.end_section('ns3_module_stats') root_module.begin_section('ns3_module_list_routing') ns3_module_list_routing.register_methods(root_module) @@ -703,6 +681,28 @@ def register_methods(root_module): ns3_module_list_routing__local.register_methods(root_module) root_module.end_section('ns3_module_list_routing') + root_module.begin_section('ns3_module_virtual_net_device') + ns3_module_virtual_net_device.register_methods(root_module) + + try: + import ns3_module_virtual_net_device__local + except ImportError: + pass + else: + ns3_module_virtual_net_device__local.register_methods(root_module) + + root_module.end_section('ns3_module_virtual_net_device') + root_module.begin_section('ns3_module_wifi') + ns3_module_wifi.register_methods(root_module) + + try: + import ns3_module_wifi__local + except ImportError: + pass + else: + ns3_module_wifi__local.register_methods(root_module) + + root_module.end_section('ns3_module_wifi') root_module.begin_section('ns3_module_emu') ns3_module_emu.register_methods(root_module) @@ -725,17 +725,17 @@ def register_methods(root_module): ns3_module_bridge__local.register_methods(root_module) root_module.end_section('ns3_module_bridge') - root_module.begin_section('ns3_module_onoff') - ns3_module_onoff.register_methods(root_module) + root_module.begin_section('ns3_module_global_routing') + ns3_module_global_routing.register_methods(root_module) try: - import ns3_module_onoff__local + import ns3_module_global_routing__local except ImportError: pass else: - ns3_module_onoff__local.register_methods(root_module) + ns3_module_global_routing__local.register_methods(root_module) - root_module.end_section('ns3_module_onoff') + root_module.end_section('ns3_module_global_routing') root_module.begin_section('ns3_module_udp_echo') ns3_module_udp_echo.register_methods(root_module) @@ -747,17 +747,6 @@ def register_methods(root_module): ns3_module_udp_echo__local.register_methods(root_module) root_module.end_section('ns3_module_udp_echo') - root_module.begin_section('ns3_module_ping6') - ns3_module_ping6.register_methods(root_module) - - try: - import ns3_module_ping6__local - except ImportError: - pass - else: - ns3_module_ping6__local.register_methods(root_module) - - root_module.end_section('ns3_module_ping6') root_module.begin_section('ns3_module_nix_vector_routing') ns3_module_nix_vector_routing.register_methods(root_module) @@ -780,17 +769,6 @@ def register_methods(root_module): ns3_module_olsr__local.register_methods(root_module) root_module.end_section('ns3_module_olsr') - root_module.begin_section('ns3_module_flow_monitor') - ns3_module_flow_monitor.register_methods(root_module) - - try: - import ns3_module_flow_monitor__local - except ImportError: - pass - else: - ns3_module_flow_monitor__local.register_methods(root_module) - - root_module.end_section('ns3_module_flow_monitor') root_module.begin_section('ns3_module_radvd') ns3_module_radvd.register_methods(root_module) @@ -802,6 +780,28 @@ def register_methods(root_module): ns3_module_radvd__local.register_methods(root_module) root_module.end_section('ns3_module_radvd') + root_module.begin_section('ns3_module_ping6') + ns3_module_ping6.register_methods(root_module) + + try: + import ns3_module_ping6__local + except ImportError: + pass + else: + ns3_module_ping6__local.register_methods(root_module) + + root_module.end_section('ns3_module_ping6') + root_module.begin_section('ns3_module_flow_monitor') + ns3_module_flow_monitor.register_methods(root_module) + + try: + import ns3_module_flow_monitor__local + except ImportError: + pass + else: + ns3_module_flow_monitor__local.register_methods(root_module) + + root_module.end_section('ns3_module_flow_monitor') root_module.begin_section('ns3_module_mesh') ns3_module_mesh.register_methods(root_module) @@ -1039,17 +1039,6 @@ def register_functions(root_module): ns3_module_common__local.register_functions(root_module) root_module.end_section('ns3_module_common') - root_module.begin_section('ns3_module_node') - ns3_module_node.register_functions(root_module) - - try: - import ns3_module_node__local - except ImportError: - pass - else: - ns3_module_node__local.register_functions(root_module) - - root_module.end_section('ns3_module_node') root_module.begin_section('ns3_module_contrib') ns3_module_contrib.register_functions(root_module) @@ -1061,6 +1050,83 @@ def register_functions(root_module): ns3_module_contrib__local.register_functions(root_module) root_module.end_section('ns3_module_contrib') + root_module.begin_section('ns3_module_node') + ns3_module_node.register_functions(root_module) + + try: + import ns3_module_node__local + except ImportError: + pass + else: + ns3_module_node__local.register_functions(root_module) + + root_module.end_section('ns3_module_node') + root_module.begin_section('ns3_module_tap_bridge') + ns3_module_tap_bridge.register_functions(root_module) + + try: + import ns3_module_tap_bridge__local + except ImportError: + pass + else: + ns3_module_tap_bridge__local.register_functions(root_module) + + root_module.end_section('ns3_module_tap_bridge') + root_module.begin_section('ns3_module_v4ping') + ns3_module_v4ping.register_functions(root_module) + + try: + import ns3_module_v4ping__local + except ImportError: + pass + else: + ns3_module_v4ping__local.register_functions(root_module) + + root_module.end_section('ns3_module_v4ping') + root_module.begin_section('ns3_module_static_routing') + ns3_module_static_routing.register_functions(root_module) + + try: + import ns3_module_static_routing__local + except ImportError: + pass + else: + ns3_module_static_routing__local.register_functions(root_module) + + root_module.end_section('ns3_module_static_routing') + root_module.begin_section('ns3_module_packet_sink') + ns3_module_packet_sink.register_functions(root_module) + + try: + import ns3_module_packet_sink__local + except ImportError: + pass + else: + ns3_module_packet_sink__local.register_functions(root_module) + + root_module.end_section('ns3_module_packet_sink') + root_module.begin_section('ns3_module_stats') + ns3_module_stats.register_functions(root_module) + + try: + import ns3_module_stats__local + except ImportError: + pass + else: + ns3_module_stats__local.register_functions(root_module) + + root_module.end_section('ns3_module_stats') + root_module.begin_section('ns3_module_onoff') + ns3_module_onoff.register_functions(root_module) + + try: + import ns3_module_onoff__local + except ImportError: + pass + else: + ns3_module_onoff__local.register_functions(root_module) + + root_module.end_section('ns3_module_onoff') root_module.begin_section('ns3_module_point_to_point') ns3_module_point_to_point.register_functions(root_module) @@ -1083,17 +1149,6 @@ def register_functions(root_module): ns3_module_internet_stack__local.register_functions(root_module) root_module.end_section('ns3_module_internet_stack') - root_module.begin_section('ns3_module_tap_bridge') - ns3_module_tap_bridge.register_functions(root_module) - - try: - import ns3_module_tap_bridge__local - except ImportError: - pass - else: - ns3_module_tap_bridge__local.register_functions(root_module) - - root_module.end_section('ns3_module_tap_bridge') root_module.begin_section('ns3_module_csma') ns3_module_csma.register_functions(root_module) @@ -1105,83 +1160,6 @@ def register_functions(root_module): ns3_module_csma__local.register_functions(root_module) root_module.end_section('ns3_module_csma') - root_module.begin_section('ns3_module_wifi') - ns3_module_wifi.register_functions(root_module) - - try: - import ns3_module_wifi__local - except ImportError: - pass - else: - ns3_module_wifi__local.register_functions(root_module) - - root_module.end_section('ns3_module_wifi') - root_module.begin_section('ns3_module_static_routing') - ns3_module_static_routing.register_functions(root_module) - - try: - import ns3_module_static_routing__local - except ImportError: - pass - else: - ns3_module_static_routing__local.register_functions(root_module) - - root_module.end_section('ns3_module_static_routing') - root_module.begin_section('ns3_module_v4ping') - ns3_module_v4ping.register_functions(root_module) - - try: - import ns3_module_v4ping__local - except ImportError: - pass - else: - ns3_module_v4ping__local.register_functions(root_module) - - root_module.end_section('ns3_module_v4ping') - root_module.begin_section('ns3_module_virtual_net_device') - ns3_module_virtual_net_device.register_functions(root_module) - - try: - import ns3_module_virtual_net_device__local - except ImportError: - pass - else: - ns3_module_virtual_net_device__local.register_functions(root_module) - - root_module.end_section('ns3_module_virtual_net_device') - root_module.begin_section('ns3_module_packet_sink') - ns3_module_packet_sink.register_functions(root_module) - - try: - import ns3_module_packet_sink__local - except ImportError: - pass - else: - ns3_module_packet_sink__local.register_functions(root_module) - - root_module.end_section('ns3_module_packet_sink') - root_module.begin_section('ns3_module_global_routing') - ns3_module_global_routing.register_functions(root_module) - - try: - import ns3_module_global_routing__local - except ImportError: - pass - else: - ns3_module_global_routing__local.register_functions(root_module) - - root_module.end_section('ns3_module_global_routing') - root_module.begin_section('ns3_module_stats') - ns3_module_stats.register_functions(root_module) - - try: - import ns3_module_stats__local - except ImportError: - pass - else: - ns3_module_stats__local.register_functions(root_module) - - root_module.end_section('ns3_module_stats') root_module.begin_section('ns3_module_list_routing') ns3_module_list_routing.register_functions(root_module) @@ -1193,6 +1171,28 @@ def register_functions(root_module): ns3_module_list_routing__local.register_functions(root_module) root_module.end_section('ns3_module_list_routing') + root_module.begin_section('ns3_module_virtual_net_device') + ns3_module_virtual_net_device.register_functions(root_module) + + try: + import ns3_module_virtual_net_device__local + except ImportError: + pass + else: + ns3_module_virtual_net_device__local.register_functions(root_module) + + root_module.end_section('ns3_module_virtual_net_device') + root_module.begin_section('ns3_module_wifi') + ns3_module_wifi.register_functions(root_module) + + try: + import ns3_module_wifi__local + except ImportError: + pass + else: + ns3_module_wifi__local.register_functions(root_module) + + root_module.end_section('ns3_module_wifi') root_module.begin_section('ns3_module_emu') ns3_module_emu.register_functions(root_module) @@ -1215,17 +1215,17 @@ def register_functions(root_module): ns3_module_bridge__local.register_functions(root_module) root_module.end_section('ns3_module_bridge') - root_module.begin_section('ns3_module_onoff') - ns3_module_onoff.register_functions(root_module) + root_module.begin_section('ns3_module_global_routing') + ns3_module_global_routing.register_functions(root_module) try: - import ns3_module_onoff__local + import ns3_module_global_routing__local except ImportError: pass else: - ns3_module_onoff__local.register_functions(root_module) + ns3_module_global_routing__local.register_functions(root_module) - root_module.end_section('ns3_module_onoff') + root_module.end_section('ns3_module_global_routing') root_module.begin_section('ns3_module_udp_echo') ns3_module_udp_echo.register_functions(root_module) @@ -1237,17 +1237,6 @@ def register_functions(root_module): ns3_module_udp_echo__local.register_functions(root_module) root_module.end_section('ns3_module_udp_echo') - root_module.begin_section('ns3_module_ping6') - ns3_module_ping6.register_functions(root_module) - - try: - import ns3_module_ping6__local - except ImportError: - pass - else: - ns3_module_ping6__local.register_functions(root_module) - - root_module.end_section('ns3_module_ping6') root_module.begin_section('ns3_module_nix_vector_routing') ns3_module_nix_vector_routing.register_functions(root_module) @@ -1270,17 +1259,6 @@ def register_functions(root_module): ns3_module_olsr__local.register_functions(root_module) root_module.end_section('ns3_module_olsr') - root_module.begin_section('ns3_module_flow_monitor') - ns3_module_flow_monitor.register_functions(root_module) - - try: - import ns3_module_flow_monitor__local - except ImportError: - pass - else: - ns3_module_flow_monitor__local.register_functions(root_module) - - root_module.end_section('ns3_module_flow_monitor') root_module.begin_section('ns3_module_radvd') ns3_module_radvd.register_functions(root_module) @@ -1292,6 +1270,28 @@ def register_functions(root_module): ns3_module_radvd__local.register_functions(root_module) root_module.end_section('ns3_module_radvd') + root_module.begin_section('ns3_module_ping6') + ns3_module_ping6.register_functions(root_module) + + try: + import ns3_module_ping6__local + except ImportError: + pass + else: + ns3_module_ping6__local.register_functions(root_module) + + root_module.end_section('ns3_module_ping6') + root_module.begin_section('ns3_module_flow_monitor') + ns3_module_flow_monitor.register_functions(root_module) + + try: + import ns3_module_flow_monitor__local + except ImportError: + pass + else: + ns3_module_flow_monitor__local.register_functions(root_module) + + root_module.end_section('ns3_module_flow_monitor') root_module.begin_section('ns3_module_mesh') ns3_module_mesh.register_functions(root_module) From 1668a400c9624cafc3b89ac35d9db1780ac52f96 Mon Sep 17 00:00:00 2001 From: Mathieu Lacage Date: Thu, 12 Nov 2009 13:01:01 +0100 Subject: [PATCH 02/29] replace RefCountBase with SimpleRefCount<> to avoid duplicate refcounting implementations. --- src/applications/radvd/radvd-interface.h | 4 +- src/applications/radvd/radvd-prefix.h | 3 +- src/common/ascii-writer.h | 4 +- src/common/packet.cc | 30 +---- src/common/packet.h | 6 +- src/contrib/flow-monitor/flow-classifier.cc | 2 + src/contrib/flow-monitor/flow-classifier.h | 5 +- src/contrib/flow-monitor/flow-probe.h | 6 +- src/contrib/flow-monitor/ipv4-flow-probe.h | 2 +- src/core/attribute.h | 8 +- src/core/callback.h | 17 +-- src/core/ref-count-base.cc | 46 +------- src/core/ref-count-base.h | 64 ++--------- src/core/simple-ref-count.h | 103 ++++++++++++++++++ src/core/system-thread.h | 35 +----- src/core/trace-source-accessor.cc | 15 --- src/core/trace-source-accessor.h | 7 +- src/core/unix-system-thread.cc | 3 +- src/core/wscript | 1 + .../mesh/dot11s/ie-dot11s-beacon-timing.h | 2 +- src/devices/mesh/dot11s/ie-dot11s-preq.h | 2 +- .../mesh/mesh-wifi-interface-mac-plugin.h | 4 +- .../mesh/wifi-information-element-vector.cc | 4 + .../mesh/wifi-information-element-vector.h | 4 +- src/devices/wifi/interference-helper.h | 6 +- src/node/ipv4-route.h | 8 +- src/node/ipv6-route.h | 6 +- src/node/packetbb.cc | 74 +------------ src/node/packetbb.h | 35 +----- src/simulator/event-impl.cc | 4 +- src/simulator/event-impl.h | 27 +---- 31 files changed, 177 insertions(+), 360 deletions(-) create mode 100644 src/core/simple-ref-count.h diff --git a/src/applications/radvd/radvd-interface.h b/src/applications/radvd/radvd-interface.h index a53175cef..046c9b6e4 100644 --- a/src/applications/radvd/radvd-interface.h +++ b/src/applications/radvd/radvd-interface.h @@ -22,7 +22,7 @@ #define RADVD_INTERFACE_H #include - +#include "ns3/simple-ref-count.h" #include "radvd-prefix.h" namespace ns3 @@ -33,7 +33,7 @@ namespace ns3 * \class RadvdInterface * \brief Radvd interface configuration. */ -class RadvdInterface : public RefCountBase +class RadvdInterface : public SimpleRefCount { public: /** diff --git a/src/applications/radvd/radvd-prefix.h b/src/applications/radvd/radvd-prefix.h index 2c1433e84..70b02806a 100644 --- a/src/applications/radvd/radvd-prefix.h +++ b/src/applications/radvd/radvd-prefix.h @@ -24,6 +24,7 @@ #include #include "ns3/ipv6-address.h" +#include "ns3/simple-ref-count.h" namespace ns3 { @@ -33,7 +34,7 @@ namespace ns3 * \class RadvdPrefix * \brief Router prefix for radvd application. */ -class RadvdPrefix : public RefCountBase +class RadvdPrefix : public SimpleRefCount { public: /** diff --git a/src/common/ascii-writer.h b/src/common/ascii-writer.h index 03cdc7cf4..648832438 100644 --- a/src/common/ascii-writer.h +++ b/src/common/ascii-writer.h @@ -23,7 +23,7 @@ #include #include -#include "ns3/ref-count-base.h" +#include "ns3/simple-ref-count.h" #include "ns3/ptr.h" namespace ns3 { @@ -35,7 +35,7 @@ class Packet; * * \brief Ascii output */ -class AsciiWriter : public RefCountBase +class AsciiWriter : public SimpleRefCount { public: static Ptr Get (std::ostream &os); diff --git a/src/common/packet.cc b/src/common/packet.cc index 9741662c4..244c26e6f 100644 --- a/src/common/packet.cc +++ b/src/common/packet.cc @@ -112,21 +112,6 @@ PacketTagIterator::Item::GetTag (Tag &tag) const } -void -Packet::Ref (void) const -{ - m_refCount++; -} -void -Packet::Unref (void) const -{ - m_refCount--; - if (m_refCount == 0) - { - delete this; - } -} - Ptr Packet::Copy (void) const { @@ -141,8 +126,7 @@ Packet::Packet () m_byteTagList (), m_packetTagList (), m_metadata (m_globalUid, 0), - m_nixVector (0), - m_refCount (1) + m_nixVector (0) { m_globalUid++; } @@ -151,8 +135,7 @@ Packet::Packet (const Packet &o) : m_buffer (o.m_buffer), m_byteTagList (o.m_byteTagList), m_packetTagList (o.m_packetTagList), - m_metadata (o.m_metadata), - m_refCount (1) + m_metadata (o.m_metadata) { o.m_nixVector ? m_nixVector = o.m_nixVector->Copy () : m_nixVector = 0; @@ -179,8 +162,7 @@ Packet::Packet (uint32_t size) m_byteTagList (), m_packetTagList (), m_metadata (m_globalUid, size), - m_nixVector (0), - m_refCount (1) + m_nixVector (0) { m_globalUid++; } @@ -189,8 +171,7 @@ Packet::Packet (uint8_t const*buffer, uint32_t size) m_byteTagList (), m_packetTagList (), m_metadata (m_globalUid, size), - m_nixVector (0), - m_refCount (1) + m_nixVector (0) { m_globalUid++; m_buffer.AddAtStart (size); @@ -204,8 +185,7 @@ Packet::Packet (const Buffer &buffer, const ByteTagList &byteTagList, m_byteTagList (byteTagList), m_packetTagList (packetTagList), m_metadata (metadata), - m_nixVector (0), - m_refCount (1) + m_nixVector (0) {} Ptr diff --git a/src/common/packet.h b/src/common/packet.h index 87add7437..77841235f 100644 --- a/src/common/packet.h +++ b/src/common/packet.h @@ -198,12 +198,9 @@ private: * The performance aspects of the Packet API are discussed in * \ref packetperf */ -class Packet +class Packet : public SimpleRefCount { public: - void Ref (void) const; - void Unref (void) const; - Ptr Copy (void) const; /** @@ -540,7 +537,6 @@ private: /* Please see comments above about nix-vector */ Ptr m_nixVector; - mutable uint32_t m_refCount; static uint32_t m_globalUid; }; diff --git a/src/contrib/flow-monitor/flow-classifier.cc b/src/contrib/flow-monitor/flow-classifier.cc index fb184101f..287e5bfbe 100644 --- a/src/contrib/flow-monitor/flow-classifier.cc +++ b/src/contrib/flow-monitor/flow-classifier.cc @@ -28,6 +28,8 @@ FlowClassifier::FlowClassifier () { } +FlowClassifier::~FlowClassifier () +{} FlowId FlowClassifier::GetNewFlowId () diff --git a/src/contrib/flow-monitor/flow-classifier.h b/src/contrib/flow-monitor/flow-classifier.h index fca1c865c..5bf08fd2a 100644 --- a/src/contrib/flow-monitor/flow-classifier.h +++ b/src/contrib/flow-monitor/flow-classifier.h @@ -21,7 +21,7 @@ #ifndef __FLOW_CLASSIFIER_H__ #define __FLOW_CLASSIFIER_H__ -#include "ns3/ref-count-base.h" +#include "ns3/simple-ref-count.h" #include namespace ns3 { @@ -39,13 +39,14 @@ typedef uint32_t FlowPacketId; /// statistics reference only those abstract identifiers in order to /// keep the core architecture generic and not tied down to any /// particular flow capture method or classification system. -class FlowClassifier : public RefCountBase +class FlowClassifier : public SimpleRefCount { FlowId m_lastNewFlowId; public: FlowClassifier (); + virtual ~FlowClassifier (); virtual void SerializeToXmlStream (std::ostream &os, int indent) const = 0; diff --git a/src/contrib/flow-monitor/flow-probe.h b/src/contrib/flow-monitor/flow-probe.h index f5857a0e6..faacd1e37 100644 --- a/src/contrib/flow-monitor/flow-probe.h +++ b/src/contrib/flow-monitor/flow-probe.h @@ -24,7 +24,7 @@ #include #include -#include "ns3/ref-count-base.h" +#include "ns3/simple-ref-count.h" #include "ns3/flow-classifier.h" #include "ns3/nstime.h" @@ -36,14 +36,14 @@ class FlowMonitor; /// in a specific point of the simulated space, report those events to /// the global FlowMonitor, and collect its own flow statistics /// regarding only the packets that pass through that probe. -class FlowProbe : public RefCountBase +class FlowProbe : public SimpleRefCount { protected: FlowProbe (Ptr flowMonitor); public: - ~FlowProbe (); + virtual ~FlowProbe (); struct FlowStats { diff --git a/src/contrib/flow-monitor/ipv4-flow-probe.h b/src/contrib/flow-monitor/ipv4-flow-probe.h index 686516002..5bde99f63 100644 --- a/src/contrib/flow-monitor/ipv4-flow-probe.h +++ b/src/contrib/flow-monitor/ipv4-flow-probe.h @@ -41,7 +41,7 @@ class Ipv4FlowProbe : public FlowProbe public: Ipv4FlowProbe (Ptr monitor, Ptr classifier, Ptr node); - ~Ipv4FlowProbe (); + virtual ~Ipv4FlowProbe (); /// \brief enumeration of possible reasons why a packet may be dropped enum DropReason diff --git a/src/core/attribute.h b/src/core/attribute.h index 2ba5ab1f3..dd1a5cd05 100644 --- a/src/core/attribute.h +++ b/src/core/attribute.h @@ -23,7 +23,7 @@ #include #include #include "ptr.h" -#include "ref-count-base.h" +#include "simple-ref-count.h" namespace ns3 { @@ -48,7 +48,7 @@ class ObjectBase; * Most subclasses of this base class are implemented by the * ATTRIBUTE_HELPER_* macros. */ -class AttributeValue : public RefCountBase +class AttributeValue : public SimpleRefCount { public: AttributeValue (); @@ -94,7 +94,7 @@ public: * of this base class are usually provided through the MakeAccessorHelper * template functions, hidden behind an ATTRIBUTE_HELPER_* macro. */ -class AttributeAccessor : public RefCountBase +class AttributeAccessor : public SimpleRefCount { public: AttributeAccessor (); @@ -146,7 +146,7 @@ public: * Most subclasses of this base class are implemented by the * ATTRIBUTE_HELPER_HEADER and ATTRIBUTE_HELPER_CPP macros. */ -class AttributeChecker : public RefCountBase +class AttributeChecker : public SimpleRefCount { public: AttributeChecker (); diff --git a/src/core/callback.h b/src/core/callback.h index eb4729a39..e09de6750 100644 --- a/src/core/callback.h +++ b/src/core/callback.h @@ -27,6 +27,7 @@ #include "type-traits.h" #include "attribute.h" #include "attribute-helper.h" +#include "simple-ref-count.h" #include namespace ns3 { @@ -72,25 +73,11 @@ struct CallbackTraits } }; -class CallbackImplBase +class CallbackImplBase : public SimpleRefCount { public: - CallbackImplBase () - : m_count (1) {} virtual ~CallbackImplBase () {} - void Ref (void) const { - m_count++; - } - void Unref (void) const { - m_count--; - if (m_count == 0) { - delete this; - } - } - uint32_t GetReferenceCount (void) const { return m_count; } virtual bool IsEqual (Ptr other) const = 0; -private: - mutable uint32_t m_count; }; // declare the CallbackImpl class diff --git a/src/core/ref-count-base.cc b/src/core/ref-count-base.cc index 06abf7c22..c89cc6a83 100644 --- a/src/core/ref-count-base.cc +++ b/src/core/ref-count-base.cc @@ -1,52 +1,8 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ -/* - * Copyright (c) 2007 Georgia Tech Research Corporation - * - * 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: George Riley - * Adapted from original code in object.h by: - * Authors: Gustavo Carneiro , - * Mathieu Lacage - */ - #include "ref-count-base.h" namespace ns3 { -RefCountBase::RefCountBase() - : m_count (1) -{ -} - -RefCountBase::RefCountBase (const RefCountBase &o) - : m_count (1) +RefCountBase::~RefCountBase () {} -RefCountBase & -RefCountBase::operator = (const RefCountBase &o) -{ - return *this; -} - -RefCountBase::~RefCountBase () -{ -} - -uint32_t -RefCountBase::GetReferenceCount (void) const -{ - return m_count; -} } // namespace ns3 diff --git a/src/core/ref-count-base.h b/src/core/ref-count-base.h index 08e9946fa..3663698ca 100644 --- a/src/core/ref-count-base.h +++ b/src/core/ref-count-base.h @@ -23,74 +23,26 @@ #ifndef __REF_COUNT_BASE_H__ #define __REF_COUNT_BASE_H__ -#include +#include "simple-ref-count.h" namespace ns3 { /** - * \brief a base class that provides implementations of reference counting - * operations. - * - * A base class that provides implementations of reference counting - * operations, for classes that wish to use the templatized smart - * pointer for memory management but that do not wish to derive from - * class ns3::Object. + * \brief A deprecated way to get reference-counting powers * + * Users who wish to use reference counting for a class of their own should use + * instead the template \ref ns3::SimpleRefCount. This class is maintained + * purely for compatibility to avoid breaking the code of users. */ -class RefCountBase +class RefCountBase : public SimpleRefCount { public: - RefCountBase(); - RefCountBase (const RefCountBase &o); - RefCountBase &operator = (const RefCountBase &o); - virtual ~RefCountBase (); /** - * Increment the reference count. This method should not be called - * by user code. RefCountBase instances are expected to be used in - * conjunction with the Ptr template which would make calling Ref - * unecessary and dangerous. + * This only thing this class does it declare a virtual destructor */ - inline void Ref (void) const; - /** - * Decrement the reference count. This method should not be called - * by user code. RefCountBase instances are expected to be used in - * conjunction with the Ptr template which would make calling Ref - * unecessary and dangerous. - */ - inline void Unref (void) const; - - /** - * Get the reference count of the object. Normally not needed; for language bindings. - */ - uint32_t GetReferenceCount (void) const; - -private: - // Note we make this mutable so that the const methods can still - // change it. - mutable uint32_t m_count; // Reference count + virtual ~RefCountBase () = 0; }; } // namespace ns3 -namespace ns3 { - -// Implementation of the in-line methods -void -RefCountBase::Ref (void) const -{ - m_count++; -} - -void -RefCountBase::Unref (void) const -{ - m_count--; - if (m_count == 0) - { // All references removed, ok to delete - delete this; - } -} - -} // namespace ns3 - #endif /* __REF_COUNT_BASE_H__*/ diff --git a/src/core/simple-ref-count.h b/src/core/simple-ref-count.h new file mode 100644 index 000000000..69625968e --- /dev/null +++ b/src/core/simple-ref-count.h @@ -0,0 +1,103 @@ +/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ +/* + * Copyright (c) 2007 Georgia Tech Research Corporation, 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 + * + * Authors: George Riley + * Gustavo Carneiro , + * Mathieu Lacage + */ +#ifndef SIMPLE_REF_COUNT_H +#define SIMPLE_REF_COUNT_H + +#include "empty.h" +#include + +namespace ns3 { + +/** + * \brief A template-based reference counting class + * + * This template can be used to give reference-counting powers + * to a class. This template does not require this class to + * have a virtual destructor or no parent class. + * + * Note: if you are moving to this template from the RefCountBase class, + * you need to be careful to mark appropriately your destructor virtual + * if needed. i.e., if your class has subclasses, _do_ mark your destructor + * virtual. + * + * \internal + * Note: we rely on the fairly common EBCO (empty base class optimization) + * to get rid of the empty parent when the user does not provide + * a non-trivial parent. + */ +template +class SimpleRefCount : public PARENT +{ +public: + SimpleRefCount () + : m_count (1) + {} + SimpleRefCount (const SimpleRefCount &o) + : m_count (1) + {} + SimpleRefCount &operator = (const SimpleRefCount &o) + { + return *this; + } + /** + * Increment the reference count. This method should not be called + * by user code. SimpleRefCount instances are expected to be used in + * conjunction with the Ptr template which would make calling Ref + * unecessary and dangerous. + */ + inline void Ref (void) const + { + m_count++; + } + /** + * Decrement the reference count. This method should not be called + * by user code. SimpleRefCount instances are expected to be used in + * conjunction with the Ptr template which would make calling Ref + * unecessary and dangerous. + */ + inline void Unref (void) const + { + m_count--; + if (m_count == 0) + { + delete static_cast (const_cast (this)); + } + } + + /** + * Get the reference count of the object. + * Normally not needed; for language bindings. + */ + uint32_t GetReferenceCount (void) const + { + return m_count; + } + +private: + // Note we make this mutable so that the const methods can still + // change it. + mutable uint32_t m_count; +}; + +} // namespace ns3 + +#endif /* SIMPLE_REF_COUNT_H */ diff --git a/src/core/system-thread.h b/src/core/system-thread.h index 05b3108dc..c97285197 100644 --- a/src/core/system-thread.h +++ b/src/core/system-thread.h @@ -42,7 +42,7 @@ class SystemThreadImpl; * * Synchronization between threads is provided via the SystemMutex class. */ -class SystemThread +class SystemThread : public SimpleRefCount { public: /** @@ -115,22 +115,6 @@ public: */ ~SystemThread(); - /** - * Increment the reference count. This method should not be called - * by user code. Object instances are expected to be used in conjunction - * of the Ptr template which would make calling Ref unecessary and - * dangerous. - */ - inline void Ref (void) const; - - /** - * Decrement the reference count. This method should not be called - * by user code. Object instances are expected to be used in conjunction - * of the Ptr template which would make calling Ref unecessary and - * dangerous. - */ - inline void Unref (void) const; - /** * @brief Start a thread of execution, running the provided callback. */ @@ -181,26 +165,9 @@ public: private: SystemThreadImpl * m_impl; - mutable uint32_t m_count; bool m_break; }; - void -SystemThread::Ref (void) const -{ - m_count++; -} - - void -SystemThread::Unref (void) const -{ - m_count--; - if (m_count == 0) - { - delete this; - } -} - } //namespace ns3 #endif /* SYSTEM_THREAD_H */ diff --git a/src/core/trace-source-accessor.cc b/src/core/trace-source-accessor.cc index 841e88442..7ffe93415 100644 --- a/src/core/trace-source-accessor.cc +++ b/src/core/trace-source-accessor.cc @@ -22,23 +22,8 @@ namespace ns3 { TraceSourceAccessor::TraceSourceAccessor () - : m_count (1) {} TraceSourceAccessor::~TraceSourceAccessor () {} -void -TraceSourceAccessor::Ref (void) const -{ - m_count++; -} -void -TraceSourceAccessor::Unref (void) const -{ - m_count--; - if (m_count == 0) - { - delete this; - } -} } // namespace ns3 diff --git a/src/core/trace-source-accessor.h b/src/core/trace-source-accessor.h index e85f260ca..b86224e26 100644 --- a/src/core/trace-source-accessor.h +++ b/src/core/trace-source-accessor.h @@ -23,6 +23,7 @@ #include #include "callback.h" #include "ptr.h" +#include "simple-ref-count.h" namespace ns3 { @@ -36,13 +37,11 @@ class ObjectBase; * This class abstracts the kind of trace source to which we want to connect * and provides services to Connect and Disconnect a sink to a trace source. */ -class TraceSourceAccessor +class TraceSourceAccessor : public SimpleRefCount { public: TraceSourceAccessor (); virtual ~TraceSourceAccessor (); - void Ref (void) const; - void Unref (void) const; /** * \param obj the object instance which contains the target trace source. @@ -66,8 +65,6 @@ public: * \param cb the callback to disconnect from the target trace source. */ virtual bool Disconnect (ObjectBase *obj, std::string context, const CallbackBase &cb) const = 0; -private: - mutable uint32_t m_count; }; /** diff --git a/src/core/unix-system-thread.cc b/src/core/unix-system-thread.cc index 16eb5ff43..676d4d8e0 100644 --- a/src/core/unix-system-thread.cc +++ b/src/core/unix-system-thread.cc @@ -141,8 +141,7 @@ SystemThreadImpl::DoRun (void *arg) // class above. // SystemThread::SystemThread (Callback callback) - : m_impl (new SystemThreadImpl (callback)), - m_count (1) + : m_impl (new SystemThreadImpl (callback)) { NS_LOG_FUNCTION_NOARGS (); } diff --git a/src/core/wscript b/src/core/wscript index 40f146858..6144afd44 100644 --- a/src/core/wscript +++ b/src/core/wscript @@ -90,6 +90,7 @@ def build(bld): 'callback.h', 'object-base.h', 'ref-count-base.h', + 'simple-ref-count.h', 'type-id.h', 'attribute-list.h', 'ptr.h', diff --git a/src/devices/mesh/dot11s/ie-dot11s-beacon-timing.h b/src/devices/mesh/dot11s/ie-dot11s-beacon-timing.h index 8d4c404e2..e7d35995f 100644 --- a/src/devices/mesh/dot11s/ie-dot11s-beacon-timing.h +++ b/src/devices/mesh/dot11s/ie-dot11s-beacon-timing.h @@ -31,7 +31,7 @@ namespace dot11s { * \ingroup dot11s * \brief Describes one unit of beacon timing element */ -class IeBeaconTimingUnit : public RefCountBase +class IeBeaconTimingUnit : public SimpleRefCount { public: IeBeaconTimingUnit (); diff --git a/src/devices/mesh/dot11s/ie-dot11s-preq.h b/src/devices/mesh/dot11s/ie-dot11s-preq.h index 8471f6673..74df22d46 100644 --- a/src/devices/mesh/dot11s/ie-dot11s-preq.h +++ b/src/devices/mesh/dot11s/ie-dot11s-preq.h @@ -33,7 +33,7 @@ namespace dot11s { * \brief Describes an address unit in PREQ information element * See 7.3.2.96 for more details */ -class DestinationAddressUnit : public RefCountBase +class DestinationAddressUnit : public SimpleRefCount { public: DestinationAddressUnit (); diff --git a/src/devices/mesh/mesh-wifi-interface-mac-plugin.h b/src/devices/mesh/mesh-wifi-interface-mac-plugin.h index e064e482d..473be36ad 100644 --- a/src/devices/mesh/mesh-wifi-interface-mac-plugin.h +++ b/src/devices/mesh/mesh-wifi-interface-mac-plugin.h @@ -25,7 +25,7 @@ #include "ns3/packet.h" #include "ns3/mac48-address.h" #include "ns3/mesh-wifi-beacon.h" -#include "ns3/ref-count-base.h" +#include "ns3/simple-ref-count.h" namespace ns3 { @@ -38,7 +38,7 @@ class MeshWifiInterfaceMac; * * TODO: plugins description */ -class MeshWifiInterfaceMacPlugin : public RefCountBase +class MeshWifiInterfaceMacPlugin : public SimpleRefCount { public: /// This is for subclasses diff --git a/src/devices/mesh/wifi-information-element-vector.cc b/src/devices/mesh/wifi-information-element-vector.cc index 2e7b82b46..c779e3b58 100644 --- a/src/devices/mesh/wifi-information-element-vector.cc +++ b/src/devices/mesh/wifi-information-element-vector.cc @@ -36,6 +36,10 @@ #include "dot11s/ie-dot11s-rann.h" namespace ns3 { + +WifiInformationElement::~WifiInformationElement () +{} + bool operator< (WifiInformationElement const & a, WifiInformationElement const & b) { diff --git a/src/devices/mesh/wifi-information-element-vector.h b/src/devices/mesh/wifi-information-element-vector.h index e6506c58c..9e1725316 100644 --- a/src/devices/mesh/wifi-information-element-vector.h +++ b/src/devices/mesh/wifi-information-element-vector.h @@ -23,6 +23,7 @@ #define IE_VECTOR_H #include "ns3/header.h" +#include "ns3/simple-ref-count.h" namespace ns3 { class Packet; @@ -79,9 +80,10 @@ enum WifiElementId { * Element ID as defined in this standard. The Length field specifies the number of octets in the Information * field. */ -class WifiInformationElement : public RefCountBase +class WifiInformationElement : public SimpleRefCount { public: + virtual ~WifiInformationElement (); ///\name Each subclass must implement //\{ virtual void Print (std::ostream &os) const = 0; diff --git a/src/devices/wifi/interference-helper.h b/src/devices/wifi/interference-helper.h index 20caa6472..1409b5ceb 100644 --- a/src/devices/wifi/interference-helper.h +++ b/src/devices/wifi/interference-helper.h @@ -27,7 +27,7 @@ #include "wifi-preamble.h" #include "wifi-phy-standard.h" #include "ns3/nstime.h" -#include "ns3/ref-count-base.h" +#include "ns3/simple-ref-count.h" namespace ns3 { @@ -36,13 +36,13 @@ class ErrorRateModel; class InterferenceHelper { public: - class Event : public RefCountBase + class Event : public SimpleRefCount { public: Event (uint32_t size, WifiMode payloadMode, enum WifiPreamble preamble, Time duration, double rxPower); - virtual ~Event (); + ~Event (); Time GetDuration (void) const; Time GetStartTime (void) const; diff --git a/src/node/ipv4-route.h b/src/node/ipv4-route.h index d58f9bb87..db89413e0 100644 --- a/src/node/ipv4-route.h +++ b/src/node/ipv4-route.h @@ -23,7 +23,7 @@ #include #include -#include "ns3/ref-count-base.h" +#include "ns3/simple-ref-count.h" #include "ipv4-address.h" namespace ns3 { @@ -38,7 +38,8 @@ class NetDevice; * This is a reference counted object. In the future, we will add other * entries from struct dst_entry, struct rtable, and struct dst_ops as needed. */ -class Ipv4Route : public RefCountBase { +class Ipv4Route : public SimpleRefCount +{ public: Ipv4Route (); @@ -103,7 +104,8 @@ std::ostream& operator<< (std::ostream& os, Ipv4Route const& route); * * \brief Ipv4 multicast route cache entry (similar to Linux struct mfc_cache) */ -class Ipv4MulticastRoute : public RefCountBase { +class Ipv4MulticastRoute : public SimpleRefCount +{ public: Ipv4MulticastRoute (); diff --git a/src/node/ipv6-route.h b/src/node/ipv6-route.h index 0b7c37ec7..c7554f225 100644 --- a/src/node/ipv6-route.h +++ b/src/node/ipv6-route.h @@ -25,7 +25,7 @@ #include #include -#include "ns3/ref-count-base.h" +#include "ns3/simple-ref-count.h" #include "ipv6-address.h" @@ -39,7 +39,7 @@ class NetDevice; * \class Ipv6Route * \brief IPv6 route cache entry. */ -class Ipv6Route : public RefCountBase +class Ipv6Route : public SimpleRefCount { public: /** @@ -129,7 +129,7 @@ std::ostream& operator<< (std::ostream& os, Ipv6Route const& route); * \class Ipv6MulticastRoute * \brief IPv6 multicast route entry. */ -class Ipv6MulticastRoute : public RefCountBase +class Ipv6MulticastRoute : public SimpleRefCount { public: /** diff --git a/src/node/packetbb.cc b/src/node/packetbb.cc index 27292f253..67bde24cf 100644 --- a/src/node/packetbb.cc +++ b/src/node/packetbb.cc @@ -497,7 +497,6 @@ PbbAddressTlvBlock::operator!= (const PbbAddressTlvBlock &other) const PbbPacket::PbbPacket (void) { - m_refCount = 1; m_version = VERSION; m_hasseqnum = false; } @@ -746,21 +745,6 @@ PbbPacket::MessageClear (void) m_messageList.clear (); } -void -PbbPacket::Ref (void) const -{ - m_refCount++; -} - -void -PbbPacket::Unref (void) const -{ - m_refCount--; - if (m_refCount == 0) - { - delete this; - } -} TypeId PbbPacket::GetTypeId (void) @@ -947,7 +931,6 @@ PbbPacket::operator!= (const PbbPacket &other) const PbbMessage::PbbMessage () { - m_refCount = 1; /* Default to IPv4 */ m_addrSize = IPV4; m_hasOriginatorAddress = false; @@ -1274,22 +1257,6 @@ PbbMessage::AddressBlockClear (void) return m_addressBlockList.clear(); } -void -PbbMessage::Ref (void) const -{ - m_refCount++; -} - -void -PbbMessage::Unref (void) const -{ - m_refCount--; - if (m_refCount == 0) - { - delete this; - } -} - uint32_t PbbMessage::GetSerializedSize (void) const { @@ -1699,13 +1666,10 @@ PbbMessageIpv6::AddressBlockDeserialize (Buffer::Iterator &start) const /* End PbbMessageIpv6 Class */ PbbAddressBlock::PbbAddressBlock () -{ - m_refCount = 1; -} +{} PbbAddressBlock::~PbbAddressBlock () -{ -} +{} /* Manipulating the address block */ @@ -2002,23 +1966,6 @@ PbbAddressBlock::TlvClear (void) { m_addressTlvList.Clear(); } - -void -PbbAddressBlock::Ref (void) const -{ - m_refCount++; -} - -void -PbbAddressBlock::Unref (void) const -{ - m_refCount--; - if (m_refCount == 0) - { - delete this; - } -} - uint32_t PbbAddressBlock::GetSerializedSize (void) const { @@ -2448,7 +2395,6 @@ PbbAddressBlockIpv6::PrintAddress (std::ostream &os, ConstAddressIterator iter) PbbTlv::PbbTlv (void) { - m_refCount = 1; m_hasTypeExt = false; m_hasIndexStart = false; m_hasIndexStop = false; @@ -2573,22 +2519,6 @@ PbbTlv::HasValue (void) const return m_hasValue; } -void -PbbTlv::Ref (void) const -{ - m_refCount++; -} - -void -PbbTlv::Unref (void) const -{ - m_refCount--; - if (m_refCount == 0) - { - delete this; - } -} - uint32_t PbbTlv::GetSerializedSize (void) const { diff --git a/src/node/packetbb.h b/src/node/packetbb.h index 1ee3014dc..6d73df481 100644 --- a/src/node/packetbb.h +++ b/src/node/packetbb.h @@ -31,6 +31,7 @@ #include "ns3/address.h" #include "ns3/header.h" #include "ns3/buffer.h" +#include "ns3/simple-ref-count.h" namespace ns3 { @@ -360,7 +361,7 @@ private: * * See: http://tools.ietf.org/html/rfc5444 for details. */ -class PbbPacket : public Header +class PbbPacket : public SimpleRefCount { public: typedef std::list< Ptr >::iterator TlvIterator; @@ -595,10 +596,6 @@ public: */ void MessageClear (void); - /* Smart pointer methods */ - void Ref (void) const; - void Unref (void) const; - /* Methods implemented by all headers */ static TypeId GetTypeId (void); virtual TypeId GetInstanceTypeId (void) const; @@ -644,8 +641,6 @@ private: bool m_hasseqnum; uint16_t m_seqnum; - - mutable uint32_t m_refCount; }; /** @@ -655,7 +650,7 @@ private: * virtual base class, when creating a message, you should instantiate either * PbbMessageIpv4 or PbbMessageIpv6. */ -class PbbMessage +class PbbMessage : public SimpleRefCount { public: typedef std::list< Ptr >::iterator TlvIterator; @@ -959,10 +954,6 @@ public: */ void AddressBlockClear (void); - /* Smart pointer methods */ - void Ref (void) const; - void Unref (void) const; - /** * \brief Deserializes a message, returning the correct object depending on * whether it is an IPv4 message or an IPv6 message. @@ -1048,8 +1039,6 @@ private: bool m_hasSequenceNumber; uint16_t m_sequenceNumber; - - mutable uint32_t m_refCount; }; /** @@ -1098,7 +1087,7 @@ protected: * This is a pure virtual base class, when creating address blocks, you should * instantiate either PbbAddressBlockIpv4 or PbbAddressBlockIpv6. */ -class PbbAddressBlock +class PbbAddressBlock : public SimpleRefCount { public: typedef std::list< Address >::iterator AddressIterator; @@ -1412,10 +1401,6 @@ public: */ void TlvClear (void); - /* Smart pointer methods */ - void Ref (void) const; - void Unref (void) const; - /** * \return The size (in bytes) needed to serialize this address block. */ @@ -1475,8 +1460,6 @@ private: std::list
m_addressList; std::list m_prefixList; PbbAddressTlvBlock m_addressTlvList; - - mutable uint32_t m_refCount; }; /** @@ -1520,11 +1503,11 @@ protected: /** * \brief A packet or message TLV */ -class PbbTlv +class PbbTlv : public SimpleRefCount { public: PbbTlv (void); - ~PbbTlv (void); + virtual ~PbbTlv (void); /** * \brief Sets the type of this TLV. @@ -1599,10 +1582,6 @@ public: */ bool HasValue (void) const; - /* Smart pointer methods */ - void Ref (void) const; - void Unref (void) const; - /** * \return The size (in bytes) needed to serialize this TLV. */ @@ -1672,8 +1651,6 @@ private: bool m_isMultivalue; bool m_hasValue; Buffer m_value; - - mutable uint32_t m_refCount; }; /** diff --git a/src/simulator/event-impl.cc b/src/simulator/event-impl.cc index 03db87d6c..42c6deb02 100644 --- a/src/simulator/event-impl.cc +++ b/src/simulator/event-impl.cc @@ -20,15 +20,13 @@ #include "event-impl.h" - namespace ns3 { EventImpl::~EventImpl () {} EventImpl::EventImpl () - : m_cancel (false), - m_count (1) + : m_cancel (false) {} void diff --git a/src/simulator/event-impl.h b/src/simulator/event-impl.h index 479eefc12..0bdb4a007 100644 --- a/src/simulator/event-impl.h +++ b/src/simulator/event-impl.h @@ -21,6 +21,7 @@ #define EVENT_IMPL_H #include +#include "ns3/simple-ref-count.h" namespace ns3 { @@ -35,12 +36,10 @@ namespace ns3 { * most subclasses are usually created by one of the many Simulator::Schedule * methods. */ -class EventImpl +class EventImpl : public SimpleRefCount { public: EventImpl (); - inline void Ref (void) const; - inline void Unref (void) const; virtual ~EventImpl () = 0; /** * Called by the simulation engine to notify the event that it has expired. @@ -64,30 +63,8 @@ protected: private: bool m_cancel; - mutable uint32_t m_count; }; -}; // namespace ns3 - -namespace ns3 { - -void -EventImpl::Ref (void) const -{ - m_count++; -} - -void -EventImpl::Unref (void) const -{ - uint32_t c; - c = --m_count; - if (c == 0) - { - delete this; - } -} - } // namespace ns3 #endif /* EVENT_IMPL_H */ From 0289746207a7730e1f4ae72be56c1b5b602cf418 Mon Sep 17 00:00:00 2001 From: Guillaume Seguin Date: Thu, 12 Nov 2009 13:19:35 +0100 Subject: [PATCH 03/29] Simulator::SetScheduler now takes an ObjectFactory --- CHANGES.html | 22 ++++++++++++ src/simulator/default-simulator-impl.cc | 4 ++- src/simulator/default-simulator-impl.h | 2 +- src/simulator/realtime-simulator-impl.cc | 4 ++- src/simulator/realtime-simulator-impl.h | 2 +- src/simulator/simulator-impl.h | 3 +- src/simulator/simulator.cc | 43 +++++++++++++++--------- src/simulator/simulator.h | 3 +- utils/bench-simulator.cc | 13 ++++--- 9 files changed, 71 insertions(+), 25 deletions(-) diff --git a/CHANGES.html b/CHANGES.html index 7003d49c0..3d344a5da 100644 --- a/CHANGES.html +++ b/CHANGES.html @@ -61,6 +61,28 @@ can be found here. +
+

Changes from ns-3.6 to ns-3.7

+ +

Changes to existing API:

+
    +
  • Simulator::SetScheduler: this method now takes an ObjectFactory +instead of an object pointer directly. Existing callers can trivially be +updated to use this new method.
    +Before: +
    +Ptr<Scheduler> sched = CreateObject<ListScheduler> ();
    +Simulator::SetScheduler (sched);
    +
    +After: +
    +ObjectFactory sched;
    +sched.SetTypeId ("ns3::ListScheduler");
    +Simulator::SetScheduler (sched);
    +
    + +
+

Changes from ns-3.5 to ns-3.6

diff --git a/src/simulator/default-simulator-impl.cc b/src/simulator/default-simulator-impl.cc index 394545651..39506737d 100644 --- a/src/simulator/default-simulator-impl.cc +++ b/src/simulator/default-simulator-impl.cc @@ -86,8 +86,10 @@ DefaultSimulatorImpl::Destroy () } void -DefaultSimulatorImpl::SetScheduler (Ptr scheduler) +DefaultSimulatorImpl::SetScheduler (ObjectFactory schedulerFactory) { + Ptr scheduler = schedulerFactory.Create (); + if (m_events != 0) { while (!m_events->IsEmpty ()) diff --git a/src/simulator/default-simulator-impl.h b/src/simulator/default-simulator-impl.h index 4811a57a1..c5156078b 100644 --- a/src/simulator/default-simulator-impl.h +++ b/src/simulator/default-simulator-impl.h @@ -56,7 +56,7 @@ public: virtual Time Now (void) const; virtual Time GetDelayLeft (const EventId &id) const; virtual Time GetMaximumSimulationTime (void) const; - virtual void SetScheduler (Ptr scheduler); + virtual void SetScheduler (ObjectFactory schedulerFactory); private: void ProcessOneEvent (void); diff --git a/src/simulator/realtime-simulator-impl.cc b/src/simulator/realtime-simulator-impl.cc index b096c99f0..ccbd2fa4f 100644 --- a/src/simulator/realtime-simulator-impl.cc +++ b/src/simulator/realtime-simulator-impl.cc @@ -122,10 +122,12 @@ RealtimeSimulatorImpl::Destroy () } void -RealtimeSimulatorImpl::SetScheduler (Ptr scheduler) +RealtimeSimulatorImpl::SetScheduler (ObjectFactory schedulerFactory) { NS_LOG_FUNCTION_NOARGS (); + Ptr scheduler = schedulerFactory.Create (); + { CriticalSection cs (m_mutex); diff --git a/src/simulator/realtime-simulator-impl.h b/src/simulator/realtime-simulator-impl.h index 8a3becd57..832919af1 100644 --- a/src/simulator/realtime-simulator-impl.h +++ b/src/simulator/realtime-simulator-impl.h @@ -66,7 +66,7 @@ public: virtual Time Now (void) const; virtual Time GetDelayLeft (const EventId &id) const; virtual Time GetMaximumSimulationTime (void) const; - virtual void SetScheduler (Ptr scheduler); + virtual void SetScheduler (ObjectFactory schedulerFactory); void ScheduleRealtime (Time const &time, EventImpl *event); void ScheduleRealtimeNow (EventImpl *event); diff --git a/src/simulator/simulator-impl.h b/src/simulator/simulator-impl.h index 4479b23bb..166905a9d 100644 --- a/src/simulator/simulator-impl.h +++ b/src/simulator/simulator-impl.h @@ -25,6 +25,7 @@ #include "event-id.h" #include "nstime.h" #include "ns3/object.h" +#include "ns3/object-factory.h" #include "ns3/ptr.h" namespace ns3 { @@ -49,7 +50,7 @@ public: virtual Time Now (void) const = 0; virtual Time GetDelayLeft (const EventId &id) const = 0; virtual Time GetMaximumSimulationTime (void) const = 0; - virtual void SetScheduler (Ptr scheduler) = 0; + virtual void SetScheduler (ObjectFactory schedulerFactory) = 0; }; } // namespace ns3 diff --git a/src/simulator/simulator.cc b/src/simulator/simulator.cc index 5c9552d99..dda4f9d63 100644 --- a/src/simulator/simulator.cc +++ b/src/simulator/simulator.cc @@ -25,6 +25,7 @@ # include "realtime-simulator-impl.h" #endif #include "scheduler.h" +#include "map-scheduler.h" #include "event-impl.h" #include "ns3/ptr.h" @@ -51,8 +52,8 @@ GlobalValue g_simTypeImpl = GlobalValue ("SimulatorImplementationType", GlobalValue g_schedTypeImpl = GlobalValue ("SchedulerType", "The object class to use as the scheduler implementation", - StringValue ("ns3::MapScheduler"), - MakeStringChecker ()); + TypeIdValue (MapScheduler::GetTypeId ()), + MakeTypeIdChecker ()); #ifdef NS3_LOG_ENABLE @@ -97,7 +98,7 @@ static SimulatorImpl * GetImpl (void) StringValue s; g_schedTypeImpl.GetValue (s); factory.SetTypeId (s.Get ()); - impl->SetScheduler (factory.Create ()); + impl->SetScheduler (factory); } // @@ -133,10 +134,10 @@ Simulator::Destroy (void) } void -Simulator::SetScheduler (Ptr scheduler) +Simulator::SetScheduler (ObjectFactory schedulerFactory) { - NS_LOG_FUNCTION (scheduler); - GetImpl ()->SetScheduler (scheduler); + NS_LOG_FUNCTION (schedulerFactory); + GetImpl ()->SetScheduler (schedulerFactory); } bool @@ -302,7 +303,7 @@ Simulator::SetImplementation (Ptr impl) StringValue s; g_schedTypeImpl.GetValue (s); factory.SetTypeId (s.Get ()); - impl->SetScheduler (factory.Create ()); + impl->SetScheduler (factory); // // Note: we call LogSetTimePrinter _after_ creating the implementation // object because the act of creation can trigger calls to the logging @@ -334,7 +335,7 @@ namespace ns3 { class SimulatorEventsTestCase : public TestCase { public: - SimulatorEventsTestCase (Ptr scheduler); + SimulatorEventsTestCase (ObjectFactory schedulerFactory); virtual bool DoRun (void); void A (int a); void B (int b); @@ -350,10 +351,13 @@ public: EventId m_idC; bool m_destroy; EventId m_destroyId; + ObjectFactory m_schedulerFactory; }; -SimulatorEventsTestCase::SimulatorEventsTestCase (Ptr scheduler) - : TestCase ("Check that basic event handling is working with " + scheduler->GetInstanceTypeId ().GetName ()) +SimulatorEventsTestCase::SimulatorEventsTestCase (ObjectFactory schedulerFactory) + : TestCase ("Check that basic event handling is working with " + + schedulerFactory.GetTypeId ().GetName ()), + m_schedulerFactory (schedulerFactory) {} uint64_t SimulatorEventsTestCase::NowUs (void) @@ -422,6 +426,8 @@ SimulatorEventsTestCase::DoRun (void) m_c = true; m_d = false; + Simulator::SetScheduler (m_schedulerFactory); + EventId a = Simulator::Schedule (MicroSeconds (10), &SimulatorEventsTestCase::A, this, 1); Simulator::Schedule (MicroSeconds (11), &SimulatorEventsTestCase::B, this, 2); m_idC = Simulator::Schedule (MicroSeconds (12), &SimulatorEventsTestCase::C, this, 3); @@ -767,11 +773,18 @@ public: SimulatorTestSuite () : TestSuite ("simulator") { - AddTestCase (new SimulatorEventsTestCase (CreateObject ())); - AddTestCase (new SimulatorEventsTestCase (CreateObject ())); - AddTestCase (new SimulatorEventsTestCase (CreateObject ())); - AddTestCase (new SimulatorEventsTestCase (CreateObject ())); - AddTestCase (new SimulatorEventsTestCase (CreateObject ())); + ObjectFactory factory; + factory.SetTypeId (ListScheduler::GetTypeId ()); + + AddTestCase (new SimulatorEventsTestCase (factory)); + factory.SetTypeId (MapScheduler::GetTypeId ()); + AddTestCase (new SimulatorEventsTestCase (factory)); + factory.SetTypeId (HeapScheduler::GetTypeId ()); + AddTestCase (new SimulatorEventsTestCase (factory)); + factory.SetTypeId (CalendarScheduler::GetTypeId ()); + AddTestCase (new SimulatorEventsTestCase (factory)); + factory.SetTypeId (Ns2CalendarScheduler::GetTypeId ()); + AddTestCase (new SimulatorEventsTestCase (factory)); } } g_simulatorTestSuite; diff --git a/src/simulator/simulator.h b/src/simulator/simulator.h index 477a55be8..ec02182fa 100644 --- a/src/simulator/simulator.h +++ b/src/simulator/simulator.h @@ -27,6 +27,7 @@ #include "nstime.h" #include "ns3/deprecated.h" +#include "ns3/object-factory.h" #include #include @@ -80,7 +81,7 @@ public: * in the previous scheduler will be transfered to the new scheduler * before we start to use it. */ - static void SetScheduler (Ptr scheduler); + static void SetScheduler (ObjectFactory schedulerFactory); /** * Every event scheduled by the Simulator::insertAtDestroy method is diff --git a/utils/bench-simulator.cc b/utils/bench-simulator.cc index 8a3011ec1..c06ddbae1 100644 --- a/utils/bench-simulator.cc +++ b/utils/bench-simulator.cc @@ -162,21 +162,26 @@ int main (int argc, char *argv[]) } while (argc > 0) { + ObjectFactory factory; if (strcmp ("--list", argv[0]) == 0) { - Simulator::SetScheduler (CreateObject ()); + factory.SetTypeId ("ns3::ListScheduler"); + Simulator::SetScheduler (factory); } else if (strcmp ("--heap", argv[0]) == 0) { - Simulator::SetScheduler (CreateObject ()); + factory.SetTypeId ("ns3::HeapScheduler"); + Simulator::SetScheduler (factory); } else if (strcmp ("--map", argv[0]) == 0) { - Simulator::SetScheduler (CreateObject ()); + factory.SetTypeId ("ns3::HeapScheduler"); + Simulator::SetScheduler (factory); } else if (strcmp ("--calendar", argv[0]) == 0) { - Simulator::SetScheduler (CreateObject ()); + factory.SetTypeId ("ns3::CalendarScheduler"); + Simulator::SetScheduler (factory); } else if (strcmp ("--debug", argv[0]) == 0) { From f428177e251b5823628486cdde0facc1275a9820 Mon Sep 17 00:00:00 2001 From: fmoatamr Date: Thu, 12 Nov 2009 14:08:51 +0100 Subject: [PATCH 04/29] Make building works under g++-4.0.4,4.1.2 and OSX PPC --- src/contrib/stats/data-calculator.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/contrib/stats/data-calculator.h b/src/contrib/stats/data-calculator.h index 4f95b5da3..688832eaf 100644 --- a/src/contrib/stats/data-calculator.h +++ b/src/contrib/stats/data-calculator.h @@ -33,6 +33,12 @@ namespace ns3 { class StatisticalSummary { public: + /** + * Destructor + */ + virtual ~StatisticalSummary () + { + } /** * Returns the number of the observations. */ From d47f2a3b86d81701dba33c277b948524f8be08c8 Mon Sep 17 00:00:00 2001 From: Kirill Andreev Date: Fri, 13 Nov 2009 11:47:02 +0300 Subject: [PATCH 05/29] [Bug 740] OLSR MprCompute () works wrong: fixed --- src/routing/olsr/olsr-header.cc | 2 +- src/routing/olsr/olsr-routing-protocol.cc | 133 +++++++++++++++++++++- src/routing/olsr/olsr-routing-protocol.h | 11 ++ src/routing/olsr/olsr-state.cc | 5 + src/routing/olsr/olsr-state.h | 3 + 5 files changed, 150 insertions(+), 4 deletions(-) diff --git a/src/routing/olsr/olsr-header.cc b/src/routing/olsr/olsr-header.cc index 2a66280b3..e09e24083 100644 --- a/src/routing/olsr/olsr-header.cc +++ b/src/routing/olsr/olsr-header.cc @@ -785,7 +785,7 @@ public: } g_olsrTestSuite; OlsrTestSuite::OlsrTestSuite() - : TestSuite("olsr-routing", UNIT) + : TestSuite("Routing-OLSR-header", UNIT) { AddTestCase(new OlsrHnaTestCase()); AddTestCase(new OlsrTcTestCase()); diff --git a/src/routing/olsr/olsr-routing-protocol.cc b/src/routing/olsr/olsr-routing-protocol.cc index 7ec59bb0f..4211da0a7 100644 --- a/src/routing/olsr/olsr-routing-protocol.cc +++ b/src/routing/olsr/olsr-routing-protocol.cc @@ -716,6 +716,10 @@ RoutingProtocol::MprComputation() if (max == NULL || nb_tuple->willingness > max->willingness) { max = nb_tuple; + for (TwoHopNeighborSet::iterator newCovered = N2.begin (); newCovered != N2.end (); newCovered++) + { + coveredTwoHopNeighbors.insert (newCovered->twoHopNeighborAddr); + } max_r = r; } else if (nb_tuple->willingness == max->willingness) @@ -740,11 +744,12 @@ RoutingProtocol::MprComputation() if (max != NULL) { mprSet.insert (max->neighborMainAddr); - for (TwoHopNeighborSet::iterator twoHopNeigh = N2.begin (); - twoHopNeigh != N2.end (); ) + // Remove the nodes from N2 which are now covered by a node in the MPR set. + for (TwoHopNeighborSet::iterator twoHopNeigh = N2.begin (); twoHopNeigh != N2.end (); ) { - if (twoHopNeigh->neighborMainAddr == max->neighborMainAddr) + if (coveredTwoHopNeighbors.find (twoHopNeigh->twoHopNeighborAddr) != coveredTwoHopNeighbors.end ()) { + NS_LOG_LOGIC ("2-hop neigh. " << twoHopNeigh->twoHopNeighborAddr << " is already covered by an MPR."); twoHopNeigh = N2.erase (twoHopNeigh); } else @@ -2780,6 +2785,128 @@ RoutingProtocol::GetEntries () const } return retval; } +OlsrMprTestCase::OlsrMprTestCase () + : TestCase ("Check OLSR MPR computing mechanism") +{ +} +OlsrMprTestCase::~OlsrMprTestCase () +{ +} +bool +OlsrMprTestCase::DoRun () +{ + /* + * Create a 3x3 grid like the following: + * 3---6---9 + * |\ /|\ /| + * | X | X | + * |/ \|/ \| + * 2---5---8 + * |\ /|\ /| + * | X | X | + * |/ \|/ \| + * 1---4---7 + * PrepareTopology fills all 2-hop neighbors of station 1 and creates a routing protocol + * We are the station number 2. Obvious, that an only MPR in this case is 5 + */ + Ptr m_protocol = CreateObject (); + m_protocol->m_mainAddress = Ipv4Address ("10.0.0.2"); + // we fill all possible 2-hop neighborhood + TwoHopNeighborTuple tuple; + tuple.expirationTime = Seconds (3600); + // All neighbor stations which are seen from station 5 + tuple.neighborMainAddr = Ipv4Address ("10.0.0.5"); + tuple.twoHopNeighborAddr = Ipv4Address ("10.0.0.1"); + m_protocol->m_state.InsertTwoHopNeighborTuple (tuple); + tuple.twoHopNeighborAddr = Ipv4Address ("10.0.0.2"); + m_protocol->m_state.InsertTwoHopNeighborTuple (tuple); + tuple.twoHopNeighborAddr = Ipv4Address ("10.0.0.3"); + m_protocol->m_state.InsertTwoHopNeighborTuple (tuple); + tuple.twoHopNeighborAddr = Ipv4Address ("10.0.0.4"); + m_protocol->m_state.InsertTwoHopNeighborTuple (tuple); + tuple.twoHopNeighborAddr = Ipv4Address ("10.0.0.6"); + m_protocol->m_state.InsertTwoHopNeighborTuple (tuple); + tuple.twoHopNeighborAddr = Ipv4Address ("10.0.0.7"); + m_protocol->m_state.InsertTwoHopNeighborTuple (tuple); + tuple.twoHopNeighborAddr = Ipv4Address ("10.0.0.8"); + m_protocol->m_state.InsertTwoHopNeighborTuple (tuple); + tuple.twoHopNeighborAddr = Ipv4Address ("10.0.0.9"); + m_protocol->m_state.InsertTwoHopNeighborTuple (tuple); + // All neighbor stations which are seen from station 4 + tuple.neighborMainAddr = Ipv4Address ("10.0.0.4"); + tuple.twoHopNeighborAddr = Ipv4Address ("10.0.0.1"); + m_protocol->m_state.InsertTwoHopNeighborTuple (tuple); + tuple.twoHopNeighborAddr = Ipv4Address ("10.0.0.2"); + m_protocol->m_state.InsertTwoHopNeighborTuple (tuple); + tuple.twoHopNeighborAddr = Ipv4Address ("10.0.0.5"); + m_protocol->m_state.InsertTwoHopNeighborTuple (tuple); + tuple.twoHopNeighborAddr = Ipv4Address ("10.0.0.8"); + m_protocol->m_state.InsertTwoHopNeighborTuple (tuple); + tuple.twoHopNeighborAddr = Ipv4Address ("10.0.0.7"); + m_protocol->m_state.InsertTwoHopNeighborTuple (tuple); + + // All neighbor stations which are seen from station 6 + tuple.neighborMainAddr = Ipv4Address ("10.0.0.6"); + tuple.twoHopNeighborAddr = Ipv4Address ("10.0.0.3"); + m_protocol->m_state.InsertTwoHopNeighborTuple (tuple); + tuple.twoHopNeighborAddr = Ipv4Address ("10.0.0.2"); + m_protocol->m_state.InsertTwoHopNeighborTuple (tuple); + tuple.twoHopNeighborAddr = Ipv4Address ("10.0.0.5"); + m_protocol->m_state.InsertTwoHopNeighborTuple (tuple); + tuple.twoHopNeighborAddr = Ipv4Address ("10.0.0.8"); + m_protocol->m_state.InsertTwoHopNeighborTuple (tuple); + tuple.twoHopNeighborAddr = Ipv4Address ("10.0.0.9"); + m_protocol->m_state.InsertTwoHopNeighborTuple (tuple); + + // All neighbor stations which are seen from station 1 + tuple.neighborMainAddr = Ipv4Address ("10.0.0.1"); + tuple.twoHopNeighborAddr = Ipv4Address ("10.0.0.2"); + m_protocol->m_state.InsertTwoHopNeighborTuple (tuple); + tuple.twoHopNeighborAddr = Ipv4Address ("10.0.0.5"); + m_protocol->m_state.InsertTwoHopNeighborTuple (tuple); + tuple.twoHopNeighborAddr = Ipv4Address ("10.0.0.4"); + + // All neighbor stations which are seen from station 3 + tuple.neighborMainAddr = Ipv4Address ("10.0.0.3"); + tuple.twoHopNeighborAddr = Ipv4Address ("10.0.0.2"); + m_protocol->m_state.InsertTwoHopNeighborTuple (tuple); + tuple.twoHopNeighborAddr = Ipv4Address ("10.0.0.5"); + m_protocol->m_state.InsertTwoHopNeighborTuple (tuple); + tuple.twoHopNeighborAddr = Ipv4Address ("10.0.0.6"); + // First, we fill all neighbors + // If neighbors willingness = OLSR_WILL_DEFAULT, an only station number 5 will be an MPR + NeighborTuple neigbor; + neigbor.status = NeighborTuple::STATUS_SYM; + neigbor.willingness = OLSR_WILL_DEFAULT; + neigbor.neighborMainAddr = Ipv4Address ("10.0.0.3"); + m_protocol->m_state.InsertNeighborTuple (neigbor); + neigbor.neighborMainAddr = Ipv4Address ("10.0.0.6"); + m_protocol->m_state.InsertNeighborTuple (neigbor); + neigbor.neighborMainAddr = Ipv4Address ("10.0.0.5"); + m_protocol->m_state.InsertNeighborTuple (neigbor); + neigbor.neighborMainAddr = Ipv4Address ("10.0.0.4"); + m_protocol->m_state.InsertNeighborTuple (neigbor); + neigbor.neighborMainAddr = Ipv4Address ("10.0.0.1"); + m_protocol->m_state.InsertNeighborTuple (neigbor); + //Now, calculateMPR + m_protocol->MprComputation (); + //Check results + NS_TEST_ASSERT_MSG_EQ (m_protocol->m_state.FindMprAddress (Ipv4Address ("10.0.0.5")), true, "MPR is incorrect!"); + NS_TEST_ASSERT_MSG_EQ (m_protocol->m_state.GetMprSet ().size (), 1 , "An only address must be chosen!\n"); + return false; +} + +static class OlsrProtocolTestSuite : public TestSuite +{ +public: + OlsrProtocolTestSuite (); +} g_olsrProtocolTestSuite; + +OlsrProtocolTestSuite::OlsrProtocolTestSuite() + : TestSuite("Routing-OLSR", UNIT) +{ + AddTestCase (new OlsrMprTestCase ()); +} }} // namespace olsr, ns3 diff --git a/src/routing/olsr/olsr-routing-protocol.h b/src/routing/olsr/olsr-routing-protocol.h index aaf021aed..bab7865c8 100644 --- a/src/routing/olsr/olsr-routing-protocol.h +++ b/src/routing/olsr/olsr-routing-protocol.h @@ -25,6 +25,7 @@ #define __OLSR_AGENT_IMPL_H__ #include "olsr-header.h" +#include "ns3/test.h" #include "olsr-state.h" #include "olsr-repositories.h" @@ -58,11 +59,21 @@ struct RoutingTableEntry destAddr (), nextAddr (), interface (0), distance (0) {}; }; +class RoutingProtocol; +/// Testcase for MPR computation mechanism +class OlsrMprTestCase : public TestCase { +public: + OlsrMprTestCase (); + ~OlsrMprTestCase (); + virtual bool DoRun (void); + ; +}; class RoutingProtocol : public Ipv4RoutingProtocol { public: + friend class OlsrMprTestCase; static TypeId GetTypeId (void); RoutingProtocol (); diff --git a/src/routing/olsr/olsr-state.cc b/src/routing/olsr/olsr-state.cc index 6836758ee..14fae5cfe 100644 --- a/src/routing/olsr/olsr-state.cc +++ b/src/routing/olsr/olsr-state.cc @@ -272,6 +272,11 @@ OlsrState::SetMprSet (MprSet mprSet) { m_mprSet = mprSet; } +MprSet +OlsrState::GetMprSet () const +{ + return m_mprSet; +} /********** Duplicate Set Manipulation **********/ diff --git a/src/routing/olsr/olsr-state.h b/src/routing/olsr/olsr-state.h index b2ea6749b..069bebf22 100644 --- a/src/routing/olsr/olsr-state.h +++ b/src/routing/olsr/olsr-state.h @@ -98,7 +98,10 @@ public: // MPR bool FindMprAddress (const Ipv4Address &address); + /// MprSet is set by routing protocol after MprCompute void SetMprSet (MprSet mprSet); + /// Gets an MPR Set needed by tests + MprSet GetMprSet () const; // Duplicate DuplicateTuple* FindDuplicateTuple (const Ipv4Address &address, From aad89f3e8a5c5250ff627dc664156bac0eea136a Mon Sep 17 00:00:00 2001 From: Pavel Boyko Date: Fri, 13 Nov 2009 13:23:08 +0300 Subject: [PATCH 06/29] cosmetics --- src/routing/olsr/olsr-header.cc | 2 +- src/routing/olsr/olsr-routing-protocol.cc | 150 +++++++++++----------- 2 files changed, 76 insertions(+), 76 deletions(-) diff --git a/src/routing/olsr/olsr-header.cc b/src/routing/olsr/olsr-header.cc index e09e24083..2c7faf4e2 100644 --- a/src/routing/olsr/olsr-header.cc +++ b/src/routing/olsr/olsr-header.cc @@ -785,7 +785,7 @@ public: } g_olsrTestSuite; OlsrTestSuite::OlsrTestSuite() - : TestSuite("Routing-OLSR-header", UNIT) + : TestSuite("routing-olsr-header", UNIT) { AddTestCase(new OlsrHnaTestCase()); AddTestCase(new OlsrTcTestCase()); diff --git a/src/routing/olsr/olsr-routing-protocol.cc b/src/routing/olsr/olsr-routing-protocol.cc index 4211da0a7..b6489e813 100644 --- a/src/routing/olsr/olsr-routing-protocol.cc +++ b/src/routing/olsr/olsr-routing-protocol.cc @@ -2796,83 +2796,83 @@ bool OlsrMprTestCase::DoRun () { /* - * Create a 3x3 grid like the following: - * 3---6---9 - * |\ /|\ /| - * | X | X | - * |/ \|/ \| - * 2---5---8 - * |\ /|\ /| - * | X | X | - * |/ \|/ \| - * 1---4---7 - * PrepareTopology fills all 2-hop neighbors of station 1 and creates a routing protocol - * We are the station number 2. Obvious, that an only MPR in this case is 5 - */ - Ptr m_protocol = CreateObject (); - m_protocol->m_mainAddress = Ipv4Address ("10.0.0.2"); - // we fill all possible 2-hop neighborhood - TwoHopNeighborTuple tuple; - tuple.expirationTime = Seconds (3600); - // All neighbor stations which are seen from station 5 - tuple.neighborMainAddr = Ipv4Address ("10.0.0.5"); - tuple.twoHopNeighborAddr = Ipv4Address ("10.0.0.1"); - m_protocol->m_state.InsertTwoHopNeighborTuple (tuple); - tuple.twoHopNeighborAddr = Ipv4Address ("10.0.0.2"); - m_protocol->m_state.InsertTwoHopNeighborTuple (tuple); - tuple.twoHopNeighborAddr = Ipv4Address ("10.0.0.3"); - m_protocol->m_state.InsertTwoHopNeighborTuple (tuple); - tuple.twoHopNeighborAddr = Ipv4Address ("10.0.0.4"); - m_protocol->m_state.InsertTwoHopNeighborTuple (tuple); - tuple.twoHopNeighborAddr = Ipv4Address ("10.0.0.6"); - m_protocol->m_state.InsertTwoHopNeighborTuple (tuple); - tuple.twoHopNeighborAddr = Ipv4Address ("10.0.0.7"); - m_protocol->m_state.InsertTwoHopNeighborTuple (tuple); - tuple.twoHopNeighborAddr = Ipv4Address ("10.0.0.8"); - m_protocol->m_state.InsertTwoHopNeighborTuple (tuple); - tuple.twoHopNeighborAddr = Ipv4Address ("10.0.0.9"); - m_protocol->m_state.InsertTwoHopNeighborTuple (tuple); - // All neighbor stations which are seen from station 4 - tuple.neighborMainAddr = Ipv4Address ("10.0.0.4"); - tuple.twoHopNeighborAddr = Ipv4Address ("10.0.0.1"); - m_protocol->m_state.InsertTwoHopNeighborTuple (tuple); - tuple.twoHopNeighborAddr = Ipv4Address ("10.0.0.2"); - m_protocol->m_state.InsertTwoHopNeighborTuple (tuple); - tuple.twoHopNeighborAddr = Ipv4Address ("10.0.0.5"); - m_protocol->m_state.InsertTwoHopNeighborTuple (tuple); - tuple.twoHopNeighborAddr = Ipv4Address ("10.0.0.8"); - m_protocol->m_state.InsertTwoHopNeighborTuple (tuple); - tuple.twoHopNeighborAddr = Ipv4Address ("10.0.0.7"); - m_protocol->m_state.InsertTwoHopNeighborTuple (tuple); + * Create a 3x3 grid like the following: + * 3---6---9 + * |\ /|\ /| + * | X | X | + * |/ \|/ \| + * 2---5---8 + * |\ /|\ /| + * | X | X | + * |/ \|/ \| + * 1---4---7 + * PrepareTopology fills all 2-hop neighbors of station 1 and creates a routing protocol + * We are the station number 2. Obvious, that an only MPR in this case is 5 + */ + Ptr m_protocol = CreateObject (); + m_protocol->m_mainAddress = Ipv4Address ("10.0.0.2"); + // we fill all possible 2-hop neighborhood + TwoHopNeighborTuple tuple; + tuple.expirationTime = Seconds (3600); + // All neighbor stations which are seen from station 5 + tuple.neighborMainAddr = Ipv4Address ("10.0.0.5"); + tuple.twoHopNeighborAddr = Ipv4Address ("10.0.0.1"); + m_protocol->m_state.InsertTwoHopNeighborTuple (tuple); + tuple.twoHopNeighborAddr = Ipv4Address ("10.0.0.2"); + m_protocol->m_state.InsertTwoHopNeighborTuple (tuple); + tuple.twoHopNeighborAddr = Ipv4Address ("10.0.0.3"); + m_protocol->m_state.InsertTwoHopNeighborTuple (tuple); + tuple.twoHopNeighborAddr = Ipv4Address ("10.0.0.4"); + m_protocol->m_state.InsertTwoHopNeighborTuple (tuple); + tuple.twoHopNeighborAddr = Ipv4Address ("10.0.0.6"); + m_protocol->m_state.InsertTwoHopNeighborTuple (tuple); + tuple.twoHopNeighborAddr = Ipv4Address ("10.0.0.7"); + m_protocol->m_state.InsertTwoHopNeighborTuple (tuple); + tuple.twoHopNeighborAddr = Ipv4Address ("10.0.0.8"); + m_protocol->m_state.InsertTwoHopNeighborTuple (tuple); + tuple.twoHopNeighborAddr = Ipv4Address ("10.0.0.9"); + m_protocol->m_state.InsertTwoHopNeighborTuple (tuple); + // All neighbor stations which are seen from station 4 + tuple.neighborMainAddr = Ipv4Address ("10.0.0.4"); + tuple.twoHopNeighborAddr = Ipv4Address ("10.0.0.1"); + m_protocol->m_state.InsertTwoHopNeighborTuple (tuple); + tuple.twoHopNeighborAddr = Ipv4Address ("10.0.0.2"); + m_protocol->m_state.InsertTwoHopNeighborTuple (tuple); + tuple.twoHopNeighborAddr = Ipv4Address ("10.0.0.5"); + m_protocol->m_state.InsertTwoHopNeighborTuple (tuple); + tuple.twoHopNeighborAddr = Ipv4Address ("10.0.0.8"); + m_protocol->m_state.InsertTwoHopNeighborTuple (tuple); + tuple.twoHopNeighborAddr = Ipv4Address ("10.0.0.7"); + m_protocol->m_state.InsertTwoHopNeighborTuple (tuple); - // All neighbor stations which are seen from station 6 - tuple.neighborMainAddr = Ipv4Address ("10.0.0.6"); - tuple.twoHopNeighborAddr = Ipv4Address ("10.0.0.3"); - m_protocol->m_state.InsertTwoHopNeighborTuple (tuple); - tuple.twoHopNeighborAddr = Ipv4Address ("10.0.0.2"); - m_protocol->m_state.InsertTwoHopNeighborTuple (tuple); - tuple.twoHopNeighborAddr = Ipv4Address ("10.0.0.5"); - m_protocol->m_state.InsertTwoHopNeighborTuple (tuple); - tuple.twoHopNeighborAddr = Ipv4Address ("10.0.0.8"); - m_protocol->m_state.InsertTwoHopNeighborTuple (tuple); - tuple.twoHopNeighborAddr = Ipv4Address ("10.0.0.9"); - m_protocol->m_state.InsertTwoHopNeighborTuple (tuple); + // All neighbor stations which are seen from station 6 + tuple.neighborMainAddr = Ipv4Address ("10.0.0.6"); + tuple.twoHopNeighborAddr = Ipv4Address ("10.0.0.3"); + m_protocol->m_state.InsertTwoHopNeighborTuple (tuple); + tuple.twoHopNeighborAddr = Ipv4Address ("10.0.0.2"); + m_protocol->m_state.InsertTwoHopNeighborTuple (tuple); + tuple.twoHopNeighborAddr = Ipv4Address ("10.0.0.5"); + m_protocol->m_state.InsertTwoHopNeighborTuple (tuple); + tuple.twoHopNeighborAddr = Ipv4Address ("10.0.0.8"); + m_protocol->m_state.InsertTwoHopNeighborTuple (tuple); + tuple.twoHopNeighborAddr = Ipv4Address ("10.0.0.9"); + m_protocol->m_state.InsertTwoHopNeighborTuple (tuple); - // All neighbor stations which are seen from station 1 - tuple.neighborMainAddr = Ipv4Address ("10.0.0.1"); - tuple.twoHopNeighborAddr = Ipv4Address ("10.0.0.2"); - m_protocol->m_state.InsertTwoHopNeighborTuple (tuple); - tuple.twoHopNeighborAddr = Ipv4Address ("10.0.0.5"); - m_protocol->m_state.InsertTwoHopNeighborTuple (tuple); - tuple.twoHopNeighborAddr = Ipv4Address ("10.0.0.4"); + // All neighbor stations which are seen from station 1 + tuple.neighborMainAddr = Ipv4Address ("10.0.0.1"); + tuple.twoHopNeighborAddr = Ipv4Address ("10.0.0.2"); + m_protocol->m_state.InsertTwoHopNeighborTuple (tuple); + tuple.twoHopNeighborAddr = Ipv4Address ("10.0.0.5"); + m_protocol->m_state.InsertTwoHopNeighborTuple (tuple); + tuple.twoHopNeighborAddr = Ipv4Address ("10.0.0.4"); - // All neighbor stations which are seen from station 3 - tuple.neighborMainAddr = Ipv4Address ("10.0.0.3"); - tuple.twoHopNeighborAddr = Ipv4Address ("10.0.0.2"); - m_protocol->m_state.InsertTwoHopNeighborTuple (tuple); - tuple.twoHopNeighborAddr = Ipv4Address ("10.0.0.5"); - m_protocol->m_state.InsertTwoHopNeighborTuple (tuple); - tuple.twoHopNeighborAddr = Ipv4Address ("10.0.0.6"); + // All neighbor stations which are seen from station 3 + tuple.neighborMainAddr = Ipv4Address ("10.0.0.3"); + tuple.twoHopNeighborAddr = Ipv4Address ("10.0.0.2"); + m_protocol->m_state.InsertTwoHopNeighborTuple (tuple); + tuple.twoHopNeighborAddr = Ipv4Address ("10.0.0.5"); + m_protocol->m_state.InsertTwoHopNeighborTuple (tuple); + tuple.twoHopNeighborAddr = Ipv4Address ("10.0.0.6"); // First, we fill all neighbors // If neighbors willingness = OLSR_WILL_DEFAULT, an only station number 5 will be an MPR NeighborTuple neigbor; @@ -2903,7 +2903,7 @@ public: } g_olsrProtocolTestSuite; OlsrProtocolTestSuite::OlsrProtocolTestSuite() - : TestSuite("Routing-OLSR", UNIT) + : TestSuite("routing-olsr", UNIT) { AddTestCase (new OlsrMprTestCase ()); } From 038e05bfd5827f8ce28ae0c4b05bf2fa36663be3 Mon Sep 17 00:00:00 2001 From: Pavel Boyko Date: Fri, 13 Nov 2009 14:51:59 +0300 Subject: [PATCH 07/29] ChannelNumber attribute added to YansWifiPhy. Now it is possible to setup wifi channel using WifiPhyHelper::Set() method. --- src/devices/wifi/yans-wifi-phy.cc | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/devices/wifi/yans-wifi-phy.cc b/src/devices/wifi/yans-wifi-phy.cc index 107c07011..5e6a02099 100644 --- a/src/devices/wifi/yans-wifi-phy.cc +++ b/src/devices/wifi/yans-wifi-phy.cc @@ -114,12 +114,20 @@ YansWifiPhy::GetTypeId (void) TimeValue (MicroSeconds (250)), MakeTimeAccessor (&YansWifiPhy::m_channelSwitchDelay), MakeTimeChecker ()) + .AddAttribute ("ChannelNumber", + "Channel center frequency = Channel starting frequency + 5 MHz * (nch - 1)", + UintegerValue (1), + MakeUintegerAccessor (&YansWifiPhy::SetChannelNumber, + &YansWifiPhy::GetChannelNumber), + MakeUintegerChecker ()) + ; return tid; } YansWifiPhy::YansWifiPhy () - : m_endSyncEvent (), + : m_channelNumber (1), + m_endSyncEvent (), m_random (0.0, 1.0), m_channelStartingFrequency (0) { @@ -304,7 +312,6 @@ YansWifiPhy::SetChannel (Ptr channel) { m_channel = channel; m_channel->Add (this); - m_channelNumber = 1; // always start on channel starting frequency (channel 1) } void From 74c973cfaff8a4673ac550df24e9c1b145c351e1 Mon Sep 17 00:00:00 2001 From: Pavel Boyko Date: Fri, 13 Nov 2009 18:20:50 +0300 Subject: [PATCH 08/29] bugfix in YansWifiPhy::SetChannelNumber() --- src/devices/wifi/yans-wifi-phy.cc | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/devices/wifi/yans-wifi-phy.cc b/src/devices/wifi/yans-wifi-phy.cc index 5e6a02099..d3be72062 100644 --- a/src/devices/wifi/yans-wifi-phy.cc +++ b/src/devices/wifi/yans-wifi-phy.cc @@ -317,7 +317,15 @@ YansWifiPhy::SetChannel (Ptr channel) void YansWifiPhy::SetChannelNumber (uint16_t nch) { - NS_ASSERT(!IsStateSwitching()); + if (Simulator::Now () == Seconds (0)) + { + // this is not channel switch, this is initialization + NS_LOG_DEBUG("start at channel " << nch); + m_channelNumber = nch; + return; + } + + NS_ASSERT (!IsStateSwitching()); switch (m_state->GetState ()) { case YansWifiPhy::SYNC: NS_LOG_DEBUG ("drop packet because of channel switching while reception"); From b4fde3c4591f282f430d74a001524f5a13b729ae Mon Sep 17 00:00:00 2001 From: Nicola Baldo Date: Fri, 13 Nov 2009 16:45:28 +0100 Subject: [PATCH 09/29] added UniformDiscPositionAllocator (bug 672) --- src/mobility/position-allocator.cc | 68 ++++++++++++++++++++++++++++++ src/mobility/position-allocator.h | 51 +++++++++++++++++++++- 2 files changed, 118 insertions(+), 1 deletion(-) diff --git a/src/mobility/position-allocator.cc b/src/mobility/position-allocator.cc index 31427117b..c2605608e 100644 --- a/src/mobility/position-allocator.cc +++ b/src/mobility/position-allocator.cc @@ -315,4 +315,72 @@ RandomDiscPositionAllocator::GetNext (void) const } + +NS_OBJECT_ENSURE_REGISTERED (UniformDiscPositionAllocator); + +TypeId +UniformDiscPositionAllocator::GetTypeId (void) +{ + static TypeId tid = TypeId ("ns3::UniformDiscPositionAllocator") + .SetParent () + .SetGroupName ("Mobility") + .AddConstructor () + .AddAttribute ("rho", + "The radius of the disc", + DoubleValue (0.0), + MakeDoubleAccessor (&UniformDiscPositionAllocator::m_rho), + MakeDoubleChecker ()) + .AddAttribute ("X", + "The x coordinate of the center of the disc.", + DoubleValue (0.0), + MakeDoubleAccessor (&UniformDiscPositionAllocator::m_x), + MakeDoubleChecker ()) + .AddAttribute ("Y", + "The y coordinate of the center of the disc.", + DoubleValue (0.0), + MakeDoubleAccessor (&UniformDiscPositionAllocator::m_y), + MakeDoubleChecker ()) + ; + return tid; +} + +UniformDiscPositionAllocator::UniformDiscPositionAllocator () +{} +UniformDiscPositionAllocator::~UniformDiscPositionAllocator () +{} + +void +UniformDiscPositionAllocator::SetRho (double rho) +{ + m_rho = rho; +} +void +UniformDiscPositionAllocator::SetX (double x) +{ + m_x = x; +} +void +UniformDiscPositionAllocator::SetY (double y) +{ + m_y = y; +} +Vector +UniformDiscPositionAllocator::GetNext (void) const +{ + UniformVariable r (-m_rho, m_rho); + double x,y; + do + { + x = r.GetValue (); + y = r.GetValue (); + } + while (sqrt(x*x + y*y) > m_rho); + + x += m_x; + y += m_y; + NS_LOG_DEBUG ("Disc position x=" << x << ", y=" << y); + return Vector (x, y, 0.0); +} + + } // namespace ns3 diff --git a/src/mobility/position-allocator.h b/src/mobility/position-allocator.h index da6f49f0b..8c066ea1c 100644 --- a/src/mobility/position-allocator.h +++ b/src/mobility/position-allocator.h @@ -182,7 +182,8 @@ private: /** * \brief allocate random positions within a disc - * according to a pair of random variables. + * according to a given distribution for the polar coordinates of each + * node with respect to the provided center of the disc */ class RandomDiscPositionAllocator : public PositionAllocator { @@ -204,6 +205,54 @@ private: double m_y; }; + +/** + * UniformDiscPositionAllocator allocates the positions randomly within a disc \f$ D \f$ lying on the + * plane \f$ z=0 \f$ and having center at coordinates \f$ (x,y,0) \f$ + * and radius \f$ \rho \f$. The random positions are chosen such that, + * for any subset \f$ S \subset D \f$, the expected value of the + * fraction of points which fall into \f$ S \subset D \f$ corresponds + * to \f$ \frac{|S|}{|D|} \f$, i.e., to the ratio of the area of the + * subset to the area of the whole disc. + * + * \note using UniformDiscPositionAllocator is not equivalent to using + * a RandomDiscPositionAllocator with a uniformly-distributed radius, + * since doing that would results in a point distribution which is + * more dense towards the center of the disc. + */ +class UniformDiscPositionAllocator : public PositionAllocator +{ +public: + static TypeId GetTypeId (void); + UniformDiscPositionAllocator (); + virtual ~UniformDiscPositionAllocator (); + + /** + * + * @param rho the value of the radius of the disc + */ + void SetRho (double rho); + + /** + * + * + * @param x the X coordinate of the center of the disc + */ + void SetX (double x); + + /** + * + * @param y the Y coordinate of the center of the disc + */ + void SetY (double y); + + virtual Vector GetNext (void) const; +private: + double m_rho; + double m_x; + double m_y; +}; + } // namespace ns3 #endif /* RANDOM_POSITION_H */ From f15069aca0e4895006dd64738591054548cffa34 Mon Sep 17 00:00:00 2001 From: Tom Henderson Date: Fri, 13 Nov 2009 09:14:32 -0800 Subject: [PATCH 10/29] Align with texi2html-1.82 api changes --- doc/manual/Makefile | 2 +- doc/testing/Makefile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/manual/Makefile b/doc/manual/Makefile index 5fb001472..6da034bc2 100644 --- a/doc/manual/Makefile +++ b/doc/manual/Makefile @@ -64,7 +64,7 @@ manual.html: version $(IMAGES) $(CHAPTERS) $(TEXI2HTML) ${CSS} manual.texi manual/manual.html: version $(IMAGES) $(CHAPTERS) - $(TEXI2HTML) ${CSS} ${SPLIT} manual.texi + $(TEXI2HTML) ${CSS} ${SPLIT} --output manual manual.texi figures-clean: rm -rf $(IMAGES) diff --git a/doc/testing/Makefile b/doc/testing/Makefile index b533252ff..c22b76e8d 100644 --- a/doc/testing/Makefile +++ b/doc/testing/Makefile @@ -34,7 +34,7 @@ testing.html: version $(IMAGES) $(CHAPTERS) $(TEXI2HTML) ${CSS} testing.texi testing/testing.html: version $(IMAGES) $(CHAPTERS) - $(TEXI2HTML) ${CSS} ${SPLIT} testing.texi + $(TEXI2HTML) ${CSS} ${SPLIT} --output testing testing.texi figures-clean: rm -rf $(IMAGES) From f27efc04c2d883d16f8e9a2b668bb3452a6e7b04 Mon Sep 17 00:00:00 2001 From: Tom Henderson Date: Fri, 13 Nov 2009 09:19:06 -0800 Subject: [PATCH 11/29] add missing dependencies --- doc/manual/Makefile | 17 +++++++++++++++++ doc/testing/Makefile | 6 ++++++ 2 files changed, 23 insertions(+) diff --git a/doc/manual/Makefile b/doc/manual/Makefile index 6da034bc2..1aa12c6a2 100644 --- a/doc/manual/Makefile +++ b/doc/manual/Makefile @@ -32,10 +32,22 @@ IMAGES = $(IMAGES_EPS) $(IMAGES_PNG) $(IMAGES_PDF) CHAPTERS = \ manual.texi \ + animation.texi \ attributes.texi \ + bridge.texi \ callbacks.texi \ csma.texi \ emulation.texi \ + emu.texi \ + flow-monitor.texi \ + helpers.texi \ + internet.texi \ + ipv4.texi \ + ipv6.texi \ + log.texi \ + manual.texi \ + mesh.texi \ + names.texi \ new-models.texi \ node.texi \ objects.texi \ @@ -43,11 +55,16 @@ CHAPTERS = \ output.texi \ packets.texi \ point-to-point.texi \ + python.texi \ random.texi \ realtime.texi \ routing.texi \ + simple.texi \ sockets.texi \ statistics.texi \ + tap.texi \ + tcp.texi \ + tracing.texi \ troubleshoot.texi \ wifi.texi diff --git a/doc/testing/Makefile b/doc/testing/Makefile index c22b76e8d..0ffcf5231 100644 --- a/doc/testing/Makefile +++ b/doc/testing/Makefile @@ -19,7 +19,13 @@ IMAGES = $(IMAGES_EPS) $(IMAGES_PNG) $(IMAGES_PDF) CHAPTERS = \ testing.texi \ overview.texi \ + background.texi \ + testing-framework.texi \ + how-to-write-tests.texi \ + validation.texi \ + random-variables.texi \ propagation-loss.texi \ + references.texi \ %.eps : %.dia; $(DIA) -t eps $< -e $@ %.png : %.dia; $(DIA) -t png $< -e $@ From 886ebc725b55b976f2b40c185dec80d2d561685f Mon Sep 17 00:00:00 2001 From: Tom Henderson Date: Fri, 13 Nov 2009 09:37:52 -0800 Subject: [PATCH 12/29] HOWTOs are now on the wiki --- doc/howtos/howtos-application.h | 203 ------------------------------ doc/howtos/howtos-callbacks.h | 38 ------ doc/howtos/howtos-net-device.h | 162 ------------------------ doc/howtos/howtos-packet-header.h | 119 ------------------ doc/howtos/howtos.h | 20 --- doc/main.h | 6 +- 6 files changed, 3 insertions(+), 545 deletions(-) delete mode 100644 doc/howtos/howtos-application.h delete mode 100644 doc/howtos/howtos-callbacks.h delete mode 100644 doc/howtos/howtos-net-device.h delete mode 100644 doc/howtos/howtos-packet-header.h delete mode 100644 doc/howtos/howtos.h diff --git a/doc/howtos/howtos-application.h b/doc/howtos/howtos-application.h deleted file mode 100644 index 33ba848c3..000000000 --- a/doc/howtos/howtos-application.h +++ /dev/null @@ -1,203 +0,0 @@ -/*! - \page application How to create a traffic generator ? - \anchor howtos-application - - Question: How do I create a new traffic generator ? - - Answer: It is possible to instanciate \ref ns3::Packet "Packet" - objects, schedule events, and call functions from any piece of code - in ns-3 so, technically, there is no single answer to the question of - how we can write a new traffic generator. However, the - \ref ns3::Socket "Socket" API was really designed to be the single - point of entry for traffic generators or traffic analysers and the - \ref ns3::Application "Application" class was designed to hold - together any number of sockets. - - Implementing a new traffic generator thus boils down to: -- implementing a new subclass of the \ref ns3::Application "Application" - base class -- instanciate one or many sockets within that application -- start scheduling events when \ref ns3::Application::StartApplication "StartApplication" - is called -- stop scheduling events when \ref ns3::Application::StopApplication "StopApplication" - is called -- create packets and send them over one or many sockets in each event - -The following "random" generator generates packets separated by a random -delay and with a random size. - -\code -class RandomGenerator : public Application -{ -public: - RandomGenerator (); - void SetDelay (RandomVariable delay); - void SetSize (RandomVariable size); - void SetRemote (std::string socketType, - Address remote); -private: - virtual void StartApplication (void); - virtual void StopApplication (void); - void DoGenerate (void); - - RandomVariable m_delay; - RandomVariable m_size; - Ptr m_socket; -}; -\endcode - -The socket is created in the SetRemote method: -\code -void -RandomGenerator::SetRemote (std::string socketType, - Address remote) -{ - TypeId tid = TypeId::LookupByName (socketType); - m_socket = Socket::CreateSocket (GetNode (), tid); - m_socket->Bind (); - m_socket->ShutdownRecv (); - m_socket->Connect (remote); -} -\endcode -While the the crux of the logic is located in the DoGenerate method -which is called from within StartApplication: -\code -void -RandomGenerator::DoGenerate (void) -{ - m_next = Simulator::Schedule (Seconds (m_delay.GetValue ()), - &RandomGenerator::DoGenerate, this); - Ptr p = Create (m_size.GetIntValue ()); - m_socket->Send (p); -} -\endcode - -To make that application more integrated in ns-3, it needs an associated -helper class: -\code -class RandomAppHelper -{ -public: - RandomAppHelper (std::string protocol, Address remote); - void SetPacketSize (RandomVariable packetSize); - void SetDelay (RandomVariable delay); - ApplicationContainer Install (NodeContainer nodes); -private: - std::string m_protocol; - Address m_remote; - RandomVariable m_packetSize; - RandomVariable m_delay; -}; -\endcode - -which could be trivially implemented as: -\code -ApplicationContainer -RandomAppHelper::Install (NodeContainer nodes) -{ - ApplicationContainer applications; - for (NodeContainer::Iterator i = nodes.Begin (); i != nodes.End (); ++i) - { - Ptr app = CreateObject (); - app->SetSize (m_packetSize); - app->SetDelay (m_delay); - app->SetRemote (m_protocol, m_remote); - (*i)->AddApplication (app); - applications.Add (app); - } - return applications; -} -\endcode - -Despite being functional, this API is not very consistant with the style of -the other helper classes, all of which allow you to control the parameters -of the underlying class through attributes and not explicit setters. The -following API thus replaces the pair SetPacketSize/SetDelay with a single -method SetAttribute: -\code -class RandomAppHelper -{ -public: - RandomAppHelper (std::string protocol, Address remote); - void SetAttribute (std::string name, const AttributeValue &value); - ApplicationContainer Install (NodeContainer c); -private: - std::string m_protocol; - Address m_remote; - ObjectFactory m_factory; -}; -\endcode - -And which can be used as follows: -\code -RandomAppHelper app = RandomAppHelper ("ns3::TcpSocketFactory", - InetSocketAddress (Ipv4Address ("192.168.1.10"), 10)); -app.SetAttribute ("Delay", StringValue ("Constant:2.5")); -app.SetAttribute ("Size", StringValue ("Constant:2100")); -app.Install (nodes); -\endcode - -The implementation, in this case, is not necessarily longer but its -simplicity hides a lot of behind-the-scenes complexity: - -\code -void -RandomAppHelper::SetAttribute (std::string name, const AttributeValue &value) -{ - m_factory.Set (name, value); -} -ApplicationContainer -RandomAppHelper::Install (NodeContainer nodes) -{ - ApplicationContainer applications; - for (NodeContainer::Iterator i = nodes.Begin (); i != nodes.End (); ++i) - { - Ptr app = m_factory.Create (); - app->SetRemote (m_socketType, m_remote); - (*i)->AddApplication (app); - applications.Add (app); - } - return applications; -} -\endcode - -The key difference between this implementation and the previous one -is that this helper does not handle explicitely the attributes -delay and packet size. Instead, it stores them in an -\ref ns3::ObjectFactory "ObjectFactory" object. This, of course, -does not work magically, and requires extra support from the -underlying RandomGenerator class. Specifically, it requires -that the underlying RandomGenerator defines its attributes -in its \ref ns3::TypeId "TypeId" in a new public static method: - -\code -class RandomGenerator -{ -public: - static TypeId GetTypeId (void); -}; -\endcode - -The corresponding implementation is shown below: - -\code -TypeId -RandomGenerator::GetTypeId (void) -{ - static TypeId tid = TypeId ("RandomGenerator") - .SetParent () - .AddConstructor () - .AddAttribute ("Delay", "The delay between two packets (s)", - RandomVariableValue (ConstantVariable (1.0)), - MakeRandomVariableAccessor (&RandomGenerator::m_delay), - MakeRandomVariableChecker ()) - .AddAttribute ("PacketSize", "The size of each packet (bytes)", - RandomVariableValue (ConstantVariable (2000)), - MakeRandomVariableAccessor (&RandomGenerator::m_size), - MakeRandomVariableChecker ()) - ; - return tid; -} -\endcode - -*/ diff --git a/doc/howtos/howtos-callbacks.h b/doc/howtos/howtos-callbacks.h deleted file mode 100644 index c0a16654c..000000000 --- a/doc/howtos/howtos-callbacks.h +++ /dev/null @@ -1,38 +0,0 @@ -/*! -\page callbacks Using ns-3 callbacks -\anchor howtos-callbacks - -\section null_callbacks Null Callbacks - -Question: The API I am using calls for using a callback (in the -function signature), but I do not -want to provide one. Is there a way to provide a null callback? - -Answer: Use the ns3::MakeNullCallback construct: -\code -template -Callback< R, T1, T2, T3, T4, T5, T6 > ns3::MakeNullCallback (void) -\endcode - -Example usage: The ns3::Socket class uses callbacks to indicate completion -of events such as a successful TCP connect(). These callbacks are set -in the following function: -\code - void Socket::SetConnectCallback (Callback > connectionSucceeded, - Callback > connectionFailed, - Callback > halfClose); - -\endcode -But suppose you do not care about registering a callback for the -halfClose event (but you want to register one for the -connectionSucceeded and connectionFailed cases). In that case, you -can pass a null callback as the third argument. You just need to -pass a callback with the matching signature, as follows: -\code - localSocket->SetConnectCallback ( - MakeCallback (&ConnectionSucceededCallback), - MakeCallback (&ConnectionFailedCallback), - MakeNullCallback > () ); -\endcode - -*/ diff --git a/doc/howtos/howtos-net-device.h b/doc/howtos/howtos-net-device.h deleted file mode 100644 index 00bb016e1..000000000 --- a/doc/howtos/howtos-net-device.h +++ /dev/null @@ -1,162 +0,0 @@ -/*! - \page net-device How to create a new OSI layer 1 + 2 implementation ? - \anchor howtos-net-device - - Question: How do I integrate a new OSI layer 1 + 2 implementation ? - - Answer: The OSI layers 1 and 2 are represented by the ns3::NetDevice - and ns3::Channel classes. To plug transparently in ns-3, a new layer 1+2 model - thus simply needs to provide two new subclasses of these two base classes. - - To make that subclassing process easy, two skeleton classes are provided in - the src/node directory: simple-net-device.h (ns3::SimpleNetDevice) and - simple-channel.h (ns3::SimpleChannel) implement a broadcast passthru medium - using 48bit MAC addresses without any kind of MAC access algorithm or PHY - layer modeling. - - The ns3::SimpleChannel class is really very simple: it provides - an implementation for the ns3::Channel::GetNDevices and ns3::Channel::GetDevice - methods defined in the Channel base class and, then defines the channel-specific - send and add methods: -- The Add method is used by SimpleNetDevice::SetChannel to register a new - SimpleNetDevice with its associated channel. -- The Send method is used by SimpleNetDevice::Send to send a packet over the - broadcast medium and ensure that it gets delivered to all associated devices - (except the sender). - -\code -class SimpleChannel : public Channel -{ -public: - static TypeId GetTypeId (void); - SimpleChannel (); - - void Send (Ptr p, uint16_t protocol, Mac48Address to, Mac48Address from, - Ptr sender); - - void Add (Ptr device); - - // inherited from ns3::Channel - virtual uint32_t GetNDevices (void) const; - virtual Ptr GetDevice (uint32_t i) const; - -private: - std::vector > m_devices; -}; -\endcode - -The SimpleNetDevice class is also trivial since it implements no special -MAC-layer processing: -\code -class SimpleNetDevice : public NetDevice -{ -public: - static TypeId GetTypeId (void); - SimpleNetDevice (); - - void Receive (Ptr packet, uint16_t protocol, Mac48Address to, Mac48Address from); - void SetChannel (Ptr channel); - void SetAddress (Mac48Address address); - - // inherited from NetDevice base class. - virtual void SetName(const std::string name); - ... -}; -\endcode - -The code below illustrates how the three model-specific methods defined above are -implemented: - -\code -void -SimpleNetDevice::Receive (Ptr packet, uint16_t protocol, - Mac48Address to, Mac48Address from) -{ - if (to == m_address || to == Mac48Address::GetBroadcast ()) - { - m_rxCallback (this, packet, protocol, from); - } -} -void -SimpleNetDevice::SetChannel (Ptr channel) -{ - m_channel = channel; - m_channel->Add (this); -} -void -SimpleNetDevice::SetAddress (Mac48Address address) -{ - m_address = address; -} -\endcode - -Building a topology with such a device is then a matter of -instanciating a set of SimpleNetDevice objects connected on a shared -SimpleChannel: -\code -NodeContainer nodes; -nodes.Create (10); -Ptr channel = CreateObject (); -for (uint32_t i = 0; i < nodes.GetN (); ++i) - { - CreateSimpleDevice (nodes.Get (i), channel); - } -\endcode - -With the following CreateSimpleDevice function: -\code -static Ptr -CreateSimpleDevice (Ptr node, Ptr channel) -{ - Ptr device = CreateObject (); - device->SetAddress (Mac48Address:Allocate ()); - device->SetChannel (channel); - node->AddDevice (device); - return device; -} -\endcode - -Of course, ultimately, you need to provide a helper class for this new device and channel -to save each user from having to re-implement their own CreateSimpleDevice helper -function: - -\code -class SimpleHelper -{ -public: - NetDeviceContainer Install (NodeContainer nodes, Ptr channel); - NetDeviceContainer Install (NodeContainer nodes); -}; -\endcode - -with the following straightforward implementation, inspired by the CreateSimpleDevice -function defined above: - -\code -NetDeviceContainer -SimpleHelper::Install (NodeContainer nodes, Ptr channel) -{ - NetDeviceContainer devices; - for (NodeContainer::Iterator i = nodes.Begin (); i != nodes.End (); ++i) - { - Ptr dev = CreateObject (); - dev->SetAddress (Mac48Address::Allocate ()); - dev->SetChannel (channel); - (*i)->AddDevice (dev); - devices.Add (dev); - } - return devices; -} -NetDeviceContainer -SimpleHelper::Install (NodeContainer nodes) -{ - return Install (nodes, CreateObject ()); -} -\endcode - -Of course, at some point, this device helper class should also contain a couple of -ascii and pcap tracing helper functions but, since the default SimpleNetDevice -class we used as an example here does not report any trace event, it would -be of little use. - -*/ diff --git a/doc/howtos/howtos-packet-header.h b/doc/howtos/howtos-packet-header.h deleted file mode 100644 index cf442167e..000000000 --- a/doc/howtos/howtos-packet-header.h +++ /dev/null @@ -1,119 +0,0 @@ -/*! -\page packet-header-trailer How to create a new type of protocol header or trailer -\anchor howtos-packet-header-trailer - -Question: I want to implement a new protocol X which uses a new -type of header Y. How do I implement and use this new header Y in ns-3 ? - -Answer: The key is to implement a new subclass of the ns3::Header -base class to represent your protocol header: -\code -class YHeader : public Header -{ -public: - // must be implemented to become a valid new header. - static TypeId GetTypeId (void); - virtual TypeId GetInstanceTypeId (void) const; - virtual uint32_t GetSerializedSize (void) const; - virtual void Serialize (Buffer::Iterator start) const; - virtual uint32_t Deserialize (Buffer::Iterator start); - virtual void Print (std::ostream &os) const; - - // allow protocol-specific access to the header data. - void SetData (uint32_t data); - uint32_t GetData (void) const; -private: - uint32_t m_data; -}; -\endcode - -Once this class is implemented, you can easily store your protocol -header into a packet: -\code -Ptr p = ...; -YHeader yHeader; -yHeader.SetData (0xdeadbeaf); -// copy the header into the packet -p->AddHeader (yHeader); -\endcode -and get it out of a packet: -\code -Ptr p = ...; -YHeader yHeader; -// copy the header from the packet -p->RemoveHeader (yHeader); -uint32_t data = yHeader.GetData (); -\endcode - -The implementation of the new header is very simple. First, you need -to give a TypeId to your YHeader class: -\code -TypeId -YHeader::GetTypeId (void) -{ - static TypeId tid = TypeId ("YHeader") - .SetParent
() - .AddConstructor () - ; - return tid; -} -TypeId -YHeader::GetInstanceTypeId (void) -{ - return GetTypeId (); -} -\endcode - -Then, you need to allow your header to serialize and deserialize itself -to a byte buffer in its network representation. Here, our new protocol -header contains first a 2-byte constant, and, then, the data field so, -the total size of the header is 2+4=6 bytes. -\code -uint32_t -YHeader::GetSerializedSize (void) const -{ - return 6; -} -void -YHeader::Serialize (Buffer::Iterator start) const -{ - // The 2 byte-constant - start.WriteU8 (0xfe); - start.WriteU8 (0xef); - // The data. - start.WriteHtonU32 (m_data); -} -uint32_t -YHeader::Deserialize (Buffer::Iterator start) -{ - uint8_t tmp; - tmp = start.ReadU8 (); - NS_ASSERT (tmp == 0xfe); - tmp = start.ReadU8 (); - NS_ASSERT (tmp == 0xef); - m_data = start.ReadNtohU32 (); - return 6; // the number of bytes consumed. -} -\endcode - -Finally, to make sure that Packet::Print also prints the content -of your header, just as it prints the content of the other -headers of the system, you need to provide a Print method: -\code -void -YHeader::Print (std::ostream &os) const -{ - os << "data=" << m_data; -} -\endcode - -The code will look the same if you want to implement a trailer, -that is, a protocol data structure which will be appended to the -end of the packet, not its start: you need to make sure that -you derive from the ns3::Trailer base class and that you call -Packet::AddTrailer and Packet::RemoveTrailer. Another important -detail is that you must make sure to rewind the iterator in your -Serialize and Deserialize methods writing to or reading from -the underlying buffer. - -*/ diff --git a/doc/howtos/howtos.h b/doc/howtos/howtos.h deleted file mode 100644 index 199b0d1b9..000000000 --- a/doc/howtos/howtos.h +++ /dev/null @@ -1,20 +0,0 @@ -/*! -\page howtos ns-3 HOWTOs -\anchor howtos-anchor - -This is an organized set of frequently asked questions (FAQ) and HOWTOs -for ns-3. This complements the following wiki pages: - -- User FAQ -- Developer FAQ - -Please consider contributing tips to either the wiki (yourself) or -by submitting a patch to this maintained documentation. - -- \subpage callbacks -- \subpage packet-header-trailer -- \subpage net-device -- \subpage application - -*/ - diff --git a/doc/main.h b/doc/main.h index 260438f8c..0b4a43528 100644 --- a/doc/main.h +++ b/doc/main.h @@ -15,12 +15,12 @@ * organizes all of the public API and supporting manual text * along the source code directory structure. This forms the * "ns-3 manual", and it is available in HTML and PDF forms. - * - \ref howtos-anchor "HOWTOs": A set of HOWTOs and FAQs is - * maintained on another Doxygen "Related Page" * - tutorial: The ns-3 tutorial is a separate document maintained in GNU Texinfo. + * - Reference manual: The ns-3 tutorial is a separate document maintained in GNU Texinfo. + * - Testing and validation manual: The ns-3 tutorial is a separate document maintained in GNU Texinfo. * - The ns-3 wiki * contains additional user-contributed material. Some wiki-contributed - * material may migrate to and overlap with the Doxygen information. + * material may migrate to and overlap with the Doxygen and manual information. * * \section install-sec Building the Documentation * From c150beb6da39e00f5e10095e2d2d25145ea95daa Mon Sep 17 00:00:00 2001 From: Tom Henderson Date: Fri, 13 Nov 2009 09:38:44 -0800 Subject: [PATCH 13/29] Align with texi2html-1.82 api changes --- doc/tutorial/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/tutorial/Makefile b/doc/tutorial/Makefile index 8dc4415ce..5c397e78d 100644 --- a/doc/tutorial/Makefile +++ b/doc/tutorial/Makefile @@ -27,7 +27,7 @@ html: $(TEXI2HTML) ${CSS} tutorial.texi split-html: - $(TEXI2HTML) ${CSS} ${SPLIT} tutorial.texi + $(TEXI2HTML) ${CSS} ${SPLIT} --output tutorial tutorial.texi pdf: $(TEXI2PDF) tutorial.texi From 704b8c2c50eef6004b3c604fd3d3e27d9c8631db Mon Sep 17 00:00:00 2001 From: Tom Henderson Date: Fri, 13 Nov 2009 13:21:59 -0800 Subject: [PATCH 14/29] fix tutorial pdf build --- doc/tutorial/tutorial.texi | 2 ++ 1 file changed, 2 insertions(+) diff --git a/doc/tutorial/tutorial.texi b/doc/tutorial/tutorial.texi index 958262e0b..f4fca50b0 100644 --- a/doc/tutorial/tutorial.texi +++ b/doc/tutorial/tutorial.texi @@ -64,7 +64,9 @@ along with this program. If not, see @uref{http://www.gnu.org/licenses/}. @end titlepage @c So the toc is printed at the start. +@ifnottex @anchor{Full Table of Contents} +@end ifnottex @contents @ifnottex From b50c6979a20136af700b239027c2687be3237c78 Mon Sep 17 00:00:00 2001 From: Tom Henderson Date: Fri, 13 Nov 2009 13:25:14 -0800 Subject: [PATCH 15/29] update doxygen main page --- doc/main.h | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/doc/main.h b/doc/main.h index 0b4a43528..cb88d7175 100644 --- a/doc/main.h +++ b/doc/main.h @@ -6,18 +6,17 @@ * Doxygen. * Doxygen is typically used for * API documentation, and organizes such documentation across different - * modules. This project uses Doxygen both for building the manual around - * the API documentation, and a separate GNU texinfo document is used for - * the manual. + * modules. This project uses Doxygen for building the definitive + * maintained API documentation, Separate GNU texinfo documents are used for + * a tutorial, reference manual, and testing and validation manual. * * The ns-3 project documentation is organized as follows: * - modules: The "Modules" tab (above) * organizes all of the public API and supporting manual text - * along the source code directory structure. This forms the - * "ns-3 manual", and it is available in HTML and PDF forms. - * - tutorial: The ns-3 tutorial is a separate document maintained in GNU Texinfo. - * - Reference manual: The ns-3 tutorial is a separate document maintained in GNU Texinfo. - * - Testing and validation manual: The ns-3 tutorial is a separate document maintained in GNU Texinfo. + * along the source code directory structure. + * - tutorial: The ns-3 tutorial is a separate document maintained in GNU Texinfo. + * - Reference manual: The ns-3 reference manual is a separate document maintained in GNU Texinfo. + * - Testing and validation manual: The ns-3 testing and validation manual is a separate document maintained in GNU Texinfo. * - The ns-3 wiki * contains additional user-contributed material. Some wiki-contributed * material may migrate to and overlap with the Doxygen and manual information. From 001791bad880b0a020dd3f7e6bda70c3f19fe226 Mon Sep 17 00:00:00 2001 From: Sebastien Vincent Date: Sat, 14 Nov 2009 11:25:12 +0100 Subject: [PATCH 16/29] Fix build on MinGW. --- examples/stats/wifi-example-sim.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/examples/stats/wifi-example-sim.cc b/examples/stats/wifi-example-sim.cc index 17c504ab9..71ed007cd 100644 --- a/examples/stats/wifi-example-sim.cc +++ b/examples/stats/wifi-example-sim.cc @@ -32,6 +32,8 @@ // #define NS3_LOG_ENABLE // Now defined by Makefile +#include + #include #include "ns3/core-module.h" From 5ce9ad2d7832cf22346fc43f70bd32a89f18fa09 Mon Sep 17 00:00:00 2001 From: Guillaume Seguin Date: Sat, 14 Nov 2009 17:47:05 +0100 Subject: [PATCH 17/29] Introduce Simulator::ScheduleWithContext* and Simulator::GetContext --- src/node/channel.h | 3 + src/simulator/default-simulator-impl.cc | 49 ++++- src/simulator/default-simulator-impl.h | 10 +- src/simulator/event-id.cc | 10 +- src/simulator/event-id.h | 4 +- src/simulator/realtime-simulator-impl.cc | 61 +++++- src/simulator/realtime-simulator-impl.h | 4 + src/simulator/scheduler.h | 5 +- src/simulator/simulator-impl.h | 3 + src/simulator/simulator.cc | 57 ++++-- src/simulator/simulator.h | 236 +++++++++++++++++++++++ 11 files changed, 398 insertions(+), 44 deletions(-) diff --git a/src/node/channel.h b/src/node/channel.h index 67fd082a9..b0c2b6d6b 100644 --- a/src/node/channel.h +++ b/src/node/channel.h @@ -36,6 +36,9 @@ class NetDevice; * * A channel is a logical path over which information flows. The path can * be as simple as a short piece of wire, or as complicated as space-time. + * + * Subclasses must use Simulator::ScheduleWithContext to correctly update + * event contexts when scheduling an event from one node to another one. */ class Channel : public Object { diff --git a/src/simulator/default-simulator-impl.cc b/src/simulator/default-simulator-impl.cc index 39506737d..22f79d4e0 100644 --- a/src/simulator/default-simulator-impl.cc +++ b/src/simulator/default-simulator-impl.cc @@ -53,10 +53,11 @@ DefaultSimulatorImpl::DefaultSimulatorImpl () // uid 0 is "invalid" events // uid 1 is "now" events // uid 2 is "destroy" events - m_uid = 4; + m_uid = 4; // before ::Run is entered, the m_currentUid will be zero m_currentUid = 0; m_currentTs = 0; + m_currentContext = 0xffffffff; m_unscheduledEvents = 0; } @@ -107,10 +108,11 @@ DefaultSimulatorImpl::ProcessOneEvent (void) Scheduler::Event next = m_events->RemoveNext (); NS_ASSERT (next.key.m_ts >= m_currentTs); - --m_unscheduledEvents; + m_unscheduledEvents--; NS_LOG_LOGIC ("handle " << next.key.m_ts); m_currentTs = next.key.m_ts; + m_currentContext = next.key.m_context; m_currentUid = next.key.m_uid; next.impl->Invoke (); next.impl->Unref (); @@ -162,6 +164,11 @@ DefaultSimulatorImpl::Stop (void) m_stop = true; } +void +DefaultSimulatorImpl::Stop (Time const &time) +{ + Simulator::Schedule (time, &Simulator::Stop); +} // // Schedule an event for a _relative_ time in the future. @@ -169,18 +176,34 @@ DefaultSimulatorImpl::Stop (void) EventId DefaultSimulatorImpl::Schedule (Time const &time, EventImpl *event) { - Time tAbsolute = time + Now(); + Time tAbsolute = time + TimeStep (m_currentTs); NS_ASSERT (tAbsolute.IsPositive ()); NS_ASSERT (tAbsolute >= TimeStep (m_currentTs)); Scheduler::Event ev; ev.impl = event; ev.key.m_ts = (uint64_t) tAbsolute.GetTimeStep (); + ev.key.m_context = GetContext (); ev.key.m_uid = m_uid; m_uid++; - ++m_unscheduledEvents; + m_unscheduledEvents++; + m_events->Insert (ev); + return EventId (event, ev.key.m_ts, ev.key.m_context, ev.key.m_uid); +} + +void +DefaultSimulatorImpl::ScheduleWithContext (uint32_t context, Time const &time, EventImpl *event) +{ + NS_LOG_FUNCTION (this << context << time.GetTimeStep () << m_currentTs << event); + + Scheduler::Event ev; + ev.impl = event; + ev.key.m_ts = m_currentTs + time.GetTimeStep (); + ev.key.m_context = context; + ev.key.m_uid = m_uid; + m_uid++; + m_unscheduledEvents++; m_events->Insert (ev); - return EventId (event, ev.key.m_ts, ev.key.m_uid); } EventId @@ -189,17 +212,18 @@ DefaultSimulatorImpl::ScheduleNow (EventImpl *event) Scheduler::Event ev; ev.impl = event; ev.key.m_ts = m_currentTs; + ev.key.m_context = GetContext (); ev.key.m_uid = m_uid; m_uid++; - ++m_unscheduledEvents; + m_unscheduledEvents++; m_events->Insert (ev); - return EventId (event, ev.key.m_ts, ev.key.m_uid); + return EventId (event, ev.key.m_ts, ev.key.m_context, ev.key.m_uid); } EventId DefaultSimulatorImpl::ScheduleDestroy (EventImpl *event) { - EventId id (Ptr (event, false), m_currentTs, 2); + EventId id (Ptr (event, false), m_currentTs, 0xffffffff, 2); m_destroyEvents.push_back (id); m_uid++; return id; @@ -247,13 +271,14 @@ DefaultSimulatorImpl::Remove (const EventId &id) Scheduler::Event event; event.impl = id.PeekEventImpl (); event.key.m_ts = id.GetTs (); + event.key.m_context = id.GetContext (); event.key.m_uid = id.GetUid (); m_events->Remove (event); event.impl->Cancel (); // whenever we remove an event from the event list, we have to unref it. event.impl->Unref (); - --m_unscheduledEvents; + m_unscheduledEvents--; } void @@ -307,6 +332,12 @@ DefaultSimulatorImpl::GetMaximumSimulationTime (void) const return TimeStep (0x7fffffffffffffffLL); } +uint32_t +DefaultSimulatorImpl::GetContext (void) const +{ + return m_currentContext; +} + } // namespace ns3 diff --git a/src/simulator/default-simulator-impl.h b/src/simulator/default-simulator-impl.h index c5156078b..db3b25ee8 100644 --- a/src/simulator/default-simulator-impl.h +++ b/src/simulator/default-simulator-impl.h @@ -26,14 +26,12 @@ #include "event-impl.h" #include "ns3/ptr.h" -#include "ns3/assert.h" -#include "ns3/log.h" #include namespace ns3 { - class DefaultSimulatorImpl : public SimulatorImpl +class DefaultSimulatorImpl : public SimulatorImpl { public: static TypeId GetTypeId (void); @@ -45,7 +43,9 @@ public: virtual bool IsFinished (void) const; virtual Time Next (void) const; virtual void Stop (void); + virtual void Stop (Time const &time); virtual EventId Schedule (Time const &time, EventImpl *event); + virtual void ScheduleWithContext (uint32_t context, Time const &time, EventImpl *event); virtual EventId ScheduleNow (EventImpl *event); virtual EventId ScheduleDestroy (EventImpl *event); virtual void Remove (const EventId &ev); @@ -57,18 +57,20 @@ public: virtual Time GetDelayLeft (const EventId &id) const; virtual Time GetMaximumSimulationTime (void) const; virtual void SetScheduler (ObjectFactory schedulerFactory); + virtual uint32_t GetContext (void) const; private: void ProcessOneEvent (void); uint64_t NextTs (void) const; - typedef std::list DestroyEvents; + DestroyEvents m_destroyEvents; bool m_stop; Ptr m_events; uint32_t m_uid; uint32_t m_currentUid; uint64_t m_currentTs; + uint32_t m_currentContext; // number of events that have been inserted but not yet scheduled, // not counting the "destroy" events; this is used for validation int m_unscheduledEvents; diff --git a/src/simulator/event-id.cc b/src/simulator/event-id.cc index 78d476f94..a8258cfd6 100644 --- a/src/simulator/event-id.cc +++ b/src/simulator/event-id.cc @@ -26,12 +26,14 @@ namespace ns3 { EventId::EventId () : m_eventImpl (0), m_ts (0), + m_context (0), m_uid (0) {} -EventId::EventId (const Ptr &impl, uint64_t ts, uint32_t uid) +EventId::EventId (const Ptr &impl, uint64_t ts, uint32_t context, uint32_t uid) : m_eventImpl (impl), m_ts (ts), + m_context (context), m_uid (uid) {} void @@ -60,6 +62,11 @@ EventId::GetTs (void) const return m_ts; } uint32_t +EventId::GetContext (void) const +{ + return m_context; +} +uint32_t EventId::GetUid (void) const { return m_uid; @@ -69,6 +76,7 @@ bool operator == (const EventId &a, const EventId &b) { return a.m_uid == b.m_uid && + a.m_context == b.m_context && a.m_ts == b.m_ts && a.m_eventImpl == b.m_eventImpl; } diff --git a/src/simulator/event-id.h b/src/simulator/event-id.h index 2269646de..a28acbba6 100644 --- a/src/simulator/event-id.h +++ b/src/simulator/event-id.h @@ -47,7 +47,7 @@ class EventId { public: EventId (); // internal. - EventId (const Ptr &impl, uint64_t ts, uint32_t uid); + EventId (const Ptr &impl, uint64_t ts, uint32_t context, uint32_t uid); /** * This method is syntactic sugar for the ns3::Simulator::cancel * method. @@ -72,11 +72,13 @@ public: */ EventImpl *PeekEventImpl (void) const; uint64_t GetTs (void) const; + uint32_t GetContext (void) const; uint32_t GetUid (void) const; private: friend bool operator == (const EventId &a, const EventId &b); Ptr m_eventImpl; uint64_t m_ts; + uint32_t m_context; uint32_t m_uid; }; diff --git a/src/simulator/realtime-simulator-impl.cc b/src/simulator/realtime-simulator-impl.cc index ccbd2fa4f..8b6cc68c3 100644 --- a/src/simulator/realtime-simulator-impl.cc +++ b/src/simulator/realtime-simulator-impl.cc @@ -77,6 +77,7 @@ RealtimeSimulatorImpl::RealtimeSimulatorImpl () // before ::Run is entered, the m_currentUid will be zero m_currentUid = 0; m_currentTs = 0; + m_currentContext = 0xffffffff; m_unscheduledEvents = 0; // Be very careful not to do anything that would cause a change or assignment @@ -309,7 +310,7 @@ RealtimeSimulatorImpl::ProcessOneEvent (void) NS_ASSERT_MSG (m_events->IsEmpty () == false, "RealtimeSimulatorImpl::ProcessOneEvent(): event queue is empty"); next = m_events->RemoveNext (); - --m_unscheduledEvents; + m_unscheduledEvents--; // // We cannot make any assumption that "next" is the same event we originally waited @@ -327,6 +328,7 @@ RealtimeSimulatorImpl::ProcessOneEvent (void) // is frozen until the next event is executed. // m_currentTs = next.key.m_ts; + m_currentContext = next.key.m_context; m_currentUid = next.key.m_uid; // @@ -506,10 +508,11 @@ RealtimeSimulatorImpl::RunOneEvent (void) Scheduler::Event next = m_events->RemoveNext (); NS_ASSERT (next.key.m_ts >= m_currentTs); - --m_unscheduledEvents; + m_unscheduledEvents--; NS_LOG_LOGIC ("handle " << next.key.m_ts); m_currentTs = next.key.m_ts; + m_currentContext = next.key.m_context; m_currentUid = next.key.m_ts; event = next.impl; } @@ -524,6 +527,12 @@ RealtimeSimulatorImpl::Stop (void) m_stop = true; } +void +RealtimeSimulatorImpl::Stop (Time const &time) +{ + Simulator::Schedule (time, &Simulator::Stop); +} + // // Schedule an event for a _relative_ time in the future. // @@ -546,14 +555,38 @@ RealtimeSimulatorImpl::Schedule (Time const &time, EventImpl *impl) NS_ASSERT_MSG (tAbsolute >= TimeStep (m_currentTs), "RealtimeSimulatorImpl::Schedule(): time < m_currentTs"); ev.impl = impl; ev.key.m_ts = (uint64_t) tAbsolute.GetTimeStep (); + ev.key.m_context = GetContext (); ev.key.m_uid = m_uid; m_uid++; - ++m_unscheduledEvents; + m_unscheduledEvents++; m_events->Insert (ev); m_synchronizer->Signal (); } - return EventId (impl, ev.key.m_ts, ev.key.m_uid); + return EventId (impl, ev.key.m_ts, ev.key.m_context, ev.key.m_uid); +} + +void +RealtimeSimulatorImpl::ScheduleWithContext (uint32_t context, Time const &time, EventImpl *impl) +{ + NS_LOG_FUNCTION (time << impl); + + { + CriticalSection cs (m_mutex); + uint64_t ts; + + ts = m_currentTs + time.GetTimeStep (); + NS_ASSERT_MSG (ts >= m_currentTs, "RealtimeSimulatorImpl::ScheduleRealtime(): schedule for time < m_currentTs"); + Scheduler::Event ev; + ev.impl = impl; + ev.key.m_ts = ts; + ev.key.m_context = context; + ev.key.m_uid = m_uid; + m_uid++; + m_unscheduledEvents++; + m_events->Insert (ev); + m_synchronizer->Signal (); + } } EventId @@ -566,14 +599,15 @@ RealtimeSimulatorImpl::ScheduleNow (EventImpl *impl) ev.impl = impl; ev.key.m_ts = m_currentTs; + ev.key.m_context = GetContext (); ev.key.m_uid = m_uid; m_uid++; - ++m_unscheduledEvents; + m_unscheduledEvents++; m_events->Insert (ev); m_synchronizer->Signal (); } - return EventId (impl, ev.key.m_ts, ev.key.m_uid); + return EventId (impl, ev.key.m_ts, ev.key.m_context, ev.key.m_uid); } Time @@ -601,7 +635,7 @@ RealtimeSimulatorImpl::ScheduleRealtime (Time const &time, EventImpl *impl) ev.key.m_ts = ts; ev.key.m_uid = m_uid; m_uid++; - ++m_unscheduledEvents; + m_unscheduledEvents++; m_events->Insert (ev); m_synchronizer->Signal (); } @@ -626,7 +660,7 @@ RealtimeSimulatorImpl::ScheduleRealtimeNow (EventImpl *impl) ev.key.m_ts = ts; ev.key.m_uid = m_uid; m_uid++; - ++m_unscheduledEvents; + m_unscheduledEvents++; m_events->Insert (ev); m_synchronizer->Signal (); } @@ -652,7 +686,7 @@ RealtimeSimulatorImpl::ScheduleDestroy (EventImpl *impl) // overridden by the uid of 2 which identifies this as an event to be // executed at Simulator::Destroy time. // - id = EventId (Ptr (impl, false), m_currentTs, 2); + id = EventId (Ptr (impl, false), m_currentTs, 0xffffffff, 2); m_destroyEvents.push_back (id); m_uid++; } @@ -704,10 +738,11 @@ RealtimeSimulatorImpl::Remove (const EventId &id) Scheduler::Event event; event.impl = id.PeekEventImpl (); event.key.m_ts = id.GetTs (); + event.key.m_context = id.GetContext (); event.key.m_uid = id.GetUid (); m_events->Remove (event); - --m_unscheduledEvents; + m_unscheduledEvents--; event.impl->Cancel (); event.impl->Unref (); } @@ -773,6 +808,12 @@ RealtimeSimulatorImpl::GetMaximumSimulationTime (void) const return TimeStep (0x7fffffffffffffffLL); } +uint32_t +RealtimeSimulatorImpl::GetContext (void) const +{ + return m_currentContext; +} + void RealtimeSimulatorImpl::SetSynchronizationMode (enum SynchronizationMode mode) { diff --git a/src/simulator/realtime-simulator-impl.h b/src/simulator/realtime-simulator-impl.h index 832919af1..b7ff62476 100644 --- a/src/simulator/realtime-simulator-impl.h +++ b/src/simulator/realtime-simulator-impl.h @@ -55,7 +55,9 @@ public: virtual bool IsFinished (void) const; virtual Time Next (void) const; virtual void Stop (void); + virtual void Stop (Time const &time); virtual EventId Schedule (Time const &time, EventImpl *event); + virtual void ScheduleWithContext (uint32_t context, Time const &time, EventImpl *event); virtual EventId ScheduleNow (EventImpl *event); virtual EventId ScheduleDestroy (EventImpl *event); virtual void Remove (const EventId &ev); @@ -67,6 +69,7 @@ public: virtual Time GetDelayLeft (const EventId &id) const; virtual Time GetMaximumSimulationTime (void) const; virtual void SetScheduler (ObjectFactory schedulerFactory); + virtual uint32_t GetContext (void) const; void ScheduleRealtime (Time const &time, EventImpl *event); void ScheduleRealtimeNow (EventImpl *event); @@ -96,6 +99,7 @@ private: uint32_t m_uid; uint32_t m_currentUid; uint64_t m_currentTs; + uint32_t m_currentContext; mutable SystemMutex m_mutex; diff --git a/src/simulator/scheduler.h b/src/simulator/scheduler.h index 394987f7c..3ed2ab0ba 100644 --- a/src/simulator/scheduler.h +++ b/src/simulator/scheduler.h @@ -56,8 +56,9 @@ class Scheduler : public Object static TypeId GetTypeId (void); struct EventKey { - uint64_t m_ts; - uint32_t m_uid; + uint64_t m_ts; + uint32_t m_uid; + uint32_t m_context; }; struct Event { EventImpl *impl; diff --git a/src/simulator/simulator-impl.h b/src/simulator/simulator-impl.h index 166905a9d..67664ee0b 100644 --- a/src/simulator/simulator-impl.h +++ b/src/simulator/simulator-impl.h @@ -39,7 +39,9 @@ public: virtual bool IsFinished (void) const = 0; virtual Time Next (void) const = 0; virtual void Stop (void) = 0; + virtual void Stop (Time const &time) = 0; virtual EventId Schedule (Time const &time, EventImpl *event) = 0; + virtual void ScheduleWithContext (uint32_t context, Time const &time, EventImpl *event) = 0; virtual EventId ScheduleNow (EventImpl *event) = 0; virtual EventId ScheduleDestroy (EventImpl *event) = 0; virtual void Remove (const EventId &ev) = 0; @@ -51,6 +53,7 @@ public: virtual Time GetDelayLeft (const EventId &id) const = 0; virtual Time GetMaximumSimulationTime (void) const = 0; virtual void SetScheduler (ObjectFactory schedulerFactory) = 0; + virtual uint32_t GetContext (void) const = 0; }; } // namespace ns3 diff --git a/src/simulator/simulator.cc b/src/simulator/simulator.cc index dda4f9d63..ae00f5f12 100644 --- a/src/simulator/simulator.cc +++ b/src/simulator/simulator.cc @@ -20,10 +20,6 @@ #include "ns3/core-config.h" #include "simulator.h" #include "simulator-impl.h" -#include "default-simulator-impl.h" -#ifdef HAVE_PTHREAD_H -# include "realtime-simulator-impl.h" -#endif #include "scheduler.h" #include "map-scheduler.h" #include "event-impl.h" @@ -71,19 +67,19 @@ TimePrinter (std::ostream &os) #endif /* NS3_LOG_ENABLE */ -static Ptr *PeekImpl (void) +static SimulatorImpl **PeekImpl (void) { - static Ptr impl = 0; + static SimulatorImpl *impl = 0; return &impl; } static SimulatorImpl * GetImpl (void) { - Ptr &impl = *PeekImpl (); + SimulatorImpl **pimpl = PeekImpl (); /* Please, don't include any calls to logging macros in this function * or pay the price, that is, stack explosions. */ - if (impl == 0) + if (*pimpl == 0) { { ObjectFactory factory; @@ -91,14 +87,14 @@ static SimulatorImpl * GetImpl (void) g_simTypeImpl.GetValue (s); factory.SetTypeId (s.Get ()); - impl = factory.Create (); + *pimpl = GetPointer (factory.Create ()); } { ObjectFactory factory; StringValue s; g_schedTypeImpl.GetValue (s); factory.SetTypeId (s.Get ()); - impl->SetScheduler (factory); + (*pimpl)->SetScheduler (factory); } // @@ -110,7 +106,7 @@ static SimulatorImpl * GetImpl (void) // LogSetTimePrinter (&TimePrinter); } - return PeekPointer (impl); + return *pimpl; } void @@ -118,8 +114,8 @@ Simulator::Destroy (void) { NS_LOG_FUNCTION_NOARGS (); - Ptr &impl = *PeekImpl (); - if (impl == 0) + SimulatorImpl **pimpl = PeekImpl (); + if (*pimpl == 0) { return; } @@ -129,8 +125,9 @@ Simulator::Destroy (void) * the stack explodes. */ LogSetTimePrinter (0); - impl->Destroy (); - impl = 0; + (*pimpl)->Destroy (); + (*pimpl)->Unref (); + *pimpl = 0; } void @@ -179,7 +176,7 @@ void Simulator::Stop (Time const &time) { NS_LOG_FUNCTION (time); - Simulator::Schedule (time, &Simulator::Stop); + GetImpl ()->Stop (time); } Time @@ -205,6 +202,13 @@ Simulator::Schedule (Time const &time, const Ptr &ev) return DoSchedule (time, GetPointer (ev)); } +void +Simulator::ScheduleWithContext (uint32_t context, Time const &time, const Ptr &ev) +{ + NS_LOG_FUNCTION (time << context << ev); + return DoScheduleWithContext (context, time, GetPointer (ev)); +} + EventId Simulator::ScheduleNow (const Ptr &ev) { @@ -223,6 +227,11 @@ Simulator::DoSchedule (Time const &time, EventImpl *impl) { return GetImpl ()->Schedule (time, impl); } +void +Simulator::DoScheduleWithContext (uint32_t context, Time const &time, EventImpl *impl) +{ + return GetImpl ()->ScheduleWithContext (context, time, impl); +} EventId Simulator::DoScheduleNow (EventImpl *impl) { @@ -242,6 +251,13 @@ Simulator::Schedule (Time const &time, void (*f) (void)) return DoSchedule (time, MakeEvent (f)); } +void +Simulator::ScheduleWithContext (uint32_t context, Time const &time, void (*f) (void)) +{ + NS_LOG_FUNCTION (time << context << f); + return DoScheduleWithContext (context, time, MakeEvent (f)); +} + EventId Simulator::ScheduleNow (void (*f) (void)) { @@ -290,6 +306,13 @@ Simulator::GetMaximumSimulationTime (void) return GetImpl ()->GetMaximumSimulationTime (); } +uint32_t +Simulator::GetContext (void) +{ + NS_LOG_FUNCTION_NOARGS (); + return GetImpl ()->GetContext (); +} + void Simulator::SetImplementation (Ptr impl) { @@ -297,7 +320,7 @@ Simulator::SetImplementation (Ptr impl) { NS_FATAL_ERROR ("It is not possible to set the implementation after calling any Simulator:: function. Call Simulator::SetImplementation earlier or after Simulator::Destroy."); } - *PeekImpl () = impl; + *PeekImpl () = GetPointer (impl); // Set the default scheduler ObjectFactory factory; StringValue s; diff --git a/src/simulator/simulator.h b/src/simulator/simulator.h index ec02182fa..cb7e825f4 100644 --- a/src/simulator/simulator.h +++ b/src/simulator/simulator.h @@ -283,6 +283,145 @@ public: typename T1, typename T2, typename T3, typename T4, typename T5> static EventId Schedule (Time const &time, void (*f) (U1,U2,U3,U4,U5), T1 a1, T2 a2, T3 a3, T4 a4, T5 a5); + /** + * Schedule an event with the given context. + * A context of 0xffffffff means no context is specified. + * + * @param time the relative expiration time of the event. + * @param context user-specified context parameter + * @param mem_ptr member method pointer to invoke + * @param obj the object on which to invoke the member method + */ + template + static void ScheduleWithContext (uint32_t context, Time const &time, MEM mem_ptr, OBJ obj); + + /** + * @param time the relative expiration time of the event. + * @param context user-specified context parameter + * @param mem_ptr member method pointer to invoke + * @param obj the object on which to invoke the member method + * @param a1 the first argument to pass to the invoked method + */ + template + static void ScheduleWithContext (uint32_t context, Time const &time, MEM mem_ptr, OBJ obj, T1 a1); + + /** + * @param time the relative expiration time of the event. + * @param context user-specified context parameter + * @param mem_ptr member method pointer to invoke + * @param obj the object on which to invoke the member method + * @param a1 the first argument to pass to the invoked method + * @param a2 the second argument to pass to the invoked method + */ + template + static void ScheduleWithContext (uint32_t context, Time const &time, MEM mem_ptr, OBJ obj, T1 a1, T2 a2); + + /** + * @param time the relative expiration time of the event. + * @param context user-specified context parameter + * @param mem_ptr member method pointer to invoke + * @param obj the object on which to invoke the member method + * @param a1 the first argument to pass to the invoked method + * @param a2 the second argument to pass to the invoked method + * @param a3 the third argument to pass to the invoked method + */ + template + static void ScheduleWithContext (uint32_t context, Time const &time, MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3); + + /** + * @param time the relative expiration time of the event. + * @param context user-specified context parameter + * @param mem_ptr member method pointer to invoke + * @param obj the object on which to invoke the member method + * @param a1 the first argument to pass to the invoked method + * @param a2 the second argument to pass to the invoked method + * @param a3 the third argument to pass to the invoked method + * @param a4 the fourth argument to pass to the invoked method + */ + template + static void ScheduleWithContext (uint32_t context, Time const &time, MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3, T4 a4); + + /** + * @param time the relative expiration time of the event. + * @param context user-specified context parameter + * @param mem_ptr member method pointer to invoke + * @param obj the object on which to invoke the member method + * @param a1 the first argument to pass to the invoked method + * @param a2 the second argument to pass to the invoked method + * @param a3 the third argument to pass to the invoked method + * @param a4 the fourth argument to pass to the invoked method + * @param a5 the fifth argument to pass to the invoked method + */ + template + static void ScheduleWithContext (uint32_t context, Time const &time, MEM mem_ptr, OBJ obj, + T1 a1, T2 a2, T3 a3, T4 a4, T5 a5); + /** + * @param time the relative expiration time of the event. + * @param context user-specified context parameter + * @param f the function to invoke + */ + static void ScheduleWithContext (uint32_t context, Time const &time, void (*f) (void)); + + /** + * @param time the relative expiration time of the event. + * @param context user-specified context parameter + * @param f the function to invoke + * @param a1 the first argument to pass to the function to invoke + */ + template + static void ScheduleWithContext (uint32_t context, Time const &time, void (*f) (U1), T1 a1); + + /** + * @param time the relative expiration time of the event. + * @param context user-specified context parameter + * @param f the function to invoke + * @param a1 the first argument to pass to the function to invoke + * @param a2 the second argument to pass to the function to invoke + */ + template + static void ScheduleWithContext (uint32_t context, Time const &time, void (*f) (U1,U2), T1 a1, T2 a2); + + /** + * @param time the relative expiration time of the event. + * @param context user-specified context parameter + * @param f the function to invoke + * @param a1 the first argument to pass to the function to invoke + * @param a2 the second argument to pass to the function to invoke + * @param a3 the third argument to pass to the function to invoke + */ + template + static void ScheduleWithContext (uint32_t context, Time const &time, void (*f) (U1,U2,U3), T1 a1, T2 a2, T3 a3); + + /** + * @param time the relative expiration time of the event. + * @param context user-specified context parameter + * @param f the function to invoke + * @param a1 the first argument to pass to the function to invoke + * @param a2 the second argument to pass to the function to invoke + * @param a3 the third argument to pass to the function to invoke + * @param a4 the fourth argument to pass to the function to invoke + */ + template + static void ScheduleWithContext (uint32_t context, Time const &time, void (*f) (U1,U2,U3,U4), T1 a1, T2 a2, T3 a3, T4 a4); + + /** + * @param time the relative expiration time of the event. + * @param context user-specified context parameter + * @param f the function to invoke + * @param a1 the first argument to pass to the function to invoke + * @param a2 the second argument to pass to the function to invoke + * @param a3 the third argument to pass to the function to invoke + * @param a4 the fourth argument to pass to the function to invoke + * @param a5 the fifth argument to pass to the function to invoke + */ + template + static void ScheduleWithContext (uint32_t context, Time const &time, void (*f) (U1,U2,U3,U4,U5), T1 a1, T2 a2, T3 a3, T4 a4, T5 a5); + /** * Schedule an event to expire Now. All events scheduled to * to expire "Now" are scheduled FIFO, after all normal events @@ -588,6 +727,11 @@ public: */ static Time GetMaximumSimulationTime (void); + /** + * \returns the current simulation context + */ + static uint32_t GetContext (void); + /** * \param time delay until the event expires * \param event the event to schedule @@ -598,6 +742,17 @@ public: */ static EventId Schedule (Time const &time, const Ptr &event); + /** + * \param time delay until the event expires + * \param context event context + * \param event the event to schedule + * \returns a unique identifier for the newly-scheduled event. + * + * This method will be typically used by language bindings + * to delegate events to their own subclass of the EventImpl base class. + */ + static void ScheduleWithContext (uint32_t context, Time const &time, const Ptr &event); + /** * \param event the event to schedule * \returns a unique identifier for the newly-scheduled event. @@ -620,6 +775,7 @@ private: ~Simulator (); static EventId DoSchedule (Time const &time, EventImpl *event); + static void DoScheduleWithContext (uint32_t context, Time const &time, EventImpl *event); static EventId DoScheduleNow (EventImpl *event); static EventId DoScheduleDestroy (EventImpl *event); }; @@ -721,6 +877,86 @@ EventId Simulator::Schedule (Time const &time, void (*f) (U1,U2,U3,U4,U5), T1 a1 +template +void Simulator::ScheduleWithContext (uint32_t context, Time const &time, MEM mem_ptr, OBJ obj) +{ + DoScheduleWithContext (context, time, MakeEvent (mem_ptr, obj)); +} + + +template +void Simulator::ScheduleWithContext (uint32_t context, Time const &time, MEM mem_ptr, OBJ obj, T1 a1) +{ + return DoScheduleWithContext (context, time, MakeEvent (mem_ptr, obj, a1)); +} + +template +void Simulator::ScheduleWithContext (uint32_t context, Time const &time, MEM mem_ptr, OBJ obj, T1 a1, T2 a2) +{ + return DoScheduleWithContext (context, time, MakeEvent (mem_ptr, obj, a1, a2)); +} + +template +void Simulator::ScheduleWithContext (uint32_t context, Time const &time, MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3) +{ + return DoScheduleWithContext (context, time, MakeEvent (mem_ptr, obj, a1, a2, a3)); +} + +template +void Simulator::ScheduleWithContext (uint32_t context, Time const &time, MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3, T4 a4) +{ + return DoScheduleWithContext (context, time, MakeEvent (mem_ptr, obj, a1, a2, a3, a4)); +} + +template +void Simulator::ScheduleWithContext (uint32_t context, Time const &time, MEM mem_ptr, OBJ obj, + T1 a1, T2 a2, T3 a3, T4 a4, T5 a5) +{ + return DoScheduleWithContext (context, time, MakeEvent (mem_ptr, obj, a1, a2, a3, a4, a5)); +} + +template +void Simulator::ScheduleWithContext (uint32_t context, Time const &time, void (*f) (U1), T1 a1) +{ + return DoScheduleWithContext (context, time, MakeEvent (f, a1)); +} + +template +void Simulator::ScheduleWithContext (uint32_t context, Time const &time, void (*f) (U1,U2), T1 a1, T2 a2) +{ + return DoScheduleWithContext (context, time, MakeEvent (f, a1, a2)); +} + +template +void Simulator::ScheduleWithContext (uint32_t context, Time const &time, void (*f) (U1,U2,U3), T1 a1, T2 a2, T3 a3) +{ + return DoScheduleWithContext (context, time, MakeEvent (f, a1, a2, a3)); +} + +template +void Simulator::ScheduleWithContext (uint32_t context, Time const &time, void (*f) (U1,U2,U3,U4), T1 a1, T2 a2, T3 a3, T4 a4) +{ + return DoScheduleWithContext (context, time, MakeEvent (f, a1, a2, a3, a4)); +} + +template +void Simulator::ScheduleWithContext (uint32_t context, Time const &time, void (*f) (U1,U2,U3,U4,U5), T1 a1, T2 a2, T3 a3, T4 a4, T5 a5) +{ + return DoScheduleWithContext (context, time, MakeEvent (f, a1, a2, a3, a4, a5)); +} + + + + template EventId Simulator::ScheduleNow (MEM mem_ptr, OBJ obj) From 94cf348701530c74564b9588ea3da2bc49ff8f38 Mon Sep 17 00:00:00 2001 From: Guillaume Seguin Date: Sat, 14 Nov 2009 17:47:05 +0100 Subject: [PATCH 18/29] Print node context in log messages --- src/core/log.cc | 16 +++++++++++++++- src/core/log.h | 25 +++++++++++++++++++++++-- src/simulator/simulator.cc | 16 ++++++++++++++++ 3 files changed, 54 insertions(+), 3 deletions(-) diff --git a/src/core/log.cc b/src/core/log.cc index cc050bfd0..e9e7d9f2a 100644 --- a/src/core/log.cc +++ b/src/core/log.cc @@ -35,6 +35,7 @@ namespace ns3 { LogTimePrinter g_logTimePrinter = 0; +LogNodePrinter g_logNodePrinter = 0; typedef std::list > ComponentList; typedef std::list >::iterator ComponentListI; @@ -124,7 +125,7 @@ LogComponent::EnvVarCheck (char const * name) component = tmp; if (component == myName || component == "*") { - int level = LOG_ALL | LOG_PREFIX_TIME | LOG_PREFIX_FUNC; + int level = LOG_ALL | LOG_PREFIX_TIME | LOG_PREFIX_FUNC | LOG_PREFIX_NODE; Enable ((enum LogLevel)level); return; } @@ -178,6 +179,10 @@ LogComponent::EnvVarCheck (char const * name) { level |= LOG_PREFIX_TIME; } + else if (lev == "prefix_node") + { + level |= LOG_PREFIX_NODE; + } else if (lev == "level_error") { level |= LOG_LEVEL_ERROR; @@ -360,6 +365,15 @@ LogTimePrinter LogGetTimePrinter(void) return g_logTimePrinter; } +void LogSetNodePrinter (LogNodePrinter printer) +{ + g_logNodePrinter = printer; +} +LogNodePrinter LogGetNodePrinter(void) +{ + return g_logNodePrinter; +} + ParameterLogger::ParameterLogger (std::ostream &os) : m_itemNumber (0), diff --git a/src/core/log.h b/src/core/log.h index ef141f351..b1ec1dadc 100644 --- a/src/core/log.h +++ b/src/core/log.h @@ -48,11 +48,12 @@ enum LogLevel { LOG_LOGIC = 0x00000020, // control flow tracing within functions LOG_LEVEL_LOGIC = 0x0000003f, - LOG_ALL = 0x3fffffff, // print everything + LOG_ALL = 0x1fffffff, // print everything LOG_LEVEL_ALL = LOG_ALL, LOG_PREFIX_FUNC = 0x80000000, // prefix all trace prints with function - LOG_PREFIX_TIME = 0x40000000 // prefix all trace prints with simulation time + LOG_PREFIX_TIME = 0x40000000, // prefix all trace prints with simulation time + LOG_PREFIX_NODE = 0x20000000 // prefix all trace prints with simulation node }; /** @@ -160,6 +161,17 @@ void LogComponentDisableAll (enum LogLevel level); } \ } +#define NS_LOG_APPEND_NODE_PREFIX \ + if (g_log.IsEnabled (ns3::LOG_PREFIX_NODE)) \ + { \ + ns3::LogNodePrinter printer = ns3::LogGetNodePrinter (); \ + if (printer != 0) \ + { \ + (*printer) (std::clog); \ + std::clog << " "; \ + } \ + } + #define NS_LOG_APPEND_FUNC_PREFIX \ if (g_log.IsEnabled (ns3::LOG_PREFIX_FUNC)) \ { \ @@ -192,6 +204,7 @@ void LogComponentDisableAll (enum LogLevel level); if (g_log.IsEnabled (level)) \ { \ NS_LOG_APPEND_TIME_PREFIX; \ + NS_LOG_APPEND_NODE_PREFIX; \ NS_LOG_APPEND_CONTEXT; \ NS_LOG_APPEND_FUNC_PREFIX; \ std::clog << msg << std::endl; \ @@ -246,6 +259,7 @@ void LogComponentDisableAll (enum LogLevel level); if (g_log.IsEnabled (ns3::LOG_FUNCTION)) \ { \ NS_LOG_APPEND_TIME_PREFIX; \ + NS_LOG_APPEND_NODE_PREFIX; \ NS_LOG_APPEND_CONTEXT; \ std::clog << g_log.Name () << ":" \ << __FUNCTION__ << "()" << std::endl; \ @@ -276,6 +290,7 @@ void LogComponentDisableAll (enum LogLevel level); if (g_log.IsEnabled (ns3::LOG_FUNCTION)) \ { \ NS_LOG_APPEND_TIME_PREFIX; \ + NS_LOG_APPEND_NODE_PREFIX; \ NS_LOG_APPEND_CONTEXT; \ std::clog << g_log.Name () << ":" \ << __FUNCTION__ << "("; \ @@ -321,10 +336,14 @@ namespace ns3 { void LogComponentPrintList (void); typedef void (*LogTimePrinter) (std::ostream &os); +typedef void (*LogNodePrinter) (std::ostream &os); void LogSetTimePrinter (LogTimePrinter); LogTimePrinter LogGetTimePrinter(void); +void LogSetNodePrinter (LogNodePrinter); +LogNodePrinter LogGetNodePrinter(void); + class LogComponent { public: @@ -384,6 +403,8 @@ public: #define LogSetTimePrinter(printer) #define LogGetTimePrinter +#define LogSetNodePrinter(printer) +#define LogGetNodePrinter #endif /* LOG_ENABLE */ diff --git a/src/simulator/simulator.cc b/src/simulator/simulator.cc index ae00f5f12..3a51d6f41 100644 --- a/src/simulator/simulator.cc +++ b/src/simulator/simulator.cc @@ -65,6 +65,19 @@ TimePrinter (std::ostream &os) os << Simulator::Now ().GetSeconds () << "s"; } +static void +NodePrinter (std::ostream &os) +{ + if (Simulator::GetContext () == 0xffffffff) + { + os << "-1"; + } + else + { + os << Simulator::GetContext (); + } +} + #endif /* NS3_LOG_ENABLE */ static SimulatorImpl **PeekImpl (void) @@ -105,6 +118,7 @@ static SimulatorImpl * GetImpl (void) // in an infinite recursion until the stack explodes. // LogSetTimePrinter (&TimePrinter); + LogSetNodePrinter (&NodePrinter); } return *pimpl; } @@ -125,6 +139,7 @@ Simulator::Destroy (void) * the stack explodes. */ LogSetTimePrinter (0); + LogSetNodePrinter (0); (*pimpl)->Destroy (); (*pimpl)->Unref (); *pimpl = 0; @@ -335,6 +350,7 @@ Simulator::SetImplementation (Ptr impl) // in an infinite recursion until the stack explodes. // LogSetTimePrinter (&TimePrinter); + LogSetNodePrinter (&NodePrinter); } Ptr Simulator::GetImplementation (void) From c420843c3d71eacf4d941954e781d4ad869e006d Mon Sep 17 00:00:00 2001 From: Guillaume Seguin Date: Sat, 14 Nov 2009 17:47:05 +0100 Subject: [PATCH 19/29] Call Simulator::ScheduleWithContext from ns3::Channel subclasses when sending packets to other nodes --- src/devices/csma/csma-channel.cc | 34 +++++++++++-------- .../point-to-point/point-to-point-channel.cc | 5 +-- src/devices/wifi/yans-wifi-channel.cc | 15 ++++++-- src/node/simple-channel.cc | 4 ++- .../ns3wifi/wifi-interference-test-suite.cc | 10 +++--- 5 files changed, 45 insertions(+), 23 deletions(-) diff --git a/src/devices/csma/csma-channel.cc b/src/devices/csma/csma-channel.cc index 20b870db1..c5a4d97cc 100644 --- a/src/devices/csma/csma-channel.cc +++ b/src/devices/csma/csma-channel.cc @@ -212,8 +212,27 @@ CsmaChannel::TransmitEnd() NS_LOG_LOGIC ("Schedule event in " << m_delay.GetSeconds () << " sec"); + + NS_LOG_LOGIC ("Receive"); + + std::vector::iterator it; + uint32_t devId = 0; + for (it = m_deviceList.begin (); it < m_deviceList.end(); it++) + { + if (it->IsActive ()) + { + // schedule reception events + Simulator::ScheduleWithContext (it->devicePtr->GetNode ()->GetId (), + m_delay, + &CsmaNetDevice::Receive, it->devicePtr, + m_currentPkt->Copy (), m_deviceList[m_currentSrc].devicePtr); + } + devId++; + } + + // also schedule for the tx side to go back to IDLE Simulator::Schedule (m_delay, &CsmaChannel::PropagationCompleteEvent, - this); + this); return retVal; } @@ -224,19 +243,6 @@ CsmaChannel::PropagationCompleteEvent() NS_LOG_INFO ("UID is " << m_currentPkt->GetUid () << ")"); NS_ASSERT (m_state == PROPAGATING); - - NS_LOG_LOGIC ("Receive"); - - std::vector::iterator it; - uint32_t devId = 0; - for (it = m_deviceList.begin (); it < m_deviceList.end(); it++) - { - if (it->IsActive ()) - { - it->devicePtr->Receive (m_currentPkt->Copy (), m_deviceList[m_currentSrc].devicePtr); - } - devId++; - } m_state = IDLE; } diff --git a/src/devices/point-to-point/point-to-point-channel.cc b/src/devices/point-to-point/point-to-point-channel.cc index eb6865e14..2522058f1 100644 --- a/src/devices/point-to-point/point-to-point-channel.cc +++ b/src/devices/point-to-point/point-to-point-channel.cc @@ -93,8 +93,9 @@ PointToPointChannel::TransmitStart( uint32_t wire = src == m_link[0].m_src ? 0 : 1; - Simulator::Schedule (txTime + m_delay, &PointToPointNetDevice::Receive, - m_link[wire].m_dst, p); + Simulator::ScheduleWithContext (m_link[wire].m_dst->GetNode ()->GetId (), + txTime + m_delay, &PointToPointNetDevice::Receive, + m_link[wire].m_dst, p); // Call the tx anim callback on the net device m_txrxPointToPoint (p, src, m_link[wire].m_dst, txTime, txTime + m_delay); diff --git a/src/devices/wifi/yans-wifi-channel.cc b/src/devices/wifi/yans-wifi-channel.cc index fee768abb..05385410e 100644 --- a/src/devices/wifi/yans-wifi-channel.cc +++ b/src/devices/wifi/yans-wifi-channel.cc @@ -92,8 +92,19 @@ YansWifiChannel::Send (Ptr sender, Ptr packet, double NS_LOG_DEBUG ("propagation: txPower="< p, uint16_t protocol, { continue; } - Simulator::ScheduleNow (&SimpleNetDevice::Receive, tmp, p->Copy (), protocol, to, from); + Simulator::ScheduleWithContext (tmp->GetNode ()->GetId (), Seconds (0), + &SimpleNetDevice::Receive, tmp, p->Copy (), protocol, to, from); } } diff --git a/src/test/ns3wifi/wifi-interference-test-suite.cc b/src/test/ns3wifi/wifi-interference-test-suite.cc index 9f287ac11..200d64851 100644 --- a/src/test/ns3wifi/wifi-interference-test-suite.cc +++ b/src/test/ns3wifi/wifi-interference-test-suite.cc @@ -211,11 +211,13 @@ WifiInterferenceTestCase::WifiSimpleInterference (std::string phyMode,double Prs // Tracing // wifiPhy.EnablePcap ("wifi-simple-interference", devices.Get (0)); - Simulator::Schedule (Seconds (startTime), &GenerateTraffic, - source, PpacketSize, numPackets, interPacketInterval); + Simulator::ScheduleWithContext (source->GetNode ()->GetId (), + Seconds (startTime), &GenerateTraffic, + source, PpacketSize, numPackets, interPacketInterval); - Simulator::Schedule (Seconds (startTime + delta/1000000.0), &GenerateTraffic, - interferer, IpacketSize, numPackets, interPacketInterval); + Simulator::ScheduleWithContext (interferer->GetNode ()->GetId (), + Seconds (startTime + delta/1000000.0), &GenerateTraffic, + interferer, IpacketSize, numPackets, interPacketInterval); Simulator::Run (); Simulator::Destroy (); From a23934a4b7111304a9d35d93c6a318f5e179866a Mon Sep 17 00:00:00 2001 From: Guillaume Seguin Date: Sat, 14 Nov 2009 17:47:05 +0100 Subject: [PATCH 20/29] Make applications generate traffic within their associated context/node --- examples/emulation/emu-ping.cc | 4 +- examples/ipv6/radvd-two-prefix.cc | 4 +- examples/ipv6/radvd.cc | 4 +- examples/stats/wifi-example-sim.cc | 4 +- examples/tutorial/fifth.cc | 4 +- examples/wireless/wifi-simple-adhoc.cc | 7 +- examples/wireless/wifi-simple-infra.cc | 5 +- examples/wireless/wifi-simple-interference.cc | 10 +-- src/core/object.cc | 18 +++++ src/core/object.h | 20 ++++++ src/devices/wifi/nqap-wifi-mac.cc | 27 ++++++-- src/devices/wifi/nqap-wifi-mac.h | 2 + src/devices/wifi/qap-wifi-mac.cc | 27 ++++++-- src/devices/wifi/qap-wifi-mac.h | 2 + src/helper/application-container.cc | 4 +- .../random-direction-2d-mobility-model.cc | 19 ++++-- .../random-direction-2d-mobility-model.h | 4 +- src/mobility/random-walk-2d-mobility-model.cc | 13 ++-- src/mobility/random-walk-2d-mobility-model.h | 5 +- .../random-waypoint-mobility-model.cc | 19 +++--- src/mobility/random-waypoint-mobility-model.h | 5 +- src/node/application.cc | 68 +++++++++---------- src/node/application.h | 34 +++------- src/node/node-list.cc | 1 + src/node/node.cc | 18 +++++ src/node/node.h | 1 + src/routing/list-routing/ipv4-list-routing.cc | 13 ++++ src/routing/list-routing/ipv4-list-routing.h | 1 + src/routing/olsr/olsr-routing-protocol.cc | 4 +- src/routing/olsr/olsr-routing-protocol.h | 4 +- 30 files changed, 225 insertions(+), 126 deletions(-) diff --git a/examples/emulation/emu-ping.cc b/examples/emulation/emu-ping.cc index 0a9fc0b4f..d4ae019d8 100644 --- a/examples/emulation/emu-ping.cc +++ b/examples/emulation/emu-ping.cc @@ -186,8 +186,8 @@ main (int argc, char *argv[]) Ptr app = CreateObject (); app->SetAttribute ("Remote", Ipv4AddressValue (remoteIp)); node->AddApplication (app); - app->Start (Seconds (1.0)); - app->Stop (Seconds (5.0)); + app->SetStartTime (Seconds (1.0)); + app->SetStopTime (Seconds (5.0)); // // Give the application a name. This makes life much easier when constructing diff --git a/examples/ipv6/radvd-two-prefix.cc b/examples/ipv6/radvd-two-prefix.cc index f382ba52c..bea674c40 100644 --- a/examples/ipv6/radvd-two-prefix.cc +++ b/examples/ipv6/radvd-two-prefix.cc @@ -183,8 +183,8 @@ int main (int argc, char** argv) radvd->AddConfiguration (routerInterface2); r->AddApplication (radvd); - radvd->Start (Seconds (1.0)); - radvd->Stop (Seconds (2.0)); + radvd->SetStartTime (Seconds (1.0)); + radvd->SetStopTime (Seconds (2.0)); /* Create a Ping6 application to send ICMPv6 echo request from n0 to n1 via R */ uint32_t packetSize = 1024; diff --git a/examples/ipv6/radvd.cc b/examples/ipv6/radvd.cc index e6be2af22..dbe05ff87 100644 --- a/examples/ipv6/radvd.cc +++ b/examples/ipv6/radvd.cc @@ -123,8 +123,8 @@ int main (int argc, char** argv) radvd->AddConfiguration (routerInterface2); r->AddApplication (radvd); - radvd->Start (Seconds (1.0)); - radvd->Stop (Seconds (10.0)); + radvd->SetStartTime (Seconds (1.0)); + radvd->SetStopTime (Seconds (10.0)); /* Create a Ping6 application to send ICMPv6 echo request from n0 to n1 via R */ uint32_t packetSize = 1024; diff --git a/examples/stats/wifi-example-sim.cc b/examples/stats/wifi-example-sim.cc index 71ed007cd..4a8dec963 100644 --- a/examples/stats/wifi-example-sim.cc +++ b/examples/stats/wifi-example-sim.cc @@ -167,12 +167,12 @@ int main(int argc, char *argv[]) { Ptr appSource = NodeList::GetNode(0); Ptr sender = CreateObject(); appSource->AddApplication(sender); - sender->Start(Seconds(1)); + sender->SetStartTime(Seconds(1)); Ptr appSink = NodeList::GetNode(1); Ptr receiver = CreateObject(); appSink->AddApplication(receiver); - receiver->Start(Seconds(0)); + receiver->SetStartTime(Seconds(0)); // Config::Set("/NodeList/*/ApplicationList/*/$Sender/Destination", // Ipv4AddressValue("192.168.0.2")); diff --git a/examples/tutorial/fifth.cc b/examples/tutorial/fifth.cc index 75e8f48b0..3687cec2a 100644 --- a/examples/tutorial/fifth.cc +++ b/examples/tutorial/fifth.cc @@ -210,8 +210,8 @@ main (int argc, char *argv[]) Ptr app = CreateObject (); app->Setup (ns3TcpSocket, sinkAddress, 1040, 1000, DataRate ("1Mbps")); nodes.Get (0)->AddApplication (app); - app->Start (Seconds (1.)); - app->Stop (Seconds (20.)); + app->SetStartTime (Seconds (1.)); + app->SetStopTime (Seconds (20.)); devices.Get (1)->TraceConnectWithoutContext("PhyRxDrop", MakeCallback (&RxDrop)); diff --git a/examples/wireless/wifi-simple-adhoc.cc b/examples/wireless/wifi-simple-adhoc.cc index 0a2dcbd79..5336fde31 100644 --- a/examples/wireless/wifi-simple-adhoc.cc +++ b/examples/wireless/wifi-simple-adhoc.cc @@ -80,7 +80,7 @@ static void GenerateTraffic (Ptr socket, uint32_t pktSize, { socket->Send (Create (pktSize)); Simulator::Schedule (pktInterval, &GenerateTraffic, - socket, pktSize,pktCount-1, pktInterval); + socket, pktSize,pktCount-1, pktInterval); } else { @@ -187,8 +187,9 @@ int main (int argc, char *argv[]) // Output what we are doing NS_LOG_UNCOND ("Testing " << numPackets << " packets sent with receiver rss " << rss ); - Simulator::Schedule (Seconds (1.0), &GenerateTraffic, - source, packetSize, numPackets, interPacketInterval); + Simulator::ScheduleWithContext (source->GetNode ()->GetId (), + Seconds (1.0), &GenerateTraffic, + source, packetSize, numPackets, interPacketInterval); Simulator::Run (); Simulator::Destroy (); diff --git a/examples/wireless/wifi-simple-infra.cc b/examples/wireless/wifi-simple-infra.cc index 5422f6a84..d9e31328b 100644 --- a/examples/wireless/wifi-simple-infra.cc +++ b/examples/wireless/wifi-simple-infra.cc @@ -200,8 +200,9 @@ int main (int argc, char *argv[]) // Output what we are doing NS_LOG_UNCOND ("Testing " << numPackets << " packets sent with receiver rss " << rss ); - Simulator::Schedule (Seconds (1.0), &GenerateTraffic, - source, packetSize, numPackets, interPacketInterval); + Simulator::ScheduleWithContext (source->GetNode ()->GetId (), + Seconds (1.0), &GenerateTraffic, + source, packetSize, numPackets, interPacketInterval); Simulator::Stop (Seconds (30.0)); Simulator::Run (); diff --git a/examples/wireless/wifi-simple-interference.cc b/examples/wireless/wifi-simple-interference.cc index 93d2d98e4..e62472fe9 100644 --- a/examples/wireless/wifi-simple-interference.cc +++ b/examples/wireless/wifi-simple-interference.cc @@ -245,11 +245,13 @@ int main (int argc, char *argv[]) // Output what we are doing NS_LOG_UNCOND ("Primary packet RSS=" << Prss << " dBm and interferer RSS=" << Irss << " dBm at time offset=" << delta << " ms"); - Simulator::Schedule (Seconds (startTime), &GenerateTraffic, - source, PpacketSize, numPackets, interPacketInterval); + Simulator::ScheduleWithContext (source->GetNode ()->GetId (), + Seconds (startTime), &GenerateTraffic, + source, PpacketSize, numPackets, interPacketInterval); - Simulator::Schedule (Seconds (startTime + delta/1000000.0), &GenerateTraffic, - interferer, IpacketSize, numPackets, interPacketInterval); + Simulator::ScheduleWithContext (interferer->GetNode ()->GetId (), + Seconds (startTime + delta/1000000.0), &GenerateTraffic, + interferer, IpacketSize, numPackets, interPacketInterval); Simulator::Run (); Simulator::Destroy (); diff --git a/src/core/object.cc b/src/core/object.cc index 79f6bce00..34c35fc50 100644 --- a/src/core/object.cc +++ b/src/core/object.cc @@ -81,6 +81,7 @@ Object::GetTypeId (void) Object::Object () : m_tid (Object::GetTypeId ()), m_disposed (false), + m_started (false), m_aggregates ((struct Aggregates *)malloc (sizeof (struct Aggregates))), m_getObjectCount (0) { @@ -113,6 +114,7 @@ Object::~Object () Object::Object (const Object &o) : m_tid (o.m_tid), m_disposed (false), + m_started (false), m_aggregates ((struct Aggregates *)malloc (sizeof (struct Aggregates))), m_getObjectCount (0) { @@ -158,6 +160,17 @@ Object::DoGetObject (TypeId tid) const } return 0; } +void +Object::Start (void) +{ + uint32_t n = m_aggregates->n; + for (uint32_t i = 0; i < n; i++) + { + Object *current = m_aggregates->buffer[i]; + current->DoStart (); + current->m_started = true; + } +} void Object::Dispose (void) { @@ -264,6 +277,11 @@ Object::DoDispose (void) NS_ASSERT (!m_disposed); } +void +Object::DoStart (void) +{ + NS_ASSERT (!m_started); +} bool Object::Check (void) const diff --git a/src/core/object.h b/src/core/object.h index 4488b351e..f9d6edaed 100644 --- a/src/core/object.h +++ b/src/core/object.h @@ -140,6 +140,12 @@ public: */ AggregateIterator GetAggregateIterator (void) const; + /** + * Execute starting code of an object. What this method does is really up + * to the user. + */ + void Start (void); + protected: /** * This function is called by the AggregateObject on all the objects connected in the listed chain. @@ -148,6 +154,15 @@ protected: * additional/special behavior when aggregated to another object. */ virtual void NotifyNewAggregate (); + /** + * This method is called only once by Object::Start. If the user + * calls Object::Start multiple times, DoStart is called only the + * first time. + * + * Subclasses are expected to override this method and _chain up_ + * to their parent's implementation once they are done. + */ + virtual void DoStart (void); /** * This method is called by Object::Dispose or by the object's * destructor, whichever comes first. @@ -250,6 +265,11 @@ private: * has run, false otherwise. */ bool m_disposed; + /** + * Set to true once the DoStart method has run, + * false otherwise + */ + bool m_started; /** * a pointer to an array of 'aggregates'. i.e., a pointer to * each object aggregated to this object is stored in this diff --git a/src/devices/wifi/nqap-wifi-mac.cc b/src/devices/wifi/nqap-wifi-mac.cc index 07e5ec7b1..21f8974d9 100644 --- a/src/devices/wifi/nqap-wifi-mac.cc +++ b/src/devices/wifi/nqap-wifi-mac.cc @@ -90,6 +90,8 @@ NqapWifiMac::NqapWifiMac () m_dca->SetManager (m_dcfManager); m_dca->SetTxOkCallback (MakeCallback (&NqapWifiMac::TxOk, this)); m_dca->SetTxFailedCallback (MakeCallback (&NqapWifiMac::TxFailed, this)); + + m_enableBeaconGeneration = false; } NqapWifiMac::~NqapWifiMac () { @@ -110,6 +112,7 @@ NqapWifiMac::DoDispose (void) m_dca = 0; m_beaconDca = 0; m_stationManager = 0; + m_enableBeaconGeneration = false; m_beaconEvent.Cancel (); WifiMac::DoDispose (); } @@ -118,20 +121,21 @@ void NqapWifiMac::SetBeaconGeneration (bool enable) { NS_LOG_FUNCTION (this << enable); - if (enable) + if (!enable) + { + m_beaconEvent.Cancel (); + } + else if (enable && !m_enableBeaconGeneration) { m_beaconEvent = Simulator::ScheduleNow (&NqapWifiMac::SendOneBeacon, this); } - else - { - m_beaconEvent.Cancel (); - } + m_enableBeaconGeneration = enable; } bool NqapWifiMac::GetBeaconGeneration (void) const { - return m_beaconEvent.IsRunning (); + return m_enableBeaconGeneration; } Time NqapWifiMac::GetBeaconInterval (void) const @@ -594,4 +598,15 @@ NqapWifiMac::FinishConfigureStandard (enum WifiPhyStandard standard) } +void +NqapWifiMac::DoStart (void) +{ + m_beaconEvent.Cancel (); + if (m_enableBeaconGeneration) + { + m_beaconEvent = Simulator::ScheduleNow (&NqapWifiMac::SendOneBeacon, this); + } + WifiMac::DoStart (); +} + } // namespace ns3 diff --git a/src/devices/wifi/nqap-wifi-mac.h b/src/devices/wifi/nqap-wifi-mac.h index 414248571..a1704886f 100644 --- a/src/devices/wifi/nqap-wifi-mac.h +++ b/src/devices/wifi/nqap-wifi-mac.h @@ -112,6 +112,7 @@ private: void SetBeaconGeneration (bool enable); bool GetBeaconGeneration (void) const; virtual void DoDispose (void); + virtual void DoStart (void); NqapWifiMac (const NqapWifiMac & ctor_arg); NqapWifiMac &operator = (const NqapWifiMac &o); Ptr GetDcaTxop (void) const; @@ -123,6 +124,7 @@ private: Ptr m_phy; Callback,Mac48Address, Mac48Address> m_upCallback; Time m_beaconInterval; + bool m_enableBeaconGeneration; DcfManager *m_dcfManager; MacRxMiddle *m_rxMiddle; diff --git a/src/devices/wifi/qap-wifi-mac.cc b/src/devices/wifi/qap-wifi-mac.cc index 7c5e51c29..e66fdf5bc 100644 --- a/src/devices/wifi/qap-wifi-mac.cc +++ b/src/devices/wifi/qap-wifi-mac.cc @@ -109,6 +109,8 @@ QapWifiMac::QapWifiMac () SetQueue (AC_VI); SetQueue (AC_BE); SetQueue (AC_BK); + + m_enableBeaconGeneration = false; } QapWifiMac::~QapWifiMac () @@ -129,6 +131,7 @@ QapWifiMac::DoDispose () m_low = 0; m_phy = 0; m_beaconDca = 0; + m_enableBeaconGeneration = false; m_beaconEvent.Cancel (); m_stationManager = 0; for (Queues::iterator i = m_queues.begin (); i != m_queues.end (); ++i) @@ -142,20 +145,21 @@ void QapWifiMac::SetBeaconGeneration (bool enable) { NS_LOG_FUNCTION (this << enable); - if (enable) - { - m_beaconEvent = Simulator::ScheduleNow (&QapWifiMac::SendOneBeacon, this); - } - else + if (!enable) { m_beaconEvent.Cancel (); } + else if (enable && !m_enableBeaconGeneration) + { + m_beaconEvent = Simulator::ScheduleNow (&QapWifiMac::SendOneBeacon, this); + } + m_enableBeaconGeneration = enable; } bool QapWifiMac::GetBeaconGeneration (void) const { - return m_beaconEvent.IsRunning (); + return m_enableBeaconGeneration; } Time @@ -772,4 +776,15 @@ QapWifiMac::FinishConfigureStandard (enum WifiPhyStandard standard) } } +void +QapWifiMac::DoStart (void) +{ + m_beaconEvent.Cancel (); + if (m_enableBeaconGeneration) + { + m_beaconEvent = Simulator::ScheduleNow (&QapWifiMac::SendOneBeacon, this); + } + WifiMac::DoStart (); +} + } //namespace ns3 diff --git a/src/devices/wifi/qap-wifi-mac.h b/src/devices/wifi/qap-wifi-mac.h index 1c789e96f..c83391376 100644 --- a/src/devices/wifi/qap-wifi-mac.h +++ b/src/devices/wifi/qap-wifi-mac.h @@ -92,6 +92,7 @@ private: typedef std::list, AmsduSubframeHeader> >::const_iterator DeaggregatedMsdusCI; virtual void DoDispose (void); + virtual void DoStart (void); void Receive (Ptr packet, WifiMacHeader const*hdr); void ForwardUp (Ptr packet, Mac48Address from, Mac48Address to); void ForwardDown (Ptr packet, Mac48Address from, Mac48Address to); @@ -130,6 +131,7 @@ private: Ssid m_ssid; EventId m_beaconEvent; Time m_beaconInterval; + bool m_enableBeaconGeneration; Callback, Mac48Address, Mac48Address> m_forwardUp; }; diff --git a/src/helper/application-container.cc b/src/helper/application-container.cc index 041b0ee6c..a63eaf105 100644 --- a/src/helper/application-container.cc +++ b/src/helper/application-container.cc @@ -85,7 +85,7 @@ ApplicationContainer::Start (Time start) for (Iterator i = Begin (); i != End (); ++i) { Ptr app = *i; - app->Start (start); + app->SetStartTime (start); } } void @@ -94,7 +94,7 @@ ApplicationContainer::Stop (Time stop) for (Iterator i = Begin (); i != End (); ++i) { Ptr app = *i; - app->Stop (stop); + app->SetStopTime (stop); } } diff --git a/src/mobility/random-direction-2d-mobility-model.cc b/src/mobility/random-direction-2d-mobility-model.cc index d11312cc6..2a8595f78 100644 --- a/src/mobility/random-direction-2d-mobility-model.cc +++ b/src/mobility/random-direction-2d-mobility-model.cc @@ -55,11 +55,6 @@ RandomDirection2dMobilityModel::GetTypeId (void) return tid; } - -RandomDirection2dMobilityModel::RandomDirection2dMobilityModel () -{ - m_event = Simulator::ScheduleNow (&RandomDirection2dMobilityModel::Start, this); -} void RandomDirection2dMobilityModel::DoDispose (void) { @@ -67,7 +62,14 @@ RandomDirection2dMobilityModel::DoDispose (void) MobilityModel::DoDispose (); } void -RandomDirection2dMobilityModel::Start (void) +RandomDirection2dMobilityModel::DoStart (void) +{ + DoStartPrivate (); + MobilityModel::DoStart (); +} + +void +RandomDirection2dMobilityModel::DoStartPrivate (void) { double direction = m_direction.GetValue (0, 2 * PI); SetDirectionAndSpeed (direction); @@ -79,6 +81,7 @@ RandomDirection2dMobilityModel::BeginPause (void) m_helper.Update (); m_helper.Pause (); Time pause = Seconds (m_pause.GetValue ()); + m_event.Cancel (); m_event = Simulator::Schedule (pause, &RandomDirection2dMobilityModel::ResetDirectionAndSpeed, this); NotifyCourseChange (); } @@ -97,6 +100,7 @@ RandomDirection2dMobilityModel::SetDirectionAndSpeed (double direction) m_helper.Unpause (); Vector next = m_bounds.CalculateIntersection (position, vector); Time delay = Seconds (CalculateDistance (position, next) / speed); + m_event.Cancel (); m_event = Simulator::Schedule (delay, &RandomDirection2dMobilityModel::BeginPause, this); NotifyCourseChange (); @@ -136,7 +140,8 @@ RandomDirection2dMobilityModel::DoSetPosition (const Vector &position) { m_helper.SetPosition (position); Simulator::Remove (m_event); - m_event = Simulator::ScheduleNow (&RandomDirection2dMobilityModel::Start, this); + m_event.Cancel (); + m_event = Simulator::ScheduleNow (&RandomDirection2dMobilityModel::DoStartPrivate, this); } Vector RandomDirection2dMobilityModel::DoGetVelocity (void) const diff --git a/src/mobility/random-direction-2d-mobility-model.h b/src/mobility/random-direction-2d-mobility-model.h index ecea0288f..bf8cc01c1 100644 --- a/src/mobility/random-direction-2d-mobility-model.h +++ b/src/mobility/random-direction-2d-mobility-model.h @@ -45,14 +45,14 @@ class RandomDirection2dMobilityModel : public MobilityModel public: static TypeId GetTypeId (void); - RandomDirection2dMobilityModel (); private: - void Start (void); void ResetDirectionAndSpeed (void); void BeginPause (void); void SetDirectionAndSpeed (double direction); void InitializeDirectionAndSpeed (void); + void DoStartPrivate (void); virtual void DoDispose (void); + virtual void DoStart (void); virtual Vector DoGetPosition (void) const; virtual void DoSetPosition (const Vector &position); virtual Vector DoGetVelocity (void) const; diff --git a/src/mobility/random-walk-2d-mobility-model.cc b/src/mobility/random-walk-2d-mobility-model.cc index e426a6575..11b5a3a55 100644 --- a/src/mobility/random-walk-2d-mobility-model.cc +++ b/src/mobility/random-walk-2d-mobility-model.cc @@ -72,13 +72,15 @@ RandomWalk2dMobilityModel::GetTypeId (void) return tid; } -RandomWalk2dMobilityModel::RandomWalk2dMobilityModel () +void +RandomWalk2dMobilityModel::DoStart (void) { - m_event = Simulator::ScheduleNow (&RandomWalk2dMobilityModel::Start, this); + DoStartPrivate (); + MobilityModel::DoStart (); } void -RandomWalk2dMobilityModel::Start (void) +RandomWalk2dMobilityModel::DoStartPrivate (void) { m_helper.Update (); double speed = m_speed.GetValue (); @@ -109,9 +111,10 @@ RandomWalk2dMobilityModel::DoWalk (Time delayLeft) Vector nextPosition = position; nextPosition.x += speed.x * delayLeft.GetSeconds (); nextPosition.y += speed.y * delayLeft.GetSeconds (); + m_event.Cancel (); if (m_bounds.IsInside (nextPosition)) { - m_event = Simulator::Schedule (delayLeft, &RandomWalk2dMobilityModel::Start, this); + m_event = Simulator::Schedule (delayLeft, &RandomWalk2dMobilityModel::DoStartPrivate, this); } else { @@ -163,7 +166,7 @@ RandomWalk2dMobilityModel::DoSetPosition (const Vector &position) NS_ASSERT (m_bounds.IsInside (position)); m_helper.SetPosition (position); Simulator::Remove (m_event); - m_event = Simulator::ScheduleNow (&RandomWalk2dMobilityModel::Start, this); + m_event = Simulator::ScheduleNow (&RandomWalk2dMobilityModel::DoStartPrivate, this); } Vector RandomWalk2dMobilityModel::DoGetVelocity (void) const diff --git a/src/mobility/random-walk-2d-mobility-model.h b/src/mobility/random-walk-2d-mobility-model.h index 504b2e82d..f0b4bcf36 100644 --- a/src/mobility/random-walk-2d-mobility-model.h +++ b/src/mobility/random-walk-2d-mobility-model.h @@ -52,13 +52,12 @@ class RandomWalk2dMobilityModel : public MobilityModel MODE_TIME }; - RandomWalk2dMobilityModel (); - private: - void Start (void); void Rebound (Time timeLeft); void DoWalk (Time timeLeft); + void DoStartPrivate (void); virtual void DoDispose (void); + virtual void DoStart (void); virtual Vector DoGetPosition (void) const; virtual void DoSetPosition (const Vector &position); virtual Vector DoGetVelocity (void) const; diff --git a/src/mobility/random-waypoint-mobility-model.cc b/src/mobility/random-waypoint-mobility-model.cc index bff248676..f6f3bc27b 100644 --- a/src/mobility/random-waypoint-mobility-model.cc +++ b/src/mobility/random-waypoint-mobility-model.cc @@ -54,11 +54,6 @@ RandomWaypointMobilityModel::GetTypeId (void) return tid; } -RandomWaypointMobilityModel::RandomWaypointMobilityModel () -{ - m_event = Simulator::ScheduleNow (&RandomWaypointMobilityModel::Start, this); -} - void RandomWaypointMobilityModel::BeginWalk (void) { @@ -74,13 +69,21 @@ RandomWaypointMobilityModel::BeginWalk (void) m_helper.SetVelocity (Vector (k*dx, k*dy, k*dz)); m_helper.Unpause (); Time travelDelay = Seconds (CalculateDistance (destination, m_current) / speed); + m_event.Cancel (); m_event = Simulator::Schedule (travelDelay, - &RandomWaypointMobilityModel::Start, this); + &RandomWaypointMobilityModel::DoStartPrivate, this); NotifyCourseChange (); } void -RandomWaypointMobilityModel::Start (void) +RandomWaypointMobilityModel::DoStart (void) +{ + DoStartPrivate (); + MobilityModel::DoStart (); +} + +void +RandomWaypointMobilityModel::DoStartPrivate (void) { m_helper.Update (); m_helper.Pause (); @@ -100,7 +103,7 @@ RandomWaypointMobilityModel::DoSetPosition (const Vector &position) { m_helper.SetPosition (position); Simulator::Remove (m_event); - m_event = Simulator::ScheduleNow (&RandomWaypointMobilityModel::Start, this); + m_event = Simulator::ScheduleNow (&RandomWaypointMobilityModel::DoStartPrivate, this); } Vector RandomWaypointMobilityModel::DoGetVelocity (void) const diff --git a/src/mobility/random-waypoint-mobility-model.h b/src/mobility/random-waypoint-mobility-model.h index d3386d5ec..3dae7c290 100644 --- a/src/mobility/random-waypoint-mobility-model.h +++ b/src/mobility/random-waypoint-mobility-model.h @@ -45,10 +45,11 @@ class RandomWaypointMobilityModel : public MobilityModel { public: static TypeId GetTypeId (void); - RandomWaypointMobilityModel (); +protected: + virtual void DoStart (void); private: - void Start (void); void BeginWalk (void); + void DoStartPrivate (void); virtual Vector DoGetPosition (void) const; virtual void DoSetPosition (const Vector &position); virtual Vector DoGetVelocity (void) const; diff --git a/src/node/application.cc b/src/node/application.cc index f89dd7a56..4ae464bfe 100644 --- a/src/node/application.cc +++ b/src/node/application.cc @@ -40,6 +40,14 @@ Application::GetTypeId (void) { static TypeId tid = TypeId ("ns3::Application") .SetParent () + .AddAttribute ("StartTime", "Time at which the application will start", + TimeValue (Seconds (0.0)), + MakeTimeAccessor (&Application::m_startTime), + MakeTimeChecker ()) + .AddAttribute ("StopTime", "Time at which the application will stop", + TimeValue (TimeStep (0)), + MakeTimeAccessor (&Application::m_stopTime), + MakeTimeChecker ()) ; return tid; } @@ -52,38 +60,38 @@ Application::Application() Application::~Application() {} +void +Application::SetStartTime (Time start) +{ + m_startTime = start; +} +void +Application::SetStopTime (Time stop) +{ + m_stopTime = stop; +} + + void Application::DoDispose (void) { m_node = 0; - Simulator::Cancel(m_startEvent); - Simulator::Cancel(m_stopEvent); + m_startEvent.Cancel (); + m_stopEvent.Cancel (); Object::DoDispose (); } - -void Application::Start(const Time& startTime) -{ - ScheduleStart (startTime); -} -void Application::Start(const RandomVariable& startVar) +void +Application::DoStart (void) { - RandomVariable v = startVar; - ScheduleStart (Seconds (v.GetValue ())); + m_startEvent = Simulator::Schedule (m_startTime, &Application::StartApplication, this); + if (m_stopTime != TimeStep (0)) + { + m_stopEvent = Simulator::Schedule (m_stopTime, &Application::StopApplication, this); + } + Object::DoStart (); } - - -void Application::Stop(const Time& stopTime) -{ - ScheduleStop (stopTime); -} - -void Application::Stop(const RandomVariable& stopVar) -{ - RandomVariable v = stopVar; - ScheduleStop (Seconds (v.GetValue ())); -} - + Ptr Application::GetNode() const { return m_node; @@ -105,20 +113,6 @@ void Application::StopApplication() { // Provide null functionality in case subclass is not interested } - -// Private helpers -void Application::ScheduleStart (const Time &startTime) -{ - m_startEvent = Simulator::Schedule (startTime, - &Application::StartApplication, this); -} - -void Application::ScheduleStop (const Time &stopTime) -{ - m_stopEvent = Simulator::Schedule (stopTime, - &Application::StopApplication, this); -} - } //namespace ns3 diff --git a/src/node/application.h b/src/node/application.h index bb706cd4f..27cb61176 100644 --- a/src/node/application.h +++ b/src/node/application.h @@ -64,7 +64,7 @@ public: static TypeId GetTypeId (void); Application (); virtual ~Application (); - + /** * \brief Specify application start time * \param startTime Start time for this application, @@ -76,15 +76,7 @@ public: * private "StartApplication" method defined below, which is called at the * time specified, to cause the application to begin. */ - void Start (const Time& startTime); - - /** - * \brief Specify application start time. - * \param startVariable the random variable to use to pick - * the real start time as a relative time, in units of - * seconds, relative to the current simulation time. - */ - void Start (const RandomVariable& startVariable); + void SetStartTime (Time start); /** * \brief Specify application stop time @@ -97,16 +89,8 @@ public: * the private StopApplication method, to be notified when that * time has come. */ - void Stop (const Time& stopTime); - - /** - * \brief Specify application stop time - * \param stopVariable the random variable to use to pick - * the real stop time, in units of seconds, - * relative to the current simulation time. - */ - void Stop (const RandomVariable& stopVariable); - + void SetStopTime (Time stop); + /** * \returns the Node to which this Application object is attached. */ @@ -137,13 +121,13 @@ private: virtual void StopApplication (void); protected: virtual void DoDispose (void); -private: - void ScheduleStart (const Time &time); - void ScheduleStop (const Time &time); + virtual void DoStart (void); - EventId m_startEvent; - EventId m_stopEvent; Ptr m_node; + Time m_startTime; + Time m_stopTime; + EventId m_startEvent; + EventId m_stopEvent; }; } //namespace ns3 diff --git a/src/node/node-list.cc b/src/node/node-list.cc index 57e4dc07b..f2fc7192e 100644 --- a/src/node/node-list.cc +++ b/src/node/node-list.cc @@ -119,6 +119,7 @@ NodeListPriv::Add (Ptr node) { uint32_t index = m_nodes.size (); m_nodes.push_back (node); + Simulator::ScheduleWithContext (index, TimeStep (0), &Node::Start, node); return index; } diff --git a/src/node/node.cc b/src/node/node.cc index d1265ec7a..cb7b2df85 100644 --- a/src/node/node.cc +++ b/src/node/node.cc @@ -167,6 +167,24 @@ Node::DoDispose() m_applications.clear (); Object::DoDispose (); } +void +Node::DoStart (void) +{ + for (std::vector >::iterator i = m_devices.begin (); + i != m_devices.end (); i++) + { + Ptr device = *i; + device->Start (); + } + for (std::vector >::iterator i = m_applications.begin (); + i != m_applications.end (); i++) + { + Ptr application = *i; + application->Start (); + } + + Object::DoStart (); +} void Node::NotifyDeviceAdded (Ptr device) diff --git a/src/node/node.h b/src/node/node.h index 2ce67b530..bb19cb631 100644 --- a/src/node/node.h +++ b/src/node/node.h @@ -186,6 +186,7 @@ protected: * end of their own DoDispose method. */ virtual void DoDispose (void); + virtual void DoStart (void); private: /** diff --git a/src/routing/list-routing/ipv4-list-routing.cc b/src/routing/list-routing/ipv4-list-routing.cc index 09749ca04..a8e265baf 100644 --- a/src/routing/list-routing/ipv4-list-routing.cc +++ b/src/routing/list-routing/ipv4-list-routing.cc @@ -68,6 +68,19 @@ Ipv4ListRouting::DoDispose (void) m_ipv4 = 0; } +void +Ipv4ListRouting::DoStart (void) +{ + for (Ipv4RoutingProtocolList::iterator rprotoIter = m_routingProtocols.begin (); + rprotoIter != m_routingProtocols.end (); rprotoIter++) + { + Ptr protocol = (*rprotoIter).second; + protocol->Start (); + } + Ipv4RoutingProtocol::DoStart (); +} + + Ptr Ipv4ListRouting::RouteOutput (Ptr p, const Ipv4Header &header, uint32_t oif, enum Socket::SocketErrno &sockerr) { diff --git a/src/routing/list-routing/ipv4-list-routing.h b/src/routing/list-routing/ipv4-list-routing.h index 42581ab53..780db8805 100644 --- a/src/routing/list-routing/ipv4-list-routing.h +++ b/src/routing/list-routing/ipv4-list-routing.h @@ -88,6 +88,7 @@ public: protected: void DoDispose (void); + void DoStart (void); private: typedef std::pair > Ipv4RoutingProtocolEntry; typedef std::list Ipv4RoutingProtocolList; diff --git a/src/routing/olsr/olsr-routing-protocol.cc b/src/routing/olsr/olsr-routing-protocol.cc index b6489e813..be16fb25d 100644 --- a/src/routing/olsr/olsr-routing-protocol.cc +++ b/src/routing/olsr/olsr-routing-protocol.cc @@ -213,8 +213,6 @@ RoutingProtocol::SetIpv4 (Ptr ipv4) m_linkTupleTimerFirstTime = true; m_ipv4 = ipv4; - - Simulator::ScheduleNow (&RoutingProtocol::Start, this); } void RoutingProtocol::DoDispose () @@ -231,7 +229,7 @@ void RoutingProtocol::DoDispose () Ipv4RoutingProtocol::DoDispose (); } -void RoutingProtocol::Start () +void RoutingProtocol::DoStart () { if (m_mainAddress == Ipv4Address ()) { diff --git a/src/routing/olsr/olsr-routing-protocol.h b/src/routing/olsr/olsr-routing-protocol.h index bab7865c8..30f5e2c01 100644 --- a/src/routing/olsr/olsr-routing-protocol.h +++ b/src/routing/olsr/olsr-routing-protocol.h @@ -81,6 +81,8 @@ public: void SetMainInterface (uint32_t interface); +protected: + virtual void DoStart (void); private: std::map m_table; ///< Data structure for the routing table. @@ -111,7 +113,7 @@ private: Ptr m_ipv4; private: - void Start (); + void Clear (); uint32_t GetSize () const { return m_table.size (); } std::vector GetEntries () const; From 4fee5f016bb8114d31ca5b4ec9e743edb661d946 Mon Sep 17 00:00:00 2001 From: Guillaume Seguin Date: Sat, 14 Nov 2009 17:47:05 +0100 Subject: [PATCH 21/29] Make sure that every incoming packet has a context --- src/node/node.cc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/node/node.cc b/src/node/node.cc index cb7b2df85..72c85f194 100644 --- a/src/node/node.cc +++ b/src/node/node.cc @@ -265,6 +265,9 @@ bool Node::ReceiveFromDevice (Ptr device, Ptr packet, uint16_t protocol, const Address &from, const Address &to, NetDevice::PacketType packetType, bool promiscuous) { + NS_ASSERT_MSG (Simulator::GetContext () == GetId (), "Received packet with erroneous context ; " << + "make sure the channels in use are correctly updating events context " << + "when transfering events from one node to another."); NS_LOG_DEBUG("Node " << GetId () << " ReceiveFromDevice: dev " << device->GetIfIndex () << " (type=" << device->GetInstanceTypeId ().GetName () << ") Packet UID " << packet->GetUid ()); From 24344fd911ea3fb950517318c4309ea404e85b6d Mon Sep 17 00:00:00 2001 From: Mathieu Lacage Date: Sat, 14 Nov 2009 18:01:31 +0100 Subject: [PATCH 22/29] document API changes for release --- CHANGES.html | 73 ++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 62 insertions(+), 11 deletions(-) diff --git a/CHANGES.html b/CHANGES.html index 3d344a5da..fd7275326 100644 --- a/CHANGES.html +++ b/CHANGES.html @@ -46,26 +46,67 @@ us a note on ns-developers mailing list.


Changes from ns-3.6 to ns-3.7

+

Changes to build system:

New API:

-

Changes to existing API:

- -

Changed behavior:

    -
  • Changed default value of YansWifiPhy::EnergyDetectionThreshold from --140.0 dBm to -96.0 dBm. Changed default value of -YansWifiPhy::CcaModelThreshold from -140.0 dBm to -99.0 dBm. Rationale -can be found -here. +
  • Simulator event contexts: The Simulator API now keeps track of a per-event +'context' (a 32bit integer which, by convention identifies a node by its id). Simulator::GetContext +returns the context of the currently-executing event while Simulator::ScheduleWithContext creates an +event with a context different from the execution context of the caller. This API is used +by the ns-3 logging system to report the execution context of each log line. +
  • Object::DoStart: Users who need to complete their object setup at the start of a simulation +can override this virtual method, perform their adhoc setup, and then, must chain up to their parent.
-
-

Changes from ns-3.6 to ns-3.7

-

Changes to existing API:

    +
  • Application::Start and Application::Stop have been renamed to +Application::SetStartTime and Application::SetStopTime. +
  • Channel::Send: this method does not really exist but each subclass of the Channel +base class must implement a similar method which sends a packet from a node to another node. +Users must now use Simulator::ScheduleWithContext instead of Simulator::Schedule to schedule +the reception event on a remote node.
    +For example, before: +
    +void
    +SimpleChannel::Send (Ptr<Packet> p, uint16_t protocol, 
    +		     Mac48Address to, Mac48Address from,
    +		     Ptr<SimpleNetDevice> sender)
    +{
    +  for (std::vector<Ptr<SimpleNetDevice> >::const_iterator i = m_devices.begin (); i != m_devices.end (); ++i)
    +    {
    +      Ptr<SimpleNetDevice> tmp = *i;
    +      if (tmp == sender)
    +	{
    +	  continue;
    +	}
    +      Simulator::ScheduleNow (&SimpleNetDevice::Receive, tmp, p->Copy (), protocol, to, from);
    +    }
    +}
    +
    +After: +
    +void
    +SimpleChannel::Send (Ptr<Packet> p, uint16_t protocol, 
    +		     Mac48Address to, Mac48Address from,
    +		     Ptr<SimpleNetDevice> sender)
    +{
    +  for (std::vector<Ptr<SimpleNetDevice> >::const_iterator i = m_devices.begin (); i != m_devices.end (); ++i)
    +    {
    +      Ptr<SimpleNetDevice> tmp = *i;
    +      if (tmp == sender)
    +	{
    +	  continue;
    +	}
    +      Simulator::ScheduleWithContext (tmp->GetNode ()->GetId (), Seconds (0),
    +                                      &SimpleNetDevice::Receive, tmp, p->Copy (), protocol, to, from);
    +    }
    +}
    +
    +
  • Simulator::SetScheduler: this method now takes an ObjectFactory instead of an object pointer directly. Existing callers can trivially be updated to use this new method.
    @@ -83,6 +124,16 @@ Simulator::SetScheduler (sched);
+

Changed behavior:

+
    +
  • Changed default value of YansWifiPhy::EnergyDetectionThreshold from +-140.0 dBm to -96.0 dBm. Changed default value of +YansWifiPhy::CcaModelThreshold from -140.0 dBm to -99.0 dBm. Rationale +can be found +here. +
+ +

Changes from ns-3.5 to ns-3.6

From 15fe91dedeffd4db44b3852f5fc819cd39865bd8 Mon Sep 17 00:00:00 2001 From: Mathieu Lacage Date: Sat, 14 Nov 2009 18:04:40 +0100 Subject: [PATCH 23/29] start RELEASE_NOTES for 3.7 --- RELEASE_NOTES | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/RELEASE_NOTES b/RELEASE_NOTES index e21e19aa7..94ee6d58b 100644 --- a/RELEASE_NOTES +++ b/RELEASE_NOTES @@ -9,6 +9,43 @@ http://www.nsnam.org including tutorials: http://www.nsnam.org/tutorials.html Consult the file CHANGES.html for more detailed information about changed API and behavior across ns-3 releases. +Release 3.7 +=========== + +Availability +------------ +This release is not yet available + +Supported platforms +------------------- +ns-3.7 has been tested on the following platforms: + - linux x86 gcc 4.4.1, 4.2, 4.1, and, 3.4.6. + - linux x86_64 gcc 4.4.0, 4.3.2, 4.2.3, 4.2.1, 4.1.3, 3.4.6 + - MacOS X ppc and x86 (gcc 4.0.x and 4.2.x) + - cygwin gcc 3.4.4 (debug only), gcc 4.3.2 (debug and optimized) + +Not all ns-3 options are available on all platforms; consult the +wiki for more information: +http://www.nsnam.org/wiki/index.php/Installation + +New user-visible features +------------------------- + + * The ns-3 logging macros (NS_LOG_*) now report automatically the node id + of the event which called the macro. + +API changes from ns-3.5 +----------------------- +API changes for this release are documented in the file CHANGES.html. + +Known issues +------------ +ns-3.6 build is known to fail on the following platforms: + - gcc 3.3 and earlier + - optimized builds on gcc 3.4.4 and 3.4.5 + - optimized builds on linux x86 gcc 4.0.x + + Release 3.6 =========== From 51a25721af1d5ef975d9d0f370b863ce053c100e Mon Sep 17 00:00:00 2001 From: Tom Henderson Date: Sat, 14 Nov 2009 07:13:06 -0800 Subject: [PATCH 24/29] further updates to main.h --- doc/main.h | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/doc/main.h b/doc/main.h index cb88d7175..7616ea517 100644 --- a/doc/main.h +++ b/doc/main.h @@ -26,8 +26,9 @@ * ns-3 requires Doxygen version 1.5.4 or greater to fully build all items, * although earlier versions of Doxygen will mostly work. * - * Type "./waf doxygen" to build the documentation. The doc/ directory contains - * configuration for Doxygen (doxygen.conf and main.txt). The Doxygen + * Type "./waf --doxygen" or "./waf --doxygen-no-build" to build the + * documentation. The doc/ directory contains + * configuration for Doxygen (doxygen.conf) and main.h. The Doxygen * build process puts html files into the doc/html/ directory, and latex * filex into the doc/latex/ directory. * @@ -43,8 +44,14 @@ * to network simulations but shared by pretty much every model * of a network component. * - node: located in src/node. Defines the abstract interfaces which - * must be implemented by every node and more specifically, by ipv4 nodes. + * must be implemented by every node and more specifically, by + * IPv4 and IPv6 nodes. * - devices: located in src/devices. Contains a set of MAC-level models + * - InternetStack: located in src/internet-stack. Contains TCP/IP models. + * - Applications: located in src/applications + * - Routing: located in src/routing; routing protocols. + * - Mobility: located in src/mobility; Mobility models for nodes + * - Helper: located in src/helper; Helper API for the simulator * * More detail can be found in the Modules * tab. From ffd8e7fc185bb99374e3ce8dfa104ef5d02f71f5 Mon Sep 17 00:00:00 2001 From: Pavel Boyko Date: Sat, 14 Nov 2009 08:48:35 -0800 Subject: [PATCH 25/29] Default TTL of IPv4 broadcast datagrams changed from 1 to 64 --- CHANGES.html | 3 +++ src/internet-stack/ipv4-l3-protocol.cc | 3 +-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CHANGES.html b/CHANGES.html index fd7275326..b865b8d1b 100644 --- a/CHANGES.html +++ b/CHANGES.html @@ -60,6 +60,9 @@ by the ns-3 logging system to report the execution context of each log line.
  • Object::DoStart: Users who need to complete their object setup at the start of a simulation can override this virtual method, perform their adhoc setup, and then, must chain up to their parent. +
      +
    • Default TTL of IPv4 broadcast datagrams changed from 1 to 64. +

    Changes to existing API:

      diff --git a/src/internet-stack/ipv4-l3-protocol.cc b/src/internet-stack/ipv4-l3-protocol.cc index 917548654..df612dc9b 100644 --- a/src/internet-stack/ipv4-l3-protocol.cc +++ b/src/internet-stack/ipv4-l3-protocol.cc @@ -406,6 +406,7 @@ Ipv4L3Protocol::Receive( Ptr device, Ptr p, uint16_t pr for (SocketList::iterator i = m_sockets.begin (); i != m_sockets.end (); ++i) { + NS_LOG_LOGIC ("Forwarding to raw socket"); Ptr socket = *i; socket->ForwardUp (packet, ipHeader, device); } @@ -469,7 +470,6 @@ Ipv4L3Protocol::Send (Ptr packet, if (destination.IsBroadcast ()) { NS_LOG_LOGIC ("Ipv4L3Protocol::Send case 1: limited broadcast"); - ttl = 1; ipHeader = BuildHeader (source, destination, protocol, packet->GetSize (), ttl, mayFragment); uint32_t ifaceIndex = 0; for (Ipv4InterfaceList::iterator ifaceIter = m_interfaces.begin (); @@ -502,7 +502,6 @@ Ipv4L3Protocol::Send (Ptr packet, destination.CombineMask (ifAddr.GetMask ()) == ifAddr.GetLocal ().CombineMask (ifAddr.GetMask ()) ) { NS_LOG_LOGIC ("Ipv4L3Protocol::Send case 2: subnet directed bcast to " << ifAddr.GetLocal ()); - ttl = 1; ipHeader = BuildHeader (source, destination, protocol, packet->GetSize (), ttl, mayFragment); Ptr packetCopy = packet->Copy (); m_sendOutgoingTrace (ipHeader, packetCopy, ifaceIndex); From fa99e038317f8c33ac6c8ae7a13ae6bedf854c52 Mon Sep 17 00:00:00 2001 From: Mathieu Lacage Date: Sat, 14 Nov 2009 21:55:18 +0100 Subject: [PATCH 26/29] update udp test to new API --- src/internet-stack/udp-test.cc | 38 ++++++++++++++++++++-------------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/src/internet-stack/udp-test.cc b/src/internet-stack/udp-test.cc index adb2a6ecc..6bbec3f44 100644 --- a/src/internet-stack/udp-test.cc +++ b/src/internet-stack/udp-test.cc @@ -77,6 +77,8 @@ class UdpSocketImplTest: public TestCase { Ptr m_receivedPacket; Ptr m_receivedPacket2; + void DoSendData (Ptr socket, std::string to); + void SendData (Ptr socket, std::string to); public: virtual bool DoRun (void); @@ -120,6 +122,24 @@ void UdpSocketImplTest::ReceivePkt2 (Ptr socket) NS_ASSERT (availableData == m_receivedPacket2->GetSize ()); } +void +UdpSocketImplTest::DoSendData (Ptr socket, std::string to) +{ + Address realTo = InetSocketAddress (Ipv4Address(to.c_str()), 1234); + NS_TEST_EXPECT_MSG_EQ (socket->SendTo (Create (123), 0, realTo), + 123, "XXX"); +} + +void +UdpSocketImplTest::SendData (Ptr socket, std::string to) +{ + m_receivedPacket = Create (); + m_receivedPacket2 = Create (); + Simulator::ScheduleWithContext (socket->GetNode ()->GetId (), Seconds (0), + &UdpSocketImplTest::DoSendData, this, socket, to); + Simulator::Run (); +} + bool UdpSocketImplTest::DoRun (void) { @@ -203,11 +223,7 @@ UdpSocketImplTest::DoRun (void) // ------ Now the tests ------------ // Unicast test - m_receivedPacket = Create (); - m_receivedPacket2 = Create (); - NS_TEST_EXPECT_MSG_EQ (txSocket->SendTo ( Create (123), 0, - InetSocketAddress (Ipv4Address("10.0.0.1"), 1234)), 123, "trivial"); - Simulator::Run (); + SendData (txSocket, "10.0.0.1"); NS_TEST_EXPECT_MSG_EQ (m_receivedPacket->GetSize (), 123, "trivial"); NS_TEST_EXPECT_MSG_EQ (m_receivedPacket2->GetSize (), 0, "second interface should receive it"); @@ -216,11 +232,7 @@ UdpSocketImplTest::DoRun (void) // Simple broadcast test - m_receivedPacket = Create (); - m_receivedPacket2 = Create (); - NS_TEST_EXPECT_MSG_EQ (txSocket->SendTo ( Create (123), 0, - InetSocketAddress (Ipv4Address("255.255.255.255"), 1234)), 123, "trivial"); - Simulator::Run (); + SendData (txSocket, "255.255.255.255"); NS_TEST_EXPECT_MSG_EQ (m_receivedPacket->GetSize (), 123, "trivial"); NS_TEST_EXPECT_MSG_EQ (m_receivedPacket2->GetSize (), 0, "second socket should not receive it (it is bound specifically to the second interface's address"); @@ -237,11 +249,7 @@ UdpSocketImplTest::DoRun (void) rxSocket2->SetRecvCallback (MakeCallback (&UdpSocketImplTest::ReceivePkt2, this)); NS_TEST_EXPECT_MSG_EQ (rxSocket2->Bind (InetSocketAddress (Ipv4Address ("0.0.0.0"), 1234)), 0, "trivial"); - m_receivedPacket = Create (); - m_receivedPacket2 = Create (); - NS_TEST_EXPECT_MSG_EQ (txSocket->SendTo (Create (123), 0, - InetSocketAddress (Ipv4Address("255.255.255.255"), 1234)), 123, "trivial"); - Simulator::Run (); + SendData (txSocket, "255.255.255.255"); NS_TEST_EXPECT_MSG_EQ (m_receivedPacket->GetSize (), 123, "trivial"); NS_TEST_EXPECT_MSG_EQ (m_receivedPacket2->GetSize (), 123, "trivial"); From 61f9a5144cbc257beb88f04fae01421562c594f8 Mon Sep 17 00:00:00 2001 From: Tom Henderson Date: Sat, 14 Nov 2009 21:02:53 -0800 Subject: [PATCH 27/29] Align tcp test program with Application API change --- src/test/ns3tcp/ns3tcp-cwnd-test-suite.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/test/ns3tcp/ns3tcp-cwnd-test-suite.cc b/src/test/ns3tcp/ns3tcp-cwnd-test-suite.cc index 25cd26619..d3563f975 100644 --- a/src/test/ns3tcp/ns3tcp-cwnd-test-suite.cc +++ b/src/test/ns3tcp/ns3tcp-cwnd-test-suite.cc @@ -303,8 +303,8 @@ Ns3TcpCwndTestCase1::DoRun (void) Ptr app = CreateObject (); app->Setup (ns3TcpSocket, sinkAddress, 1040, 10, DataRate ("5Mbps")); nodes.Get (0)->AddApplication (app); - app->Start (Seconds (1.)); - app->Stop (Seconds (1.1)); + app->SetStartTime (Seconds (1.)); + app->SetStopTime (Seconds (1.1)); // // The idea here is that someone will look very closely at the all of the @@ -484,8 +484,8 @@ Ns3TcpCwndTestCase2::DoRun (void) Ptr app = CreateObject (); app->Setup (ns3TcpSocket, sinkAddress, 1040, 1000, DataRate ("1Mbps")); n0n1.Get (0)->AddApplication (app); - app->Start (Seconds (1.0)); - app->Stop (Seconds (5.4)); + app->SetStartTime (Seconds (1.0)); + app->SetStopTime (Seconds (5.4)); if (m_writeResults) { From 60fa8dde789a31da048be997b8cce8ecddead126 Mon Sep 17 00:00:00 2001 From: Tom Henderson Date: Sat, 14 Nov 2009 21:03:33 -0800 Subject: [PATCH 28/29] file TTL change under another category --- CHANGES.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGES.html b/CHANGES.html index b865b8d1b..1beecb862 100644 --- a/CHANGES.html +++ b/CHANGES.html @@ -60,9 +60,6 @@ by the ns-3 logging system to report the execution context of each log line.
    • Object::DoStart: Users who need to complete their object setup at the start of a simulation can override this virtual method, perform their adhoc setup, and then, must chain up to their parent.
    -
      -
    • Default TTL of IPv4 broadcast datagrams changed from 1 to 64. -

    Changes to existing API:

      @@ -135,6 +132,9 @@ YansWifiPhy::CcaModelThreshold from -140.0 dBm to -99.0 dBm. Rationale can be found here.
    +
      +
    • Default TTL of IPv4 broadcast datagrams changed from 1 to 64. +

    From 123fc6afc89a61a831c5ee864fad4bbb264c7fac Mon Sep 17 00:00:00 2001 From: Mathieu Lacage Date: Sun, 15 Nov 2009 09:16:32 +0100 Subject: [PATCH 29/29] make the destructor non-pure for the python bindings --- src/core/ref-count-base.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/ref-count-base.h b/src/core/ref-count-base.h index 3663698ca..a464b3c5b 100644 --- a/src/core/ref-count-base.h +++ b/src/core/ref-count-base.h @@ -40,7 +40,7 @@ public: /** * This only thing this class does it declare a virtual destructor */ - virtual ~RefCountBase () = 0; + virtual ~RefCountBase (); }; } // namespace ns3