39 #include <ns3/applications-module.h>
40 #include <ns3/core-module.h>
41 #include <ns3/csma-module.h>
42 #include <ns3/internet-apps-module.h>
43 #include <ns3/internet-module.h>
44 #include <ns3/network-module.h>
45 #include <ns3/ofswitch13-module.h>
50 main(
int argc,
char* argv[])
52 uint16_t simTime = 10;
58 cmd.AddValue(
"simTime",
"Simulation time (seconds)", simTime);
59 cmd.AddValue(
"verbose",
"Enable verbose output",
verbose);
60 cmd.AddValue(
"trace",
"Enable datapath stats and pcap traces", trace);
61 cmd.Parse(argc, argv);
94 Ptr<Node> controllerNode = CreateObject<Node>();
99 of13Helper->InstallController(controllerNode, tunnelController);
115 hostDevices.
Add(pairDevs.
Get(0));
116 hostSwitchDevices.
Add(pairDevs.
Get(1));
117 sw0->AddSwitchPort(pairDevs.
Get(1));
121 hostDevices.
Add(pairDevs.
Get(0));
122 hostSwitchDevices.
Add(pairDevs.
Get(1));
123 sw1->AddSwitchPort(pairDevs.
Get(1));
135 ipv4Helper.
SetBase(ipDomain1, mask24);
137 hostIpIfaces.
Add(ipIfaces.
Get(0));
140 ipv4Helper.
SetBase(ipDomain2, mask24);
142 hostIpIfaces.
Add(ipIfaces.
Get(0));
146 tunnelController->SaveArpEntry(
149 tunnelController->SaveArpEntry(
152 tunnelController->SaveArpEntry(hostIpIfaces.
GetAddress(0),
154 tunnelController->SaveArpEntry(hostIpIfaces.
GetAddress(1),
161 hostStaticRouting->AddNetworkRouteTo(ipDomain2, mask24, sw0GatewayIp, 1);
163 hostStaticRouting->AddNetworkRouteTo(ipDomain1, mask24, sw1GatewayIp, 1);
179 ipv4Helper.
SetBase(tunnelDomain, mask24);
180 ipIfaces = ipv4Helper.
Assign(pairDevs);
188 port = sw0->AddSwitchPort(logicalPort0);
189 tunnelController->SaveTunnelEndpoint(sw0->GetDatapathId(),
196 port = sw1->AddSwitchPort(logicalPort1);
197 tunnelController->SaveTunnelEndpoint(sw1->GetDatapathId(),
202 Ptr<GtpTunnelApp> tunnelApp0 = CreateObject<GtpTunnelApp>(logicalPort0, physicalDev0);
205 Ptr<GtpTunnelApp> tunnelApp1 = CreateObject<GtpTunnelApp>(logicalPort1, physicalDev1);
209 of13Helper->CreateOpenFlowChannels();
213 pingHelper.SetAttribute(
"VerboseMode",
EnumValue(Ping::VerboseMode::VERBOSE));
220 of13Helper->EnableOpenFlowPcap(
"openflow");
221 of13Helper->EnableDatapathStats(
"switch-stats");
222 csmaHelper.
EnablePcap(
"ofswitch", switches,
true);
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.
AttributeValue implementation for Boolean.
Parse command-line arguments.
build a set of CsmaNetDevice objects
void SetChannelAttribute(std::string n1, const AttributeValue &v1)
NetDeviceContainer Install(Ptr< Node > node) const
This method creates an ns3::CsmaChannel with the attributes configured by CsmaHelper::SetChannelAttri...
AttributeValue implementation for DataRate.
Hold variables of type enum.
static void Bind(std::string name, const AttributeValue &value)
Iterate over the set of GlobalValues until a matching name is found and then set its value with Globa...
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.
Ipv4Address NewAddress()
Increment the IP address counter used to allocate IP addresses.
void SetBase(Ipv4Address network, Ipv4Mask mask, Ipv4Address base="0.0.0.1")
Set the base network number, network mask and base address.
Ipv4InterfaceContainer Assign(const NetDeviceContainer &c)
Assign IP addresses to the net devices specified in the container based on the current network prefix...
Ipv4 addresses are stored in host order in this class.
Access to the IPv4 forwarding table, interfaces, and configuration.
holds a vector of std::pair of Ptr<Ipv4> and interface index.
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.
void Add(const Ipv4InterfaceContainer &other)
Concatenate the entries in the other container with ours.
Ipv4Address GetAddress(uint32_t i, uint32_t j=0) const
a class to represent an Ipv4 address mask
Helper class that adds ns3::Ipv4StaticRouting objects.
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...
static Mac48Address ConvertFrom(const Address &address)
static Mac48Address Allocate()
Allocate a new Mac48Address.
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.
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
Ptr< Node > Get(uint32_t i) const
Get the Ptr<Node> stored in this container at a given index.
uint32_t AddApplication(Ptr< Application > application)
Associate an Application to this Node.
Holds a vector of ns3::OFSwitch13Device pointers.
Ptr< OFSwitch13Device > Get(uint32_t i) const
Get the Ptr<OFSwitch13Device> stored in this container at a given index.
static void EnableDatapathLogs(std::string prefix="", bool explicitFilename=false)
Enable OpenFlow datapath logs at all OpenFlow switch devices on the simulation.
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.
void EnablePcap(std::string prefix, Ptr< NetDevice > nd, bool promiscuous=false, bool explicitFilename=false)
Enable pcap output the indicated net device.
Create a ping application and associate it to a node.
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
static void Run()
Run the simulation.
static void Stop()
Tell the Simulator the calling event should be the last one executed.
AttributeValue implementation for Time.
Hold an unsigned integer type.
void SetAddress(Address address) override
Set the address of this interface.
void(* DataRate)(DataRate oldValue, DataRate newValue)
TracedValue callback signature for DataRate.
Time Seconds(double value)
Construct a Time in the indicated unit.
Time MilliSeconds(uint64_t 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.
@ LOG_LEVEL_ALL
Print everything.