From a93f09f7de237351a58106d81a14dba5e6b3a8c7 Mon Sep 17 00:00:00 2001 From: fmoatamr Date: Wed, 28 Oct 2009 15:43:43 +0100 Subject: [PATCH 01/64] Fix testing under Mac OS X --- test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test.py b/test.py index 1a35ac5f2..bf34d9a86 100755 --- a/test.py +++ b/test.py @@ -560,7 +560,7 @@ def make_library_path(): for path in NS3_MODULE_PATH: os.environ["DYLD_LIBRARY_PATH"] += ":" + path if options.verbose: - print "os.environ[\"DYLD_LIBRARY_PATH\"] == %s" % os.environ["DY_LIBRARY_PATH"] + print "os.environ[\"DYLD_LIBRARY_PATH\"] == %s" % os.environ["DYLD_LIBRARY_PATH"] elif sys.platform == "win32": if not have_PATH: os.environ["PATH"] = "" From 0af2cc7a7f8f980e06f984372280abcdfe8c22b3 Mon Sep 17 00:00:00 2001 From: Mirko Banchi Date: Wed, 28 Oct 2009 18:27:43 +0100 Subject: [PATCH 02/64] A-MSDU aggregation is not a default feature. --- src/helper/qos-wifi-mac-helper.cc | 39 ++++++++++++++++++------------- 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/src/helper/qos-wifi-mac-helper.cc b/src/helper/qos-wifi-mac-helper.cc index 4f1a08444..9ad423795 100644 --- a/src/helper/qos-wifi-mac-helper.cc +++ b/src/helper/qos-wifi-mac-helper.cc @@ -27,14 +27,7 @@ namespace ns3 { QosWifiMacHelper::QosWifiMacHelper () -{ - ObjectFactory defaultAggregator; - defaultAggregator.SetTypeId ("ns3::MsduStandardAggregator"); - m_aggregators.insert (std::make_pair (AC_VO, defaultAggregator)); - m_aggregators.insert (std::make_pair (AC_VI, defaultAggregator)); - m_aggregators.insert (std::make_pair (AC_BE, defaultAggregator)); - m_aggregators.insert (std::make_pair (AC_BK, defaultAggregator)); -} +{} QosWifiMacHelper::~QosWifiMacHelper () {} @@ -77,8 +70,7 @@ QosWifiMacHelper::SetMsduAggregatorForAc (AccessClass accessClass, std::string t std::string n2, const AttributeValue &v2, std::string n3, const AttributeValue &v3) { - std::map::iterator it; - it = m_aggregators.find (accessClass); + std::map::iterator it = m_aggregators.find (accessClass); if (it != m_aggregators.end ()) { it->second.SetTypeId (type); @@ -87,17 +79,32 @@ QosWifiMacHelper::SetMsduAggregatorForAc (AccessClass accessClass, std::string t it->second.Set (n2, v2); it->second.Set (n3, v3); } + else + { + ObjectFactory factory; + factory.SetTypeId (type); + factory.Set (n0, v0); + factory.Set (n1, v1); + factory.Set (n2, v2); + factory.Set (n3, v3); + m_aggregators.insert (std::make_pair (accessClass, factory)); + } } void QosWifiMacHelper::Setup (Ptr mac, enum AccessClass ac, std::string dcaAttrName) const { - ObjectFactory factory = m_aggregators.find (ac)->second; - PointerValue ptr; - mac->GetAttribute (dcaAttrName, ptr); - Ptr edca = ptr.Get (); - Ptr aggregator = factory.Create (); - edca->SetMsduAggregator (aggregator); + std::map::const_iterator it = m_aggregators.find (ac); + if (it != m_aggregators.end ()) + { + ObjectFactory factory = it->second; + + PointerValue ptr; + mac->GetAttribute (dcaAttrName, ptr); + Ptr edca = ptr.Get (); + Ptr aggregator = factory.Create (); + edca->SetMsduAggregator (aggregator); + } } From 1fc87be0b0adfc1caa5a09250f099e89a8a6e334 Mon Sep 17 00:00:00 2001 From: "Gustavo J. A. M. Carneiro" Date: Thu, 29 Oct 2009 11:12:12 +0000 Subject: [PATCH 03/64] Bring back the --doxygen-no-build option from the dead. --- wscript | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/wscript b/wscript index ad147f8cf..ba2a6d795 100644 --- a/wscript +++ b/wscript @@ -194,8 +194,13 @@ def set_options(opt): help=('Compile NS-3 statically: works only on linux, without python'), dest='enable_static', action='store_true', default=False) + opt.add_option('--doxygen-no-build', + help=('Run doxygen to generate html documentation from source comments, ' + 'but do not wait for ns-3 to finish the full build.'), + action="store_true", default=False, + dest='doxygen_no_build') - # options provided in a script in a subdirectory named "src" + # options provided in subdirectories opt.sub_options('src') opt.sub_options('bindings/python') opt.sub_options('src/internet-stack') @@ -596,6 +601,11 @@ def build(bld): raise Utils.WafError("Cannot run regression tests: building the ns-3 examples is not enabled" " (regression tests are based on examples)") + + if Options.options.doxygen_no_build: + _doxygen(bld) + raise SystemExit(0) + def shutdown(ctx): bld = wutils.bld if wutils.bld is None: @@ -712,9 +722,7 @@ def shell(ctx): env = wutils.bld.env wutils.run_argv([shell], env, {'NS3_MODULE_PATH': os.pathsep.join(env['NS3_MODULE_PATH'])}) -def doxygen(bld): - """do a full build, generate the introspected doxygen and then the doxygen""" - Scripting.build(bld) +def _doxygen(bld): env = wutils.bld.env proc_env = wutils.get_proc_env() @@ -736,6 +744,11 @@ def doxygen(bld): if subprocess.Popen(['doxygen', doxygen_config]).wait(): raise SystemExit(1) +def doxygen(bld): + """do a full build, generate the introspected doxygen and then the doxygen""" + Scripting.build(bld) + _doxygen(bld) + def lcov_report(): env = Build.bld.env variant_name = env['NS3_ACTIVE_VARIANT'] From 30bcda7b13df1bd8153f4a0246de9c6c040b996c Mon Sep 17 00:00:00 2001 From: Kirill Andreev Date: Thu, 29 Oct 2009 15:39:41 +0300 Subject: [PATCH 04/64] Mesh: HWMP: fixed proactive routes --- src/devices/mesh/dot11s/hwmp-protocol.cc | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/devices/mesh/dot11s/hwmp-protocol.cc b/src/devices/mesh/dot11s/hwmp-protocol.cc index 7c3883d69..095a08d2a 100644 --- a/src/devices/mesh/dot11s/hwmp-protocol.cc +++ b/src/devices/mesh/dot11s/hwmp-protocol.cc @@ -320,7 +320,7 @@ HwmpProtocol::ForwardUnicast (uint32_t sourceIface, const Mac48Address source, { NS_ASSERT(destination != Mac48Address::GetBroadcast ()); HwmpRtable::LookupResult result = m_rtable->LookupReactive (destination); - NS_LOG_DEBUG("Requested src = "<LookupProactive (); - } if (result.retransmitter == Mac48Address::GetBroadcast ()) { return; From acaad3a93d65d28477daf77ef7dbc400764459e5 Mon Sep 17 00:00:00 2001 From: Craig Dowell Date: Fri, 30 Oct 2009 10:23:40 -0700 Subject: [PATCH 05/64] remind test.py how to build on unix and limit build scope when posible --- test.py | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/test.py b/test.py index bf34d9a86..6a029e0b8 100755 --- a/test.py +++ b/test.py @@ -804,11 +804,33 @@ def run_tests(): # For example, if the user only wants to run BVT tests, we only have # to build the test-runner and can ignore all of the examples. # + # If the user only wants to run a single example, then we can just build + # that example. + # + # If there is no constraint, then we have to build everything since the + # user wants to run everything. + # if options.kinds or options.list or (len(options.constrain) and options.constrain in core_kinds): - proc = subprocess.Popen("waf --target=test-runner", shell = True) - else: - proc = subprocess.Popen("waf", shell = True) + if sys.platform == "win32": + waf_cmd = "waf --target=test-runner" + else: + waf_cmd = "./waf --target=test-runner" + elif len(options.example): + if sys.platform == "win32": + waf_cmd = "waf --target=%s" % os.path.basename(options.example) + else: + waf_cmd = "./waf --target=%s" % os.path.basename(options.example) + else: + if sys.platform == "win32": + waf_cmd = "waf" + else: + waf_cmd = "./waf" + + if options.verbose: + print "Building: %s" % waf_cmd + + proc = subprocess.Popen(waf_cmd, shell = True) proc.communicate() # From 4fe473bca2010d8179b1ad5497d245f5fd12ced8 Mon Sep 17 00:00:00 2001 From: "Gustavo J. A. M. Carneiro" Date: Sun, 1 Nov 2009 22:47:04 +0000 Subject: [PATCH 06/64] Bug 733: OLSR MPR Computation give incorrect result --- src/routing/olsr/olsr-routing-protocol.cc | 82 +++++++++++++++++------ 1 file changed, 63 insertions(+), 19 deletions(-) diff --git a/src/routing/olsr/olsr-routing-protocol.cc b/src/routing/olsr/olsr-routing-protocol.cc index 2537ddcd0..7ec59bb0f 100644 --- a/src/routing/olsr/olsr-routing-protocol.cc +++ b/src/routing/olsr/olsr-routing-protocol.cc @@ -552,7 +552,23 @@ RoutingProtocol::MprComputation() } } - NS_LOG_DEBUG ("Size of N2: " << N2.size ()); +#ifdef NS3_LOG_ENABLE + { + std::ostringstream os; + os << "["; + for (TwoHopNeighborSet::const_iterator iter = N2.begin (); + iter != N2.end (); iter++) + { + TwoHopNeighborSet::const_iterator next = iter; + next++; + os << iter->neighborMainAddr << "->" << iter->twoHopNeighborAddr; + if (next != N2.end ()) + os << ", "; + } + os << "]"; + NS_LOG_DEBUG ("N2: " << os.str ()); + } +#endif //NS3_LOG_ENABLE // 1. Start with an MPR set made of all members of N with // N_willingness equal to WILL_ALWAYS @@ -584,30 +600,37 @@ RoutingProtocol::MprComputation() // 3. Add to the MPR set those nodes in N, which are the *only* // nodes to provide reachability to a node in N2. std::set coveredTwoHopNeighbors; - for (TwoHopNeighborSet::iterator twoHopNeigh = N2.begin (); twoHopNeigh != N2.end (); twoHopNeigh++) + for (TwoHopNeighborSet::const_iterator twoHopNeigh = N2.begin (); twoHopNeigh != N2.end (); twoHopNeigh++) { - NeighborSet::const_iterator onlyNeighbor = N.end (); - - for (NeighborSet::const_iterator neighbor = N.begin (); - neighbor != N.end (); neighbor++) + bool onlyOne = true; + // try to find another neighbor that can reach twoHopNeigh->twoHopNeighborAddr + for (TwoHopNeighborSet::const_iterator otherTwoHopNeigh = N2.begin (); otherTwoHopNeigh != N2.end (); otherTwoHopNeigh++) { - if (neighbor->neighborMainAddr == twoHopNeigh->neighborMainAddr) + if (otherTwoHopNeigh->twoHopNeighborAddr == twoHopNeigh->twoHopNeighborAddr + && otherTwoHopNeigh->neighborMainAddr != twoHopNeigh->neighborMainAddr) { - if (onlyNeighbor == N.end ()) - { - onlyNeighbor = neighbor; - } - else - { - onlyNeighbor = N.end (); - break; - } + onlyOne = false; + break; } } - if (onlyNeighbor != N.end ()) + if (onlyOne) { - mprSet.insert (onlyNeighbor->neighborMainAddr); - coveredTwoHopNeighbors.insert (twoHopNeigh->twoHopNeighborAddr); + NS_LOG_LOGIC ("Neighbor " << twoHopNeigh->neighborMainAddr + << " is the only that can reach 2-hop neigh. " + << twoHopNeigh->twoHopNeighborAddr + << " => select as MPR."); + + mprSet.insert (twoHopNeigh->neighborMainAddr); + + // take note of all the 2-hop neighbors reachable by the newly elected MPR + for (TwoHopNeighborSet::const_iterator otherTwoHopNeigh = N2.begin (); + otherTwoHopNeigh != N2.end (); otherTwoHopNeigh++) + { + if (otherTwoHopNeigh->neighborMainAddr == twoHopNeigh->neighborMainAddr) + { + coveredTwoHopNeighbors.insert (otherTwoHopNeigh->twoHopNeighborAddr); + } + } } } // Remove the nodes from N2 which are now covered by a node in the MPR set. @@ -616,6 +639,7 @@ RoutingProtocol::MprComputation() { 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 @@ -628,6 +652,26 @@ RoutingProtocol::MprComputation() // least one node in the MPR set: while (N2.begin () != N2.end ()) { + +#ifdef NS3_LOG_ENABLE + { + std::ostringstream os; + os << "["; + for (TwoHopNeighborSet::const_iterator iter = N2.begin (); + iter != N2.end (); iter++) + { + TwoHopNeighborSet::const_iterator next = iter; + next++; + os << iter->neighborMainAddr << "->" << iter->twoHopNeighborAddr; + if (next != N2.end ()) + os << ", "; + } + os << "]"; + NS_LOG_DEBUG ("Step 4 iteration: N2=" << os.str ()); + } +#endif //NS3_LOG_ENABLE + + // 4.1. For each node in N, calculate the reachability, i.e., the // number of nodes in N2 which are not yet covered by at // least one node in the MPR set, and which are reachable From 970c98baa8056001fb6b74ad7f726069c50c16fc Mon Sep 17 00:00:00 2001 From: Kirill Andreev Date: Mon, 2 Nov 2009 12:28:38 +0300 Subject: [PATCH 07/64] Mesh: fixed initiating proactive PREQ --- src/devices/mesh/dot11s/hwmp-protocol.cc | 1 - 1 file changed, 1 deletion(-) diff --git a/src/devices/mesh/dot11s/hwmp-protocol.cc b/src/devices/mesh/dot11s/hwmp-protocol.cc index 095a08d2a..acc60136f 100644 --- a/src/devices/mesh/dot11s/hwmp-protocol.cc +++ b/src/devices/mesh/dot11s/hwmp-protocol.cc @@ -1012,7 +1012,6 @@ HwmpProtocol::SetRoot () Time randomStart = Seconds (coefficient.GetValue ()); m_proactivePreqTimer = Simulator::Schedule (randomStart, &HwmpProtocol::SendProactivePreq, this); NS_LOG_DEBUG ("ROOT IS: " << m_address); - SendProactivePreq (); m_isRoot = true; } void From 3bb49b6aa42aa58a8ea4234b3a4e6245ed6d8b43 Mon Sep 17 00:00:00 2001 From: Kirill Andreev Date: Tue, 3 Nov 2009 12:50:18 +0300 Subject: [PATCH 08/64] Mesh: fixed updating routing information in HWMP, fixed precursor list in routing table --- src/devices/mesh/dot11s/dot11s-test-suite.cc | 4 +- src/devices/mesh/dot11s/hwmp-protocol.cc | 56 ++++++++++---------- src/devices/mesh/dot11s/hwmp-rtable.cc | 46 ++++------------ src/devices/mesh/dot11s/hwmp-rtable.h | 12 +++-- src/devices/mesh/dot11s/ie-dot11s-prep.cc | 1 + src/devices/mesh/dot11s/ie-dot11s-preq.cc | 18 +++---- src/devices/mesh/dot11s/ie-dot11s-rann.cc | 12 ++--- 7 files changed, 65 insertions(+), 84 deletions(-) diff --git a/src/devices/mesh/dot11s/dot11s-test-suite.cc b/src/devices/mesh/dot11s/dot11s-test-suite.cc index 6bea5c65d..5499d866a 100644 --- a/src/devices/mesh/dot11s/dot11s-test-suite.cc +++ b/src/devices/mesh/dot11s/dot11s-test-suite.cc @@ -174,9 +174,9 @@ HwmpRtableTest::TestPrecursorAdd () { for (std::vector::const_iterator i = precursors.begin (); i != precursors.end (); i++) { - table->AddPrecursor (dst, iface, *i); + table->AddPrecursor (dst, iface, *i, Seconds (100)); // Check that duplicates are filtered - table->AddPrecursor (dst, iface, *i); + table->AddPrecursor (dst, iface, *i, Seconds (100)); } } diff --git a/src/devices/mesh/dot11s/hwmp-protocol.cc b/src/devices/mesh/dot11s/hwmp-protocol.cc index acc60136f..33f005124 100644 --- a/src/devices/mesh/dot11s/hwmp-protocol.cc +++ b/src/devices/mesh/dot11s/hwmp-protocol.cc @@ -415,15 +415,18 @@ HwmpProtocol::ReceivePreq (IePreq preq, Mac48Address from, uint32_t interface, M } } } - m_hwmpSeqnoMetricDatabase[preq.GetOriginatorAddress ()] = std::make_pair (preq.GetOriginatorSeqNumber (), preq.GetMetric ()); - + m_hwmpSeqnoMetricDatabase[preq.GetOriginatorAddress ()] = + std::make_pair (preq.GetOriginatorSeqNumber (), preq.GetMetric ()); NS_LOG_DEBUG("I am " << GetAddress () << "Accepted preq from address" << from << ", preq:" << preq); std::vector > destinations = preq.GetDestinationList (); //Add reactive path to originator: if ( - ((m_rtable->LookupReactive (preq.GetOriginatorAddress ())).retransmitter == Mac48Address::GetBroadcast ()) || - ((m_rtable->LookupReactive (preq.GetOriginatorAddress ())).metric > preq.GetMetric ()) + ((int32_t)(i->second.first - preq.GetOriginatorSeqNumber ()) < 0) || + ( + (m_rtable->LookupReactive (preq.GetOriginatorAddress ()).retransmitter == Mac48Address::GetBroadcast ()) || + (m_rtable->LookupReactive (preq.GetOriginatorAddress ()).metric > preq.GetMetric ()) ) + ) { m_rtable->AddReactivePath ( preq.GetOriginatorAddress (), @@ -432,13 +435,12 @@ HwmpProtocol::ReceivePreq (IePreq preq, Mac48Address from, uint32_t interface, M preq.GetMetric (), MicroSeconds (preq.GetLifetime () * 1024), preq.GetOriginatorSeqNumber () - ); + ); ReactivePathResolved (preq.GetOriginatorAddress ()); } - //Add reactive path for precursor: if ( - ((m_rtable->LookupReactive (fromMp)).retransmitter == Mac48Address::GetBroadcast ()) || - ((m_rtable->LookupReactive (fromMp)).metric > preq.GetMetric ()) + (m_rtable->LookupReactive (fromMp).retransmitter == Mac48Address::GetBroadcast ()) || + (m_rtable->LookupReactive (fromMp).metric > metric) ) { m_rtable->AddReactivePath ( @@ -477,15 +479,6 @@ HwmpProtocol::ReceivePreq (IePreq preq, Mac48Address from, uint32_t interface, M preq.GetOriginatorSeqNumber () ); ProactivePathResolved (); - m_rtable->AddReactivePath ( - preq.GetOriginatorAddress (), - from, - interface, - preq.GetMetric (), - MicroSeconds (preq.GetLifetime () * 1024), - preq.GetOriginatorSeqNumber () - ); - ReactivePathResolved (preq.GetOriginatorAddress ()); } if (!preq.IsNeedNotPrep ()) { @@ -493,7 +486,7 @@ HwmpProtocol::ReceivePreq (IePreq preq, Mac48Address from, uint32_t interface, M GetAddress (), preq.GetOriginatorAddress (), from, - preq.GetMetric (), + (uint32_t)0, preq.GetOriginatorSeqNumber (), GetNextHwmpSeqno (), preq.GetLifetime (), @@ -523,9 +516,6 @@ HwmpProtocol::ReceivePreq (IePreq preq, Mac48Address from, uint32_t interface, M if ((! ((*i)->IsDo ())) && (result.retransmitter != Mac48Address::GetBroadcast ())) { //have a valid information and can answer - //!NB: If there is information from peer - set lifetime as - //we have got from PREQ, and set the rest lifetime of the - //route if the information is correct uint32_t lifetime = result.lifetime.GetMicroSeconds () / 1024; if ((lifetime > 0) && ((int32_t)(result.seqnum - (*i)->GetDestSeqNumber ()) >= 0)) { @@ -539,6 +529,8 @@ HwmpProtocol::ReceivePreq (IePreq preq, Mac48Address from, uint32_t interface, M lifetime, interface ); + m_rtable->AddPrecursor ((*i)->GetDestinationAddress (), interface, from, + MicroSeconds (preq.GetLifetime () * 1024)); if ((*i)->IsRf ()) { (*i)->SetFlags (true, false, (*i)->IsUsn ()); //DO = 1, RF = 0 @@ -579,29 +571,35 @@ HwmpProtocol::ReceivePrep (IePrep prep, Mac48Address from, uint32_t interface, M //Now add a path to destination and add precursor to source NS_LOG_DEBUG ("I am " << GetAddress () << ", received prep from " << prep.GetOriginatorAddress () << ", receiver was:" << from); HwmpRtable::LookupResult result = m_rtable->LookupReactive (prep.GetDestinationAddress ()); - //Add a reactive path only if it is better than existing: + //Add a reactive path only if seqno is fresher or it improves the + //metric if ( - ((m_rtable->LookupReactive (prep.GetOriginatorAddress ())).retransmitter == Mac48Address::GetBroadcast ()) || - ((m_rtable->LookupReactive (prep.GetOriginatorAddress ())).metric > prep.GetMetric ()) + (((int32_t)(i->second.first - prep.GetOriginatorSeqNumber ()) < 0)) || + ( + ((m_rtable->LookupReactive (prep.GetOriginatorAddress ())).retransmitter == Mac48Address::GetBroadcast ()) || + ((m_rtable->LookupReactive (prep.GetOriginatorAddress ())).metric > prep.GetMetric ()) ) + ) { m_rtable->AddReactivePath ( prep.GetOriginatorAddress (), from, interface, prep.GetMetric (), - MicroSeconds(prep.GetLifetime () * 1024), + MicroSeconds (prep.GetLifetime () * 1024), prep.GetOriginatorSeqNumber ()); - m_rtable->AddPrecursor (prep.GetDestinationAddress (), interface, from); + m_rtable->AddPrecursor (prep.GetDestinationAddress (), interface, from, + MicroSeconds (prep.GetLifetime () * 1024)); if (result.retransmitter != Mac48Address::GetBroadcast ()) { - m_rtable->AddPrecursor (prep.GetOriginatorAddress (), interface, result.retransmitter); + m_rtable->AddPrecursor (prep.GetOriginatorAddress (), interface, result.retransmitter, + result.lifetime); } ReactivePathResolved (prep.GetOriginatorAddress ()); } if ( ((m_rtable->LookupReactive (fromMp)).retransmitter == Mac48Address::GetBroadcast ()) || - ((m_rtable->LookupReactive (fromMp)).metric > prep.GetMetric ()) + ((m_rtable->LookupReactive (fromMp)).metric > metric) ) { m_rtable->AddReactivePath ( @@ -669,7 +667,7 @@ HwmpProtocol::SendPrep ( prep.SetDestinationAddress (dst); prep.SetDestinationSeqNumber (destinationSN); prep.SetLifetime (lifetime); - prep.SetMetric (0); + prep.SetMetric (initMetric); prep.SetOriginatorAddress (src); prep.SetOriginatorSeqNumber (originatorDsn); HwmpProtocolMacMap::const_iterator prep_sender = m_interfaces.find (interface); diff --git a/src/devices/mesh/dot11s/hwmp-rtable.cc b/src/devices/mesh/dot11s/hwmp-rtable.cc index 9830ba399..2f236d8d3 100644 --- a/src/devices/mesh/dot11s/hwmp-rtable.cc +++ b/src/devices/mesh/dot11s/hwmp-rtable.cc @@ -84,11 +84,12 @@ HwmpRtable::AddProactivePath (uint32_t metric, Mac48Address root, Mac48Address r } void HwmpRtable::AddPrecursor (Mac48Address destination, uint32_t precursorInterface, - Mac48Address precursorAddress) + Mac48Address precursorAddress, Time lifetime) { - std::pair precursor; - precursor.first = precursorInterface; - precursor.second = precursorAddress; + Precursor precursor; + precursor.interface = precursorInterface; + precursor.address = precursorAddress; + precursor.whenExpire = Simulator::Now () + lifetime; std::map::iterator i = m_routes.find (destination); if (i != m_routes.end ()) { @@ -97,9 +98,10 @@ HwmpRtable::AddPrecursor (Mac48Address destination, uint32_t precursorInterface, { //NB: Only one active route may exist, so do not check //interface ID, just address - if (i->second.precursors[j].second == precursorAddress) + if (i->second.precursors[j].address == precursorAddress) { should_add = false; + i->second.precursors[j].whenExpire = precursor.whenExpire; break; } } @@ -108,17 +110,6 @@ HwmpRtable::AddPrecursor (Mac48Address destination, uint32_t precursorInterface, i->second.precursors.push_back (precursor); } } - if (m_root.root == destination) - { - for (unsigned int j = 0; j < m_root.precursors.size (); j++) - { - if (m_root.precursors[j].second == precursorAddress) - { - return; - } - } - } - m_root.precursors.push_back (precursor); } void HwmpRtable::DeleteProactivePath () @@ -221,27 +212,12 @@ HwmpRtable::GetPrecursors (Mac48Address destination) std::map::iterator route = m_routes.find (destination); if (route != m_routes.end ()) { - for (unsigned int i = 0; i < route->second.precursors.size (); i++) + for (std::vector::const_iterator i = route->second.precursors.begin (); + i != route->second.precursors.end (); i++) { - retval.push_back (route->second.precursors[i]); - } - } - if (m_root.root == destination) - { - for (unsigned int i = 0; i < m_root.precursors.size (); i++) - { - bool should_add = true; - for (unsigned int j = 0; j < retval.size (); j++) + if (i->whenExpire > Simulator::Now ()) { - if (retval[j].second == m_root.precursors[i].second) - { - should_add = false; - break; - } - } - if (should_add) - { - retval.push_back (m_root.precursors[i]); + retval.push_back (std::make_pair(i->interface, i->address)); } } } diff --git a/src/devices/mesh/dot11s/hwmp-rtable.h b/src/devices/mesh/dot11s/hwmp-rtable.h index a22e980f5..6997ea9bc 100644 --- a/src/devices/mesh/dot11s/hwmp-rtable.h +++ b/src/devices/mesh/dot11s/hwmp-rtable.h @@ -85,7 +85,7 @@ public: Time lifetime, uint32_t seqnum ); - void AddPrecursor (Mac48Address destination, uint32_t precursorInterface, Mac48Address precursorAddress); + void AddPrecursor (Mac48Address destination, uint32_t precursorInterface, Mac48Address precursorAddress, Time lifetime); PrecursorList GetPrecursors (Mac48Address destination); void DeleteProactivePath (); void DeleteProactivePath (Mac48Address root); @@ -109,6 +109,12 @@ public: private: /// Route found in reactive mode + struct Precursor + { + Mac48Address address; + uint32_t interface; + Time whenExpire; + }; struct ReactiveRoute { Mac48Address retransmitter; @@ -116,7 +122,7 @@ private: uint32_t metric; Time whenExpire; uint32_t seqnum; - std::vector > precursors; + std::vector precursors; }; /// Route fond in proactive mode struct ProactiveRoute @@ -127,7 +133,7 @@ private: uint32_t metric; Time whenExpire; uint32_t seqnum; - std::vector > precursors; + std::vector precursors; }; /// List of routes diff --git a/src/devices/mesh/dot11s/ie-dot11s-prep.cc b/src/devices/mesh/dot11s/ie-dot11s-prep.cc index dd58053cf..6eb4b7dee 100644 --- a/src/devices/mesh/dot11s/ie-dot11s-prep.cc +++ b/src/devices/mesh/dot11s/ie-dot11s-prep.cc @@ -135,6 +135,7 @@ void IePrep::DecrementTtl () { m_ttl--; + m_hopcount ++; } void diff --git a/src/devices/mesh/dot11s/ie-dot11s-preq.cc b/src/devices/mesh/dot11s/ie-dot11s-preq.cc index 40e749f06..55b9403fd 100644 --- a/src/devices/mesh/dot11s/ie-dot11s-preq.cc +++ b/src/devices/mesh/dot11s/ie-dot11s-preq.cc @@ -317,17 +317,17 @@ void IePreq::Print (std::ostream &os) const { os << std::endl << "" << std::endl; - os << " originator address = " << m_originatorAddress << "std::endl"; - os << " TTL = " << (uint16_t) m_ttl << "std::endl"; - os << " hop count = " << (uint16_t) m_hopCount << "std::endl"; - os << " metric = " << m_metric << "std::endl"; - os << " seqno = " << m_originatorSeqNumber << "std::endl"; - os << " lifetime = " << m_lifetime << "std::endl"; - os << " preq ID = " << m_preqId << "std::endl"; - os << " Destinations are:std::endl"; + os << " originator address = " << m_originatorAddress << std::endl; + os << " TTL = " << (uint16_t) m_ttl << std::endl; + os << " hop count = " << (uint16_t) m_hopCount << std::endl; + os << " metric = " << m_metric << std::endl; + os << " seqno = " << m_originatorSeqNumber << std::endl; + os << " lifetime = " << m_lifetime << std::endl; + os << " preq ID = " << m_preqId << std::endl; + os << " Destinations are:" << std::endl; for (int j = 0; j < m_destCount; j++) { - os << " " << m_destinations[j]->GetDestinationAddress () << "std::endl"; + os << " " << m_destinations[j]->GetDestinationAddress () << std::endl; } os << "" << std::endl; } diff --git a/src/devices/mesh/dot11s/ie-dot11s-rann.cc b/src/devices/mesh/dot11s/ie-dot11s-rann.cc index 8b5ad2887..ea1bc9279 100644 --- a/src/devices/mesh/dot11s/ie-dot11s-rann.cc +++ b/src/devices/mesh/dot11s/ie-dot11s-rann.cc @@ -152,12 +152,12 @@ void IeRann::Print (std::ostream &os) const { os << std::endl << "" << std::endl; - os << " flags = " << (int) m_flags << "std::endl"; - os << " hop count = " << (int) m_hopcount << "std::endl"; - os << " TTL = " << (int) m_ttl << "std::endl"; - os << " originator address = " << m_originatorAddress << "std::endl"; - os << " dst seq. number = " << m_destSeqNumber << "std::endl"; - os << " metric = " << m_metric << "std::endl"; + os << " flags = " << (int) m_flags << std::endl; + os << " hop count = " << (int) m_hopcount << std::endl; + os << " TTL = " << (int) m_ttl << std::endl; + os << " originator address = " << m_originatorAddress << std::endl; + os << " dst seq. number = " << m_destSeqNumber << std::endl; + os << " metric = " << m_metric << std::endl; os << "" << std::endl; } From 6a66402911c6373fa228d6ebc2283d053fab2a74 Mon Sep 17 00:00:00 2001 From: Mathieu Lacage Date: Wed, 4 Nov 2009 22:08:21 +0100 Subject: [PATCH 09/64] Optimize Object::GetObject. A 40% improvement on some testcases --- src/core/object.cc | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/core/object.cc b/src/core/object.cc index c8fabe26c..a05e470d5 100644 --- a/src/core/object.cc +++ b/src/core/object.cc @@ -113,6 +113,7 @@ Object::DoGetObject (TypeId tid) const { NS_ASSERT (CheckLoose ()); const Object *currentObject = this; + const Object *prevObject = 0; TypeId objectTid = Object::GetTypeId (); do { NS_ASSERT (currentObject != 0); @@ -123,8 +124,21 @@ Object::DoGetObject (TypeId tid) const } if (cur == tid) { + if (prevObject != 0) + { + // This is an attempt to 'cache' the result of this lookup. + // the idea is that if we perform a lookup for a TypdId on this object, + // we are likely to perform the same lookup later so, we re-order + // the circular linked-list of objects here by putting the object we + // just found at the head of the list. This optimization is + // _extremely_ effective in general. + const_cast(prevObject)->m_next = currentObject->m_next; + const_cast(currentObject)->m_next = m_next; + const_cast(this)->m_next = (Object*)currentObject; + } return const_cast (currentObject); } + prevObject = currentObject; currentObject = currentObject->m_next; } while (currentObject != this); return 0; From 486d478dae168766e646c9aea0adc9ae86395073 Mon Sep 17 00:00:00 2001 From: Craig Dowell Date: Wed, 4 Nov 2009 20:28:31 -0800 Subject: [PATCH 10/64] Remove mingw from list of supported platforms --- RELEASE_NOTES | 92 +++++---------------------------------------------- 1 file changed, 8 insertions(+), 84 deletions(-) diff --git a/RELEASE_NOTES b/RELEASE_NOTES index fc8d765f3..3fed24dc5 100644 --- a/RELEASE_NOTES +++ b/RELEASE_NOTES @@ -4,84 +4,9 @@ This file contains ns-3 release notes (most recent releases first). All of the ns-3 documentation is accessible from the ns-3 website: -http://www.nsnam.org including tutorials: http://www.nsnam.org/tutorials.html - -Release 3.6 -=========== - -Availability ------------- -This release is immediately available from: -http://www.nsnam.org/releases/ns-allinone-3.6.tar.bz2 - -Supported platforms -------------------- -ns-3.6 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) - - mingw gcc 3.4.5 (debug only) - -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 -------------------------- - - a) 802.11 models: - - Add an implementation of the minstrel rate control algorithm - (Duy Nguyen for gsoc) - - AthstatsHelper: enables the wifi device to produce periodic - reports similar to the ones generated by madwifi's - athstats tool (Nicola Baldo) - - 10MHz and 5MHz channel width supported by 802.11a model - (Ramon Bauza and Kirill Andreev) - - Channel switching support. YansWifiPhy can now switch among - different channels (Ramon Bauza and Pavel Boyko) - - b) IPv6 models: - - IPv6 interface; - - IPv6 layer; - - IPv6 raw socket; - - Static IPv6 routing; - - ICMPv6 layer; - - Some ICMPv6 error messages (destination unreachable, ...); - - Neighbor Discovery Protocol (NS/NA, RS/RA, redirection); - - Ping6 application (send Echo request); - - Radvd application (send RA); - - Examples (ping6, simple-routing-ping6, radvd, radvd-two-prefix, - icmpv6-redirect). - - c) Wireless Mesh Networking models: - - General multi-interface mesh stack infrastructure (devices/mesh module). - - IEEE 802.11s (Draft 3.0) model including Peering Management Protocol and HWMP. - - Forwarding Layer for Meshing (FLAME) protocol. - - d) Nix-vector routing: - - Ipv4NixVectorHelper - - Examples (nix-simple, nms-p2p-nix) - - e) New Test Framework - - Use test.py instead of ./waf check or ./waf --regression - - Previous unit tests have been ported to new framework. - - Examples are tested for run-ability. - - f) A new Flow Monitor module - - To very easily measure flow metrics in a simulation - - No need to use trace callbacks or parsing trace files - -API changes from ns-3.5 ------------------------ -API changes for this release are documented in the file CHANGES.html. - -Known issues ------------- -ns-3 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 +http://www.nsnam.org +including tutorials: +http://www.nsnam.org/tutorials.html Release 3.5 =========== @@ -89,16 +14,15 @@ Release 3.5 Availability ------------ This release is immediately available from: -http://www.nsnam.org/releases/ns-allinone-3.5.tar.bz2 +http://www.nsnam.org/releases/ns-3.5.tar.bz2 Supported platforms ------------------- -ns-3.5 has been tested on the following platforms: +ns-3.4 has been tested on the following platforms: - linux x86 gcc 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) - - mingw gcc 3.4.5 (debug only) Not all ns-3 options are available on all platforms; consult the wiki for more information: @@ -139,8 +63,8 @@ Future releases --------------- Our next release, which is expected to happen in 2 to 4 months from now, will feature the merging of some of our projects currently in development including -fuller IPv6 support, some smaller features such as a new Global ARP -package, and possibly a new Testing and Validation suite. +fuller IPv6 support, and some smaller features such as a new Global ARP package +and possibly a new Testing and Validation suite. Release 3.4 =========== @@ -148,7 +72,7 @@ Release 3.4 Availability ------------ This release is immediately available from: -http://www.nsnam.org/releases/ns-allinone-3.4.tar.bz2 +http://www.nsnam.org/releases/ns-3.4.tar.bz2 Supported platforms ------------------- From 41b20ef8ea4bab9817ac14156f2e8602d1eccfa6 Mon Sep 17 00:00:00 2001 From: Craig Dowell Date: Wed, 4 Nov 2009 21:08:32 -0800 Subject: [PATCH 11/64] swap in released 3.6 release notes --- RELEASE_NOTES | 91 ++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 83 insertions(+), 8 deletions(-) diff --git a/RELEASE_NOTES b/RELEASE_NOTES index 3fed24dc5..8b2e49834 100644 --- a/RELEASE_NOTES +++ b/RELEASE_NOTES @@ -4,9 +4,83 @@ This file contains ns-3 release notes (most recent releases first). All of the ns-3 documentation is accessible from the ns-3 website: -http://www.nsnam.org -including tutorials: -http://www.nsnam.org/tutorials.html +http://www.nsnam.org including tutorials: http://www.nsnam.org/tutorials.html + +Release 3.6 +=========== + +Availability +------------ +This release is immediately available from: +http://www.nsnam.org/releases/ns-allinone-3.6.tar.bz2 + +Supported platforms +------------------- +ns-3.6 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 +------------------------- + + a) 802.11 models: + - Add an implementation of the minstrel rate control algorithm + (Duy Nguyen for gsoc) + - AthstatsHelper: enables the wifi device to produce periodic + reports similar to the ones generated by madwifi's + athstats tool (Nicola Baldo) + - 10MHz and 5MHz channel width supported by 802.11a model + (Ramon Bauza and Kirill Andreev) + - Channel switching support. YansWifiPhy can now switch among + different channels (Ramon Bauza and Pavel Boyko) + + b) IPv6 models: + - IPv6 interface; + - IPv6 layer; + - IPv6 raw socket; + - Static IPv6 routing; + - ICMPv6 layer; + - Some ICMPv6 error messages (destination unreachable, ...); + - Neighbor Discovery Protocol (NS/NA, RS/RA, redirection); + - Ping6 application (send Echo request); + - Radvd application (send RA); + - Examples (ping6, simple-routing-ping6, radvd, radvd-two-prefix, + icmpv6-redirect). + + c) Wireless Mesh Networking models: + - General multi-interface mesh stack infrastructure (devices/mesh module). + - IEEE 802.11s (Draft 3.0) model including Peering Management Protocol and HWMP. + - Forwarding Layer for Meshing (FLAME) protocol. + + d) Nix-vector routing: + - Ipv4NixVectorHelper + - Examples (nix-simple, nms-p2p-nix) + + e) New Test Framework + - Use test.py instead of ./waf check or ./waf --regression + - Previous unit tests have been ported to new framework. + - Examples are tested for run-ability. + + f) A new Flow Monitor module + - To very easily measure flow metrics in a simulation + - No need to use trace callbacks or parsing trace files + +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.5 =========== @@ -14,15 +88,16 @@ Release 3.5 Availability ------------ This release is immediately available from: -http://www.nsnam.org/releases/ns-3.5.tar.bz2 +http://www.nsnam.org/releases/ns-allinone-3.5.tar.bz2 Supported platforms ------------------- -ns-3.4 has been tested on the following platforms: +ns-3.5 has been tested on the following platforms: - linux x86 gcc 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) + - mingw gcc 3.4.5 (debug only) Not all ns-3 options are available on all platforms; consult the wiki for more information: @@ -63,8 +138,8 @@ Future releases --------------- Our next release, which is expected to happen in 2 to 4 months from now, will feature the merging of some of our projects currently in development including -fuller IPv6 support, and some smaller features such as a new Global ARP package -and possibly a new Testing and Validation suite. +fuller IPv6 support, some smaller features such as a new Global ARP +package, and possibly a new Testing and Validation suite. Release 3.4 =========== @@ -72,7 +147,7 @@ Release 3.4 Availability ------------ This release is immediately available from: -http://www.nsnam.org/releases/ns-3.4.tar.bz2 +http://www.nsnam.org/releases/ns-allinone-3.4.tar.bz2 Supported platforms ------------------- From 46d64d4b8ef5cb6660da2349a5a481cfb897de95 Mon Sep 17 00:00:00 2001 From: fmoatamr Date: Thu, 5 Nov 2009 11:17:44 +0100 Subject: [PATCH 12/64] Bug 705: Make building works under Mingw by disabling socket.h and in.h includes only when Mingw is used --- src/contrib/net-anim/animation-interface.cc | 13 +++++++++++-- .../net-anim/point-to-point-dumbbell-helper.cc | 4 ---- src/contrib/net-anim/wscript | 6 ++++++ src/contrib/wscript | 6 ++++-- 4 files changed, 21 insertions(+), 8 deletions(-) diff --git a/src/contrib/net-anim/animation-interface.cc b/src/contrib/net-anim/animation-interface.cc index 047083689..5a750a906 100644 --- a/src/contrib/net-anim/animation-interface.cc +++ b/src/contrib/net-anim/animation-interface.cc @@ -21,9 +21,15 @@ #include #include +#include "ns3/net-anim-config.h" + // Socket related includes -#include -#include +#if defined(HAVE_SYS_SOCKET_H) && defined(HAVE_NETINET_IN_H) +# include +# include +#else +#include +#endif // ns3 includes #include "ns3/animation-interface.h" @@ -58,6 +64,7 @@ bool AnimationInterface::SetOutputFile (const std::string& fn) bool AnimationInterface::SetServerPort (uint16_t port) { +#if defined(HAVE_SYS_SOCKET_H) && defined(HAVE_NETINET_IN_H) int s = socket (AF_INET, SOCK_STREAM, 0); struct sockaddr_in addr; addr.sin_family = AF_INET; @@ -77,6 +84,8 @@ bool AnimationInterface::SetServerPort (uint16_t port) int t = 1; setsockopt (s, SOL_SOCKET, SO_LINGER, &t, sizeof(t)); return true; +#endif + return false;//never reached unless the above is disabled } bool AnimationInterface::SetInternalAnimation () diff --git a/src/contrib/net-anim/point-to-point-dumbbell-helper.cc b/src/contrib/net-anim/point-to-point-dumbbell-helper.cc index 43fddf35f..0188315ec 100644 --- a/src/contrib/net-anim/point-to-point-dumbbell-helper.cc +++ b/src/contrib/net-anim/point-to-point-dumbbell-helper.cc @@ -21,10 +21,6 @@ #include #include -// Socket related includes -#include -#include - // ns3 includes #include "ns3/animation-interface.h" #include "ns3/point-to-point-dumbbell-helper.h" diff --git a/src/contrib/net-anim/wscript b/src/contrib/net-anim/wscript index 0e0c8dd30..a3cd21edc 100644 --- a/src/contrib/net-anim/wscript +++ b/src/contrib/net-anim/wscript @@ -1,5 +1,11 @@ ## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*- +def configure(conf): + conf.check(header_name='sys/socket.h', define_name='HAVE_SYS_SOCKET_H') + conf.check(header_name='netinet/in.h', define_name='HAVE_NETINET_IN_H') + conf.write_config_header('ns3/net-anim-config.h', top=True) + + def build(bld): obj = bld.create_ns3_module('net-anim') obj.source = [ diff --git a/src/contrib/wscript b/src/contrib/wscript index 046958dda..1a32d13c9 100644 --- a/src/contrib/wscript +++ b/src/contrib/wscript @@ -14,10 +14,12 @@ def configure(conf): conf.report_optional_feature("XmlIo", "XmlIo", conf.env['ENABLE_LIBXML2'], "library 'libxml-2.0 >= 2.7' not found") - conf.sub_config('stats') - conf.write_config_header('ns3/contrib-config.h', top=True) + conf.sub_config('stats') + conf.sub_config('net-anim') + + def build(bld): module = bld.create_ns3_module('contrib', ['simulator', 'common']) module.source = [ From b47dff231137bb321768dbbafbb40cc85be907c0 Mon Sep 17 00:00:00 2001 From: Kirill Andreev Date: Thu, 5 Nov 2009 13:45:33 +0300 Subject: [PATCH 13/64] mesh:Fixed valgrind errors --- src/devices/mesh/dot11s/hwmp-protocol.cc | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/devices/mesh/dot11s/hwmp-protocol.cc b/src/devices/mesh/dot11s/hwmp-protocol.cc index 33f005124..5b4d6954f 100644 --- a/src/devices/mesh/dot11s/hwmp-protocol.cc +++ b/src/devices/mesh/dot11s/hwmp-protocol.cc @@ -401,6 +401,7 @@ HwmpProtocol::ReceivePreq (IePreq preq, Mac48Address from, uint32_t interface, M //acceptance cretirea: std::map >::const_iterator i = m_hwmpSeqnoMetricDatabase.find ( preq.GetOriginatorAddress ()); + bool freshInfo (true); if (i != m_hwmpSeqnoMetricDatabase.end ()) { if ((int32_t)(i->second.first - preq.GetOriginatorSeqNumber ()) > 0) @@ -409,6 +410,7 @@ HwmpProtocol::ReceivePreq (IePreq preq, Mac48Address from, uint32_t interface, M } if (i->second.first == preq.GetOriginatorSeqNumber ()) { + freshInfo = false; if (i->second.second <= preq.GetMetric ()) { return; @@ -421,7 +423,7 @@ HwmpProtocol::ReceivePreq (IePreq preq, Mac48Address from, uint32_t interface, M std::vector > destinations = preq.GetDestinationList (); //Add reactive path to originator: if ( - ((int32_t)(i->second.first - preq.GetOriginatorSeqNumber ()) < 0) || + (freshInfo) || ( (m_rtable->LookupReactive (preq.GetOriginatorAddress ()).retransmitter == Mac48Address::GetBroadcast ()) || (m_rtable->LookupReactive (preq.GetOriginatorAddress ()).metric > preq.GetMetric ()) @@ -562,9 +564,17 @@ HwmpProtocol::ReceivePrep (IePrep prep, Mac48Address from, uint32_t interface, M //acceptance cretirea: std::map >::const_iterator i = m_hwmpSeqnoMetricDatabase.find ( prep.GetOriginatorAddress ()); - if ((i != m_hwmpSeqnoMetricDatabase.end ()) && ((int32_t)(i->second.first - prep.GetOriginatorSeqNumber ()) > 0)) + bool freshInfo (true); + if (i != m_hwmpSeqnoMetricDatabase.end ()) { - return; + if ((int32_t)(i->second.first - prep.GetOriginatorSeqNumber ()) > 0) + { + return; + } + if (i->second.first == prep.GetOriginatorSeqNumber ()) + { + freshInfo = false; + } } m_hwmpSeqnoMetricDatabase[prep.GetOriginatorAddress ()] = std::make_pair (prep.GetOriginatorSeqNumber (), prep.GetMetric ()); //update routing info @@ -574,7 +584,7 @@ HwmpProtocol::ReceivePrep (IePrep prep, Mac48Address from, uint32_t interface, M //Add a reactive path only if seqno is fresher or it improves the //metric if ( - (((int32_t)(i->second.first - prep.GetOriginatorSeqNumber ()) < 0)) || + (freshInfo) || ( ((m_rtable->LookupReactive (prep.GetOriginatorAddress ())).retransmitter == Mac48Address::GetBroadcast ()) || ((m_rtable->LookupReactive (prep.GetOriginatorAddress ())).metric > prep.GetMetric ()) From 580033fc2b69798c0ba4518fb309fa9bd3afbebb Mon Sep 17 00:00:00 2001 From: Mathieu Lacage Date: Thu, 5 Nov 2009 21:04:05 +0100 Subject: [PATCH 14/64] Optimize Object::GetObject. Introduce an array of aggregates and sort is by access frequency. --- src/core/object.cc | 246 +++++++++++++++++++++++++++------------------ src/core/object.h | 41 ++++++-- 2 files changed, 180 insertions(+), 107 deletions(-) diff --git a/src/core/object.cc b/src/core/object.cc index a05e470d5..2725ba6cf 100644 --- a/src/core/object.cc +++ b/src/core/object.cc @@ -28,6 +28,8 @@ #include "string.h" #include #include +#include +#include NS_LOG_COMPONENT_DEFINE ("Object"); @@ -40,28 +42,23 @@ namespace ns3 { NS_OBJECT_ENSURE_REGISTERED (Object); Object::AggregateIterator::AggregateIterator () - : m_first (0), + : m_object (0), m_current (0) {} bool Object::AggregateIterator::HasNext (void) const { - if (m_current != 0 && m_current->m_next != PeekPointer (m_first)) - { - return true; - } - return false; + return m_current < m_object->m_aggregates->n; } Ptr Object::AggregateIterator::Next (void) { - m_current = m_current->m_next; - return m_current; + return m_object->m_aggregates->buffer[m_current]; } -Object::AggregateIterator::AggregateIterator (Ptr first) - : m_first (first), - m_current (first) +Object::AggregateIterator::AggregateIterator (Ptr object) + : m_object (object), + m_current (0) {} @@ -85,18 +82,45 @@ Object::Object () : m_count (1), m_tid (Object::GetTypeId ()), m_disposed (false), - m_next (this) -{} + m_aggregates ((struct Aggregates *)malloc (sizeof (struct Aggregates))), + m_getObjectCount (0) +{ + m_aggregates->n = 1; + m_aggregates->buffer[0] = this; +} Object::~Object () { - m_next = 0; + // remove this object from the aggregate list + uint32_t n = m_aggregates->n; + for (uint32_t i = 0; i < n; i++) + { + Object *current = m_aggregates->buffer[i]; + if (current == this) + { + memmove (&m_aggregates->buffer[i], + &m_aggregates->buffer[i+1], + sizeof (Object *)*(m_aggregates->n - (i+1))); + m_aggregates->n--; + } + } + // finally, if all objects have been removed from the list, + // delete the aggregate list + if (m_aggregates->n == 0) + { + free (m_aggregates); + } + m_aggregates = 0; } Object::Object (const Object &o) : m_count (1), m_tid (o.m_tid), m_disposed (false), - m_next (this) -{} + m_aggregates ((struct Aggregates *)malloc (sizeof (struct Aggregates))), + m_getObjectCount (0) +{ + m_aggregates->n = 1; + m_aggregates->buffer[0] = this; +} uint32_t Object::GetReferenceCount (void) const { @@ -112,48 +136,58 @@ Ptr Object::DoGetObject (TypeId tid) const { NS_ASSERT (CheckLoose ()); - const Object *currentObject = this; - const Object *prevObject = 0; + + uint32_t n = m_aggregates->n; TypeId objectTid = Object::GetTypeId (); - do { - NS_ASSERT (currentObject != 0); - TypeId cur = currentObject->GetInstanceTypeId (); - while (cur != tid && cur != objectTid) - { - cur = cur.GetParent (); - } - if (cur == tid) - { - if (prevObject != 0) - { - // This is an attempt to 'cache' the result of this lookup. - // the idea is that if we perform a lookup for a TypdId on this object, - // we are likely to perform the same lookup later so, we re-order - // the circular linked-list of objects here by putting the object we - // just found at the head of the list. This optimization is - // _extremely_ effective in general. - const_cast(prevObject)->m_next = currentObject->m_next; - const_cast(currentObject)->m_next = m_next; - const_cast(this)->m_next = (Object*)currentObject; - } - return const_cast (currentObject); - } - prevObject = currentObject; - currentObject = currentObject->m_next; - } while (currentObject != this); + for (uint32_t i = 0; i < n; i++) + { + Object *current = m_aggregates->buffer[i]; + TypeId cur = current->GetInstanceTypeId (); + while (cur != tid && cur != objectTid) + { + cur = cur.GetParent (); + } + if (cur == tid) + { + // This is an attempt to 'cache' the result of this lookup. + // the idea is that if we perform a lookup for a TypeId on this object, + // we are likely to perform the same lookup later so, we make sure + // that the aggregate array is sorted by the number of accesses + // to each object. + + // first, increment the access count + current->m_getObjectCount++; + // then, update the sort + UpdateSortedArray (m_aggregates, i); + // finally, return the match + return const_cast (current); + } + } return 0; } void Object::Dispose (void) { - Object *current = this; - do { - NS_ASSERT (current != 0); - NS_ASSERT (!current->m_disposed); - current->DoDispose (); - current->m_disposed = true; - current = current->m_next; - } while (current != this); + uint32_t n = m_aggregates->n; + for (uint32_t i = 0; i < n; i++) + { + Object *current = m_aggregates->buffer[i]; + NS_ASSERT (!current->m_disposed); + current->DoDispose (); + current->m_disposed = true; + } +} +void +Object::UpdateSortedArray (struct Aggregates *aggregates, uint32_t j) const +{ + while (j > 0 && + aggregates->buffer[j]->m_getObjectCount > aggregates->buffer[j-1]->m_getObjectCount) + { + Object *tmp = aggregates->buffer[j-1]; + aggregates->buffer[j-1] = aggregates->buffer[j]; + aggregates->buffer[j] = tmp; + j--; + } } void Object::AggregateObject (Ptr o) @@ -171,20 +205,38 @@ Object::AggregateObject (Ptr o) } Object *other = PeekPointer (o); - Object *next = m_next; - m_next = other->m_next; - other->m_next = next; - NS_ASSERT (CheckLoose ()); - NS_ASSERT (o->CheckLoose ()); - // call NotifyNewAggregate in the listed chain - Object *currentObject = this; - do + // first create the new aggregate buffer. + uint32_t total = m_aggregates->n + other->m_aggregates->n; + struct Aggregates *aggregates = + (struct Aggregates *)malloc (sizeof(struct Aggregates)+(total-1)*sizeof(Object*)); + aggregates->n = total; + memcpy (&aggregates->buffer[0], + &m_aggregates->buffer[0], + m_aggregates->n*sizeof(Object*)); + // append the other aggregates in the new buffer + for (uint32_t i = 0; i < other->m_aggregates->n; i++) { - // the NotifyNewAggregate of the current object implementation - // should be called on the next object in the linked chain - currentObject->NotifyNewAggregate (); - currentObject = currentObject->m_next; - } while (currentObject != this); + aggregates->buffer[m_aggregates->n+i] = other->m_aggregates->buffer[i]; + UpdateSortedArray (aggregates, m_aggregates->n + i); + } + + // free both aggregate buffers + free (m_aggregates); + free (other->m_aggregates); + + // Then, assign that buffer to every object + uint32_t n = aggregates->n; + for (uint32_t i = 0; i < n; i++) + { + Object *current = aggregates->buffer[i]; + current->m_aggregates = aggregates; + } + // Finally, call NotifyNewAggregate in the listed chain + for (uint32_t i = 0; i < n; i++) + { + Object *current = m_aggregates->buffer[i]; + current->NotifyNewAggregate (); + } } /** * This function must be implemented in the stack that needs to notify @@ -233,14 +285,12 @@ bool Object::CheckLoose (void) const { uint32_t refcount = 0; - const Object *current = this; - do + uint32_t n = m_aggregates->n; + for (uint32_t i = 0; i < n; i++) { + Object *current = m_aggregates->buffer[i]; refcount += current->m_count; - current = current->m_next; } - while (current != this); - return (refcount > 0); } @@ -249,38 +299,38 @@ Object::MaybeDelete (void) const { // First, check if any of the attached // Object has a non-zero count. - const Object *current = this; - do { - NS_ASSERT (current != 0); - if (current->m_count != 0) - { - return; - } - current = current->m_next; - } while (current != this); + uint32_t n = m_aggregates->n; + for (uint32_t i = 0; i < n; i++) + { + Object *current = m_aggregates->buffer[i]; + if (current->m_count != 0) + { + return; + } + } // Ensure we are disposed. - Object *tmp = const_cast (this); - const Object *end = this; - do { - NS_ASSERT (current != 0); - Object *next = tmp->m_next; - if (!tmp->m_disposed) - { - tmp->DoDispose (); - } - tmp = next; - } while (tmp != end); + for (uint32_t i = 0; i < n; i++) + { + Object *current = m_aggregates->buffer[i]; + if (!current->m_disposed) + { + current->DoDispose (); + } + } // all attached objects have a zero count so, - // we can delete all attached objects. - current = this; - do { - NS_ASSERT (current != 0); - Object *next = current->m_next; - delete current; - current = next; - } while (current != end); + // we can delete them all. + struct Aggregates *aggregates = m_aggregates; + for (uint32_t i = 0; i < n; i++) + { + // There is a trick here: each time we call delete below, + // the deleted object is removed from the aggregate buffer + // in the destructor so, the index of the next element to + // lookup is always zero + Object *current = aggregates->buffer[0]; + delete current; + } } } // namespace ns3 diff --git a/src/core/object.h b/src/core/object.h index 721c7453b..03564d7e5 100644 --- a/src/core/object.h +++ b/src/core/object.h @@ -85,9 +85,9 @@ public: Ptr Next (void); private: friend class Object; - AggregateIterator (Ptr first); - Ptr m_first; - Ptr m_current; + AggregateIterator (Ptr object); + Ptr m_object; + uint32_t m_current; }; Object (); @@ -215,6 +215,21 @@ private: friend class ObjectFactory; friend class AggregateIterator; + /** + * This data structure uses a classic C-style trick to + * hold an array of variable size without performing + * two memory allocations: the declaration of the structure + * declares a one-element array but when we allocate + * memory for this struct, we effectively allocate a larger + * chunk of memory than the struct to allow space for a larger + * variable sized buffer whose size is indicated by the element + * 'n' + */ + struct Aggregates { + uint32_t n; + Object *buffer[1]; + }; + Ptr DoGetObject (TypeId tid) const; bool Check (void) const; bool CheckLoose (void) const; @@ -243,6 +258,8 @@ private: */ void Construct (const AttributeList &attributes); + void UpdateSortedArray (struct Aggregates *aggregates, uint32_t i) const; + /** * The reference count for this object. Each aggregate * has an individual reference count. When the global @@ -261,13 +278,19 @@ private: */ bool m_disposed; /** - * A pointer to the next aggregate object. This is a circular - * linked list of aggregated objects: the last one points - * back to the first one. If an object is not aggregated to - * any other object, the value of this field is equal to the - * value of the 'this' pointer. + * a pointer to an array of 'aggregates'. i.e., a pointer to + * each object aggregated to this object is stored in this + * array. The array is shared by all aggregated objects + * so the size of the array is indirectly a reference count. */ - Object *m_next; + struct Aggregates * m_aggregates; + /** + * Indicates the number of times the object was accessed with a + * call to GetObject. This integer is used to implement a + * heuristic to sort the array of aggregates to put at the start + * of the array the most-frequently accessed elements. + */ + uint32_t m_getObjectCount; }; /** From 4450bbafc3100dcdc41c48618291ac83d846f0b2 Mon Sep 17 00:00:00 2001 From: Craig Dowell Date: Thu, 5 Nov 2009 19:14:37 -0800 Subject: [PATCH 15/64] pass explicit temp directory to test suites --- src/common/pcap-file-test-suite.cc | 10 ++--- src/core/test.cc | 63 ++++++++++++++++++++++++++++-- src/core/test.h | 22 +++++++++++ test.py | 14 ++++++- utils/test-runner.cc | 9 +++++ 5 files changed, 108 insertions(+), 10 deletions(-) diff --git a/src/common/pcap-file-test-suite.cc b/src/common/pcap-file-test-suite.cc index d71c19b31..e87b9bbe7 100644 --- a/src/common/pcap-file-test-suite.cc +++ b/src/common/pcap-file-test-suite.cc @@ -107,7 +107,7 @@ WriteModeCreateTestCase::DoSetup (void) std::stringstream filename; uint32_t n = rand (); filename << n; - m_testFilename = "/tmp/" + filename.str () + ".pcap"; + m_testFilename = GetTempDir () + filename.str () + ".pcap"; } void @@ -218,7 +218,7 @@ ReadModeCreateTestCase::DoSetup (void) std::stringstream filename; uint32_t n = rand (); filename << n; - m_testFilename = "/tmp/" + filename.str () + ".pcap"; + m_testFilename = GetTempDir () + filename.str () + ".pcap"; } void @@ -317,7 +317,7 @@ AppendModeCreateTestCase::DoSetup (void) std::stringstream filename; uint32_t n = rand (); filename << n; - m_testFilename = "/tmp/" + filename.str () + ".pcap"; + m_testFilename = GetTempDir () + filename.str () + ".pcap"; } void @@ -416,7 +416,7 @@ FileHeaderTestCase::DoSetup (void) std::stringstream filename; uint32_t n = rand (); filename << n; - m_testFilename = "/tmp/" + filename.str () + ".pcap"; + m_testFilename = GetTempDir () + filename.str () + ".pcap"; } void @@ -607,7 +607,7 @@ RecordHeaderTestCase::DoSetup (void) std::stringstream filename; uint32_t n = rand (); filename << n; - m_testFilename = "/tmp/" + filename.str () + ".pcap"; + m_testFilename = GetTempDir () + filename.str () + ".pcap"; } void diff --git a/src/core/test.cc b/src/core/test.cc index 77d833651..d9c46e45e 100644 --- a/src/core/test.cc +++ b/src/core/test.cc @@ -87,6 +87,7 @@ TestCase::TestCase (std::string name) m_continueOnFailure (false), m_detailsReported (false), m_basedir ("invalid"), + m_tempdir ("invalid"), m_ofs (0), m_error (false) { @@ -203,7 +204,14 @@ TestCase::GetName (void) void TestCase::SetBaseDir (std::string basedir) { - m_basedir = basedir; + if (basedir[basedir.length () - 1] != '/') + { + m_basedir = basedir + "/"; + } + else + { + m_basedir = basedir; + } } std::string @@ -212,13 +220,32 @@ TestCase::GetBaseDir (void) return m_basedir; } +void +TestCase::SetTempDir (std::string tempdir) +{ + if (tempdir[tempdir.length () - 1] != '/') + { + m_tempdir = tempdir + "/"; + } + else + { + m_tempdir = tempdir; + } +} + +std::string +TestCase::GetTempDir (void) +{ + return m_tempdir; +} + std::string TestCase::GetSourceDir (std::string file) { std::string::size_type relPathBegin = file.find_first_of ("/"); - NS_ABORT_MSG_IF (relPathBegin == std::string::npos, "TestCase::GetSrouceDir(): Internal Error"); + NS_ABORT_MSG_IF (relPathBegin == std::string::npos, "TestCase::GetSourceDir(): Internal Error"); std::string::size_type relPathEnd = file.find_last_of ("/"); - NS_ABORT_MSG_IF (relPathEnd == std::string::npos, "TestCase::GetSrouceDir(): Internal Error"); + NS_ABORT_MSG_IF (relPathEnd == std::string::npos, "TestCase::GetSourceDir(): Internal Error"); return GetBaseDir () + file.substr (relPathBegin, relPathEnd + 1 - relPathBegin); } @@ -353,6 +380,7 @@ TestSuite::TestSuite (std::string name, TestType type) : m_name (name), m_verbose (false), m_basedir ("invalid"), + m_tempdir ("invalid"), m_ofs (0), m_error (false), m_type (type) @@ -476,7 +504,14 @@ TestSuite::GetName (void) void TestSuite::SetBaseDir (std::string basedir) { - m_basedir = basedir; + if (basedir[basedir.length () - 1] != '/') + { + m_basedir = basedir + "/"; + } + else + { + m_basedir = basedir; + } } std::string @@ -485,6 +520,25 @@ TestSuite::GetBaseDir (void) return m_basedir; } +void +TestSuite::SetTempDir (std::string tempdir) +{ + if (tempdir[tempdir.length () - 1] != '/') + { + m_tempdir = tempdir + "/"; + } + else + { + m_tempdir = tempdir; + } +} + +std::string +TestSuite::GetTempDir (void) +{ + return m_tempdir; +} + void TestSuite::SetStream (std::ofstream *ofs) { @@ -589,6 +643,7 @@ TestSuite::DoRun (void) (*i)->SetVerbose (m_verbose); (*i)->SetContinueOnFailure (m_continueOnFailure); (*i)->SetBaseDir (m_basedir); + (*i)->SetTempDir (m_tempdir); (*i)->SetStream (m_ofs); // diff --git a/src/core/test.h b/src/core/test.h index 571578ff1..c19d023d8 100644 --- a/src/core/test.h +++ b/src/core/test.h @@ -662,6 +662,16 @@ public: */ std::string GetBaseDir (void); + /** + * \brief Set the temporary file directory (where to write temporary files). + */ + void SetTempDir (std::string dir); + + /** + * \brief Get the temporary file directory . + */ + std::string GetTempDir (void); + /** * \brief Get the source directory of the current source file. * @@ -830,6 +840,7 @@ private: bool m_continueOnFailure; bool m_detailsReported; std::string m_basedir; + std::string m_tempdir; std::ofstream *m_ofs; bool m_error; }; @@ -944,6 +955,16 @@ public: */ std::string GetBaseDir (void); + /** + * \brief Set the temporary file directory (where to write temporary files). + */ + void SetTempDir (std::string dir); + + /** + * \brief Get the temporary file directory. + */ + std::string GetTempDir (void); + /** * \brief Set the stream to which status and result messages will be written. * @@ -1064,6 +1085,7 @@ private: bool m_verbose; bool m_continueOnFailure; std::string m_basedir; + std::string m_tempdir; std::ofstream *m_ofs; bool m_error; TestType m_type; diff --git a/test.py b/test.py index 6a029e0b8..4804b6e64 100755 --- a/test.py +++ b/test.py @@ -616,6 +616,7 @@ class Job: self.shell_command = "" self.display_name = "" self.basedir = "" + self.tempdir = "" self.cwd = "" self.tmp_file_name = "" self.returncode = False @@ -673,6 +674,13 @@ class Job: def set_basedir(self, basedir): self.basedir = basedir + # + # This is the directory to which a running test suite should write any + # temporary files. + # + def set_tempdir(self, tempdir): + self.tempdir = tempdir + # # This is the current working directory that will be given to an executing # test as it is being run. It will be used for examples to tell them where @@ -766,7 +774,8 @@ class worker_thread(threading.Thread): # file name # (job.returncode, standard_out, standard_err, et) = run_job_synchronously(job.shell_command + - " --basedir=%s --out=%s" % (job.basedir, job.tmp_file_name), job.cwd, options.valgrind) + " --basedir=%s --tempdir=%s --out=%s" % (job.basedir, job.tempdir, job.tmp_file_name), + job.cwd, options.valgrind) job.set_elapsed_time(et) @@ -1004,6 +1013,7 @@ def run_tests(): job.set_tmp_file_name(os.path.join(testpy_output_dir, "%s.xml" % test)) job.set_cwd(os.getcwd()) job.set_basedir(os.getcwd()) + job.set_tempdir(testpy_output_dir) if (options.multiple): multiple = " --multiple" else: @@ -1074,6 +1084,7 @@ def run_tests(): job.set_tmp_file_name("") job.set_cwd(testpy_output_dir) job.set_basedir(os.getcwd()) + job.set_tempdir(testpy_output_dir) job.set_shell_command("examples/%s" % test) if options.valgrind and not eval(do_valgrind_run): @@ -1097,6 +1108,7 @@ def run_tests(): job.set_tmp_file_name("") job.set_cwd(testpy_output_dir) job.set_basedir(os.getcwd()) + job.set_tempdir(testpy_output_dir) job.set_shell_command("examples/%s" % options.example) if options.verbose: diff --git a/utils/test-runner.cc b/utils/test-runner.cc index 0c6973378..3c0d4da28 100644 --- a/utils/test-runner.cc +++ b/utils/test-runner.cc @@ -40,11 +40,13 @@ main (int argc, char *argv[]) bool doKinds = false; bool haveBasedir = false; + bool haveTempdir = false; bool haveOutfile = false; bool haveType = false; std::string suiteName; std::string basedir; + std::string tempdir; std::string outfileName; std::string typeName; @@ -96,6 +98,12 @@ main (int argc, char *argv[]) doSuite = true; } + if (arg.find ("--tempdir=") != std::string::npos) + { + tempdir = arg.substr (arg.find_first_of ("=") + 1, 9999); + haveTempdir = true; + } + if (arg.compare ("--verbose") == 0) { doVerbose = true; @@ -247,6 +255,7 @@ main (int argc, char *argv[]) if (doSuite == false || (doSuite == true && suiteName == testSuite->GetName ())) { testSuite->SetBaseDir (basedir); + testSuite->SetTempDir (tempdir); testSuite->SetStream (pofs); testSuite->SetVerbose (doVerbose); testSuite->SetContinueOnFailure (doMultiple); From 932c44209e5c7303024a4d428f1a9f2066f9e96c Mon Sep 17 00:00:00 2001 From: Craig Dowell Date: Thu, 5 Nov 2009 22:29:53 -0800 Subject: [PATCH 16/64] Make tests pass on MinGW, add fifth tutorial example --- src/core/test.cc | 34 +++++++++++++++++++++++++++++++++- test.py | 1 + 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/src/core/test.cc b/src/core/test.cc index d9c46e45e..ab1a691be 100644 --- a/src/core/test.cc +++ b/src/core/test.cc @@ -204,6 +204,10 @@ TestCase::GetName (void) void TestCase::SetBaseDir (std::string basedir) { + // + // C and C++ allow one to use forward slashes even on systems where the + // separator is actually a backslash. + // if (basedir[basedir.length () - 1] != '/') { m_basedir = basedir + "/"; @@ -223,6 +227,10 @@ TestCase::GetBaseDir (void) void TestCase::SetTempDir (std::string tempdir) { + // + // C and C++ allow one to use forward slashes even on systems where the + // separator is actually a backslash. + // if (tempdir[tempdir.length () - 1] != '/') { m_tempdir = tempdir + "/"; @@ -242,9 +250,25 @@ TestCase::GetTempDir (void) std::string TestCase::GetSourceDir (std::string file) { + // + // The parameter is actually going to be __FILE__ which may have + // backslashes in it on win32 systems. For example, + // + // ..\src\common\pcap-file-test-suite.cc (win32) + // + // or + // + // ../src/common/pcap-file-test-suite.cc (grown-up systems) + // +#ifdef WIN32 + std::string::size_type relPathBegin = file.find_first_of ("\\"); + std::string::size_type relPathEnd = file.find_last_of ("\\"); +#else std::string::size_type relPathBegin = file.find_first_of ("/"); - NS_ABORT_MSG_IF (relPathBegin == std::string::npos, "TestCase::GetSourceDir(): Internal Error"); std::string::size_type relPathEnd = file.find_last_of ("/"); +#endif + + NS_ABORT_MSG_IF (relPathBegin == std::string::npos, "TestCase::GetSourceDir(): Internal Error"); NS_ABORT_MSG_IF (relPathEnd == std::string::npos, "TestCase::GetSourceDir(): Internal Error"); return GetBaseDir () + file.substr (relPathBegin, relPathEnd + 1 - relPathBegin); @@ -504,6 +528,10 @@ TestSuite::GetName (void) void TestSuite::SetBaseDir (std::string basedir) { + // + // C and C++ allow one to use forward slashes even on systems where the + // separator is actually a backslash. + // if (basedir[basedir.length () - 1] != '/') { m_basedir = basedir + "/"; @@ -523,6 +551,10 @@ TestSuite::GetBaseDir (void) void TestSuite::SetTempDir (std::string tempdir) { + // + // C and C++ allow one to use forward slashes even on systems where the + // separator is actually a backslash. + // if (tempdir[tempdir.length () - 1] != '/') { m_tempdir = tempdir + "/"; diff --git a/test.py b/test.py index 4804b6e64..95c4a631f 100755 --- a/test.py +++ b/test.py @@ -132,6 +132,7 @@ example_tests = [ ("tutorial/second", "True", "True"), ("tutorial/third", "True", "True"), ("tutorial/fourth", "True", "True"), + ("tutorial/fifth", "True", "True"), ("udp/udp-echo", "True", "True"), From b1400fd928cab15c5169adbf7b943969f71514a8 Mon Sep 17 00:00:00 2001 From: Mathieu Lacage Date: Fri, 6 Nov 2009 11:27:04 +0100 Subject: [PATCH 17/64] Optimization: try to optimistically dynamically_cast in case the requested object is the first entry in the aggregate buffer. --- src/core/object.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/core/object.h b/src/core/object.h index 03564d7e5..e91994e90 100644 --- a/src/core/object.h +++ b/src/core/object.h @@ -122,7 +122,7 @@ public: * \returns a pointer to the requested interface or zero if it could not be found. */ template - Ptr GetObject (void) const; + inline Ptr GetObject (void) const; /** * \param tid the interface id of the requested interface * \returns a pointer to the requested interface or zero if it could not be found. @@ -383,6 +383,11 @@ template Ptr Object::GetObject () const { + T *result = dynamic_cast (m_aggregates->buffer[0]); + if (result != 0) + { + return Ptr (result); + } Ptr found = DoGetObject (T::GetTypeId ()); if (found != 0) { From a0ff88e59181dd6fadd8e3bb4e11a41420729f68 Mon Sep 17 00:00:00 2001 From: Mathieu Lacage Date: Fri, 6 Nov 2009 17:47:44 +0100 Subject: [PATCH 18/64] Optimization: use a shared reference counter instead of a per-object counter in Object::Ref/Unref --- src/core/object-ref-count.h | 121 ++++++++++++++++++++++++++++++++++++ src/core/object.cc | 28 ++++----- src/core/object.h | 59 +++--------------- src/core/wscript | 1 + 4 files changed, 144 insertions(+), 65 deletions(-) create mode 100644 src/core/object-ref-count.h diff --git a/src/core/object-ref-count.h b/src/core/object-ref-count.h new file mode 100644 index 000000000..c148ebf33 --- /dev/null +++ b/src/core/object-ref-count.h @@ -0,0 +1,121 @@ +/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ +/* + * Copyright (c) 2009 Mathieu Lacage + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation; + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Author: Mathieu Lacage + */ +#ifndef OBJECT_REF_COUNT_H +#define OBJECT_REF_COUNT_H + +#include "empty.h" + +namespace ns3 { + +/** + * This templated class provides the refcounting implementation + * for the ns3::Object class. + * + * The tricky aspect of the implementation of this class is that + * instead of storing a count directly, it keeps track of a pointer + * to a count to allow multiple instances of the class to share the + * same pointer/count. This is mainly used by the aggregation support + * of the ns3::Object class + */ +template +class ObjectRefCount : public PARENT +{ +public: + ObjectRefCount () + : m_count (new int (1)) + {} + ObjectRefCount (const ObjectRefCount &o) + : m_count (new int (1)) + {} + ObjectRefCount & operator = (const ObjectRefCount &o) + { + *m_count = *o.m_count; + return *this; + } + ~ObjectRefCount () + { + m_count = 0; + } + + /** + * Get the reference count of the object. Normally not needed; for language bindings. + */ + int GetReferenceCount (void) const { + return *m_count; + } + /** + * 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 + { + (*m_count)++; + } + /** + * 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 + { + (*m_count)--; + if ((*m_count) == 0) + { + const_cast*>(this)->DoDelete (); + } + } +protected: + /** + * \param other another object + * + * This method makes this object and the input other object + * share the same reference count. + */ + void ShareCount (ObjectRefCount *other) + { + (*m_count) += (*other->m_count); + delete other->m_count; + other->m_count = m_count; + } + /** + * Called just before deleting this object: when two + * objects share the same reference count, the user + * who is deleting them must be careful to delete the + * associated count only once and this is done by calling + * this method to get a reference to the count and, then, + * calling delete on the count. + * + * \sa ns3::Object::DoDelete + */ + int *PeekCountPtr (void) const + { + return m_count; + } +private: + virtual void DoDelete (void) = 0; + mutable int *m_count; +}; + +} // namespace ns3 + +#endif /* OBJECT_REF_COUNT_H */ diff --git a/src/core/object.cc b/src/core/object.cc index 2725ba6cf..0db017b75 100644 --- a/src/core/object.cc +++ b/src/core/object.cc @@ -79,8 +79,7 @@ Object::GetTypeId (void) Object::Object () - : m_count (1), - m_tid (Object::GetTypeId ()), + : m_tid (Object::GetTypeId ()), m_disposed (false), m_aggregates ((struct Aggregates *)malloc (sizeof (struct Aggregates))), m_getObjectCount (0) @@ -112,8 +111,7 @@ Object::~Object () m_aggregates = 0; } Object::Object (const Object &o) - : m_count (1), - m_tid (o.m_tid), + : m_tid (o.m_tid), m_disposed (false), m_aggregates ((struct Aggregates *)malloc (sizeof (struct Aggregates))), m_getObjectCount (0) @@ -121,11 +119,6 @@ Object::Object (const Object &o) m_aggregates->n = 1; m_aggregates->buffer[0] = this; } -uint32_t -Object::GetReferenceCount (void) const -{ - return m_count; -} void Object::Construct (const AttributeList &attributes) { @@ -231,6 +224,10 @@ Object::AggregateObject (Ptr o) Object *current = aggregates->buffer[i]; current->m_aggregates = aggregates; } + + // share the counts + ShareCount (other); + // Finally, call NotifyNewAggregate in the listed chain for (uint32_t i = 0; i < n; i++) { @@ -271,7 +268,7 @@ Object::DoDispose (void) bool Object::Check (void) const { - return (m_count > 0); + return (GetReferenceCount () > 0); } /* In some cases, when an event is scheduled against a subclass of @@ -289,13 +286,12 @@ Object::CheckLoose (void) const for (uint32_t i = 0; i < n; i++) { Object *current = m_aggregates->buffer[i]; - refcount += current->m_count; + refcount += current->GetReferenceCount (); } return (refcount > 0); } - void -Object::MaybeDelete (void) const +Object::DoDelete (void) { // First, check if any of the attached // Object has a non-zero count. @@ -303,7 +299,7 @@ Object::MaybeDelete (void) const for (uint32_t i = 0; i < n; i++) { Object *current = m_aggregates->buffer[i]; - if (current->m_count != 0) + if (current->GetReferenceCount () != 0) { return; } @@ -319,6 +315,8 @@ Object::MaybeDelete (void) const } } + int *count = PeekCountPtr (); + // all attached objects have a zero count so, // we can delete them all. struct Aggregates *aggregates = m_aggregates; @@ -331,6 +329,8 @@ Object::MaybeDelete (void) const Object *current = aggregates->buffer[0]; delete current; } + + delete count; } } // namespace ns3 diff --git a/src/core/object.h b/src/core/object.h index e91994e90..4488b351e 100644 --- a/src/core/object.h +++ b/src/core/object.h @@ -28,6 +28,7 @@ #include "attribute.h" #include "object-base.h" #include "attribute-list.h" +#include "object-ref-count.h" namespace ns3 { @@ -55,7 +56,7 @@ class TraceSourceAccessor; * invoked from the Object::Unref method before destroying the object, even if the user * did not call Object::Dispose directly. */ -class Object : public ObjectBase +class Object : public ObjectRefCount { public: static TypeId GetTypeId (void); @@ -98,26 +99,6 @@ public: */ virtual TypeId GetInstanceTypeId (void) const; - /** - * 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; - - /** - * Get the reference count of the object. Normally not needed; for language bindings. - */ - uint32_t GetReferenceCount (void) const; - /** * \returns a pointer to the requested interface or zero if it could not be found. */ @@ -233,13 +214,6 @@ private: Ptr DoGetObject (TypeId tid) const; bool Check (void) const; bool CheckLoose (void) const; - /** - * Attempt to delete this object. This method iterates - * over all aggregated objects to check if they all - * have a zero refcount. If yes, the object and all - * its aggregates are deleted. If not, nothing is done. - */ - void MaybeDelete (void) const; /** * \param tid an TypeId * @@ -259,15 +233,14 @@ private: void Construct (const AttributeList &attributes); void UpdateSortedArray (struct Aggregates *aggregates, uint32_t i) const; - /** - * The reference count for this object. Each aggregate - * has an individual reference count. When the global - * reference count (the sum of all reference counts) - * reaches zero, the object and all its aggregates is - * deleted. + * Attempt to delete this object. This method iterates + * over all aggregated objects to check if they all + * have a zero refcount. If yes, the object and all + * its aggregates are deleted. If not, nothing is done. */ - mutable uint32_t m_count; + virtual void DoDelete (void); + /** * Identifies the type of this object instance. */ @@ -363,22 +336,6 @@ namespace ns3 { * The Object implementation which depends on templates *************************************************************************/ -void -Object::Ref (void) const -{ - m_count++; -} -void -Object::Unref (void) const -{ - NS_ASSERT (Check ()); - m_count--; - if (m_count == 0) - { - MaybeDelete (); - } -} - template Ptr Object::GetObject () const diff --git a/src/core/wscript b/src/core/wscript index 519f17eda..40f146858 100644 --- a/src/core/wscript +++ b/src/core/wscript @@ -126,6 +126,7 @@ def build(bld): 'abort.h', 'names.h', 'vector.h', + 'object-ref-count.h', ] if sys.platform == 'win32': From f8fe3ebcb38a5dae87a14a91eeca09e4501c8b4c Mon Sep 17 00:00:00 2001 From: Mathieu Lacage Date: Fri, 6 Nov 2009 15:16:18 -0800 Subject: [PATCH 19/64] Ipv4L3Protocol::GetInterface optimization --- src/internet-stack/ipv4-l3-protocol.cc | 17 +++++------------ src/internet-stack/ipv4-l3-protocol.h | 3 ++- 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/src/internet-stack/ipv4-l3-protocol.cc b/src/internet-stack/ipv4-l3-protocol.cc index 8e95c4f70..917548654 100644 --- a/src/internet-stack/ipv4-l3-protocol.cc +++ b/src/internet-stack/ipv4-l3-protocol.cc @@ -82,8 +82,7 @@ Ipv4L3Protocol::GetTypeId (void) } Ipv4L3Protocol::Ipv4L3Protocol() - : m_nInterfaces (0), - m_identification (0) + : m_identification (0) { NS_LOG_FUNCTION_NOARGS (); } @@ -266,9 +265,8 @@ uint32_t Ipv4L3Protocol::AddIpv4Interface (Ptrinterface) { NS_LOG_FUNCTION (this << interface); - uint32_t index = m_nInterfaces; + uint32_t index = m_interfaces.size (); m_interfaces.push_back (interface); - m_nInterfaces++; return index; } @@ -276,14 +274,9 @@ Ptr Ipv4L3Protocol::GetInterface (uint32_t index) const { NS_LOG_FUNCTION (this << index); - uint32_t tmp = 0; - for (Ipv4InterfaceList::const_iterator i = m_interfaces.begin (); i != m_interfaces.end (); i++) + if (index < m_interfaces.size ()) { - if (index == tmp) - { - return *i; - } - tmp++; + return m_interfaces[index]; } return 0; } @@ -292,7 +285,7 @@ uint32_t Ipv4L3Protocol::GetNInterfaces (void) const { NS_LOG_FUNCTION_NOARGS (); - return m_nInterfaces; + return m_interfaces.size (); } int32_t diff --git a/src/internet-stack/ipv4-l3-protocol.h b/src/internet-stack/ipv4-l3-protocol.h index b58029820..e3996559c 100644 --- a/src/internet-stack/ipv4-l3-protocol.h +++ b/src/internet-stack/ipv4-l3-protocol.h @@ -22,6 +22,7 @@ #define IPV4_L3_PROTOCOL_H #include +#include #include #include "ns3/ipv4-address.h" #include "ns3/ptr.h" @@ -233,7 +234,7 @@ private: Ptr GetIcmp (void) const; bool IsUnicast (Ipv4Address ad, Ipv4Mask interfaceMask) const; - typedef std::list > Ipv4InterfaceList; + typedef std::vector > Ipv4InterfaceList; typedef std::list > SocketList; typedef std::list > L4List_t; From 4a367fd431458ac1a952870668ad072963ad8421 Mon Sep 17 00:00:00 2001 From: Tom Henderson Date: Fri, 6 Nov 2009 15:22:33 -0800 Subject: [PATCH 20/64] update AUTHORS list --- AUTHORS | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/AUTHORS b/AUTHORS index 93e5c0225..bdfd3f84d 100644 --- a/AUTHORS +++ b/AUTHORS @@ -12,23 +12,34 @@ Luis Cortes (cortes@gatech.edu) Craig Dowell (craigdo@ee.washington.edu) David Gross (gdavid.devel@gmail.com) Tom Henderson (tomhend@u.washington.edu) -Andrey Mazo (mazo@iitp.ru) +Andrey Hippo (ahippo@yandex.ru) Sam Jansen (sam.jansen@gmail.com) Liu Jian (liujatp@gmail.com) Joe Kopena (tjkopena@cs.drexel.edu) Aleksey Kovalenko (kovalenko@iitp.ru) Mathieu Lacage (mathieu.lacage@sophia.inria.fr) Emmanuelle Laprise (emmmanuelle.laprise@bluekazoo.ca) +Keith Ma (keith.nwsuaf@gmail.com) Federico Maguolo (maguolof@dei.unipd.it) +Antti Makela (zarhan@cc.hut.fi) Francesco Malandrino (francesco.malandrino@gmail.com) +Fabian Mauchle (f1mauchl@hsr.ch) +Andrey Mazo (mazo@iitp.ru) Faker Moatamri (faker.moatamri@sophia.inria.fr) Duy Nguyen (duy@soe.ucsc.edu) +Tommaso Pecorella (tommaso.pecorella@unifi.it) +Yana Podkosova (yanapdk@rambler.ru) Guangyu Pei (guangyu.pei@boeing.com) George F. Riley (riley@ece.gatech.edu) Providence Salumu Munga (Providence.Salumu@gmail.com, Providence.Salumu_Munga@it-sudparis.eu) +Guillaume Seguin (guillaume.seguin@sophia.inria.fr) Kulin Shah (m.kulin@gmail.com) +Ewgenij Starostin (estar@cs.tu-berlin.de) +Adrian S. W. Tam (adrian.sw.tam@gmail.com) +Wilson Thong (wilsonwk@ee.cityu.edu.hk) Mauro Tortonesi (mauro.tortonesi@unife.it) Sebastien Vincent (vincent@clarinet.u-strasbg.fr) Guillaume Vu-Brugier (gvubrugier@gmail.com) +Tom Wambold (tom5760@gmail.com) Florian Westphal (fw@strlen.de) Josh Pelkey (jpelkey@gatech.edu) From c057928e1eac4be6292ee747be5ecda903b792d5 Mon Sep 17 00:00:00 2001 From: Andrey Mazo Date: Mon, 9 Nov 2009 12:24:51 +0300 Subject: [PATCH 21/64] Remove my old email from AUTHORS list. --- AUTHORS | 1 - 1 file changed, 1 deletion(-) diff --git a/AUTHORS b/AUTHORS index bdfd3f84d..7ade1a3d3 100644 --- a/AUTHORS +++ b/AUTHORS @@ -12,7 +12,6 @@ Luis Cortes (cortes@gatech.edu) Craig Dowell (craigdo@ee.washington.edu) David Gross (gdavid.devel@gmail.com) Tom Henderson (tomhend@u.washington.edu) -Andrey Hippo (ahippo@yandex.ru) Sam Jansen (sam.jansen@gmail.com) Liu Jian (liujatp@gmail.com) Joe Kopena (tjkopena@cs.drexel.edu) From 1fc1107e920be00b57587a3e876147874425f2fb Mon Sep 17 00:00:00 2001 From: Mathieu Lacage Date: Mon, 9 Nov 2009 16:02:05 +0100 Subject: [PATCH 22/64] delete dead code --- src/core/object.cc | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/src/core/object.cc b/src/core/object.cc index 0db017b75..79f6bce00 100644 --- a/src/core/object.cc +++ b/src/core/object.cc @@ -293,18 +293,7 @@ Object::CheckLoose (void) const void Object::DoDelete (void) { - // First, check if any of the attached - // Object has a non-zero count. uint32_t n = m_aggregates->n; - for (uint32_t i = 0; i < n; i++) - { - Object *current = m_aggregates->buffer[i]; - if (current->GetReferenceCount () != 0) - { - return; - } - } - // Ensure we are disposed. for (uint32_t i = 0; i < n; i++) { @@ -317,8 +306,7 @@ Object::DoDelete (void) int *count = PeekCountPtr (); - // all attached objects have a zero count so, - // we can delete them all. + // Now, actually delete all objects struct Aggregates *aggregates = m_aggregates; for (uint32_t i = 0; i < n; i++) { From f0a2528a9fbab1ec9f5136848e8cce2e59914d33 Mon Sep 17 00:00:00 2001 From: Mathieu Lacage Date: Mon, 9 Nov 2009 16:45:54 +0100 Subject: [PATCH 23/64] gah, we don't want to copy the count in the assignment operator --- src/core/object-ref-count.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/core/object-ref-count.h b/src/core/object-ref-count.h index c148ebf33..57f8fc980 100644 --- a/src/core/object-ref-count.h +++ b/src/core/object-ref-count.h @@ -46,7 +46,6 @@ public: {} ObjectRefCount & operator = (const ObjectRefCount &o) { - *m_count = *o.m_count; return *this; } ~ObjectRefCount () From 0f37dd8bdca49b25bef7992280720a2d02ac4a98 Mon Sep 17 00:00:00 2001 From: Mathieu Lacage Date: Tue, 10 Nov 2009 07:45:32 +0100 Subject: [PATCH 24/64] remove uneeded header --- src/common/packet.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/common/packet.h b/src/common/packet.h index 835c8bbfd..87add7437 100644 --- a/src/common/packet.h +++ b/src/common/packet.h @@ -32,7 +32,6 @@ #include "ns3/callback.h" #include "ns3/assert.h" #include "ns3/ptr.h" -#include "ns3/deprecated.h" namespace ns3 { From fa3ec325220e2a08c72001b7a72af1ba88be756e Mon Sep 17 00:00:00 2001 From: Guillaume Seguin Date: Tue, 10 Nov 2009 10:31:51 +0100 Subject: [PATCH 25/64] set the implementation Scheduler after setting the implementation --- src/simulator/simulator.cc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/simulator/simulator.cc b/src/simulator/simulator.cc index 7a0c2a7fb..5c9552d99 100644 --- a/src/simulator/simulator.cc +++ b/src/simulator/simulator.cc @@ -297,6 +297,12 @@ 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; + // Set the default scheduler + ObjectFactory factory; + StringValue s; + g_schedTypeImpl.GetValue (s); + factory.SetTypeId (s.Get ()); + impl->SetScheduler (factory.Create ()); // // Note: we call LogSetTimePrinter _after_ creating the implementation // object because the act of creation can trigger calls to the logging From a12e6a18c2aa1e79a2d98793d95489feadd592a1 Mon Sep 17 00:00:00 2001 From: Phillip Sitbon Date: Tue, 10 Nov 2009 12:10:35 +0100 Subject: [PATCH 26/64] Add Waypoint Mobility model to mainstream --- src/mobility/mobility.h | 5 + src/mobility/waypoint-mobility-model.cc | 182 ++++++++++++++++++++++++ src/mobility/waypoint-mobility-model.h | 115 +++++++++++++++ src/mobility/waypoint.cc | 74 ++++++++++ src/mobility/waypoint.h | 74 ++++++++++ src/mobility/wscript | 4 + 6 files changed, 454 insertions(+) create mode 100644 src/mobility/waypoint-mobility-model.cc create mode 100644 src/mobility/waypoint-mobility-model.h create mode 100644 src/mobility/waypoint.cc create mode 100644 src/mobility/waypoint.h diff --git a/src/mobility/mobility.h b/src/mobility/mobility.h index 98e2f37e1..05cf769e7 100644 --- a/src/mobility/mobility.h +++ b/src/mobility/mobility.h @@ -28,4 +28,9 @@ * - ns3::RandomDirection2dMobilityModel: a 2d random direction mobility * model where the bounds of the mobility are are a rectangle. * + * - ns3::WaypointMobilityModel: A model which determines paths from sets + * of ns3::Waypoint objects, similar to using events to update velocity + * and direction with a ns3::ConstantVelocityMobilityModel. This model + * is slightly faster for this task and uses less memory. + * */ diff --git a/src/mobility/waypoint-mobility-model.cc b/src/mobility/waypoint-mobility-model.cc new file mode 100644 index 000000000..06a9d7326 --- /dev/null +++ b/src/mobility/waypoint-mobility-model.cc @@ -0,0 +1,182 @@ +/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ +/* + * Copyright (c) 2009 Phillip Sitbon + * + * 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: Phillip Sitbon + */ +#include +#include "ns3/abort.h" +#include "ns3/simulator.h" +#include "ns3/uinteger.h" +#include "ns3/log.h" +#include "waypoint-mobility-model.h" + +NS_LOG_COMPONENT_DEFINE ("WaypointMobilityModel"); + +namespace ns3 { + +NS_OBJECT_ENSURE_REGISTERED (WaypointMobilityModel); + + +TypeId +WaypointMobilityModel::GetTypeId (void) +{ + static TypeId tid = TypeId ("ns3::WaypointMobilityModel") + .SetParent () + .SetGroupName ("Mobility") + .AddConstructor () + .AddAttribute ("NextWaypoint", "The next waypoint used to determine position.", + TypeId::ATTR_GET, + WaypointValue (), + MakeWaypointAccessor (&WaypointMobilityModel::GetNextWaypoint), + MakeWaypointChecker ()) + .AddAttribute ("WaypointsLeft", "The number of waypoints remaining.", + TypeId::ATTR_GET, + UintegerValue (0), + MakeUintegerAccessor (&WaypointMobilityModel::WaypointsLeft), + MakeUintegerChecker ()) + ; + return tid; +} + + +WaypointMobilityModel::WaypointMobilityModel () + : m_first (true) +{ +} +WaypointMobilityModel::~WaypointMobilityModel () +{ +} +void +WaypointMobilityModel::DoDispose (void) +{ + MobilityModel::DoDispose (); +} +void +WaypointMobilityModel::AddWaypoint (const Waypoint &waypoint) +{ + if ( m_first ) + { + m_first = false; + m_current = m_next = waypoint; + } + else + { + NS_ABORT_MSG_IF ( !m_waypoints.empty () && (m_waypoints.back ().GetTime () >= waypoint.GetTime ()), + "Waypoints must be added in ascending time order"); + m_waypoints.push_back (waypoint); + } +} +Waypoint +WaypointMobilityModel::GetNextWaypoint (void) const +{ + Update (); + return m_next; +} +uint32_t +WaypointMobilityModel::WaypointsLeft (void) const +{ + Update (); + return m_waypoints.size(); +} +void +WaypointMobilityModel::Update (void) const +{ + const Time now = Simulator::Now (); + bool newWaypoint = false; + + if ( now <= m_current.GetTime () ) + { + return; + } + + while ( now >= m_next.GetTime () ) + { + if ( m_waypoints.empty () ) + { + if ( m_current.GetTime () <= m_next.GetTime () ) + { + m_current.SetPosition(m_next.GetPosition ()); + m_current.SetTime (now); + m_velocity = Vector (0,0,0); + NotifyCourseChange (); + } + else + { + m_current.SetTime (now); + } + + return; + } + + m_current = m_next; + m_next = m_waypoints.front (); + m_waypoints.pop_front (); + newWaypoint = true; + + const double t_span = (m_next.GetTime () - m_current.GetTime ()).GetSeconds (); + NS_ASSERT (t_span > 0); + m_velocity.x = (m_next.GetPosition ().x - m_current.GetPosition ().x) / t_span; + m_velocity.y = (m_next.GetPosition ().y - m_current.GetPosition ().y) / t_span; + m_velocity.z = (m_next.GetPosition ().z - m_current.GetPosition ().z) / t_span; + } + + + const double t_diff = (now - m_current.GetTime ()).GetSeconds(); + Vector pos; + pos.x = m_current.GetPosition ().x + m_velocity.x * t_diff; + pos.y = m_current.GetPosition ().y + m_velocity.y * t_diff; + pos.z = m_current.GetPosition ().z + m_velocity.z * t_diff; + m_current.SetPosition (pos); + m_current.SetTime (now); + + if ( newWaypoint ) + { + NotifyCourseChange (); + } +} +Vector +WaypointMobilityModel::DoGetPosition (void) const +{ + Update (); + return m_current.GetPosition (); +} +void +WaypointMobilityModel::DoSetPosition (const Vector &position) +{ + const Time now = Simulator::Now (); + Update (); + m_current.SetTime (std::max (now, m_next.GetTime ())); + m_current.SetPosition (position); + m_velocity = Vector (0,0,0); + NotifyCourseChange (); +} +void +WaypointMobilityModel::EndMobility (void) +{ + m_waypoints.clear (); + m_current.SetTime (Seconds (std::numeric_limits::infinity ())); + m_next.SetTime (m_current.GetTime ()); + m_first = true; +} +Vector +WaypointMobilityModel::DoGetVelocity (void) const +{ + return m_velocity; +} + +} // namespace ns3 + diff --git a/src/mobility/waypoint-mobility-model.h b/src/mobility/waypoint-mobility-model.h new file mode 100644 index 000000000..7504efbbd --- /dev/null +++ b/src/mobility/waypoint-mobility-model.h @@ -0,0 +1,115 @@ +/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ +/* + * Copyright (c) 2009 Phillip Sitbon + * + * 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: Phillip Sitbon + */ +#ifndef WAYPOINT_MOBILITY_MODEL_H +#define WAYPOINT_MOBILITY_MODEL_H + +#include +#include +#include "mobility-model.h" +#include "ns3/vector.h" +#include "waypoint.h" + +namespace ns3 { + +/** + * \brief a waypoint-based mobility model + * + * Each object determines its velocity and position at a given time + * from a set of ns3::Waypoint objects. The position of each object + * is not updated unless queried, and past waypoints are discarded + * after the current simulation time greater than their time value. + * + * The initial position of each object corresponds to the position of + * the first waypoint, and the initial velocity of each object is zero. + * Upon reaching the last waypoint, object positions becomes static and + * velocity is zero. + * + * When a node is in between waypoints (in time), it moves with a constant + * velocity between the position at the previous waypoint and the position + * at the current waypoint. To make a node hold a certain position for a + * time interval, two waypoints with the same position (but different times) + * should be inserted sequentially. + * + * Waypoints can be added at any time, and setting the current position + * of an object will set its velocity to zero until the next waypoint time + * (at which time the object jumps to the next waypoint), unless there are + * no more waypoints in which case it will not change without user + * intervention. + * + */ +class WaypointMobilityModel : public MobilityModel +{ + public: + static TypeId GetTypeId (void); + + /** + * Create a path with no waypoints at location (0,0,0). + */ + WaypointMobilityModel (); + virtual ~WaypointMobilityModel (); + + /** + * \param waypoint waypoint to append to the object path. + * + * Add a waypoint to the path of the object. The time must + * be greater than the previous waypoint added, otherwise + * a fatal error occurs. The first waypoint is set as the + * current position with a velocity of zero. + * + */ + void AddWaypoint (const Waypoint &waypoint); + + /** + * Get the waypoint that this object is traveling towards. + */ + Waypoint GetNextWaypoint (void) const; + + /** + * Get the number of waypoints left for this object, excluding + * the next one. + */ + uint32_t WaypointsLeft (void) const; + + /** + * Clear any existing waypoints and set the current waypoint + * time to infinity. Calling this is only an optimization and + * not required. After calling this function, adding waypoints + * behaves as it would for a new object. + */ + void EndMobility (void); + + private: + void Update (void) const; + virtual void DoDispose (void); + virtual Vector DoGetPosition (void) const; + virtual void DoSetPosition (const Vector &position); + virtual Vector DoGetVelocity (void) const; + + bool m_first; + mutable std::deque m_waypoints; + mutable Waypoint m_current; + mutable Waypoint m_next; + mutable Vector m_velocity; +}; + +} // namespace ns3 + +#endif /* WAYPOINT_MOBILITY_MODEL_H */ + diff --git a/src/mobility/waypoint.cc b/src/mobility/waypoint.cc new file mode 100644 index 000000000..28efd05fe --- /dev/null +++ b/src/mobility/waypoint.cc @@ -0,0 +1,74 @@ +/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ +/* + * Copyright (c) 2009 Phillip Sitbon + * + * 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: Phillip Sitbon + */ +#include "waypoint.h" + +namespace ns3 { + +ATTRIBUTE_HELPER_CPP (Waypoint); + +Waypoint::Waypoint (const Time &waypointTime, const Vector &waypointPosition) + : m_time (waypointTime), + m_position (waypointPosition) +{} +Waypoint::Waypoint () + : m_time (0.0), + m_position (0,0,0) +{} + +Time Waypoint::GetTime () const +{ + return m_time; +} + +void Waypoint::SetTime (Time time) +{ + m_time = time; +} + +Vector Waypoint::GetPosition () const +{ + return m_position; +} + +void Waypoint::SetPosition (Vector pos) +{ + m_position = pos; +} + +std::ostream &operator << (std::ostream &os, const Waypoint &waypoint) +{ + os << waypoint.GetTime ().GetSeconds () << "$" << waypoint.GetPosition (); + return os; +} +std::istream &operator >> (std::istream &is, Waypoint &waypoint) +{ + char separator; + Time time = waypoint.GetTime (); + Vector pos = waypoint.GetPosition (); + is >> time >> separator >> pos; + if (separator != '$') + { + is.setstate (std::ios_base::failbit); + } + return is; +} + +} // namespace ns3 + diff --git a/src/mobility/waypoint.h b/src/mobility/waypoint.h new file mode 100644 index 000000000..af3e9ab43 --- /dev/null +++ b/src/mobility/waypoint.h @@ -0,0 +1,74 @@ +/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ +/* + * Copyright (c) 2009 Phillip Sitbon + * + * 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: Phillip Sitbon + */ +#ifndef WAYPOINT_H +#define WAYPOINT_H + +#include "ns3/attribute.h" +#include "ns3/attribute-helper.h" +#include "ns3/nstime.h" +#include "ns3/vector.h" + +namespace ns3 { + +/** + * \brief a (time, location) pair. + * + */ +class Waypoint +{ +public: + /** + * \param _time time of waypoint. + * \param _position position of waypoint corresponding to the given time. + * + * Create a waypoint. + */ + Waypoint (const Time &waypointTime, const Vector &waypointPosition); + + /** + * Create a waypoint at time 0 and position (0,0,0). + */ + Waypoint (); + Time GetTime () const; + void SetTime (Time time); + Vector GetPosition () const; + void SetPosition (Vector vec); +private: + /* The waypoint time */ + Time m_time; + /* The position of the waypoint */ + Vector m_position; +}; + +/** + * \class ns3::WaypointValue + * \brief hold objects of type ns3::Waypoint + */ +ATTRIBUTE_HELPER_HEADER ( Waypoint); + +std::ostream & +operator << (std::ostream &os, const Waypoint &waypoint); +std::istream & +operator >> (std::istream &is, Waypoint &waypoint); + +} // namespace ns3 + +#endif /* WAYPOINT_H */ + diff --git a/src/mobility/wscript b/src/mobility/wscript index 6bcfd2e5c..b78c3163c 100644 --- a/src/mobility/wscript +++ b/src/mobility/wscript @@ -14,6 +14,8 @@ def build(bld): 'random-walk-2d-mobility-model.cc', 'random-direction-2d-mobility-model.cc', 'constant-acceleration-mobility-model.cc', + 'waypoint.cc', + 'waypoint-mobility-model.cc', ] headers = bld.new_task_gen('ns3header') @@ -30,4 +32,6 @@ def build(bld): 'random-walk-2d-mobility-model.h', 'random-direction-2d-mobility-model.h', 'constant-acceleration-mobility-model.h', + 'waypoint.h', + 'waypoint-mobility-model.h', ] From 3e852713a3df10f1866b9d7a4ab1131e3f48bdfb Mon Sep 17 00:00:00 2001 From: Pavel Boyko Date: Tue, 10 Nov 2009 14:44:23 +0300 Subject: [PATCH 27/64] Bug 689: default energy detection and CCA thresholds are changed to be more realistic. --- src/devices/wifi/yans-wifi-phy.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/devices/wifi/yans-wifi-phy.cc b/src/devices/wifi/yans-wifi-phy.cc index 82b0f34da..107c07011 100644 --- a/src/devices/wifi/yans-wifi-phy.cc +++ b/src/devices/wifi/yans-wifi-phy.cc @@ -52,14 +52,14 @@ YansWifiPhy::GetTypeId (void) .AddAttribute ("EnergyDetectionThreshold", "The energy of a received signal should be higher than " "this threshold (dbm) to allow the PHY layer to detect the signal.", - DoubleValue (-140.0), + DoubleValue (-96.0), MakeDoubleAccessor (&YansWifiPhy::SetEdThreshold, &YansWifiPhy::GetEdThreshold), MakeDoubleChecker ()) .AddAttribute ("CcaMode1Threshold", "The energy of a received signal should be higher than " "this threshold (dbm) to allow the PHY layer to declare CCA BUSY state", - DoubleValue (-140.0), + DoubleValue (-99.0), MakeDoubleAccessor (&YansWifiPhy::SetCcaMode1Threshold, &YansWifiPhy::GetCcaMode1Threshold), MakeDoubleChecker ()) From 3f2d10b3c84ac62feeb1605b4bdf2699abed9e34 Mon Sep 17 00:00:00 2001 From: Tom Henderson Date: Tue, 10 Nov 2009 06:13:29 -0800 Subject: [PATCH 28/64] Point to CHANGES.html --- RELEASE_NOTES | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/RELEASE_NOTES b/RELEASE_NOTES index 8b2e49834..e21e19aa7 100644 --- a/RELEASE_NOTES +++ b/RELEASE_NOTES @@ -1,11 +1,14 @@ ns-3 RELEASE NOTES -This file contains ns-3 release notes (most recent releases first). +This file contains ns-3 release notes (most recent releases first). All of the ns-3 documentation is accessible from the ns-3 website: 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.6 =========== From 81d7dad715192a5c5d9ad23f4c9bee7fc4538a06 Mon Sep 17 00:00:00 2001 From: Tom Henderson Date: Tue, 10 Nov 2009 06:14:11 -0800 Subject: [PATCH 29/64] Document changes to YansWifiPhy defaults --- CHANGES.html | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/CHANGES.html b/CHANGES.html index fb086506d..7003d49c0 100644 --- a/CHANGES.html +++ b/CHANGES.html @@ -43,6 +43,24 @@ the cracks, unfortunately. If you, as a user, can suggest improvements to this file based on your experience, please contribute a patch or drop 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. +
+

Changes from ns-3.5 to ns-3.6

From c4ad800f32c06fcacf5edff783f43c83a21f3420 Mon Sep 17 00:00:00 2001 From: Craig Dowell Date: Tue, 10 Nov 2009 11:03:04 -0800 Subject: [PATCH 30/64] correct some wildly out-of-date doxygen --- src/core/system-thread.h | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/core/system-thread.h b/src/core/system-thread.h index 0d3f5add7..05b3108dc 100644 --- a/src/core/system-thread.h +++ b/src/core/system-thread.h @@ -72,12 +72,20 @@ public: * is asking the SystemThread to call object->MyMethod () in a new thread * of execution. * - * Remember that if you are invoking a callback on an object that is - * managed by a smart pointer, you need to call PeekPointer. + * If starting a thread in your currently executing object, you can use the + * "this" pointer: + * + * Ptr st = Create ( + * MakeCallback (&MyClass::MyMethod, this)); + * st->Start (); + * + * Object lifetime is always an issue with threads, so it is common to use + * smart pointers. If you are spinning up a thread in an object that is + * managed by a smart pointer, you can use that pointer directly: * * Ptr myPtr = Create (); * Ptr st = Create ( - * MakeCallback (&MyClass::MyMethod, PeekPointer (myPtr))); + * MakeCallback (&MyClass::MyMethod, myPtr)); * st->Start (); * * Just like any thread, you can synchronize with its termination. The From 24d5900b68b5cfbdb2587fd5d88267eff66727f8 Mon Sep 17 00:00:00 2001 From: Andrey Mazo Date: Wed, 11 Nov 2009 00:27:09 +0300 Subject: [PATCH 31/64] Mesh: add constructor to TypeId of WifiInformationElementVector --- src/devices/mesh/wifi-information-element-vector.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/devices/mesh/wifi-information-element-vector.cc b/src/devices/mesh/wifi-information-element-vector.cc index 3531b4b22..2e7b82b46 100644 --- a/src/devices/mesh/wifi-information-element-vector.cc +++ b/src/devices/mesh/wifi-information-element-vector.cc @@ -58,7 +58,8 @@ TypeId WifiInformationElementVector::GetTypeId () { static TypeId tid = TypeId ("ns3::WifiInformationElementVector") - .SetParent
(); + .SetParent
() + .AddConstructor (); return tid; } TypeId From c7418563b6a49c0cbde09fa923fc8cabfe6f5fd8 Mon Sep 17 00:00:00 2001 From: Andrey Mazo Date: Wed, 11 Nov 2009 00:27:47 +0300 Subject: [PATCH 32/64] Mesh: make GetFields () const --- src/devices/mesh/dot11s/peer-link-frame.cc | 2 +- src/devices/mesh/dot11s/peer-link-frame.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/devices/mesh/dot11s/peer-link-frame.cc b/src/devices/mesh/dot11s/peer-link-frame.cc index b07fd54db..607557966 100644 --- a/src/devices/mesh/dot11s/peer-link-frame.cc +++ b/src/devices/mesh/dot11s/peer-link-frame.cc @@ -69,7 +69,7 @@ PeerLinkFrameStart::SetPlinkFrameStart (PeerLinkFrameStart::PlinkFrameStartField } } PeerLinkFrameStart::PlinkFrameStartFields -PeerLinkFrameStart::GetFields () +PeerLinkFrameStart::GetFields () const { PlinkFrameStartFields retval; //TODO: protocol version: diff --git a/src/devices/mesh/dot11s/peer-link-frame.h b/src/devices/mesh/dot11s/peer-link-frame.h index 20a24c93b..f94c32769 100644 --- a/src/devices/mesh/dot11s/peer-link-frame.h +++ b/src/devices/mesh/dot11s/peer-link-frame.h @@ -62,7 +62,7 @@ public: //action header knows about subtype void SetPlinkFrameSubtype (uint8_t subtype); void SetPlinkFrameStart (PlinkFrameStartFields); - PlinkFrameStartFields GetFields (); + PlinkFrameStartFields GetFields () const; /** \name Inherited from header: * \{ */ From 6a54bf77c47e6d2d716b69273e27edc57f348805 Mon Sep 17 00:00:00 2001 From: Phillip Sitbon Date: Wed, 11 Nov 2009 11:57:14 +0100 Subject: [PATCH 33/64] Variables time and position in waypoint are public as in the original code --- src/mobility/waypoint-mobility-model.cc | 44 ++++++++++++------------- src/mobility/waypoint.cc | 34 ++++--------------- src/mobility/waypoint.h | 9 ++--- 3 files changed, 29 insertions(+), 58 deletions(-) diff --git a/src/mobility/waypoint-mobility-model.cc b/src/mobility/waypoint-mobility-model.cc index 06a9d7326..6566fd279 100644 --- a/src/mobility/waypoint-mobility-model.cc +++ b/src/mobility/waypoint-mobility-model.cc @@ -75,7 +75,7 @@ WaypointMobilityModel::AddWaypoint (const Waypoint &waypoint) } else { - NS_ABORT_MSG_IF ( !m_waypoints.empty () && (m_waypoints.back ().GetTime () >= waypoint.GetTime ()), + NS_ABORT_MSG_IF ( !m_waypoints.empty () && (m_waypoints.back ().time >= waypoint.time), "Waypoints must be added in ascending time order"); m_waypoints.push_back (waypoint); } @@ -98,25 +98,25 @@ WaypointMobilityModel::Update (void) const const Time now = Simulator::Now (); bool newWaypoint = false; - if ( now <= m_current.GetTime () ) + if ( now <= m_current.time ) { return; } - while ( now >= m_next.GetTime () ) + while ( now >= m_next.time ) { if ( m_waypoints.empty () ) { - if ( m_current.GetTime () <= m_next.GetTime () ) + if ( m_current.time <= m_next.time ) { - m_current.SetPosition(m_next.GetPosition ()); - m_current.SetTime (now); + m_current.position = m_next.position; + m_current.time = now; m_velocity = Vector (0,0,0); NotifyCourseChange (); } else { - m_current.SetTime (now); + m_current.time = now; } return; @@ -127,21 +127,19 @@ WaypointMobilityModel::Update (void) const m_waypoints.pop_front (); newWaypoint = true; - const double t_span = (m_next.GetTime () - m_current.GetTime ()).GetSeconds (); + const double t_span = (m_next.time - m_current.time).GetSeconds (); NS_ASSERT (t_span > 0); - m_velocity.x = (m_next.GetPosition ().x - m_current.GetPosition ().x) / t_span; - m_velocity.y = (m_next.GetPosition ().y - m_current.GetPosition ().y) / t_span; - m_velocity.z = (m_next.GetPosition ().z - m_current.GetPosition ().z) / t_span; + m_velocity.x = (m_next.position.x - m_current.position.x) / t_span; + m_velocity.y = (m_next.position.y - m_current.position.y) / t_span; + m_velocity.z = (m_next.position.z - m_current.position.z) / t_span; } - const double t_diff = (now - m_current.GetTime ()).GetSeconds(); - Vector pos; - pos.x = m_current.GetPosition ().x + m_velocity.x * t_diff; - pos.y = m_current.GetPosition ().y + m_velocity.y * t_diff; - pos.z = m_current.GetPosition ().z + m_velocity.z * t_diff; - m_current.SetPosition (pos); - m_current.SetTime (now); + const double t_diff = (now - m_current.time).GetSeconds(); + m_current.position.x += m_velocity.x * t_diff; + m_current.position.y += m_velocity.y * t_diff; + m_current.position.z += m_velocity.z * t_diff; + m_current.time = now; if ( newWaypoint ) { @@ -152,15 +150,15 @@ Vector WaypointMobilityModel::DoGetPosition (void) const { Update (); - return m_current.GetPosition (); + return m_current.position; } void WaypointMobilityModel::DoSetPosition (const Vector &position) { const Time now = Simulator::Now (); Update (); - m_current.SetTime (std::max (now, m_next.GetTime ())); - m_current.SetPosition (position); + m_current.time = std::max (now, m_next.time); + m_current.position = position; m_velocity = Vector (0,0,0); NotifyCourseChange (); } @@ -168,8 +166,8 @@ void WaypointMobilityModel::EndMobility (void) { m_waypoints.clear (); - m_current.SetTime (Seconds (std::numeric_limits::infinity ())); - m_next.SetTime (m_current.GetTime ()); + m_current.time = Seconds (std::numeric_limits::infinity ()); + m_next.time = m_current.time; m_first = true; } Vector diff --git a/src/mobility/waypoint.cc b/src/mobility/waypoint.cc index 28efd05fe..ee891c627 100644 --- a/src/mobility/waypoint.cc +++ b/src/mobility/waypoint.cc @@ -24,45 +24,23 @@ namespace ns3 { ATTRIBUTE_HELPER_CPP (Waypoint); Waypoint::Waypoint (const Time &waypointTime, const Vector &waypointPosition) - : m_time (waypointTime), - m_position (waypointPosition) + : time (waypointTime), + position (waypointPosition) {} Waypoint::Waypoint () - : m_time (0.0), - m_position (0,0,0) + : time (0.0), + position (0,0,0) {} -Time Waypoint::GetTime () const -{ - return m_time; -} - -void Waypoint::SetTime (Time time) -{ - m_time = time; -} - -Vector Waypoint::GetPosition () const -{ - return m_position; -} - -void Waypoint::SetPosition (Vector pos) -{ - m_position = pos; -} - std::ostream &operator << (std::ostream &os, const Waypoint &waypoint) { - os << waypoint.GetTime ().GetSeconds () << "$" << waypoint.GetPosition (); + os << waypoint.time.GetSeconds () << "$" << waypoint.position; return os; } std::istream &operator >> (std::istream &is, Waypoint &waypoint) { char separator; - Time time = waypoint.GetTime (); - Vector pos = waypoint.GetPosition (); - is >> time >> separator >> pos; + is >> waypoint.time >> separator >> waypoint.position; if (separator != '$') { is.setstate (std::ios_base::failbit); diff --git a/src/mobility/waypoint.h b/src/mobility/waypoint.h index af3e9ab43..51d768377 100644 --- a/src/mobility/waypoint.h +++ b/src/mobility/waypoint.h @@ -46,15 +46,10 @@ public: * Create a waypoint at time 0 and position (0,0,0). */ Waypoint (); - Time GetTime () const; - void SetTime (Time time); - Vector GetPosition () const; - void SetPosition (Vector vec); -private: /* The waypoint time */ - Time m_time; + Time time; /* The position of the waypoint */ - Vector m_position; + Vector position; }; /** From 49d1be220fe4c6d46f12155d4a0396cc70d538bf Mon Sep 17 00:00:00 2001 From: Andras Varga Date: Wed, 11 Nov 2009 12:44:09 +0100 Subject: [PATCH 34/64] Bug #645: fixes for opening stats file with OMNeT++ --- examples/stats/README | 20 ++++ examples/stats/wifi-example-sim.cc | 6 ++ src/contrib/stats/basic-data-calculators.h | 26 ++--- src/contrib/stats/data-calculator.cc | 16 +++ src/contrib/stats/data-calculator.h | 51 ++++++++++ src/contrib/stats/data-output-interface.h | 5 + src/contrib/stats/omnet-data-output.cc | 112 +++++++++++++++++---- src/contrib/stats/omnet-data-output.h | 24 +++-- src/contrib/stats/sqlite-data-output.cc | 19 ++++ src/contrib/stats/sqlite-data-output.h | 4 + src/contrib/stats/time-data-calculators.cc | 10 +- 11 files changed, 244 insertions(+), 49 deletions(-) diff --git a/examples/stats/README b/examples/stats/README index e4a98209c..2918f0e24 100644 --- a/examples/stats/README +++ b/examples/stats/README @@ -14,3 +14,23 @@ More information on the statistics package and this example is available online on the ns-3 wiki at: http://www.nsnam.org/wiki/index.php/Statistical_Framework_for_Network_Simulation + +*** Using ns-3 with the OMNeT++ analysis tool *** + +The stat framework can write out the result in a format that is compatible with the +output format of OMNeT++ 4 Discrete Event Simulator Framework. +Use the wifi-example-omnet.sh script to generate the results in OMNeT++ format. + +If you want to analyse the results with OMNeT++'s result analyser tool: +a) Download OMNeT++ 4 and install it. Start the IDE. (www.omnetpp.org) +b) If you do not want to install the whole simulator framework, there is a seperate + package which contains only the analysis tool from the OMNeT++ package. + You can download it from http://omnetpp.org/download/release/omnetpp-scave.tgz + +Once you are running the OMNeT++ IDE or the separate analysis tool (SCAVE) +- Choose File|Import...|Existing Projects into Workspace, then click [Next] +- Select root directory. (choose the examples/stats directory) and click [Finish] + +Double click the wifi-example-omnet.anf in the opened project and select +the Chart page to see the created chart. Experiment with the analysis tool and read its +documentation: http://omnetpp.org/doc/omnetpp40/userguide/ch09.html diff --git a/examples/stats/wifi-example-sim.cc b/examples/stats/wifi-example-sim.cc index 601f66492..17c504ab9 100644 --- a/examples/stats/wifi-example-sim.cc +++ b/examples/stats/wifi-example-sim.cc @@ -200,6 +200,7 @@ int main(int argc, char *argv[]) { Ptr > totalTx = CreateObject >(); totalTx->SetKey("wifi-tx-frames"); + totalTx->SetContext("node[0]"); Config::Connect("/NodeList/0/DeviceList/*/$ns3::WifiNetDevice/Mac/MacTx", MakeBoundCallback(&TxCallback, totalTx)); data.AddDataCalculator(totalTx); @@ -211,6 +212,7 @@ int main(int argc, char *argv[]) { Ptr totalRx = CreateObject(); totalRx->SetKey("wifi-rx-frames"); + totalRx->SetContext("node[1]"); Config::Connect("/NodeList/1/DeviceList/*/$ns3::WifiNetDevice/Mac/MacRx", MakeCallback(&PacketCounterCalculator::PacketUpdate, totalRx)); @@ -225,6 +227,7 @@ int main(int argc, char *argv[]) { Ptr appTx = CreateObject(); appTx->SetKey("sender-tx-packets"); + appTx->SetContext("node[0]"); Config::Connect("/NodeList/0/ApplicationList/*/$Sender/Tx", MakeCallback(&PacketCounterCalculator::PacketUpdate, appTx)); @@ -237,6 +240,7 @@ int main(int argc, char *argv[]) { Ptr > appRx = CreateObject >(); appRx->SetKey("receiver-rx-packets"); + appRx->SetContext("node[1]"); receiver->SetCounter(appRx); data.AddDataCalculator(appRx); @@ -263,6 +267,7 @@ int main(int argc, char *argv[]) { Ptr appTxPkts = CreateObject(); appTxPkts->SetKey("tx-pkt-size"); + appTxPkts->SetContext("node[0]"); Config::Connect("/NodeList/0/ApplicationList/*/$Sender/Tx", MakeCallback (&PacketSizeMinMaxAvgTotalCalculator::PacketUpdate, @@ -277,6 +282,7 @@ int main(int argc, char *argv[]) { Ptr delayStat = CreateObject(); delayStat->SetKey("delay"); + delayStat->SetContext("."); receiver->SetDelayTracker(delayStat); data.AddDataCalculator(delayStat); diff --git a/src/contrib/stats/basic-data-calculators.h b/src/contrib/stats/basic-data-calculators.h index 8968047ee..6063f4381 100644 --- a/src/contrib/stats/basic-data-calculators.h +++ b/src/contrib/stats/basic-data-calculators.h @@ -29,7 +29,8 @@ namespace ns3 { //------------------------------------------------------------ //-------------------------------------------- template - class MinMaxAvgTotalCalculator : public DataCalculator { + class MinMaxAvgTotalCalculator : public DataCalculator, + public StatisticalSummary { public: MinMaxAvgTotalCalculator(); virtual ~MinMaxAvgTotalCalculator(); @@ -38,6 +39,15 @@ namespace ns3 { virtual void Output(DataOutputCallback &callback) const; + long getCount() const { return m_count; } + double getSum() const { return m_total; } + double getMin() const { return m_min; } + double getMax() const { return m_max; } + double getMean() const { return m_total / (double)m_count; } + double getStddev() const { return NaN; } // unsupported + double getVariance() const { return NaN; } // unsupported + double getSqrSum() const { return NaN; } // unsupported + protected: virtual void DoDispose(void); @@ -86,23 +96,15 @@ namespace ns3 { } // end MinMaxAvgTotalCalculator::Update } + template void MinMaxAvgTotalCalculator::Output(DataOutputCallback &callback) const { - callback.OutputSingleton(m_key, "count", m_count); - if (m_count > 0) { - callback.OutputSingleton(m_key, "total", m_total); - callback.OutputSingleton(m_key, "average", m_total/m_count); - callback.OutputSingleton(m_key, "max", m_max); - callback.OutputSingleton(m_key, "min", m_min); - } - // end MinMaxAvgTotalCalculator::Output + callback.OutputStatistic(m_context, m_key, this); } - - //------------------------------------------------------------ //-------------------------------------------- template @@ -178,7 +180,7 @@ namespace ns3 { void CounterCalculator::Output(DataOutputCallback &callback) const { - callback.OutputSingleton(m_key, "count", m_count); + callback.OutputSingleton(m_context, m_key, m_count); // end CounterCalculator::Output } diff --git a/src/contrib/stats/data-calculator.cc b/src/contrib/stats/data-calculator.cc index e96c6d591..d473f92b9 100644 --- a/src/contrib/stats/data-calculator.cc +++ b/src/contrib/stats/data-calculator.cc @@ -27,6 +27,8 @@ using namespace ns3; NS_LOG_COMPONENT_DEFINE("DataCalculator"); +static double zero = 0; +const double ns3::NaN = zero / zero; //-------------------------------------------------------------- //---------------------------------------------- @@ -68,6 +70,20 @@ DataCalculator::GetKey() const // end DataCalculator::GetKey } +//---------------------------------------------- +void +DataCalculator::SetContext(const std::string context) +{ + m_context = context; + // end DataCalculator::SetContext +} + +std::string +DataCalculator::GetContext() const +{ + return m_context; + // end DataCalculator::GetContext +} //---------------------------------------------- void DataCalculator::Enable() diff --git a/src/contrib/stats/data-calculator.h b/src/contrib/stats/data-calculator.h index 70ed3bb72..4f95b5da3 100644 --- a/src/contrib/stats/data-calculator.h +++ b/src/contrib/stats/data-calculator.h @@ -26,9 +26,56 @@ #include "ns3/simulator.h" namespace ns3 { + extern const double NaN; + inline bool isNaN(double x) { return x != x; } class DataOutputCallback; + class StatisticalSummary { + public: + /** + * Returns the number of the observations. + */ + virtual long getCount() const = 0; + + /** + * Returns the sum of the values. + * @see getWeightedSum() + */ + virtual double getSum() const = 0; + + /** + * Returns the sum of the squared values. + * @see getWeightedSqrSum() + */ + virtual double getSqrSum() const = 0; + + /** + * Returns the minimum of the values. + */ + virtual double getMin() const = 0; + + /** + * Returns the maximum of the values. + */ + virtual double getMax() const = 0; + + /** + * Returns the mean of the (weighted) observations. + */ + virtual double getMean() const = 0; + + /** + * Returns the standard deviation of the (weighted) observations. + */ + virtual double getStddev() const = 0; + + /** + * Returns the variance of the (weighted) observations. + */ + virtual double getVariance() const = 0; + }; + //------------------------------------------------------------ //-------------------------------------------- class DataCalculator : public Object { @@ -43,6 +90,9 @@ namespace ns3 { void SetKey(const std::string key); std::string GetKey() const; + void SetContext(const std::string context); + std::string GetContext() const; + virtual void Start(const Time& startTime); virtual void Stop(const Time& stopTime); @@ -52,6 +102,7 @@ namespace ns3 { bool m_enabled; // Descendant classes *must* check & respect m_enabled! std::string m_key; + std::string m_context; virtual void DoDispose(void); diff --git a/src/contrib/stats/data-output-interface.h b/src/contrib/stats/data-output-interface.h index 20c7744e4..105c9f4db 100644 --- a/src/contrib/stats/data-output-interface.h +++ b/src/contrib/stats/data-output-interface.h @@ -23,6 +23,7 @@ #include "ns3/object.h" #include "ns3/nstime.h" +#include "ns3/data-calculator.h" namespace ns3 { @@ -52,6 +53,10 @@ namespace ns3 { public: virtual ~DataOutputCallback() {} + virtual void OutputStatistic(std::string key, + std::string variable, + const StatisticalSummary *statSum) = 0; + virtual void OutputSingleton(std::string key, std::string variable, int val) = 0; diff --git a/src/contrib/stats/omnet-data-output.cc b/src/contrib/stats/omnet-data-output.cc index d67742190..9903c9ec8 100644 --- a/src/contrib/stats/omnet-data-output.cc +++ b/src/contrib/stats/omnet-data-output.cc @@ -19,6 +19,7 @@ */ #include +#include #include "ns3/log.h" #include "ns3/nstime.h" @@ -54,26 +55,31 @@ OmnetDataOutput::DoDispose() } //---------------------------------------------- + +inline bool isNumeric(const std::string& s) { + char *endp; + strtod(s.c_str(), &endp); + return endp == s.c_str() + s.size(); +} + void OmnetDataOutput::Output(DataCollector &dc) { std::ofstream scalarFile; - std::string fn = m_filePrefix + ".sca"; - scalarFile.open(fn.c_str(), std::ios_base::app); + std::string fn = m_filePrefix +"-"+dc.GetRunLabel()+ ".sca"; + scalarFile.open(fn.c_str(), std::ios_base::out); - scalarFile << std::endl; + // TODO add timestamp to the runlevel scalarFile << "run " << dc.GetRunLabel() << std::endl; - scalarFile << std::endl; scalarFile << "attr experiment \"" << dc.GetExperimentLabel() << "\"" << std::endl; scalarFile << "attr strategy \"" << dc.GetStrategyLabel() << "\"" << std::endl; - scalarFile << "attr input \"" << dc.GetInputLabel() + scalarFile << "attr measurement \"" << dc.GetInputLabel() << "\"" << std::endl; scalarFile << "attr description \"" << dc.GetDescription() << "\"" << std::endl; - scalarFile << std::endl; for (MetadataList::iterator i = dc.MetadataBegin(); i != dc.MetadataEnd(); i++) { @@ -83,7 +89,18 @@ OmnetDataOutput::Output(DataCollector &dc) } scalarFile << std::endl; - + if (isNumeric(dc.GetInputLabel())) { + scalarFile << "scalar . measurement \"" << dc.GetInputLabel() + << "\"" << std::endl; + } + for (MetadataList::iterator i = dc.MetadataBegin(); + i != dc.MetadataEnd(); i++) { + std::pair blob = (*i); + if (isNumeric(blob.second)) { + scalarFile << "scalar . \"" << blob.first << "\" \"" << blob.second << "\"" + << std::endl; + } + } OmnetOutputCallback callback(&scalarFile); for (DataCalculatorList::iterator i = dc.DataCalculatorBegin(); @@ -97,6 +114,7 @@ OmnetDataOutput::Output(DataCollector &dc) // end OmnetDataOutput::Output } + OmnetDataOutput::OmnetOutputCallback::OmnetOutputCallback (std::ostream *scalar) : m_scalar(scalar) @@ -104,42 +122,92 @@ OmnetDataOutput::OmnetOutputCallback::OmnetOutputCallback } void -OmnetDataOutput::OmnetOutputCallback::OutputSingleton(std::string key, - std::string variable, +OmnetDataOutput::OmnetOutputCallback::OutputStatistic(std::string context, + std::string name, + const StatisticalSummary *statSum) +{ + if (context == "") + context = "."; + if (name == "") + name = "\"\""; + (*m_scalar) << "statistic " << context << " " << name << std::endl; + if (!isNaN(statSum->getCount())) + (*m_scalar) << "field count " << statSum->getCount() << std::endl; + if (!isNaN(statSum->getSum())) + (*m_scalar) << "field sum " << statSum->getSum() << std::endl; + if (!isNaN(statSum->getMean())) + (*m_scalar) << "field mean " << statSum->getMean() << std::endl; + if (!isNaN(statSum->getMin())) + (*m_scalar) << "field min " << statSum->getMin() << std::endl; + if (!isNaN(statSum->getMax())) + (*m_scalar) << "field max " << statSum->getMax() << std::endl; + if (!isNaN(statSum->getSqrSum())) + (*m_scalar) << "field sqrsum " << statSum->getSqrSum() << std::endl; + if (!isNaN(statSum->getStddev())) + (*m_scalar) << "field stddev " << statSum->getStddev() << std::endl; +} + +void +OmnetDataOutput::OmnetOutputCallback::OutputSingleton(std::string context, + std::string name, int val) { - (*m_scalar) << "scalar " << key << " " << variable << " " << val << std::endl; + if (context == "") + context = "."; + if (name == "") + name = "\"\""; + (*m_scalar) << "scalar " << context << " " << name << " " << val << std::endl; // end OmnetDataOutput::OmnetOutputCallback::OutputSingleton } + void -OmnetDataOutput::OmnetOutputCallback::OutputSingleton(std::string key, - std::string variable, +OmnetDataOutput::OmnetOutputCallback::OutputSingleton(std::string context, + std::string name, uint32_t val) { - (*m_scalar) << "scalar " << key << " " << variable << " " << val << std::endl; + if (context == "") + context = "."; + if (name == "") + name = "\"\""; + (*m_scalar) << "scalar " << context << " " << name << " " << val << std::endl; // end OmnetDataOutput::OmnetOutputCallback::OutputSingleton } + void -OmnetDataOutput::OmnetOutputCallback::OutputSingleton(std::string key, - std::string variable, +OmnetDataOutput::OmnetOutputCallback::OutputSingleton(std::string context, + std::string name, double val) { - (*m_scalar) << "scalar " << key << " " << variable << " " << val << std::endl; + if (context == "") + context = "."; + if (name == "") + name = "\"\""; + (*m_scalar) << "scalar " << context << " " << name << " " << val << std::endl; // end OmnetDataOutput::OmnetOutputCallback::OutputSingleton } + void -OmnetDataOutput::OmnetOutputCallback::OutputSingleton(std::string key, - std::string variable, +OmnetDataOutput::OmnetOutputCallback::OutputSingleton(std::string context, + std::string name, std::string val) { - (*m_scalar) << "scalar " << key << " " << variable << " " << val << std::endl; + if (context == "") + context = "."; + if (name == "") + name = "\"\""; + (*m_scalar) << "scalar " << context << " " << name << " " << val << std::endl; // end OmnetDataOutput::OmnetOutputCallback::OutputSingleton } + void -OmnetDataOutput::OmnetOutputCallback::OutputSingleton(std::string key, - std::string variable, +OmnetDataOutput::OmnetOutputCallback::OutputSingleton(std::string context, + std::string name, Time val) { - (*m_scalar) << "scalar " << key << " " << variable << " " << val << std::endl; + if (context == "") + context = "."; + if (name == "") + name = "\"\""; + (*m_scalar) << "scalar " << context << " " << name << " " << val.GetTimeStep() << std::endl; // end OmnetDataOutput::OmnetOutputCallback::OutputSingleton } diff --git a/src/contrib/stats/omnet-data-output.h b/src/contrib/stats/omnet-data-output.h index a3e1bb3f3..2fadf52e9 100644 --- a/src/contrib/stats/omnet-data-output.h +++ b/src/contrib/stats/omnet-data-output.h @@ -45,24 +45,28 @@ namespace ns3 { public: OmnetOutputCallback(std::ostream *scalar); - void OutputSingleton(std::string key, - std::string variable, + void OutputStatistic(std::string context, + std::string name, + const StatisticalSummary *statSum); + + void OutputSingleton(std::string context, + std::string name, int val); - void OutputSingleton(std::string key, - std::string variable, + void OutputSingleton(std::string context, + std::string name, uint32_t val); - void OutputSingleton(std::string key, - std::string variable, + void OutputSingleton(std::string context, + std::string name, double val); - void OutputSingleton(std::string key, - std::string variable, + void OutputSingleton(std::string context, + std::string name, std::string val); - void OutputSingleton(std::string key, - std::string variable, + void OutputSingleton(std::string context, + std::string name, Time val); private: diff --git a/src/contrib/stats/sqlite-data-output.cc b/src/contrib/stats/sqlite-data-output.cc index 5e59d0f41..f04a0e342 100644 --- a/src/contrib/stats/sqlite-data-output.cc +++ b/src/contrib/stats/sqlite-data-output.cc @@ -153,6 +153,25 @@ SqliteDataOutput::SqliteOutputCallback::SqliteOutputCallback // end SqliteDataOutput::SqliteOutputCallback::SqliteOutputCallback } +void +SqliteDataOutput::SqliteOutputCallback::OutputStatistic(std::string key, + std::string variable, + const StatisticalSummary *statSum) +{ + OutputSingleton(key,variable+"-count", (double)statSum->getCount()); + if (!isNaN(statSum->getSum())) + OutputSingleton(key,variable+"-total", statSum->getSum()); + if (!isNaN(statSum->getMax())) + OutputSingleton(key,variable+"-max", statSum->getMax()); + if (!isNaN(statSum->getMin())) + OutputSingleton(key,variable+"-min", statSum->getMin()); + if (!isNaN(statSum->getSqrSum())) + OutputSingleton(key,variable+"-sqrsum", statSum->getSqrSum()); + if (!isNaN(statSum->getStddev())) + OutputSingleton(key,variable+"-stddev", statSum->getStddev()); +} + + void SqliteDataOutput::SqliteOutputCallback::OutputSingleton(std::string key, std::string variable, diff --git a/src/contrib/stats/sqlite-data-output.h b/src/contrib/stats/sqlite-data-output.h index e14dbf995..4f6660eb2 100644 --- a/src/contrib/stats/sqlite-data-output.h +++ b/src/contrib/stats/sqlite-data-output.h @@ -48,6 +48,10 @@ namespace ns3 { public: SqliteOutputCallback(Ptr owner, std::string run); + void OutputStatistic(std::string key, + std::string variable, + const StatisticalSummary *statSum); + void OutputSingleton(std::string key, std::string variable, int val); diff --git a/src/contrib/stats/time-data-calculators.cc b/src/contrib/stats/time-data-calculators.cc index 768180862..81596af8f 100644 --- a/src/contrib/stats/time-data-calculators.cc +++ b/src/contrib/stats/time-data-calculators.cc @@ -70,12 +70,12 @@ TimeMinMaxAvgTotalCalculator::Update(const Time i) void TimeMinMaxAvgTotalCalculator::Output(DataOutputCallback &callback) const { - callback.OutputSingleton(m_key, "count", m_count); + callback.OutputSingleton(m_context, m_key + "-count", m_count); if (m_count > 0) { - callback.OutputSingleton(m_key, "total", m_total); - callback.OutputSingleton(m_key, "average", m_total/Scalar(m_count)); - callback.OutputSingleton(m_key, "max", m_max); - callback.OutputSingleton(m_key, "min", m_min); + callback.OutputSingleton(m_context, m_key + "-total", m_total); + callback.OutputSingleton(m_context, m_key + "-average", m_total/Scalar(m_count)); + callback.OutputSingleton(m_context, m_key + "-max", m_max); + callback.OutputSingleton(m_context, m_key + "-min", m_min); } // end TimeMinMaxAvgTotalCalculator::Output } From 42369e043eaff26becf2e82467059d321d9b3836 Mon Sep 17 00:00:00 2001 From: Sebastien Vincent Date: Wed, 11 Nov 2009 16:21:18 +0100 Subject: [PATCH 35/64] Bug #729 IPv6 over PPP. --- .../point-to-point-net-device.cc | 28 ++++++++++++- .../point-to-point-net-device.h | 14 +++++++ src/devices/point-to-point/ppp-header.cc | 22 ++++++++--- src/devices/point-to-point/ppp-header.h | 39 +++++++++++++++---- 4 files changed, 89 insertions(+), 14 deletions(-) diff --git a/src/devices/point-to-point/point-to-point-net-device.cc b/src/devices/point-to-point/point-to-point-net-device.cc index ff6ec3693..2271cdba1 100644 --- a/src/devices/point-to-point/point-to-point-net-device.cc +++ b/src/devices/point-to-point/point-to-point-net-device.cc @@ -173,8 +173,8 @@ PointToPointNetDevice::~PointToPointNetDevice () PointToPointNetDevice::AddHeader(Ptr p, uint16_t protocolNumber) { NS_LOG_FUNCTION_NOARGS (); - NS_ASSERT_MSG (protocolNumber == 0x800, "PointToPointNetDevice::AddHeader(): protocolNumber must be 0x800"); PppHeader ppp; + ppp.SetProtocol(EtherToPpp(protocolNumber)); p->AddHeader (ppp); } @@ -184,7 +184,7 @@ PointToPointNetDevice::ProcessHeader(Ptr p, uint16_t& param) NS_LOG_FUNCTION_NOARGS (); PppHeader ppp; p->RemoveHeader (ppp); - param = 0x800; + param = PppToEther(ppp.GetProtocol()); return true; } @@ -655,5 +655,29 @@ PointToPointNetDevice::GetMtu (void) const return m_mtu; } + uint16_t +PointToPointNetDevice::PppToEther(uint16_t proto) +{ + switch(proto) + { + case 0x0021: return 0x0800; //IPv4 + case 0x0057: return 0x86DD; //IPv6 + default: NS_ASSERT_MSG(false, "PPP Protocol number not defined!"); + } + return 0; +} + + uint16_t +PointToPointNetDevice::EtherToPpp(uint16_t proto) +{ + switch(proto) + { + case 0x0800: return 0x0021; //IPv4 + case 0x86DD: return 0x0057; //IPv6 + default: NS_ASSERT_MSG(false, "PPP Protocol number not defined!"); + } + return 0; +} + } // namespace ns3 diff --git a/src/devices/point-to-point/point-to-point-net-device.h b/src/devices/point-to-point/point-to-point-net-device.h index cb2784085..9e3eab3cd 100644 --- a/src/devices/point-to-point/point-to-point-net-device.h +++ b/src/devices/point-to-point/point-to-point-net-device.h @@ -548,6 +548,20 @@ private: uint32_t m_mtu; Ptr m_currentPkt; + + /** + * \brief PPP to Ethernet protocol number mapping + * \param protocol A PPP protocol number + * \return The corresponding Ethernet protocol number + */ + static uint16_t PppToEther(uint16_t protocol); + + /** + * \brief Ethernet to PPP protocol number mapping + * \param protocol An Ethernet protocol number + * \return The corresponding PPP protocol number + */ + static uint16_t EtherToPpp(uint16_t protocol); }; } // namespace ns3 diff --git a/src/devices/point-to-point/ppp-header.cc b/src/devices/point-to-point/ppp-header.cc index 83914daac..04fa8bc5e 100644 --- a/src/devices/point-to-point/ppp-header.cc +++ b/src/devices/point-to-point/ppp-header.cc @@ -56,7 +56,7 @@ PppHeader::GetInstanceTypeId (void) const void PppHeader::Print (std::ostream &os) const { - os << "Point-to-Point Protocol: IP (0x0021)"; + os << "Point-to-Point Protocol: " << m_protocol; } uint32_t @@ -68,15 +68,27 @@ PppHeader::GetSerializedSize (void) const void PppHeader::Serialize (Buffer::Iterator start) const { - start.WriteHtonU16 (0x0021); + start.WriteHtonU16 (m_protocol); } uint32_t PppHeader::Deserialize (Buffer::Iterator start) { - uint16_t data = start.ReadNtohU16 (); - NS_ABORT_MSG_UNLESS (data == 0x0021, "MyHeader::Deserialize(): expected protocol 0x0021"); - return 2; + m_protocol = start.ReadNtohU16 (); + return GetSerializedSize(); } + void +PppHeader::SetProtocol (uint16_t protocol) +{ + m_protocol=protocol; +} + + uint16_t +PppHeader::GetProtocol (void) +{ + return m_protocol; +} + + } // namespace ns3 diff --git a/src/devices/point-to-point/ppp-header.h b/src/devices/point-to-point/ppp-header.h index 74502e04e..1224b0fca 100644 --- a/src/devices/point-to-point/ppp-header.h +++ b/src/devices/point-to-point/ppp-header.h @@ -28,9 +28,9 @@ namespace ns3 { * * This class can be used to add a header to PPP packet. Currently we do not * implement any of the state machine in RFC 1661, we just encapsulate the - * inbound packet as an IP version 4 type and send it on. The goal here is - * not really to implement the point-to-point protocol, but to encapsulate our - * packets in a known protocol so packet sniffers can parse them. + * inbound packet send it on. The goal here is not really to implement the + * point-to-point protocol, but to encapsulate our packets in a known protocol + * so packet sniffers can parse them. * * if PPP is transmitted over a serial link, it will typically be framed in * some way derivative of IBM SDLC (HDLC) with all that that entails. @@ -41,20 +41,20 @@ namespace ns3 { * teach the PcapWriter about the appropriate data link type (DLT_PPP = 9), * and we need to add a PPP header to each packet. Since we are not using * framed PPP, this just means prepending the sixteen bit PPP protocol number - * (0x0021) to the packet. The ns-3 way to do this is via a class that - * inherits from class Header. + * to the packet. The ns-3 way to do this is via a class that inherits from + * class Header. */ class PppHeader : public Header { public: /** - * \brief Construct an IP version 4 PPP header. + * \brief Construct a PPP header. */ PppHeader (); /** - * \brief Destroy an IP version 4 PPP header. + * \brief Destroy a PPP header. */ virtual ~PppHeader (); @@ -64,6 +64,31 @@ public: virtual void Serialize (Buffer::Iterator start) const; virtual uint32_t Deserialize (Buffer::Iterator start); virtual uint32_t GetSerializedSize (void) const; + + /** + * \brief Set the protocol type carried by this PPP packet + * + * The type numbers to be used are defined in RFC3818 + * + * \param protocol the protocol type being carried + */ + void SetProtocol(uint16_t protocol); + + /** + * \brief Get the protocol type carried by this PPP packet + * + * The type numbers to be used are defined in RFC3818 + * + * \return the protocol type being carried + */ + uint16_t GetProtocol(void); + +private: + + /** + * \brief The PPP protocol type of the payload packet + */ + uint16_t m_protocol; }; }; // namespace ns3 From d2d081606fdbc0619b4cbddce7e41a89c8340402 Mon Sep 17 00:00:00 2001 From: Faker Moatamri Date: Thu, 12 Nov 2009 10:20:26 +0100 Subject: [PATCH 36/64] 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 37/64] 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 38/64] 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 39/64] 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 40/64] [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 41/64] 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 42/64] 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 43/64] 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 44/64] 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 45/64] 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 46/64] 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 47/64] 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 48/64] 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 49/64] 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 50/64] 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 51/64] 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 52/64] 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 53/64] 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 54/64] 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 55/64] 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 56/64] 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 57/64] 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 58/64] 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 59/64] 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 60/64] 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 61/64] 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 62/64] 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 63/64] 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 64/64] 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