26 #include "ns3/core-module.h" 27 #include "ns3/network-module.h" 28 #include "ns3/internet-apps-module.h" 29 #include "ns3/csma-module.h" 30 #include "ns3/internet-module.h" 31 #include "ns3/point-to-point-module.h" 32 #include "ns3/applications-module.h" 39 main (
int argc,
char *argv[])
45 cmd.AddValue (
"verbose",
"turn on the logs",
verbose);
46 cmd.AddValue (
"tracing",
"turn on the tracing", tracing);
48 cmd.Parse (argc, argv);
94 address.SetBase (
"172.30.1.0",
"255.255.255.0");
105 NS_LOG_INFO (
"Setup the IP addresses and create DHCP applications.");
111 fixedNodes.
Get (0).first->SetAttribute (
"IpForward",
BooleanValue (
true));
120 DynamicCast<DhcpServer> (dhcpServerApp.
Get (0))->AddStaticDhcpEntry (devNet.
Get (2)->GetAddress (),
Ipv4Address (
"172.30.0.14"));
127 dhcpClientNetDevs.
Add (devNet.
Get (0));
128 dhcpClientNetDevs.
Add (devNet.
Get (1));
129 dhcpClientNetDevs.
Add (devNet.
Get (2));
154 csma.EnablePcapAll (
"dhcp-csma");
holds a vector of ns3::Application pointers.
ApplicationContainer InstallDhcpServer(Ptr< NetDevice > netDevice, Ipv4Address serverAddr, Ipv4Address poolAddr, Ipv4Mask poolMask, Ipv4Address minAddr, Ipv4Address maxAddr, Ipv4Address gateway=Ipv4Address())
Install DHCP server of a node / NetDevice.
Ptr< NetDevice > Get(uint32_t i) const
Get the Ptr<NetDevice> stored in this container at a given index.
Simulation virtual time values and global simulation resolution.
Smart pointer class similar to boost::intrusive_ptr.
AttributeValue implementation for Boolean.
holds a vector of std::pair of Ptr<Ipv4> and interface index.
Hold variables of type string.
a class to represent an Ipv4 address mask
The helper class used to configure and install DHCP applications on nodes.
Create an application which sends a UDP packet and waits for an echo of this packet.
static void Run(void)
Run the simulation.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
aggregate IP/TCP/UDP functionality to existing Nodes.
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Ipv4InterfaceContainer InstallFixedAddress(Ptr< NetDevice > netDevice, Ipv4Address addr, Ipv4Mask mask)
Assign a fixed IP addresses to a net device.
Build a set of PointToPointNetDevice objects.
Create a server application which waits for input UDP packets and sends them back to the original sen...
void LogComponentEnable(char const *name, enum LogLevel level)
Enable the logging output associated with that log component.
AttributeValue implementation for Time.
void Add(NetDeviceContainer other)
Append the contents of another NetDeviceContainer to the end of this container.
Hold an unsigned integer type.
holds a vector of ns3::NetDevice pointers
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)
Execute the events scheduled with ScheduleDestroy().
Access to the IPv4 forwarding table, interfaces, and configuration.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
keep track of a set of node pointers.
build a set of CsmaNetDevice objects
void Install(std::string nodeName) const
Aggregate implementations of the ns3::Ipv4, ns3::Ipv6, ns3::Udp, and ns3::Tcp classes onto the provid...
Ipv4 addresses are stored in host order in this class.
void Stop(Time stop)
Arrange for all of the Applications in this container to Stop() at the Time given as a parameter...
ApplicationContainer InstallDhcpClient(Ptr< NetDevice > netDevice) const
Install DHCP client of a nodes / NetDevice.
Helper class that adds ns3::Ipv4StaticRouting objects.
static void Stop(void)
Tell the Simulator the calling event should be the last one executed.
Time Seconds(double value)
Construct a Time in the indicated unit.
A helper class to make life easier while doing simple IPv4 address assignment in scripts.
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
std::pair< Ptr< Ipv4 >, uint32_t > Get(uint32_t i) const
Get the std::pair of an Ptr<Ipv4> and interface stored at the location specified by the index...
Ptr< Application > Get(uint32_t i) const
Get the Ptr<Application> stored in this container at a given index.
Ptr< Ipv4StaticRouting > GetStaticRouting(Ptr< Ipv4 > ipv4) const
Try and find the static routing protocol as either the main routing protocol or in the list of routin...