diff --git a/src/helper/csma-helper.cc b/src/helper/csma-helper.cc index d5d2b379b..78a1645fc 100644 --- a/src/helper/csma-helper.cc +++ b/src/helper/csma-helper.cc @@ -39,10 +39,10 @@ CsmaHelper::CsmaHelper () void CsmaHelper::SetQueue (std::string type, - std::string n1, const AttributeValue &v1, - std::string n2, const AttributeValue &v2, - std::string n3, const AttributeValue &v3, - std::string n4, const AttributeValue &v4) + std::string n1, const AttributeValue &v1, + std::string n2, const AttributeValue &v2, + std::string n3, const AttributeValue &v3, + std::string n4, const AttributeValue &v4) { m_queueFactory.SetTypeId (type); m_queueFactory.Set (n1, v1); @@ -106,9 +106,9 @@ CsmaHelper::EnablePcap (std::string filename, NodeContainer n) { Ptr node = *i; for (uint32_t j = 0; j < node->GetNDevices (); ++j) - { - devs.Add (node->GetDevice (j)); - } + { + devs.Add (node->GetDevice (j)); + } } EnablePcap (filename, devs); } @@ -153,9 +153,9 @@ CsmaHelper::EnableAscii (std::ostream &os, NodeContainer n) { Ptr node = *i; for (uint32_t j = 0; j < node->GetNDevices (); ++j) - { - devs.Add (node->GetDevice (j)); - } + { + devs.Add (node->GetDevice (j)); + } } EnableAscii (os, devs); } diff --git a/src/helper/csma-helper.h b/src/helper/csma-helper.h index 89cb7f138..9733e8236 100644 --- a/src/helper/csma-helper.h +++ b/src/helper/csma-helper.h @@ -57,10 +57,10 @@ public: * CsmaNetDevice created through CsmaHelper::Install. */ void SetQueue (std::string type, - std::string n1 = "", const AttributeValue &v1 = EmptyAttributeValue (), - std::string n2 = "", const AttributeValue &v2 = EmptyAttributeValue (), - std::string n3 = "", const AttributeValue &v3 = EmptyAttributeValue (), - std::string n4 = "", const AttributeValue &v4 = EmptyAttributeValue ()); + std::string n1 = "", const AttributeValue &v1 = EmptyAttributeValue (), + std::string n2 = "", const AttributeValue &v2 = EmptyAttributeValue (), + std::string n3 = "", const AttributeValue &v3 = EmptyAttributeValue (), + std::string n4 = "", const AttributeValue &v4 = EmptyAttributeValue ()); /** * \param n1 the name of the attribute to set diff --git a/src/helper/mobility-helper.cc b/src/helper/mobility-helper.cc index 9c0bb22fa..ad595f4d2 100644 --- a/src/helper/mobility-helper.cc +++ b/src/helper/mobility-helper.cc @@ -47,15 +47,15 @@ MobilityHelper::SetPositionAllocator (Ptr allocator) } void MobilityHelper::SetPositionAllocator (std::string type, - std::string n1, const AttributeValue &v1, - std::string n2, const AttributeValue &v2, - std::string n3, const AttributeValue &v3, - std::string n4, const AttributeValue &v4, - std::string n5, const AttributeValue &v5, - std::string n6, const AttributeValue &v6, - std::string n7, const AttributeValue &v7, - std::string n8, const AttributeValue &v8, - std::string n9, const AttributeValue &v9) + std::string n1, const AttributeValue &v1, + std::string n2, const AttributeValue &v2, + std::string n3, const AttributeValue &v3, + std::string n4, const AttributeValue &v4, + std::string n5, const AttributeValue &v5, + std::string n6, const AttributeValue &v6, + std::string n7, const AttributeValue &v7, + std::string n8, const AttributeValue &v8, + std::string n9, const AttributeValue &v9) { ObjectFactory pos; pos.SetTypeId (type); @@ -73,15 +73,15 @@ MobilityHelper::SetPositionAllocator (std::string type, void MobilityHelper::SetMobilityModel (std::string type, - std::string n1, const AttributeValue &v1, - std::string n2, const AttributeValue &v2, - std::string n3, const AttributeValue &v3, - std::string n4, const AttributeValue &v4, - std::string n5, const AttributeValue &v5, - std::string n6, const AttributeValue &v6, - std::string n7, const AttributeValue &v7, - std::string n8, const AttributeValue &v8, - std::string n9, const AttributeValue &v9) + std::string n1, const AttributeValue &v1, + std::string n2, const AttributeValue &v2, + std::string n3, const AttributeValue &v3, + std::string n4, const AttributeValue &v4, + std::string n5, const AttributeValue &v5, + std::string n6, const AttributeValue &v6, + std::string n7, const AttributeValue &v7, + std::string n8, const AttributeValue &v8, + std::string n9, const AttributeValue &v9) { m_mobility.SetTypeId (type); m_mobility.Set (n1, v1); @@ -122,29 +122,29 @@ MobilityHelper::Install (NodeContainer c) Ptr object = *i; Ptr model = object->GetObject (); if (model == 0) - { - model = m_mobility.Create ()->GetObject (); - if (model == 0) - { - NS_FATAL_ERROR ("The requested mobility model is not a mobility model: \""<< - m_mobility.GetTypeId ().GetName ()<<"\""); - } - if (m_mobilityStack.empty ()) - { - NS_LOG_DEBUG ("node="<AggregateObject (hierarchical); - NS_LOG_DEBUG ("node="<AggregateObject (hierarchical); + NS_LOG_DEBUG ("node="< model = GetMobilityModel (line.substr (startNodeId + 1, - endNodeId - startNodeId), - store); - if (model == 0) - { - continue; - } - if (startNodeId == 6) - { - double value = ReadDouble (line.substr (endNodeId + 9, std::string::npos)); - std::string coordinate = line.substr (endNodeId + 6, 1); + { + std::string line; + getline (file, line); + std::string::size_type startNodeId = line.find_first_of ("("); + std::string::size_type endNodeId = line.find_first_of (")"); + if (startNodeId == std::string::npos || + endNodeId == std::string::npos) + { + continue; + } + Ptr model = GetMobilityModel (line.substr (startNodeId + 1, + endNodeId - startNodeId), + store); + if (model == 0) + { + continue; + } + if (startNodeId == 6) + { + double value = ReadDouble (line.substr (endNodeId + 9, std::string::npos)); + std::string coordinate = line.substr (endNodeId + 6, 1); Vector position = model->GetPosition (); - if (coordinate == "X") - { + if (coordinate == "X") + { position.x = value; - NS_LOG_DEBUG ("X=" << value); - } - else if (coordinate == "Y") - { + NS_LOG_DEBUG ("X=" << value); + } + else if (coordinate == "Y") + { position.y = value; - NS_LOG_DEBUG ("Y=" << value); - } - else if (coordinate == "Z") - { + NS_LOG_DEBUG ("Y=" << value); + } + else if (coordinate == "Z") + { position.z = value; - NS_LOG_DEBUG ("Z=" << value); - } + NS_LOG_DEBUG ("Z=" << value); + } else { continue; } model->SetPosition (position); - } - else - { + } + else + { std::string::size_type atEnd = line.find_first_of (" ", 8); std::string atStr = line.substr (8, atEnd-8); NS_LOG_DEBUG (atStr); - double at = ReadDouble (atStr); - std::string::size_type xSpeedEnd = line.find_first_of (" ", endNodeId + 10); - std::string::size_type ySpeedEnd = line.find_first_of (" ", xSpeedEnd + 1); - double xSpeed = ReadDouble (line.substr (endNodeId + 10, xSpeedEnd - endNodeId - 10)); - double ySpeed = ReadDouble (line.substr (xSpeedEnd + 1, ySpeedEnd - xSpeedEnd - 1)); - double zSpeed = ReadDouble (line.substr (ySpeedEnd + 1, std::string::npos)); - NS_LOG_DEBUG ("at=" << at << "xSpeed=" << xSpeed << ", ySpeed=" << ySpeed << ", zSpeed=" << zSpeed); - Simulator::Schedule (Seconds (at), &StaticSpeedMobilityModel::SetVelocity, model, - Vector (xSpeed, ySpeed, zSpeed)); - } - } + double at = ReadDouble (atStr); + std::string::size_type xSpeedEnd = line.find_first_of (" ", endNodeId + 10); + std::string::size_type ySpeedEnd = line.find_first_of (" ", xSpeedEnd + 1); + double xSpeed = ReadDouble (line.substr (endNodeId + 10, xSpeedEnd - endNodeId - 10)); + double ySpeed = ReadDouble (line.substr (xSpeedEnd + 1, ySpeedEnd - xSpeedEnd - 1)); + double zSpeed = ReadDouble (line.substr (ySpeedEnd + 1, std::string::npos)); + NS_LOG_DEBUG ("at=" << at << "xSpeed=" << xSpeed << ", ySpeed=" << ySpeed << ", zSpeed=" << zSpeed); + Simulator::Schedule (Seconds (at), &StaticSpeedMobilityModel::SetVelocity, model, + Vector (xSpeed, ySpeed, zSpeed)); + } + } file.close(); } } diff --git a/src/helper/ns2-mobility-helper.h b/src/helper/ns2-mobility-helper.h index 809a51125..795f16392 100644 --- a/src/helper/ns2-mobility-helper.h +++ b/src/helper/ns2-mobility-helper.h @@ -90,14 +90,14 @@ Ns2MobilityHelper::Install (T begin, T end) const MyObjectStore (T begin, T end) : m_begin (begin), m_end (end) - {} + {} virtual Ptr Get (uint32_t i) const { T iterator = m_begin; iterator += i; if (iterator >= m_end) - { - return 0; - } + { + return 0; + } return *iterator; } private: diff --git a/src/helper/olsr-helper.cc b/src/helper/olsr-helper.cc index 656e276ca..86f85ffd3 100644 --- a/src/helper/olsr-helper.cc +++ b/src/helper/olsr-helper.cc @@ -30,14 +30,14 @@ OlsrHelper::OlsrHelper () void OlsrHelper::SetAgent (std::string tid, - std::string n0, const AttributeValue &v0, - std::string n1, const AttributeValue &v1, - std::string n2, const AttributeValue &v2, - std::string n3, const AttributeValue &v3, - std::string n4, const AttributeValue &v4, - std::string n5, const AttributeValue &v5, - std::string n6, const AttributeValue &v6, - std::string n7, const AttributeValue &v7) + std::string n0, const AttributeValue &v0, + std::string n1, const AttributeValue &v1, + std::string n2, const AttributeValue &v2, + std::string n3, const AttributeValue &v3, + std::string n4, const AttributeValue &v4, + std::string n5, const AttributeValue &v5, + std::string n6, const AttributeValue &v6, + std::string n7, const AttributeValue &v7) { m_agentFactory.SetTypeId (tid); m_agentFactory.Set (n0, v0); diff --git a/src/helper/olsr-helper.h b/src/helper/olsr-helper.h index d2eaea80d..3a37167e5 100644 --- a/src/helper/olsr-helper.h +++ b/src/helper/olsr-helper.h @@ -38,14 +38,14 @@ public: * \brief Set default OLSR routing agent attributes */ void SetAgent (std::string tid, - std::string n0 = "", const AttributeValue &v0 = EmptyAttributeValue (), - std::string n1 = "", const AttributeValue &v1 = EmptyAttributeValue (), - std::string n2 = "", const AttributeValue &v2 = EmptyAttributeValue (), - std::string n3 = "", const AttributeValue &v3 = EmptyAttributeValue (), - std::string n4 = "", const AttributeValue &v4 = EmptyAttributeValue (), - std::string n5 = "", const AttributeValue &v5 = EmptyAttributeValue (), - std::string n6 = "", const AttributeValue &v6 = EmptyAttributeValue (), - std::string n7 = "", const AttributeValue &v7 = EmptyAttributeValue ()); + std::string n0 = "", const AttributeValue &v0 = EmptyAttributeValue (), + std::string n1 = "", const AttributeValue &v1 = EmptyAttributeValue (), + std::string n2 = "", const AttributeValue &v2 = EmptyAttributeValue (), + std::string n3 = "", const AttributeValue &v3 = EmptyAttributeValue (), + std::string n4 = "", const AttributeValue &v4 = EmptyAttributeValue (), + std::string n5 = "", const AttributeValue &v5 = EmptyAttributeValue (), + std::string n6 = "", const AttributeValue &v6 = EmptyAttributeValue (), + std::string n7 = "", const AttributeValue &v7 = EmptyAttributeValue ()); /** * \brief Enable OLSR routing for a set of nodes diff --git a/src/helper/point-to-point-helper.cc b/src/helper/point-to-point-helper.cc index ed951b56e..ff99b6499 100644 --- a/src/helper/point-to-point-helper.cc +++ b/src/helper/point-to-point-helper.cc @@ -39,10 +39,10 @@ PointToPointHelper::PointToPointHelper () void PointToPointHelper::SetQueue (std::string type, - std::string n1, const AttributeValue &v1, - std::string n2, const AttributeValue &v2, - std::string n3, const AttributeValue &v3, - std::string n4, const AttributeValue &v4) + std::string n1, const AttributeValue &v1, + std::string n2, const AttributeValue &v2, + std::string n3, const AttributeValue &v3, + std::string n4, const AttributeValue &v4) { m_queueFactory.SetTypeId (type); m_queueFactory.Set (n1, v1); @@ -106,9 +106,9 @@ PointToPointHelper::EnablePcap (std::string filename, NodeContainer n) { Ptr node = *i; for (uint32_t j = 0; j < node->GetNDevices (); ++j) - { - devs.Add (node->GetDevice (j)); - } + { + devs.Add (node->GetDevice (j)); + } } EnablePcap (filename, devs); } @@ -153,9 +153,9 @@ PointToPointHelper::EnableAscii (std::ostream &os, NodeContainer n) { Ptr node = *i; for (uint32_t j = 0; j < node->GetNDevices (); ++j) - { - devs.Add (node->GetDevice (j)); - } + { + devs.Add (node->GetDevice (j)); + } } EnableAscii (os, devs); } diff --git a/src/helper/point-to-point-helper.h b/src/helper/point-to-point-helper.h index a86daf52a..a7fe785b7 100644 --- a/src/helper/point-to-point-helper.h +++ b/src/helper/point-to-point-helper.h @@ -57,10 +57,10 @@ public: * PointToPointNetDevice created through PointToPointHelper::Install. */ void SetQueue (std::string type, - std::string n1 = "", const AttributeValue &v1 = EmptyAttributeValue (), - std::string n2 = "", const AttributeValue &v2 = EmptyAttributeValue (), - std::string n3 = "", const AttributeValue &v3 = EmptyAttributeValue (), - std::string n4 = "", const AttributeValue &v4 = EmptyAttributeValue ()); + std::string n1 = "", const AttributeValue &v1 = EmptyAttributeValue (), + std::string n2 = "", const AttributeValue &v2 = EmptyAttributeValue (), + std::string n3 = "", const AttributeValue &v3 = EmptyAttributeValue (), + std::string n4 = "", const AttributeValue &v4 = EmptyAttributeValue ()); /** * \param name the name of the attribute to set diff --git a/src/helper/wifi-helper.cc b/src/helper/wifi-helper.cc index dd4a122c3..8e8e958ef 100644 --- a/src/helper/wifi-helper.cc +++ b/src/helper/wifi-helper.cc @@ -40,30 +40,30 @@ NS_LOG_COMPONENT_DEFINE ("WifiHelper"); namespace ns3 { static void PcapPhyTxEvent (Ptr writer, Ptr packet, - WifiMode mode, WifiPreamble preamble, - uint8_t txLevel) + WifiMode mode, WifiPreamble preamble, + uint8_t txLevel) { writer->WritePacket (packet); } static void PcapPhyRxEvent (Ptr writer, - Ptr packet, double snr, WifiMode mode, - enum WifiPreamble preamble) + Ptr packet, double snr, WifiMode mode, + enum WifiPreamble preamble) { writer->WritePacket (packet); } static void AsciiPhyTxEvent (std::ostream *os, std::string context, - Ptr packet, - WifiMode mode, WifiPreamble preamble, - uint8_t txLevel) + Ptr packet, + WifiMode mode, WifiPreamble preamble, + uint8_t txLevel) { *os << "+ " << Simulator::Now () << " " << context << " " << *packet << std::endl; } static void AsciiPhyRxOkEvent (std::ostream *os, std::string context, - Ptr packet, double snr, WifiMode mode, - enum WifiPreamble preamble) + Ptr packet, double snr, WifiMode mode, + enum WifiPreamble preamble) { *os << "r " << Simulator::Now () << " " << context << " " << *packet << std::endl; } @@ -78,14 +78,14 @@ WifiHelper::WifiHelper () void WifiHelper::SetRemoteStationManager (std::string type, - std::string n0, const AttributeValue &v0, - std::string n1, const AttributeValue &v1, - std::string n2, const AttributeValue &v2, - std::string n3, const AttributeValue &v3, - std::string n4, const AttributeValue &v4, - std::string n5, const AttributeValue &v5, - std::string n6, const AttributeValue &v6, - std::string n7, const AttributeValue &v7) + std::string n0, const AttributeValue &v0, + std::string n1, const AttributeValue &v1, + std::string n2, const AttributeValue &v2, + std::string n3, const AttributeValue &v3, + std::string n4, const AttributeValue &v4, + std::string n5, const AttributeValue &v5, + std::string n6, const AttributeValue &v6, + std::string n7, const AttributeValue &v7) { m_stationManager = ObjectFactory (); m_stationManager.SetTypeId (type); @@ -101,14 +101,14 @@ WifiHelper::SetRemoteStationManager (std::string type, void WifiHelper::SetMac (std::string type, - std::string n0, const AttributeValue &v0, - std::string n1, const AttributeValue &v1, - std::string n2, const AttributeValue &v2, - std::string n3, const AttributeValue &v3, - std::string n4, const AttributeValue &v4, - std::string n5, const AttributeValue &v5, - std::string n6, const AttributeValue &v6, - std::string n7, const AttributeValue &v7) + std::string n0, const AttributeValue &v0, + std::string n1, const AttributeValue &v1, + std::string n2, const AttributeValue &v2, + std::string n3, const AttributeValue &v3, + std::string n4, const AttributeValue &v4, + std::string n5, const AttributeValue &v5, + std::string n6, const AttributeValue &v6, + std::string n7, const AttributeValue &v7) { m_mac = ObjectFactory (); m_mac.SetTypeId (type); @@ -124,14 +124,14 @@ WifiHelper::SetMac (std::string type, void WifiHelper::SetPhy (std::string type, - std::string n0, const AttributeValue &v0, - std::string n1, const AttributeValue &v1, - std::string n2, const AttributeValue &v2, - std::string n3, const AttributeValue &v3, - std::string n4, const AttributeValue &v4, - std::string n5, const AttributeValue &v5, - std::string n6, const AttributeValue &v6, - std::string n7, const AttributeValue &v7) + std::string n0, const AttributeValue &v0, + std::string n1, const AttributeValue &v1, + std::string n2, const AttributeValue &v2, + std::string n3, const AttributeValue &v3, + std::string n4, const AttributeValue &v4, + std::string n5, const AttributeValue &v5, + std::string n6, const AttributeValue &v6, + std::string n7, const AttributeValue &v7) { m_phy = ObjectFactory (); m_phy.SetTypeId (type); @@ -177,9 +177,9 @@ WifiHelper::EnablePcap (std::string filename, NodeContainer n) { Ptr node = *i; for (uint32_t j = 0; j < node->GetNDevices (); ++j) - { - devs.Add (node->GetDevice (j)); - } + { + devs.Add (node->GetDevice (j)); + } } EnablePcap (filename, devs); } @@ -218,9 +218,9 @@ WifiHelper::EnableAscii (std::ostream &os, NodeContainer n) { Ptr node = *i; for (uint32_t j = 0; j < node->GetNDevices (); ++j) - { - devs.Add (node->GetDevice (j)); - } + { + devs.Add (node->GetDevice (j)); + } } EnableAscii (os, devs); } diff --git a/src/helper/wifi-helper.h b/src/helper/wifi-helper.h index 72cc4a198..271563462 100644 --- a/src/helper/wifi-helper.h +++ b/src/helper/wifi-helper.h @@ -65,14 +65,14 @@ public: * in the requested station manager. */ void SetRemoteStationManager (std::string type, - std::string n0 = "", const AttributeValue &v0 = EmptyAttributeValue (), - std::string n1 = "", const AttributeValue &v1 = EmptyAttributeValue (), - std::string n2 = "", const AttributeValue &v2 = EmptyAttributeValue (), - std::string n3 = "", const AttributeValue &v3 = EmptyAttributeValue (), - std::string n4 = "", const AttributeValue &v4 = EmptyAttributeValue (), - std::string n5 = "", const AttributeValue &v5 = EmptyAttributeValue (), - std::string n6 = "", const AttributeValue &v6 = EmptyAttributeValue (), - std::string n7 = "", const AttributeValue &v7 = EmptyAttributeValue ()); + std::string n0 = "", const AttributeValue &v0 = EmptyAttributeValue (), + std::string n1 = "", const AttributeValue &v1 = EmptyAttributeValue (), + std::string n2 = "", const AttributeValue &v2 = EmptyAttributeValue (), + std::string n3 = "", const AttributeValue &v3 = EmptyAttributeValue (), + std::string n4 = "", const AttributeValue &v4 = EmptyAttributeValue (), + std::string n5 = "", const AttributeValue &v5 = EmptyAttributeValue (), + std::string n6 = "", const AttributeValue &v6 = EmptyAttributeValue (), + std::string n7 = "", const AttributeValue &v7 = EmptyAttributeValue ()); /** * \param type the type of ns3::WifiMac to create. @@ -97,14 +97,14 @@ public: * in the requested mac. */ void SetMac (std::string type, - std::string n0 = "", const AttributeValue &v0 = EmptyAttributeValue (), - std::string n1 = "", const AttributeValue &v1 = EmptyAttributeValue (), - std::string n2 = "", const AttributeValue &v2 = EmptyAttributeValue (), - std::string n3 = "", const AttributeValue &v3 = EmptyAttributeValue (), - std::string n4 = "", const AttributeValue &v4 = EmptyAttributeValue (), - std::string n5 = "", const AttributeValue &v5 = EmptyAttributeValue (), - std::string n6 = "", const AttributeValue &v6 = EmptyAttributeValue (), - std::string n7 = "", const AttributeValue &v7 = EmptyAttributeValue ()); + std::string n0 = "", const AttributeValue &v0 = EmptyAttributeValue (), + std::string n1 = "", const AttributeValue &v1 = EmptyAttributeValue (), + std::string n2 = "", const AttributeValue &v2 = EmptyAttributeValue (), + std::string n3 = "", const AttributeValue &v3 = EmptyAttributeValue (), + std::string n4 = "", const AttributeValue &v4 = EmptyAttributeValue (), + std::string n5 = "", const AttributeValue &v5 = EmptyAttributeValue (), + std::string n6 = "", const AttributeValue &v6 = EmptyAttributeValue (), + std::string n7 = "", const AttributeValue &v7 = EmptyAttributeValue ()); /** * \param phyType the type of ns3::WifiPhy to create. @@ -129,14 +129,14 @@ public: * in the requested phy. */ void SetPhy (std::string phyType, - std::string n0 = "", const AttributeValue &v0 = EmptyAttributeValue (), - std::string n1 = "", const AttributeValue &v1 = EmptyAttributeValue (), - std::string n2 = "", const AttributeValue &v2 = EmptyAttributeValue (), - std::string n3 = "", const AttributeValue &v3 = EmptyAttributeValue (), - std::string n4 = "", const AttributeValue &v4 = EmptyAttributeValue (), - std::string n5 = "", const AttributeValue &v5 = EmptyAttributeValue (), - std::string n6 = "", const AttributeValue &v6 = EmptyAttributeValue (), - std::string n7 = "", const AttributeValue &v7 = EmptyAttributeValue ()); + std::string n0 = "", const AttributeValue &v0 = EmptyAttributeValue (), + std::string n1 = "", const AttributeValue &v1 = EmptyAttributeValue (), + std::string n2 = "", const AttributeValue &v2 = EmptyAttributeValue (), + std::string n3 = "", const AttributeValue &v3 = EmptyAttributeValue (), + std::string n4 = "", const AttributeValue &v4 = EmptyAttributeValue (), + std::string n5 = "", const AttributeValue &v5 = EmptyAttributeValue (), + std::string n6 = "", const AttributeValue &v6 = EmptyAttributeValue (), + std::string n7 = "", const AttributeValue &v7 = EmptyAttributeValue ());