18 #include "ns3/core-module.h"
19 #include "ns3/network-module.h"
20 #include "ns3/csma-module.h"
21 #include "ns3/csma-star-helper.h"
22 #include "ns3/applications-module.h"
23 #include "ns3/csma-module.h"
24 #include "ns3/internet-module.h"
25 #include "ns3/ipv6-address-generator.h"
50 main (
int argc,
char *argv[])
70 cmd.
AddValue (
"nSpokes",
"Number of spoke nodes to place in the star", nSpokes);
71 cmd.
AddValue (
"useIpv6",
"Use Ipv6", useIpv6);
72 cmd.
Parse (argc, argv);
96 fillNodes.
Add (newNodes);
97 fillDevices.
Add (csma.
Install (newNodes, csmaChannel));
100 NS_LOG_INFO (
"Install internet stack on all nodes.");
127 for(uint32_t i = 0; i < star.
SpokeCount (); ++i)
131 std::ostringstream subnet;
132 subnet <<
"10.1." << i <<
".0";
133 NS_LOG_INFO (
"Assign IP Addresses for CSMA subnet " << subnet.str ());
134 address.
SetBase (subnet.str ().c_str (),
"255.255.255.0",
"0.0.0.3");
136 for (uint32_t j = 0; j < nFill; ++j)
138 address.
Assign (fillDevices.
Get (i * nFill + j));
145 address6.
SetBase (v6network, ipv6AddressPrefix);
147 for (uint32_t j = 0; j < nFill; ++j)
149 address6.
Assign(fillDevices.
Get (i * nFill + j));
158 uint16_t
port = 50000;
163 PacketSinkHelper packetSinkHelper (
"ns3::TcpSocketFactory", hubLocalAddress);
165 hubApp.
Start (Seconds (1.0));
166 hubApp.
Stop (Seconds (10.0));
171 PacketSinkHelper packetSinkHelper6 (
"ns3::TcpSocketFactory", hubLocalAddress6);
173 hubApp6.
Start (Seconds (1.0));
174 hubApp6.
Stop (Seconds (10.0));
186 for (uint32_t i = 0; i < star.
SpokeCount (); ++i)
201 spokeApps.
Start (Seconds (1.0));
202 spokeApps.
Stop (Seconds (10.0));
214 for (uint32_t i = 0; i < fillNodes.
GetN (); ++i)
229 fillApps.
Start (Seconds (1.0));
230 fillApps.
Stop (Seconds (10.0));
void AssignIpv4Addresses(Ipv4AddressHelper address)
holds a vector of ns3::Application pointers.
void InstallStack(InternetStackHelper stack)
static Ipv4Address GetAny(void)
smart pointer class similar to boost::intrusive_ptr
void SetChannelAttribute(std::string n1, const AttributeValue &v1)
int main(int argc, char *argv[])
NS_LOG_COMPONENT_DEFINE("GrantedTimeWindowMpiInterface")
static void PopulateRoutingTables(void)
Build a routing database and initialize the routing tables of the nodes in the simulation.
hold variables of type string
Ptr< NetDevice > Get(uint32_t i) const
Get the Ptr stored in this container at a given index.
void Add(ApplicationContainer other)
Append the contents of another ApplicationContainer to the end of this container. ...
static void Run(void)
Run the simulation until one of:
static Ipv6Address GetAny()
Get the "any" (::) Ipv6Address.
Ipv4Address GetHubIpv4Address(uint32_t i) const
aggregate IP/TCP/UDP functionality to existing Nodes.
void SetBase(Ipv6Address network, Ipv6Prefix prefix, Ipv6Address base=Ipv6Address("::1"))
Set the base network number, network prefix, and base interface ID.
NetDeviceContainer Install(Ptr< Node > node) const
This method creates an ns3::CsmaChannel with the attributes configured by CsmaHelper::SetChannelAttri...
A helper to make it easier to instantiate an ns3::PacketSinkApplication on a set of nodes...
A helper to make it easier to instantiate an ns3::OnOffApplication on a set of nodes.
a polymophic address class
Ipv6Address GetHubIpv6Address(uint32_t i) const
Ipv6InterfaceContainer Assign(const NetDeviceContainer &c)
Allocate an Ipv6InterfaceContainer with auto-assigned addresses.
uint32_t GetN(void) const
Get the number of Ptr stored in this container.
NetDeviceContainer GetSpokeDevices() const
uint32_t GetN(void) const
Get the number of Ptr stored in this container.
void EnablePcapAll(std::string prefix, bool promiscuous=false)
Enable pcap output on each device (which is of the appropriate type) in the set of all nodes created ...
void Add(NetDeviceContainer other)
Append the contents of another NetDeviceContainer to the end of this container.
static void Init(const Ipv6Address net, const Ipv6Prefix prefix, const Ipv6Address interfaceId="::1")
Initialise the base network and interfaceId for the generator.
Hold an unsigned integer type.
holds a vector of ns3::NetDevice pointers
Ptr< Node > GetSpokeNode(uint32_t i) const
void Start(Time start)
Arrange for all of the Applications in this container to Start() at the Time given as a parameter...
Parse command-line arguments.
static void Destroy(void)
Every event scheduled by the Simulator::insertAtDestroy method is invoked.
void SetDefault(std::string name, const AttributeValue &value)
keep track of a set of node pointers.
void Install(std::string nodeName) const
Aggregate implementations of the ns3::Ipv4, ns3::Ipv6, ns3::Udp, and ns3::Tcp classes onto the provid...
void AssignIpv6Addresses(Ipv6Address network, Ipv6Prefix prefix)
build a set of CsmaNetDevice objects
Helper class to auto-assign global IPv6 unicast addresses.
Describes an IPv6 address.
hold objects of type ns3::Address
void Stop(Time stop)
Arrange for all of the Applications in this container to Stop() at the Time given as a parameter...
Ipv4InterfaceContainer Assign(const NetDeviceContainer &c)
Assign IP addresses to the net devices specified in the container based on the current network prefix...
void Add(NodeContainer other)
Append the contents of another NodeContainer to the end of this container.
uint32_t SpokeCount() const
void AddValue(const std::string &name, const std::string &help, T &value)
Add a program argument, assigning to POD.
Ptr< Node > Get(uint32_t i) const
Get the Ptr stored in this container at a given index.
Describes an IPv6 prefix.
ApplicationContainer Install(NodeContainer c) const
Install an ns3::PacketSinkApplication on each node of the input container configured with all the att...
void Parse(int argc, char *argv[])
Parse the program arguments.
A helper class to make life easier while doing simple IPv4 address assignment in scripts.
A helper to make it easier to create a star topology with Csma links.
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
Ptr< Node > GetHub() const
Ptr< T > GetObject(void) const
ApplicationContainer Install(NodeContainer c) const
Install an ns3::OnOffApplication on each node of the input container configured with all the attribut...
void SetAttribute(std::string name, const AttributeValue &value)
Helper function used to set the underlying application attributes.
void SetBase(Ipv4Address network, Ipv4Mask mask, Ipv4Address base="0.0.0.1")
Set the base network number, network mask and base address.
static Ipv6Address GetNetwork(const Ipv6Prefix prefix)
Get the current network of the given Ipv6Prefix.