24 #include "ns3/applications-module.h"
25 #include "ns3/core-module.h"
26 #include "ns3/internet-module.h"
27 #include "ns3/network-module.h"
28 #include "ns3/nix-vector-helper.h"
29 #include "ns3/point-to-point-module.h"
30 #include "ns3/topology-read-module.h"
64 std::cout <<
"TTL: " << (unsigned)
ipv4.GetTtl() << std::endl;
71 main(
int argc,
char* argv[])
73 std::string format(
"Inet");
74 std::string input(
"src/topology-read/examples/Inet_small_toposample.txt");
80 cmd.AddValue(
"format",
"Format to use for data input [Orbis|Inet|Rocketfuel].", format);
81 cmd.AddValue(
"input",
"Name of the input file.", input);
82 cmd.Parse(argc, argv);
98 nodes = inFile->Read();
101 if (inFile->LinksSize() == 0)
103 NS_LOG_ERROR(
"Problems reading the topology file. Failing.");
120 address.SetBase(
"10.0.0.0",
"255.255.255.252");
122 int totlinks = inFile->LinksSize();
128 for (iter = inFile->LinksBegin(); iter != inFile->LinksEnd(); iter++, i++)
130 nc[i] =
NodeContainer(iter->GetFromNode(), iter->GetToNode());
136 for (
int i = 0; i < totlinks; i++)
141 ndc[i] =
p2p.Install(nc[i]);
147 for (
int i = 0; i < totlinks; i++)
149 ipic[i] =
address.Assign(ndc[i]);
158 unsigned int randomServerNumber = unifRandom->
GetInteger(0, totalNodes - 1);
163 Ipv4Address ipv4AddrServer = iaddrServer.GetLocal();
176 for (
unsigned int i = 0; i <
nodes.
GetN(); i++)
178 if (i != randomServerNumber)
181 clientNodes.
Add(clientNode);
190 apps =
sink.Install(randomServerNode);
a polymophic address class
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.
Parse command-line arguments.
This class can be used to hold variables of floating point type such as 'double' or 'float'.
aggregate IP/TCP/UDP functionality to existing Nodes.
A helper class to make life easier while doing simple IPv4 address assignment in scripts.
Ipv4 addresses are stored in host order in this class.
Access to the IPv4 forwarding table, interfaces, and configuration.
a class to store IPv4 address information on an interface
holds a vector of std::pair of Ptr<Ipv4> and interface index.
holds a vector of ns3::NetDevice pointers
Helper class that adds Nix-vector routing to nodes.
keep track of a set of node pointers.
uint32_t GetN() const
Get the number of Ptr<Node> stored in this container.
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.
void SetAttribute(std::string name, const AttributeValue &value)
Set a single attribute, raising fatal errors if unsuccessful.
Ptr< T > GetObject() const
Get a pointer to the requested aggregated Object.
A helper to make it easier to instantiate an ns3::OnOffApplication on a set of nodes.
uint32_t PeekHeader(Header &header) const
Deserialize but does not remove the header from the internal buffer.
A helper to make it easier to instantiate an ns3::PacketSinkApplication on a set of nodes.
Build a set of PointToPointNetDevice objects.
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
static void Run()
Run the simulation.
Hold variables of type string.
Helper class which makes it easier to configure and use a generic TopologyReader.
void SetFileType(const std::string fileType)
Sets the input file type.
Ptr< TopologyReader > GetTopologyReader()
Gets a Ptr<TopologyReader> to the actual TopologyReader.
void SetFileName(const std::string fileName)
Sets the input file name.
std::list< Link >::const_iterator ConstLinksIterator
Constant iterator to the list of the links.
Hold an unsigned integer type.
void SetDefault(std::string name, const AttributeValue &value)
void ConnectWithoutContext(std::string path, const CallbackBase &cb)
#define NS_LOG_ERROR(msg)
Use NS_LOG to output a message of level LOG_ERROR.
#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.
void(* DataRate)(DataRate oldValue, DataRate newValue)
TracedValue callback signature for DataRate.
Time Seconds(double value)
Construct a Time in the indicated unit.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
void LogComponentEnable(const std::string &name, LogLevel level)
Enable the logging output associated with that log component.
Callback< R, Args... > MakeCallback(R(T::*memPtr)(Args...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
@ LOG_LEVEL_INFO
LOG_INFO and above.
static void SinkRx(Ptr< const Packet > p, const Address &ad)
Print the TTL of received packet.
Ptr< PacketSink > sink
Pointer to the packet sink application.