A Discrete-Event Network Simulator
API
virtual-net-device.cc
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * This program is free software; you can redistribute it and/or modify
4  * it under the terms of the GNU General Public License version 2 as
5  * published by the Free Software Foundation;
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software
14  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
15  *
16  * Based on simple-global-routing.cc
17  * The Tunnel class adds two tunnels, n0<=>n3 and n1<=>n3
18  */
19 
20 // Network topology
21 //
22 // n0
23 // \ 5 Mb/s, 2ms
24 // \ 1.5Mb/s, 10ms
25 // n2 -------------------------n3
26 // /
27 // / 5 Mb/s, 2ms
28 // n1
29 //
30 // - all links are point-to-point links with indicated one-way BW/delay
31 // - Tracing of queues and packet receptions to file "virtual-net-device.tr"
32 
33 // Tunneling changes (relative to the simple-global-routing example):
34 // - n0 will receive an extra virtual interface with hardcoded inner-tunnel address 11.0.0.1
35 // - n1 will also receive an extra virtual interface with the same inner-tunnel address 11.0.0.1
36 // - n3 will receive an extra virtual interface with inner-tunnel address 11.0.0.254
37 // - The flows will be between 11.0.0.x (inner-tunnel) addresses instead of 10.1.x.y ones
38 // - n3 will decide, on a per-packet basis, via random number, whether to
39 // send the packet to n0 or to n1.
40 //
41 // Note: here we create a tunnel where IP packets are tunneled over
42 // UDP/IP, but tunneling directly IP-over-IP would also be possible;
43 // see src/node/ipv4-raw-socket-factory.h.
44 
45 #include <iostream>
46 #include <fstream>
47 #include <string>
48 #include <cassert>
49 
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"
56 
57 using namespace ns3;
58 
59 NS_LOG_COMPONENT_DEFINE ("VirtualNetDeviceExample");
60 
66 class Tunnel
67 {
78 
87  bool
88  N0VirtualSend (Ptr<Packet> packet, const Address& source, const Address& dest, uint16_t protocolNumber)
89  {
90  NS_LOG_DEBUG ("Send to " << m_n3Address << ": " << *packet);
91  m_n0Socket->SendTo (packet, 0, InetSocketAddress (m_n3Address, 667));
92  return true;
93  }
94 
103  bool
104  N1VirtualSend (Ptr<Packet> packet, const Address& source, const Address& dest, uint16_t protocolNumber)
105  {
106  NS_LOG_DEBUG ("Send to " << m_n3Address << ": " << *packet);
107  m_n1Socket->SendTo (packet, 0, InetSocketAddress (m_n3Address, 667));
108  return true;
109  }
110 
119  bool
120  N3VirtualSend (Ptr<Packet> packet, const Address& source, const Address& dest, uint16_t protocolNumber)
121  {
122  if (m_rng->GetValue () < 0.25)
123  {
124  NS_LOG_DEBUG ("Send to " << m_n0Address << ": " << *packet);
125  m_n3Socket->SendTo (packet, 0, InetSocketAddress (m_n0Address, 667));
126  }
127  else
128  {
129  NS_LOG_DEBUG ("Send to " << m_n1Address << ": " << *packet);
130  m_n3Socket->SendTo (packet, 0, InetSocketAddress (m_n1Address, 667));
131  }
132  return true;
133  }
134 
139  void N3SocketRecv (Ptr<Socket> socket)
140  {
141  Ptr<Packet> packet = socket->Recv (65535, 0);
142  NS_LOG_DEBUG ("N3SocketRecv: " << *packet);
143  m_n3Tap->Receive (packet, 0x0800, m_n3Tap->GetAddress (), m_n3Tap->GetAddress (), NetDevice::PACKET_HOST);
144  }
145 
150  void N0SocketRecv (Ptr<Socket> socket)
151  {
152  Ptr<Packet> packet = socket->Recv (65535, 0);
153  NS_LOG_DEBUG ("N0SocketRecv: " << *packet);
154  m_n0Tap->Receive (packet, 0x0800, m_n0Tap->GetAddress (), m_n0Tap->GetAddress (), NetDevice::PACKET_HOST);
155  }
156 
161  void N1SocketRecv (Ptr<Socket> socket)
162  {
163  Ptr<Packet> packet = socket->Recv (65535, 0);
164  NS_LOG_DEBUG ("N1SocketRecv: " << *packet);
165  m_n1Tap->Receive (packet, 0x0800, m_n1Tap->GetAddress (), m_n1Tap->GetAddress (), NetDevice::PACKET_HOST);
166  }
167 
168 public:
169 
180  Ipv4Address n3Addr, Ipv4Address n0Addr, Ipv4Address n1Addr)
181  : m_n3Address (n3Addr), m_n0Address (n0Addr), m_n1Address (n1Addr)
182  {
183  m_rng = CreateObject<UniformRandomVariable> ();
184  m_n3Socket = Socket::CreateSocket (n3, TypeId::LookupByName ("ns3::UdpSocketFactory"));
185  m_n3Socket->Bind (InetSocketAddress (Ipv4Address::GetAny (), 667));
186  m_n3Socket->SetRecvCallback (MakeCallback (&Tunnel::N3SocketRecv, this));
187 
188  m_n0Socket = Socket::CreateSocket (n0, TypeId::LookupByName ("ns3::UdpSocketFactory"));
189  m_n0Socket->Bind (InetSocketAddress (Ipv4Address::GetAny (), 667));
190  m_n0Socket->SetRecvCallback (MakeCallback (&Tunnel::N0SocketRecv, this));
191 
192  m_n1Socket = Socket::CreateSocket (n1, TypeId::LookupByName ("ns3::UdpSocketFactory"));
193  m_n1Socket->Bind (InetSocketAddress (Ipv4Address::GetAny (), 667));
194  m_n1Socket->SetRecvCallback (MakeCallback (&Tunnel::N1SocketRecv, this));
195 
196  // n0 tap device
197  m_n0Tap = CreateObject<VirtualNetDevice> ();
198  m_n0Tap->SetAddress (Mac48Address ("11:00:01:02:03:01"));
200  n0->AddDevice (m_n0Tap);
201  Ptr<Ipv4> ipv4 = n0->GetObject<Ipv4> ();
202  uint32_t i = ipv4->AddInterface (m_n0Tap);
203  ipv4->AddAddress (i, Ipv4InterfaceAddress (Ipv4Address ("11.0.0.1"), Ipv4Mask ("255.255.255.0")));
204  ipv4->SetUp (i);
205 
206  // n1 tap device
207  m_n1Tap = CreateObject<VirtualNetDevice> ();
208  m_n1Tap->SetAddress (Mac48Address ("11:00:01:02:03:02"));
210  n1->AddDevice (m_n1Tap);
211  ipv4 = n1->GetObject<Ipv4> ();
212  i = ipv4->AddInterface (m_n1Tap);
213  ipv4->AddAddress (i, Ipv4InterfaceAddress (Ipv4Address ("11.0.0.1"), Ipv4Mask ("255.255.255.0")));
214  ipv4->SetUp (i);
215 
216  // n3 tap device
217  m_n3Tap = CreateObject<VirtualNetDevice> ();
218  m_n3Tap->SetAddress (Mac48Address ("11:00:01:02:03:04"));
220  n3->AddDevice (m_n3Tap);
221  ipv4 = n3->GetObject<Ipv4> ();
222  i = ipv4->AddInterface (m_n3Tap);
223  ipv4->AddAddress (i, Ipv4InterfaceAddress (Ipv4Address ("11.0.0.254"), Ipv4Mask ("255.255.255.0")));
224  ipv4->SetUp (i);
225 
226  }
227 
228 
229 };
230 
231 
232 
233 int
234 main (int argc, char *argv[])
235 {
236  // Users may find it convenient to turn on explicit logging
237  // for selected modules; the below lines suggest how to do this
238 #if 0
239  LogComponentEnable ("VirtualNetDeviceExample", LOG_LEVEL_INFO);
240 #endif
242 
243 
244  // Set up some default values for the simulation. Use the
245  Config::SetDefault ("ns3::OnOffApplication::PacketSize", UintegerValue (210));
246  Config::SetDefault ("ns3::OnOffApplication::DataRate", StringValue ("448kb/s"));
247 
248  // Allow the user to override any of the defaults and the above
249  // Config::SetDefault ()s at run-time, via command-line arguments
250  CommandLine cmd (__FILE__);
251  cmd.Parse (argc, argv);
252 
253  NS_LOG_INFO ("Create nodes.");
254  NodeContainer c;
255  c.Create (4);
256  NodeContainer n0n2 = NodeContainer (c.Get (0), c.Get (2));
257  NodeContainer n1n2 = NodeContainer (c.Get (1), c.Get (2));
258  NodeContainer n3n2 = NodeContainer (c.Get (3), c.Get (2));
259 
260  InternetStackHelper internet;
261  internet.Install (c);
262 
263  // We create the channels first without any IP addressing information
264  NS_LOG_INFO ("Create channels.");
265  PointToPointHelper p2p;
266  p2p.SetDeviceAttribute ("DataRate", StringValue ("5Mbps"));
267  p2p.SetChannelAttribute ("Delay", StringValue ("2ms"));
268  NetDeviceContainer d0d2 = p2p.Install (n0n2);
269 
270  NetDeviceContainer d1d2 = p2p.Install (n1n2);
271 
272  p2p.SetDeviceAttribute ("DataRate", StringValue ("1500kbps"));
273  p2p.SetChannelAttribute ("Delay", StringValue ("10ms"));
274  NetDeviceContainer d3d2 = p2p.Install (n3n2);
275 
276  // Later, we add IP addresses.
277  NS_LOG_INFO ("Assign IP Addresses.");
278  Ipv4AddressHelper ipv4;
279  ipv4.SetBase ("10.1.1.0", "255.255.255.0");
280  Ipv4InterfaceContainer i0i2 = ipv4.Assign (d0d2);
281 
282  ipv4.SetBase ("10.1.2.0", "255.255.255.0");
283  Ipv4InterfaceContainer i1i2 = ipv4.Assign (d1d2);
284 
285  ipv4.SetBase ("10.1.3.0", "255.255.255.0");
286  Ipv4InterfaceContainer i3i2 = ipv4.Assign (d3d2);
287 
288  // Create router nodes, initialize routing database and set up the routing
289  // tables in the nodes.
291 
292  // Add the tunnels n0<=>n3 and n1<=>n3
293  Tunnel tunnel (c.Get (3), c.Get (0), c.Get (1),
294  i3i2.GetAddress (0), i0i2.GetAddress (0), i1i2.GetAddress (0));
295 
296  // Create the OnOff application to send UDP datagrams of size
297  // 210 bytes at a rate of 448 Kb/s
298  NS_LOG_INFO ("Create Applications.");
299  uint16_t port = 9; // Discard port (RFC 863)
300  OnOffHelper onoff ("ns3::UdpSocketFactory",
301  Address (InetSocketAddress (Ipv4Address ("11.0.0.254"), port)));
302  onoff.SetConstantRate (DataRate ("448kb/s"));
303  ApplicationContainer apps = onoff.Install (c.Get (0));
304  apps.Start (Seconds (1.0));
305  apps.Stop (Seconds (10.0));
306 
307  // Create a packet sink to receive these packets
308  PacketSinkHelper sink ("ns3::UdpSocketFactory",
310  apps = sink.Install (c.Get (3));
311  apps.Start (Seconds (1.0));
312  //apps.Stop (Seconds (10.0));
313 
314  // Create a similar flow from n3 to n1, starting at time 1.1 seconds
315  onoff.SetAttribute ("Remote",
316  AddressValue (InetSocketAddress (Ipv4Address ("11.0.0.1"), port)));
317  apps = onoff.Install (c.Get (3));
318  apps.Start (Seconds (1.1));
319  apps.Stop (Seconds (10.0));
320 
321  // Create a packet sink to receive these packets
322  apps = sink.Install (c.Get (1));
323  apps.Start (Seconds (1.1));
324  //apps.Stop (Seconds (10.0));
325 
326  AsciiTraceHelper ascii;
327  p2p.EnableAsciiAll (ascii.CreateFileStream ("virtual-net-device.tr"));
328  p2p.EnablePcapAll ("virtual-net-device");
329 
330  NS_LOG_INFO ("Run Simulation.");
331  Simulator::Run ();
333  NS_LOG_INFO ("Done.");
334 
335  return 0;
336 }
ns3::NetDeviceContainer
holds a vector of ns3::NetDevice pointers
Definition: net-device-container.h:42
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:205
ns3::InetSocketAddress
an Inet address class
Definition: inet-socket-address.h:41
ns3::CommandLine
Parse command-line arguments.
Definition: command-line.h:229
ns3::AsciiTraceHelperForDevice::EnableAsciiAll
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...
Definition: trace-helper.cc:586
Tunnel::N1VirtualSend
bool N1VirtualSend(Ptr< Packet > packet, const Address &source, const Address &dest, uint16_t protocolNumber)
Send a packet through the N1 VirtualNetDevice.
Definition: virtual-net-device.cc:104
ns3::LOG_LEVEL_INFO
@ LOG_LEVEL_INFO
LOG_INFO and above.
Definition: log.h:107
ns3::Socket::Bind
virtual int Bind(const Address &address)=0
Allocate a local endpoint for this socket.
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::ApplicationContainer::Stop
void Stop(Time stop)
Arrange for all of the Applications in this container to Stop() at the Time given as a parameter.
Definition: application-container.cc:107
ns3::Ipv4AddressHelper
A helper class to make life easier while doing simple IPv4 address assignment in scripts.
Definition: ipv4-address-helper.h:48
Tunnel::N3VirtualSend
bool N3VirtualSend(Ptr< Packet > packet, const Address &source, const Address &dest, uint16_t protocolNumber)
Send a packet through the N3 VirtualNetDevice.
Definition: virtual-net-device.cc:120
ns3::Ipv4::SetUp
virtual void SetUp(uint32_t interface)=0
ns3::PointToPointHelper::SetDeviceAttribute
void SetDeviceAttribute(std::string name, const AttributeValue &value)
Set an attribute value to be propagated to each NetDevice created by the helper.
Definition: point-to-point-helper.cc:70
ns3::PointToPointHelper::SetChannelAttribute
void SetChannelAttribute(std::string name, const AttributeValue &value)
Set an attribute value to be propagated to each Channel created by the helper.
Definition: point-to-point-helper.cc:76
ns3::PcapHelperForDevice::EnablePcapAll
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 ...
Definition: trace-helper.cc:439
ns3::Object::GetObject
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object.
Definition: object.h:470
ns3::Packet::EnablePrinting
static void EnablePrinting(void)
Enable printing packets metadata.
Definition: packet.cc:572
AddressValue
AttributeValue implementation for Address.
ns3::VirtualNetDevice::SetAddress
virtual void SetAddress(Address address)
Set the address of this interface.
Definition: virtual-net-device.cc:196
ns3::VirtualNetDevice::SetSendCallback
void SetSendCallback(SendCallback transmitCb)
Set the user callback to be called when a L2 packet is to be transmitted.
Definition: virtual-net-device.cc:95
ns3::LogComponentEnable
void LogComponentEnable(char const *name, enum LogLevel level)
Enable the logging output associated with that log component.
Definition: log.cc:361
ns3::PointToPointHelper::Install
NetDeviceContainer Install(NodeContainer c)
Definition: point-to-point-helper.cc:229
ns3::Ipv4Address
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:41
ns3::NetDevice::PACKET_HOST
@ PACKET_HOST
Packet addressed oo us.
Definition: net-device.h:298
ns3::Mac48Address
an EUI-48 address
Definition: mac48-address.h:44
ns3::Socket::SendTo
virtual int SendTo(Ptr< Packet > p, uint32_t flags, const Address &toAddress)=0
Send data to a specified peer.
ns3::VirtualNetDevice::GetAddress
virtual Address GetAddress(void) const
Definition: virtual-net-device.cc:190
ns3::NodeContainer::Create
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
Definition: node-container.cc:98
ns3::Ipv4AddressHelper::SetBase
void SetBase(Ipv4Address network, Ipv4Mask mask, Ipv4Address base="0.0.0.1")
Set the base network number, network mask and base address.
Definition: ipv4-address-helper.cc:64
ns3::Ipv4
Access to the IPv4 forwarding table, interfaces, and configuration.
Definition: ipv4.h:77
Tunnel::m_n1Tap
Ptr< VirtualNetDevice > m_n1Tap
VirtualNetDevice on the N1 node.
Definition: virtual-net-device.cc:76
ns3::Ptr< Socket >
Tunnel::m_n0Address
Ipv4Address m_n0Address
Address of the N0 node.
Definition: virtual-net-device.cc:72
ns3::Ipv4::AddInterface
virtual uint32_t AddInterface(Ptr< NetDevice > device)=0
Tunnel::m_n3Tap
Ptr< VirtualNetDevice > m_n3Tap
VirtualNetDevice on the N3 node.
Definition: virtual-net-device.cc:77
ns3::DataRate
Class for representing data rates.
Definition: data-rate.h:89
ns3::Socket::SetRecvCallback
void SetRecvCallback(Callback< void, Ptr< Socket > > receivedData)
Notify application when new data is available to be read.
Definition: socket.cc:128
ns3::Ipv4GlobalRoutingHelper::PopulateRoutingTables
static void PopulateRoutingTables(void)
Build a routing database and initialize the routing tables of the nodes in the simulation.
Definition: ipv4-global-routing-helper.cc:61
Tunnel::m_n0Tap
Ptr< VirtualNetDevice > m_n0Tap
VirtualNetDevice on the N0 node.
Definition: virtual-net-device.cc:75
ns3::Address
a polymophic address class
Definition: address.h:91
Tunnel::N3SocketRecv
void N3SocketRecv(Ptr< Socket > socket)
Receive a packet on the N3 VirtualNetDevice.
Definition: virtual-net-device.cc:139
ns3::Ipv4InterfaceAddress
a class to store IPv4 address information on an interface
Definition: ipv4-interface-address.h:44
ns3::InternetStackHelper::Install
void Install(std::string nodeName) const
Aggregate implementations of the ns3::Ipv4, ns3::Ipv6, ns3::Udp, and ns3::Tcp classes onto the provid...
Definition: internet-stack-helper.cc:359
ns3::OnOffHelper
A helper to make it easier to instantiate an ns3::OnOffApplication on a set of nodes.
Definition: on-off-helper.h:43
NS_LOG_INFO
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Definition: log.h:281
ns3::AsciiTraceHelper::CreateFileStream
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.
Definition: trace-helper.cc:191
Tunnel::m_n3Socket
Ptr< Socket > m_n3Socket
Socket on the N3 node.
Definition: virtual-net-device.cc:68
ns3::Ipv4InterfaceContainer
holds a vector of std::pair of Ptr<Ipv4> and interface index.
Definition: ipv4-interface-container.h:55
ns3::NodeContainer::Get
Ptr< Node > Get(uint32_t i) const
Get the Ptr<Node> stored in this container at a given index.
Definition: node-container.cc:93
second.cmd
cmd
Definition: second.py:35
ns3::Node::AddDevice
uint32_t AddDevice(Ptr< NetDevice > device)
Associate a NetDevice to this node.
Definition: node.cc:130
Tunnel::N0VirtualSend
bool N0VirtualSend(Ptr< Packet > packet, const Address &source, const Address &dest, uint16_t protocolNumber)
Send a packet through the N0 VirtualNetDevice.
Definition: virtual-net-device.cc:88
Tunnel::m_rng
Ptr< UniformRandomVariable > m_rng
Random number generator.
Definition: virtual-net-device.cc:74
i0i2
Ipv4InterfaceContainer i0i2
Definition: adaptive-red-tests.cc:96
sink
Ptr< PacketSink > sink
Definition: wifi-tcp.cc:56
ns3::MakeCallback
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...
Definition: callback.h:1648
ns3::Simulator::Run
static void Run(void)
Run the simulation.
Definition: simulator.cc:172
ns3::StringValue
Hold variables of type string.
Definition: string.h:41
Tunnel::N1SocketRecv
void N1SocketRecv(Ptr< Socket > socket)
Receive a packet on the N1 VirtualNetDevice.
Definition: virtual-net-device.cc:161
ns3::PacketSinkHelper
A helper to make it easier to instantiate an ns3::PacketSinkApplication on a set of nodes.
Definition: packet-sink-helper.h:36
ns3::AsciiTraceHelper
Manage ASCII trace files for device models.
Definition: trace-helper.h:163
uint32_t
ns3::Ipv4Address::GetAny
static Ipv4Address GetAny(void)
Definition: ipv4-address.cc:395
NS_LOG_DEBUG
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition: log.h:273
Tunnel::m_n0Socket
Ptr< Socket > m_n0Socket
Socket on the N0 node.
Definition: virtual-net-device.cc:69
ns3::VirtualNetDevice::Receive
bool Receive(Ptr< Packet > packet, uint16_t protocol, const Address &source, const Address &destination, PacketType packetType)
Definition: virtual-net-device.cc:140
ns3::ApplicationContainer::Start
void Start(Time start)
Arrange for all of the Applications in this container to Start() at the Time given as a parameter.
Definition: application-container.cc:87
ns3::Seconds
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1244
n0n2
NodeContainer n0n2
Definition: adaptive-red-tests.cc:90
ns3::Ipv4AddressHelper::Assign
Ipv4InterfaceContainer Assign(const NetDeviceContainer &c)
Assign IP addresses to the net devices specified in the container based on the current network prefix...
Definition: ipv4-address-helper.cc:135
ns3::Simulator::Destroy
static void Destroy(void)
Execute the events scheduled with ScheduleDestroy().
Definition: simulator.cc:136
ns3::ApplicationContainer
holds a vector of ns3::Application pointers.
Definition: application-container.h:43
Tunnel::m_n1Address
Ipv4Address m_n1Address
Address of the N1 node.
Definition: virtual-net-device.cc:73
ns3::PointToPointHelper
Build a set of PointToPointNetDevice objects.
Definition: point-to-point-helper.h:45
ns3::NodeContainer
keep track of a set of node pointers.
Definition: node-container.h:39
ns3::Ipv4Mask
a class to represent an Ipv4 address mask
Definition: ipv4-address.h:256
Tunnel::m_n1Socket
Ptr< Socket > m_n1Socket
Socket on the N1 node.
Definition: virtual-net-device.cc:70
n1n2
NodeContainer n1n2
Definition: adaptive-red-tests.cc:91
ns3::Ipv4InterfaceContainer::GetAddress
Ipv4Address GetAddress(uint32_t i, uint32_t j=0) const
Definition: ipv4-interface-container.cc:59
ns3::UintegerValue
Hold an unsigned integer type.
Definition: uinteger.h:44
ns3::Socket::CreateSocket
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...
Definition: socket.cc:71
ns3::Config::SetDefault
void SetDefault(std::string name, const AttributeValue &value)
Definition: config.cc:849
Tunnel::m_n3Address
Ipv4Address m_n3Address
Address of the N3 node.
Definition: virtual-net-device.cc:71
ns3::InternetStackHelper
aggregate IP/TCP/UDP functionality to existing Nodes.
Definition: internet-stack-helper.h:88
ns3::TypeId::LookupByName
static TypeId LookupByName(std::string name)
Get a TypeId by name.
Definition: type-id.cc:829
ns3::UniformRandomVariable::GetValue
double GetValue(double min, double max)
Get the next random value, as a double in the specified range .
Definition: random-variable-stream.cc:181
ns3::Ipv4::AddAddress
virtual bool AddAddress(uint32_t interface, Ipv4InterfaceAddress address)=0
Tunnel::N0SocketRecv
void N0SocketRecv(Ptr< Socket > socket)
Receive a packet on the N0 VirtualNetDevice.
Definition: virtual-net-device.cc:150
port
uint16_t port
Definition: dsdv-manet.cc:45
ns3::Socket::Recv
virtual Ptr< Packet > Recv(uint32_t maxSize, uint32_t flags)=0
Read data from the socket.
i1i2
Ipv4InterfaceContainer i1i2
Definition: adaptive-red-tests.cc:97
Tunnel
Tunnel class - its goal is to create and manage the tunnels between endpoints.
Definition: virtual-net-device.cc:67
Tunnel::Tunnel
Tunnel(Ptr< Node > n3, Ptr< Node > n0, Ptr< Node > n1, Ipv4Address n3Addr, Ipv4Address n0Addr, Ipv4Address n1Addr)
Constructor.
Definition: virtual-net-device.cc:179