diff --git a/examples/leo-example.cc b/examples/leo-example.cc index da74093..5ae5719 100644 --- a/examples/leo-example.cc +++ b/examples/leo-example.cc @@ -1,12 +1,16 @@ /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ - #include "ns3/core-module.h" -#include "ns3/leo-helper.h" +#include "ns3/network-module.h" +#include "ns3/internet-module.h" +#include "ns3/applications-module.h" +#include "ns3/node-container.h" +#include "ns3/core-module.h" + +#include "../helper/leo-helper.h" using namespace ns3; - -int +int main (int argc, char *argv[]) { bool verbose = true; @@ -16,11 +20,60 @@ main (int argc, char *argv[]) cmd.Parse (argc,argv); - /* ... */ + Time::SetResolution (Time::NS); + LogComponentEnable ("UdpEchoClientApplication", LOG_LEVEL_INFO); + LogComponentEnable ("UdpEchoServerApplication", LOG_LEVEL_INFO); + LogComponentEnable ("UdpClient", LOG_LEVEL_INFO); + + NodeContainer satellites; + satellites.Create (100); + NodeContainer gateways; + gateways.Create (10); + NodeContainer terminals; + terminals.Create (2000); + + LeoHelper leo; + leo.SetDeviceAttribute ("DataRate", StringValue ("10Mbps")); + leo.SetChannelAttribute ("PropagationDelay", StringValue ("ns3::ConstantSpeedPropagationDelayModel")); + leo.SetChannelAttribute ("PropagationLoss", StringValue ("ns3::IslPropagationLossModel")); + leo.SetDeviceAttribute ("MobilityModel", StringValue ("ns3::LeoMobilityModel")); + + NetDeviceContainer devices; + devices = leo.Install (satellites, gateways, terminals); + + InternetStackHelper stack; + stack.Install (satellites); + stack.Install (gateways); + stack.Install (terminals); + + // make all devices addressable + Ipv6AddressHelper address; + Ipv6InterfaceContainer interfaces = address.Assign (devices); + + // we want to ping terminals + UdpEchoServerHelper echoServer (9); + ApplicationContainer serverApps = echoServer.Install (terminals); + + // install a client on each of the terminals + ApplicationContainer clientApps; + for (uint32_t i = 1; i < terminals.GetN (); i++) + { + UdpEchoClientHelper echoClient (terminals.Get (i)->GetDevice (0)->GetAddress (), 9); + echoClient.SetAttribute ("MaxPackets", UintegerValue (10)); + echoClient.SetAttribute ("Interval", TimeValue (Seconds (1.0))); + echoClient.SetAttribute ("PacketSize", UintegerValue (1024)); + + clientApps.Add (echoClient.Install (terminals.Get (i-1))); + } + + clientApps.Start (Seconds (2.0)); + clientApps.Stop (Seconds (10.0)); + + serverApps.Start (Seconds (1.0)); + serverApps.Stop (Seconds (10.0)); Simulator::Run (); Simulator::Destroy (); + return 0; } - - diff --git a/helper/isl-helper.h b/helper/isl-helper.h index a811058..79e10bb 100644 --- a/helper/isl-helper.h +++ b/helper/isl-helper.h @@ -128,7 +128,6 @@ public: */ NetDeviceContainer Install (std::vector &nodes); -private: /** * \brief Enable pcap output the indicated net device. * @@ -159,6 +158,8 @@ private: Ptr nd, bool explicitFilename); +private: + ObjectFactory m_queueFactory; //!< Queue Factory ObjectFactory m_channelFactory; //!< Channel Factory ObjectFactory m_deviceFactory; //!< Device Factory diff --git a/helper/leo-channel-helper.cc b/helper/leo-channel-helper.cc new file mode 100644 index 0000000..49f6cd4 --- /dev/null +++ b/helper/leo-channel-helper.cc @@ -0,0 +1,288 @@ +/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ + +#include "ns3/log.h" +#include "ns3/config.h" +#include "leo-channel-helper.h" +#include "ns3/enum.h" +#include "ns3/queue.h" +#include "ns3/names.h" + +#include "../model/leo-mock-channel.h" +#include "../model/leo-mock-net-device.h" + +namespace ns3 +{ + +NS_LOG_COMPONENT_DEFINE ("LeoChannelHelper"); + +LeoChannelHelper::LeoChannelHelper () +{ + m_gndQueueFactory.SetTypeId ("ns3::DropTailQueue"); + m_satQueueFactory.SetTypeId ("ns3::DropTailQueue"); + + m_gndDeviceFactory.SetTypeId ("ns3::LeoMockNetDevice"); + m_gndDeviceFactory.Set ("DeviceType", EnumValue (LeoMockNetDevice::GND)); + m_satDeviceFactory.SetTypeId ("ns3::LeoMockNetDevice"); + m_gndDeviceFactory.Set ("DeviceType", EnumValue (LeoMockNetDevice::SAT)); + + m_channelFactory.SetTypeId ("ns3::LeoMockChannel"); +} + +void +LeoChannelHelper::SetQueue(ObjectFactory &factory, + 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) +{ + QueueBase::AppendItemTypeIfNotPresent (type, "Packet"); + + factory.SetTypeId (type); + factory.Set (n1, v1); + factory.Set (n2, v2); + factory.Set (n3, v3); + factory.Set (n4, v4); +} + +void +LeoChannelHelper::SetGndQueue (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) +{ + SetQueue (m_gndQueueFactory, type, n1, v1, n2, v2, n3, v3, n4, v4); +} + +void +LeoChannelHelper::SetSatQueue (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) +{ + + SetQueue (m_satQueueFactory, type, n1, v1, n2, v2, n3, v3, n4, v4); +} + + +void +LeoChannelHelper::SetGndDeviceAttribute (std::string name, const AttributeValue &value) +{ + m_gndDeviceFactory.Set (name, value); +} + +void +LeoChannelHelper::SetSatDeviceAttribute (std::string name, const AttributeValue &value) +{ + m_satDeviceFactory.Set (name, value); +} + +void +LeoChannelHelper::SetChannelAttribute (std::string name, const AttributeValue &value) +{ + m_channelFactory.Set (name, value); +} + +void +LeoChannelHelper::EnablePcapInternal (std::string prefix, Ptr nd, bool promiscuous, bool explicitFilename) +{ + // + // All of the Pcap enable functions vector through here including the ones + // that are wandering through all of devices on perhaps all of the nodes in + // the system. We can only deal with devices of type LeoMockNetDevice. + // + Ptr device = nd->GetObject (); + if (device == 0) + { + NS_LOG_INFO ("LeoChannelHelper::EnablePcapInternal(): Device " << device << " not of type ns3::LeoMockNetDevice"); + return; + } + + PcapHelper pcapHelper; + + std::string filename; + if (explicitFilename) + { + filename = prefix; + } + else + { + filename = pcapHelper.GetFilenameFromDevice (prefix, device); + } + + Ptr file = pcapHelper.CreateFile (filename, std::ios::out, + PcapHelper::DLT_PPP); + pcapHelper.HookDefaultSink (device, "PromiscSniffer", file); +} + +void +LeoChannelHelper::EnableAsciiInternal ( + Ptr stream, + std::string prefix, + Ptr nd, + bool explicitFilename) +{ + // + // All of the ascii enable functions vector through here including the ones + // that are wandering through all of devices on perhaps all of the nodes in + // the system. We can only deal with devices of type LeoMockNetDevice. + // + Ptr device = nd->GetObject (); + if (device == 0) + { + NS_LOG_INFO ("LeoChannelHelper::EnableAsciiInternal(): Device " << device << + " not of type ns3::LeoMockNetDevice"); + return; + } + + // + // Our default trace sinks are going to use packet printing, so we have to + // make sure that is turned on. + // + Packet::EnablePrinting (); + + // + // If we are not provided an OutputStreamWrapper, we are expected to create + // one using the usual trace filename conventions and do a Hook*WithoutContext + // since there will be one file per context and therefore the context would + // be redundant. + // + if (stream == 0) + { + // + // Set up an output stream object to deal with private ofstream copy + // constructor and lifetime issues. Let the helper decide the actual + // name of the file given the prefix. + // + AsciiTraceHelper asciiTraceHelper; + + std::string filename; + if (explicitFilename) + { + filename = prefix; + } + else + { + filename = asciiTraceHelper.GetFilenameFromDevice (prefix, device); + } + + Ptr theStream = asciiTraceHelper.CreateFileStream (filename); + + // + // The MacRx trace source provides our "r" event. + // + asciiTraceHelper.HookDefaultReceiveSinkWithoutContext (device, "MacRx", theStream); + + // + // The "+", '-', and 'd' events are driven by trace sources actually in the + // transmit queue. + // + Ptr > queue = device->GetQueue (); + asciiTraceHelper.HookDefaultEnqueueSinkWithoutContext > (queue, "Enqueue", theStream); + asciiTraceHelper.HookDefaultDropSinkWithoutContext > (queue, "Drop", theStream); + asciiTraceHelper.HookDefaultDequeueSinkWithoutContext > (queue, "Dequeue", theStream); + + // PhyRxDrop trace source for "d" event + asciiTraceHelper.HookDefaultDropSinkWithoutContext (device, "PhyRxDrop", theStream); + + return; + } + + // + // If we are provided an OutputStreamWrapper, we are expected to use it, and + // to providd a context. We are free to come up with our own context if we + // want, and use the AsciiTraceHelper Hook*WithContext functions, but for + // compatibility and simplicity, we just use Config::Connect and let it deal + // with the context. + // + // Note that we are going to use the default trace sinks provided by the + // ascii trace helper. There is actually no AsciiTraceHelper in sight here, + // but the default trace sinks are actually publicly available static + // functions that are always there waiting for just such a case. + // + uint32_t nodeid = nd->GetNode ()->GetId (); + uint32_t deviceid = nd->GetIfIndex (); + std::ostringstream oss; + + oss << "/NodeList/" << nd->GetNode ()->GetId () << "/DeviceList/" << deviceid << "/$ns3::LeoMockNetDevice/MacRx"; + Config::Connect (oss.str (), MakeBoundCallback (&AsciiTraceHelper::DefaultReceiveSinkWithContext, stream)); + + oss.str (""); + oss << "/NodeList/" << nodeid << "/DeviceList/" << deviceid << "/$ns3::LeoMockNetDevice/TxQueue/Enqueue"; + Config::Connect (oss.str (), MakeBoundCallback (&AsciiTraceHelper::DefaultEnqueueSinkWithContext, stream)); + + oss.str (""); + oss << "/NodeList/" << nodeid << "/DeviceList/" << deviceid << "/$ns3::LeoMockNetDevice/TxQueue/Dequeue"; + Config::Connect (oss.str (), MakeBoundCallback (&AsciiTraceHelper::DefaultDequeueSinkWithContext, stream)); + + oss.str (""); + oss << "/NodeList/" << nodeid << "/DeviceList/" << deviceid << "/$ns3::LeoMockNetDevice/TxQueue/Drop"; + Config::Connect (oss.str (), MakeBoundCallback (&AsciiTraceHelper::DefaultDropSinkWithContext, stream)); + + oss.str (""); + oss << "/NodeList/" << nodeid << "/DeviceList/" << deviceid << "/$ns3::LeoMockNetDevice/PhyRxDrop"; + Config::Connect (oss.str (), MakeBoundCallback (&AsciiTraceHelper::DefaultDropSinkWithContext, stream)); +} + +NetDeviceContainer +LeoChannelHelper::Install (std::vector > &satellites, std::vector > &stations) +{ + Ptr channel = m_channelFactory.Create (); + + NetDeviceContainer container; + + for (Ptr node : satellites) + { + Ptr dev = m_satDeviceFactory.Create (); + dev->SetAddress (Mac48Address::Allocate ()); + node->AddDevice (dev); + Ptr > queue = m_satQueueFactory.Create > (); + dev->SetQueue (queue); + dev->Attach (channel); + container.Add (dev); + } + + for (Ptr node : stations) + { + Ptr dev = m_gndDeviceFactory.Create (); + dev->SetAddress (Mac48Address::Allocate ()); + node->AddDevice (dev); + Ptr > queue = m_gndQueueFactory.Create > (); + dev->SetQueue (queue); + dev->Attach (channel); + container.Add (dev); + } + + return container; +} + +NetDeviceContainer +LeoChannelHelper::Install (NodeContainer &satellites, NodeContainer &stations) +{ + std::vector > satelliteNodes = std::vector >(satellites.Begin(), satellites.End()); + std::vector > stationNodes = std::vector >(stations.Begin(), stations.End()); + return Install (satelliteNodes, stationNodes); +} + +NetDeviceContainer +LeoChannelHelper::Install (std::vector &satellites, std::vector &stations) +{ + std::vector > sats; + std::vector > stats; + for (std::string name : satellites) + { + Ptr node = Names::Find(name); + sats.push_back (node); + } + for (std::string name : stations) + { + Ptr node = Names::Find(name); + stats.push_back (node); + } + + return Install (sats, stats); +} + +}; /* namespace ns3 */ diff --git a/helper/leo-channel-helper.h b/helper/leo-channel-helper.h new file mode 100644 index 0000000..d304f5d --- /dev/null +++ b/helper/leo-channel-helper.h @@ -0,0 +1,72 @@ +/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ +#ifndef LEO_CANNEL_HELPER_H +#define LEO_CANNEL_HELPER_H + +#include + +#include +#include +#include + +#include + +namespace ns3 { + +/** + * \brief Build a channel for transmissions between ns3::LeoMockNetDevice s + */ +class LeoChannelHelper : public PcapHelperForDevice, + public AsciiTraceHelperForDevice +{ +public: + LeoChannelHelper (); + virtual ~LeoChannelHelper () + {}; + + NetDeviceContainer Install (NodeContainer &satellites, NodeContainer &stations); + NetDeviceContainer Install (std::vector > &satellites, std::vector > &stations); + NetDeviceContainer Install (std::vector &satellites, std::vector &stations); + + void SetGndQueue (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 ()); + + void SetSatQueue (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 ()); + + void SetGndDeviceAttribute (std::string name, const AttributeValue &value); + void SetSatDeviceAttribute (std::string name, const AttributeValue &value); + void SetChannelAttribute (std::string name, const AttributeValue &value); + + virtual void EnablePcapInternal (std::string prefix, Ptr nd, bool promiscuous, bool explicitFilename); + virtual void EnableAsciiInternal (Ptr stream, + std::string prefix, + Ptr nd, + bool explicitFilename); + +private: + ObjectFactory m_satQueueFactory; + ObjectFactory m_gndDeviceFactory; + + ObjectFactory m_satDeviceFactory; + ObjectFactory m_gndQueueFactory; + + ObjectFactory m_channelFactory; + + void SetQueue (ObjectFactory &factory, + 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); + +}; + +}; + +#endif /* LEO_CHANNEL_HELPER_H */ diff --git a/helper/leo-helper.cc b/helper/leo-helper.cc index 2a67f76..d1232b1 100644 --- a/helper/leo-helper.cc +++ b/helper/leo-helper.cc @@ -4,7 +4,183 @@ namespace ns3 { -/* ... */ - - +LeoHelper::LeoHelper() +{ } + +// TODO use template? +NetDeviceContainer +LeoHelper::Install (NodeContainer satellites, NodeContainer gateways, NodeContainer terminals) +{ + NetDeviceContainer container = m_islChannelHelper.Install (satellites); + container.Add (m_gwChannelHelper.Install (satellites, gateways)); + container.Add (m_utChannelHelper.Install (satellites, terminals)); + + return container; +} + +NetDeviceContainer +LeoHelper::Install (std::vector > &satellites, + std::vector > &gateways, + std::vector > &terminals) +{ + NetDeviceContainer container = m_islChannelHelper.Install (satellites); + container.Add (m_gwChannelHelper.Install (satellites, gateways)); + container.Add (m_utChannelHelper.Install (satellites, terminals)); + + return container; +} + +NetDeviceContainer +LeoHelper::Install (std::vector &satellites, + std::vector &gateways, + std::vector &terminals) +{ + NetDeviceContainer container = m_islChannelHelper.Install (satellites); + container.Add (m_gwChannelHelper.Install (satellites, gateways)); + container.Add (m_utChannelHelper.Install (satellites, terminals)); + + return container; +} + +void +LeoHelper::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) +{ + SetGndGwQueue (type, n1, v1, n2, v2, n3, v3, n4, v4); + SetGndUtQueue (type, n1, v1, n2, v2, n3, v3, n4, v4); + SetSatGwQueue (type, n1, v1, n2, v2, n3, v3, n4, v4); + SetSatUtQueue (type, n1, v1, n2, v2, n3, v3, n4, v4); +} + +void +LeoHelper::SetGndGwQueue (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) +{ + m_gwChannelHelper.SetGndQueue(type, n1, v1, n2, v2, n3, v3, n4, v4); +} + +void +LeoHelper::SetGndUtQueue (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) +{ + m_utChannelHelper.SetGndQueue(type, n1, v1, n2, v2, n3, v3, n4, v4); +} + +void +LeoHelper::SetSatGwQueue (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) +{ + m_gwChannelHelper.SetSatQueue(type, n1, v1, n2, v2, n3, v3, n4, v4); +} + +void +LeoHelper::SetSatUtQueue (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) +{ + m_utChannelHelper.SetSatQueue(type, n1, v1, n2, v2, n3, v3, n4, v4); +} + +void +LeoHelper::SetDeviceAttribute (std::string name, const AttributeValue &value) +{ + m_islChannelHelper.SetDeviceAttribute (name, value); + + m_gwChannelHelper.SetGndDeviceAttribute (name, value); + m_gwChannelHelper.SetSatDeviceAttribute (name, value); + + m_utChannelHelper.SetGndDeviceAttribute (name, value); + m_utChannelHelper.SetSatDeviceAttribute (name, value); +} + +void +LeoHelper::SetGndGwDeviceAttribute (std::string name, const AttributeValue &value) +{ + m_gwChannelHelper.SetGndDeviceAttribute (name, value); +} + +void +LeoHelper::SetGndUtDeviceAttribute (std::string name, const AttributeValue &value) +{ + m_utChannelHelper.SetGndDeviceAttribute(name, value); +} + +void +LeoHelper::SetSatUtDeviceAttribute (std::string name, const AttributeValue &value) +{ + m_utChannelHelper.SetSatDeviceAttribute(name, value); +} + +void +LeoHelper::SetSatGwDeviceAttribute (std::string name, const AttributeValue &value) +{ + m_gwChannelHelper.SetSatDeviceAttribute(name, value); +} + +void +LeoHelper::SetIslDeviceAttribute (std::string name, const AttributeValue &value) +{ + m_islChannelHelper.SetDeviceAttribute (name, value); +} + +void LeoHelper::SetChannelAttribute (std::string name, const AttributeValue &value) +{ + SetIslChannelAttribute (name, value); + SetUtChannelAttribute (name, value); + SetGwChannelAttribute (name, value); +} + +void +LeoHelper::SetIslChannelAttribute (std::string name, const AttributeValue &value) +{ + m_islChannelHelper.SetChannelAttribute (name, value); +} + +void +LeoHelper::SetUtChannelAttribute (std::string name, const AttributeValue &value) +{ + m_utChannelHelper.SetChannelAttribute (name, value); +} + +void +LeoHelper::SetGwChannelAttribute (std::string name, const AttributeValue &value) +{ + m_gwChannelHelper.SetChannelAttribute (name, value); +} + +void +LeoHelper::EnablePcapInternal (std::string prefix, Ptr nd, bool promiscuous, bool explicitFilename) +{ + m_islChannelHelper.EnablePcapInternal (prefix, nd, promiscuous, explicitFilename); + m_gwChannelHelper.EnablePcapInternal (prefix, nd, promiscuous, explicitFilename); + m_utChannelHelper.EnablePcapInternal (prefix, nd, promiscuous, explicitFilename); +} + +void +LeoHelper::EnableAsciiInternal ( + Ptr stream, + std::string prefix, + Ptr nd, + bool explicitFilename) +{ + m_islChannelHelper.EnableAsciiInternal (stream, prefix, nd, explicitFilename); + m_gwChannelHelper.EnableAsciiInternal (stream, prefix, nd, explicitFilename); + m_utChannelHelper.EnableAsciiInternal (stream, prefix, nd, explicitFilename); +} + +} /* namespace ns3 */ diff --git a/helper/leo-helper.h b/helper/leo-helper.h index f07787b..019222b 100644 --- a/helper/leo-helper.h +++ b/helper/leo-helper.h @@ -4,9 +4,196 @@ #include "ns3/leo.h" +#include + +#include +#include +#include +#include + +#include "leo-channel-helper.h" +#include "isl-helper.h" + namespace ns3 { -/* ... */ +/** + * \brief Builds a LEO network with user terminals, gateways and satellites. + */ +class LeoHelper +{ +public: + /** + * Creates a LeoHelper + */ + LeoHelper (); + virtual ~LeoHelper () {} + + /** + * \param satellites satellites + * \param gateways gateways + * \param terminals terminals + * \return a NetDeviceContainer for nodes + * + * This method creates + * - an ns3::IslChannel between the satellite nodes, + * - an ns3::MockLeoChannel between the satellite nodes and gateway nodes, + * - and an ns3::MockLeoChannel between the satellite nodes and terminal nodes + * with the attributes configured by LeoHelper::SetChannelAttribute, + * LeoHelper::SetIslChannelAttribute, LeoHelper::SetGatewayChannelAttribute, + * LeoHelper::SetTerminalChannelAttribute. + * + * Then, for each satellite node in the input containers, we create a + * ns3::IslNetDevice with the attributes requested, a queue for this + * ns3::NetDevice, and associate the resulting ns3::NetDevice with the + * ns3::Node and ns3::IslChannel. + * + * Then, for each satellite node and gateway node, we create a + * ns3::LeoMockNetDevice using the configured attributes and add them to a + * ns3::LeoMockChannel. + * + * Same is done with each satellite and terminal node. + */ + NetDeviceContainer Install (NodeContainer satellites, NodeContainer gateways, NodeContainer terminals); + + /** + * \param nodes Nodes + * \return a NetDeviceContainer for nodes + * + * Saves you from having to construct a temporary NodeContainer. + */ + NetDeviceContainer Install (std::vector > &satellites, + std::vector > &gateways, + std::vector > &terminals); + + /** + * \param nodes Names of the nodes + * \return a NetDeviceContainer for nodes + * + * Saves you from having to construct a temporary NodeContainer. + */ + NetDeviceContainer Install (std::vector &satellites, + std::vector &gateways, + std::vector &terminals); + /** + * Each point to point net device must have a queue to pass packets through. + * This method allows one to set the type of the queue that is automatically + * created when the device is created and attached to a node. + * + * \param type the type of queue + * \param n1 the name of the attribute to set on the queue + * \param v1 the value of the attribute to set on the queue + * \param n2 the name of the attribute to set on the queue + * \param v2 the value of the attribute to set on the queue + * \param n3 the name of the attribute to set on the queue + * \param v3 the value of the attribute to set on the queue + * \param n4 the name of the attribute to set on the queue + * \param v4 the value of the attribute to set on the queue + * + * Set the type of queue to create and associated to each + * IslNetDevice created through IslHelper::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 ()); + + void SetIslQueue (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 ()); + + void SetGndGwQueue (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 ()); + + void SetSatGwQueue (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 ()); + + void SetGndUtQueue (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 ()); + + void SetSatUtQueue (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 ()); + /** + * Set an attribute value to be propagated to each NetDevice created by the + * helper. + * + * \param name the name of the attribute to set + * \param value the value of the attribute to set + * + * Set these attributes on each ns3::IslNetDevice created + * by IslHelper::Install + */ + void SetDeviceAttribute (std::string name, const AttributeValue &value); + + void SetIslDeviceAttribute (std::string name, const AttributeValue &value); + void SetGndUtDeviceAttribute (std::string name, const AttributeValue &value); + void SetGndGwDeviceAttribute (std::string name, const AttributeValue &value); + void SetSatUtDeviceAttribute (std::string name, const AttributeValue &value); + void SetSatGwDeviceAttribute (std::string name, const AttributeValue &value); + + /** + * Set an attribute value to be propagated to each Channel created by the + * helper. + * + * \param name the name of the attribute to set + * \param value the value of the attribute to set + * + * Set these attribute on each ns3::IslChannel created + * by IslHelper::Install + */ + void SetChannelAttribute (std::string name, const AttributeValue &value); + void SetIslChannelAttribute (std::string name, const AttributeValue &value); + void SetUtChannelAttribute (std::string name, const AttributeValue &value); + void SetGwChannelAttribute (std::string name, const AttributeValue &value); +private: + /** + * \brief Enable pcap output the indicated net device. + * + * NetDevice-specific implementation mechanism for hooking the trace and + * writing to the trace file. + * + * \param prefix Filename prefix to use for pcap files. + * \param nd Net device for which you want to enable tracing. + * \param promiscuous If true capture all possible packets available at the device. + * \param explicitFilename Treat the prefix as an explicit filename if true + */ + virtual void EnablePcapInternal (std::string prefix, Ptr nd, bool promiscuous, bool explicitFilename); + + /** + * \brief Enable ascii trace output on the indicated net device. + * + * NetDevice-specific implementation mechanism for hooking the trace and + * writing to the trace file. + * + * \param stream The output stream object to use when logging ascii traces. + * \param prefix Filename prefix to use for ascii trace files. + * \param nd Net device for which you want to enable tracing. + * \param explicitFilename Treat the prefix as an explicit filename if true + */ + virtual void EnableAsciiInternal ( + Ptr stream, + std::string prefix, + Ptr nd, + bool explicitFilename); + + IslHelper m_islChannelHelper; + LeoChannelHelper m_utChannelHelper; + LeoChannelHelper m_gwChannelHelper; +}; } diff --git a/wscript b/wscript index 38227c8..3e8e7c0 100644 --- a/wscript +++ b/wscript @@ -13,6 +13,7 @@ def build(bld): 'model/isl-propagation-loss-model.cc', 'helper/isl-helper.cc', 'model/leo.cc', + 'helper/leo-channel-helper.cc', 'model/leo-mobility-model.cc', 'model/leo-mock-channel.cc', 'model/leo-mock-net-device.cc', @@ -33,6 +34,7 @@ def build(bld): 'model/isl-propagation-loss-model.h', 'helper/isl-helper.h', 'model/leo.h', + 'helper/leo-channel-helper.h', 'model/leo-mobility-model.h', 'model/leo-mock-channel.h', 'model/leo-mock-net-device.h',