29 #include "ns3/core-module.h"
30 #include "ns3/network-module.h"
31 #include "ns3/internet-module.h"
32 #include "ns3/point-to-point-module.h"
33 #include "ns3/applications-module.h"
34 #include "ns3/nix-vector-helper.h"
36 #include "ns3/topology-read-module.h"
80 std::cout <<
"TTL: " << (unsigned)ipv4.
GetTtl () << std::endl;
87 int main (
int argc,
char *argv[])
90 std::string format (
"Inet");
91 std::string input (
"src/topology-read/examples/Inet_small_toposample.txt");
95 cmd.AddValue (
"format",
"Format to use for data input [Orbis|Inet|Rocketfuel].",
97 cmd.AddValue (
"input",
"Name of the input file.",
99 cmd.Parse (argc, argv);
116 nodes = inFile->Read ();
119 if (inFile->LinksSize () == 0)
121 NS_LOG_ERROR (
"Problems reading the topology file. Failing.");
133 stack.SetRoutingHelper (nixRouting);
138 address.SetBase (
"10.0.0.0",
"255.255.255.252");
140 int totlinks = inFile->LinksSize ();
146 for ( iter = inFile->LinksBegin (); iter != inFile->LinksEnd (); iter++, i++ )
148 nc[i] =
NodeContainer (iter->GetFromNode (), iter->GetToNode ());
154 for (
int i = 0; i < totlinks; i++)
165 for (
int i = 0; i < totlinks; i++)
167 ipic[i] =
address.Assign (ndc[i]);
172 uint32_t totalNodes =
nodes.GetN ();
177 unsigned int randomServerNumber = unifRandom->
GetInteger (0, totalNodes - 1);
182 Ipv4Address ipv4AddrServer = iaddrServer.GetLocal ();
195 for (
unsigned int i = 0; i <
nodes.GetN (); i++ )
197 if (i != randomServerNumber )
200 clientNodes.
Add (clientNode);
209 apps =
sink.Install (randomServerNode);
a polymophic address class
holds a vector of ns3::Application pointers.
void Start(Time start)
Arrange for all of the Applications in this container to Start() at the Time given as a parameter.
void Stop(Time stop)
Arrange for all of the Applications in this container to Stop() at the Time given as a parameter.
Parse command-line arguments.
Class for representing data rates.
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.
void Add(NodeContainer other)
Append the contents of another NodeContainer to the end of this container.
void SetAttribute(std::string name, const AttributeValue &value)
Set a single attribute, raising fatal errors if unsuccessful.
Ptr< T > GetObject(void) 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.
void SetConstantRate(DataRate dataRate, uint32_t packetSize=512)
Helper function to set a constant rate source.
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.
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.
void SetDeviceAttribute(std::string name, const AttributeValue &value)
Set an attribute value to be propagated to each NetDevice created by the helper.
void SetChannelAttribute(std::string name, const AttributeValue &value)
Set an attribute value to be propagated to each Channel created by the helper.
NetDeviceContainer Install(NodeContainer c)
static void Destroy(void)
Execute the events scheduled with ScheduleDestroy().
static void Run(void)
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.
Time Seconds(double value)
Construct a Time in the indicated unit.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Callback< R, Ts... > MakeCallback(R(T::*memPtr)(Ts...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
static void SinkRx(Ptr< const Packet > p, const Address &ad)
Print the TTL of received packet.