17#include "ns3/applications-module.h" 
   18#include "ns3/core-module.h" 
   19#include "ns3/csma-module.h" 
   20#include "ns3/csma-star-helper.h" 
   21#include "ns3/internet-module.h" 
   22#include "ns3/ipv6-address-generator.h" 
   23#include "ns3/network-module.h" 
   48main(
int argc, 
char* argv[])
 
   67    cmd.AddValue(
"nSpokes", 
"Number of spoke nodes to place in the star", nSpokes);
 
   68    cmd.AddValue(
"useIpv6", 
"Use Ipv6", useIpv6);
 
   69    cmd.Parse(argc, argv);
 
   87    for (
uint32_t i = 0; i < star.GetSpokeDevices().GetN(); ++i)
 
   93        fillNodes.
Add(newNodes);
 
   94        fillDevices.
Add(
csma.Install(newNodes, csmaChannel));
 
   97    NS_LOG_INFO(
"Install internet stack on all nodes.");
 
   99    star.InstallStack(internet);
 
  109        star.AssignIpv6Addresses(ipv6AddressBase, ipv6AddressPrefix);
 
  124    for (
uint32_t i = 0; i < star.SpokeCount(); ++i)
 
  128            std::ostringstream subnet;
 
  129            subnet << 
"10.1." << i << 
".0";
 
  130            NS_LOG_INFO(
"Assign IP Addresses for CSMA subnet " << subnet.str());
 
  131            address.SetBase(subnet.str().c_str(), 
"255.255.255.0", 
"0.0.0.3");
 
  133            for (
uint32_t j = 0; j < nFill; ++j)
 
  135                address.Assign(fillDevices.
Get(i * nFill + j));
 
  140            Ipv6AddressGenerator::Init(ipv6AddressBase, ipv6AddressPrefix);
 
  141            Ipv6Address v6network = Ipv6AddressGenerator::GetNetwork(ipv6AddressPrefix);
 
  142            address6.
SetBase(v6network, ipv6AddressPrefix);
 
  144            for (
uint32_t j = 0; j < nFill; ++j)
 
  146                address6.
Assign(fillDevices.
Get(i * nFill + j));
 
  155    uint16_t 
port = 50000;
 
  160        PacketSinkHelper packetSinkHelper(
"ns3::TcpSocketFactory", hubLocalAddress);
 
  168        PacketSinkHelper packetSinkHelper6(
"ns3::TcpSocketFactory", hubLocalAddress6);
 
  178    onOffHelper.SetAttribute(
"OnTime", 
StringValue(
"ns3::ConstantRandomVariable[Constant=1]"));
 
  179    onOffHelper.SetAttribute(
"OffTime", 
StringValue(
"ns3::ConstantRandomVariable[Constant=0]"));
 
  183    for (
uint32_t i = 0; i < star.SpokeCount(); ++i)
 
  188            onOffHelper.SetAttribute(
"Remote", remoteAddress);
 
  193            onOffHelper.SetAttribute(
"Remote", remoteAddress);
 
  195        spokeApps.
Add(onOffHelper.Install(star.GetSpokeNode(i)));
 
  224        onOffHelper.SetAttribute(
"Remote", remoteAddress);
 
  225        fillApps.
Add(onOffHelper.Install(fillNodes.
Get(i)));
 
  237        Ipv4GlobalRoutingHelper::PopulateRoutingTables();
 
  244    csma.EnablePcapAll(
"csma-star", 
false);
 
  248    Simulator::Destroy();
 
a polymophic address class
 
AttributeValue implementation for Address.
 
holds a vector of ns3::Application pointers.
 
void Start(Time start) const
Start all of the Applications in this container at the start time given as a parameter.
 
void Stop(Time stop) const
Arrange for all of the Applications in this container to Stop() at the Time given as a parameter.
 
void Add(ApplicationContainer other)
Append the contents of another ApplicationContainer to the end of this container.
 
Parse command-line arguments.
 
build a set of CsmaNetDevice objects
 
A helper to make it easier to create a star topology with Csma links.
 
aggregate IP/TCP/UDP functionality to existing Nodes.
 
void Install(std::string nodeName) const
Aggregate implementations of the ns3::Ipv4, ns3::Ipv6, ns3::Udp, and ns3::Tcp classes onto the provid...
 
A helper class to make life easier while doing simple IPv4 address assignment in scripts.
 
Helper class to auto-assign global IPv6 unicast addresses.
 
void SetBase(Ipv6Address network, Ipv6Prefix prefix, Ipv6Address base=Ipv6Address("::1"))
Set the base network number, network prefix, and base interface ID.
 
Ipv6InterfaceContainer Assign(const NetDeviceContainer &c)
Allocate an Ipv6InterfaceContainer with auto-assigned addresses.
 
Describes an IPv6 address.
 
Describes an IPv6 prefix.
 
holds a vector of ns3::NetDevice pointers
 
void Add(NetDeviceContainer other)
Append the contents of another NetDeviceContainer to the end of this container.
 
Ptr< NetDevice > Get(uint32_t i) const
Get the Ptr<NetDevice> stored in this container at a given index.
 
keep track of a set of node pointers.
 
uint32_t GetN() const
Get the number of Ptr<Node> stored in this container.
 
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
 
void Add(const NodeContainer &nc)
Append the contents of another NodeContainer to the end of this container.
 
Ptr< Node > Get(uint32_t i) const
Get the Ptr<Node> stored in this container at a given index.
 
A helper to make it easier to instantiate an ns3::OnOffApplication on a set of nodes.
 
A helper to make it easier to instantiate an ns3::PacketSinkApplication on a set of nodes.
 
Hold variables of type string.
 
Hold an unsigned integer type.
 
void SetDefault(std::string name, const AttributeValue &value)
 
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
 
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
 
Time Seconds(double value)
Construct a Time in the indicated unit.
 
Every class exported by the ns3 library is enclosed in the ns3 namespace.