50 #include "ns3/core-module.h"
51 #include "ns3/network-module.h"
52 #include "ns3/internet-module.h"
53 #include "ns3/point-to-point-module.h"
54 #include "ns3/applications-module.h"
55 #include "ns3/virtual-net-device.h"
90 NS_LOG_DEBUG (
"Send to " << m_n3Address <<
": " << *packet);
106 NS_LOG_DEBUG (
"Send to " << m_n3Address <<
": " << *packet);
124 NS_LOG_DEBUG (
"Send to " << m_n0Address <<
": " << *packet);
129 NS_LOG_DEBUG (
"Send to " << m_n1Address <<
": " << *packet);
181 : m_n3Address (n3Addr), m_n0Address (n0Addr), m_n1Address (n1Addr)
183 m_rng = CreateObject<UniformRandomVariable> ();
197 m_n0Tap = CreateObject<VirtualNetDevice> ();
202 uint32_t i = ipv4->AddInterface (m_n0Tap);
207 m_n1Tap = CreateObject<VirtualNetDevice> ();
212 i = ipv4->AddInterface (m_n1Tap);
217 m_n3Tap = CreateObject<VirtualNetDevice> ();
222 i = ipv4->AddInterface (m_n3Tap);
234 main (
int argc,
char *argv[])
251 cmd.Parse (argc, argv);
279 ipv4.
SetBase (
"10.1.1.0",
"255.255.255.0");
282 ipv4.
SetBase (
"10.1.2.0",
"255.255.255.0");
285 ipv4.
SetBase (
"10.1.3.0",
"255.255.255.0");
302 onoff.SetConstantRate (
DataRate (
"448kb/s"));
310 apps =
sink.Install (c.
Get (3));
315 onoff.SetAttribute (
"Remote",
317 apps = onoff.Install (c.
Get (3));
322 apps =
sink.Install (c.
Get (1));
Ipv4InterfaceContainer i0i2
Ipv4InterfaceContainer i1i2
Tunnel class - its goal is to create and manage the tunnels between endpoints.
void N0SocketRecv(Ptr< Socket > socket)
Receive a packet on the N0 VirtualNetDevice.
bool N0VirtualSend(Ptr< Packet > packet, const Address &source, const Address &dest, uint16_t protocolNumber)
Send a packet through the N0 VirtualNetDevice.
Ptr< Socket > m_n3Socket
Socket on the N3 node.
void N3SocketRecv(Ptr< Socket > socket)
Receive a packet on the N3 VirtualNetDevice.
Ptr< Socket > m_n1Socket
Socket on the N1 node.
Ipv4Address m_n1Address
Address of the N1 node.
Ipv4Address m_n3Address
Address of the N3 node.
Ipv4Address m_n0Address
Address of the N0 node.
bool N3VirtualSend(Ptr< Packet > packet, const Address &source, const Address &dest, uint16_t protocolNumber)
Send a packet through the N3 VirtualNetDevice.
Ptr< UniformRandomVariable > m_rng
Random number generator.
void N1SocketRecv(Ptr< Socket > socket)
Receive a packet on the N1 VirtualNetDevice.
Ptr< VirtualNetDevice > m_n0Tap
VirtualNetDevice on the N0 node.
Ptr< VirtualNetDevice > m_n3Tap
VirtualNetDevice on the N3 node.
bool N1VirtualSend(Ptr< Packet > packet, const Address &source, const Address &dest, uint16_t protocolNumber)
Send a packet through the N1 VirtualNetDevice.
Ptr< Socket > m_n0Socket
Socket on the N0 node.
Ptr< VirtualNetDevice > m_n1Tap
VirtualNetDevice on the N1 node.
Tunnel(Ptr< Node > n3, Ptr< Node > n0, Ptr< Node > n1, Ipv4Address n3Addr, Ipv4Address n0Addr, Ipv4Address n1Addr)
Constructor.
a polymophic address class
AttributeValue implementation for Address.
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.
void EnableAsciiAll(std::string prefix)
Enable ascii trace output on each device (which is of the appropriate type) in the set of all nodes c...
Manage ASCII trace files for device models.
Ptr< OutputStreamWrapper > CreateFileStream(std::string filename, std::ios::openmode filemode=std::ios::out)
Create and initialize an output stream object we'll use to write the traced bits.
Parse command-line arguments.
Class for representing data rates.
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.
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.
static Ipv4Address GetAny(void)
static void PopulateRoutingTables(void)
Build a routing database and initialize the routing tables of the nodes in the simulation.
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.
Ipv4Address GetAddress(uint32_t i, uint32_t j=0) const
a class to represent an Ipv4 address mask
holds a vector of ns3::NetDevice pointers
@ PACKET_HOST
Packet addressed oo us.
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 AddDevice(Ptr< NetDevice > device)
Associate a NetDevice to this node.
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.
static void EnablePrinting(void)
Enable printing packets metadata.
A helper to make it easier to instantiate an ns3::PacketSinkApplication on a set of nodes.
void EnablePcapAll(std::string prefix, bool promiscuous=false)
Enable pcap output on each device (which is of the appropriate type) in the set of all nodes created ...
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.
virtual Ptr< Packet > Recv(uint32_t maxSize, uint32_t flags)=0
Read data from the socket.
void SetRecvCallback(Callback< void, Ptr< Socket > > receivedData)
Notify application when new data is available to be read.
static Ptr< Socket > CreateSocket(Ptr< Node > node, TypeId tid)
This method wraps the creation of sockets that is performed on a given node by a SocketFactory specif...
virtual int Bind(const Address &address)=0
Allocate a local endpoint for this socket.
virtual int SendTo(Ptr< Packet > p, uint32_t flags, const Address &toAddress)=0
Send data to a specified peer.
Hold variables of type string.
static TypeId LookupByName(std::string name)
Get a TypeId by name.
Hold an unsigned integer type.
bool Receive(Ptr< Packet > packet, uint16_t protocol, const Address &source, const Address &destination, PacketType packetType)
virtual void SetAddress(Address address)
Set the address of this interface.
virtual Address GetAddress(void) const
void SetSendCallback(SendCallback transmitCb)
Set the user callback to be called when a L2 packet is to be transmitted.
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_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
#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.
@ LOG_LEVEL_INFO
LOG_INFO and above.
void LogComponentEnable(char const *name, enum LogLevel level)
Enable the logging output associated with that log component.
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...