From 7605d91dbeaa5169867acc8d7f99eea522a647ea Mon Sep 17 00:00:00 2001 From: "Gustavo J. A. M. Carneiro" Date: Sun, 24 May 2009 16:18:20 +0100 Subject: [PATCH 01/20] Add TapNetDevice (formerly known as VirtualNetDevice) --- src/devices/tap-net-device/tap-net-device.cc | 271 +++++++++++++++++++ src/devices/tap-net-device/tap-net-device.h | 166 ++++++++++++ src/devices/tap-net-device/waf | 1 + src/devices/tap-net-device/wscript | 14 + src/wscript | 1 + 5 files changed, 453 insertions(+) create mode 100644 src/devices/tap-net-device/tap-net-device.cc create mode 100644 src/devices/tap-net-device/tap-net-device.h create mode 100755 src/devices/tap-net-device/waf create mode 100644 src/devices/tap-net-device/wscript diff --git a/src/devices/tap-net-device/tap-net-device.cc b/src/devices/tap-net-device/tap-net-device.cc new file mode 100644 index 000000000..871f9a799 --- /dev/null +++ b/src/devices/tap-net-device/tap-net-device.cc @@ -0,0 +1,271 @@ +/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ +/* + * Copyright (c) 2008,2009 INESC Porto + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation; + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Author: Gustavo J. A. M. Carneiro + */ + +#include "ns3/log.h" +#include "ns3/queue.h" +#include "ns3/simulator.h" +#include "ns3/mac48-address.h" +#include "ns3/llc-snap-header.h" +#include "ns3/error-model.h" +#include "tap-net-device.h" +#include "ns3/channel.h" +#include "ns3/trace-source-accessor.h" + + +NS_LOG_COMPONENT_DEFINE ("TapNetDevice"); + +namespace ns3 { + +NS_OBJECT_ENSURE_REGISTERED (TapNetDevice); + +TypeId +TapNetDevice::GetTypeId (void) +{ + static TypeId tid = TypeId ("ns3::TapNetDevice") + .SetParent () + .AddConstructor () + .AddTraceSource ("Rx", "Received payload from the MAC layer.", + MakeTraceSourceAccessor (&TapNetDevice::m_rxTrace)) + .AddTraceSource ("Tx", "Send payload to the MAC layer.", + MakeTraceSourceAccessor (&TapNetDevice::m_txTrace)) + ; + return tid; +} + +TapNetDevice::TapNetDevice () +{ + m_needsArp = false; + m_supportsSendFrom = true; + m_mtu = 65535; +} + + +void +TapNetDevice::SetSendFromCallback (SendFromCallback sendCb) +{ + m_sendCb = sendCb; +} + +void +TapNetDevice::SetNeedsArp (bool needsArp) +{ + m_needsArp = needsArp; +} + +void +TapNetDevice::SetSupportsSendFrom (bool supportsSendFrom) +{ + m_supportsSendFrom = supportsSendFrom; +} + +bool +TapNetDevice::SetMtu (const uint16_t mtu) +{ + m_mtu = mtu; + return true; +} + + +TapNetDevice::~TapNetDevice() +{ + NS_LOG_FUNCTION_NOARGS (); +} + + +void TapNetDevice::DoDispose() +{ + NS_LOG_FUNCTION_NOARGS (); + NetDevice::DoDispose (); +} + +bool +TapNetDevice::Receive (Ptr packet, uint16_t protocol, const Address &address) +{ + if (m_rxCallback (this, packet, protocol, address)) + { + m_rxTrace (packet); + return true; + } + return false; +} + +bool +TapNetDevice::PromiscReceive (Ptr packet, uint16_t protocol, + const Address &source, const Address &destination, + PacketType packetType) +{ + if (m_promiscRxCallback (this, packet, protocol, source, destination, packetType)) + { + m_rxTrace (packet); + return true; + } + return false; +} + + +void +TapNetDevice::SetName (const std::string name) +{ + m_name = name; +} + +std::string +TapNetDevice::GetName (void) const +{ + return m_name; +} + +void +TapNetDevice::SetIfIndex (const uint32_t index) +{ + m_index = index; +} + +uint32_t +TapNetDevice::GetIfIndex (void) const +{ + return m_index; +} + +Ptr +TapNetDevice::GetChannel (void) const +{ + return Ptr (); +} + +Address +TapNetDevice::GetAddress (void) const +{ + return Mac48Address (); +} + +uint16_t +TapNetDevice::GetMtu (void) const +{ + return m_mtu; +} + +bool +TapNetDevice::IsLinkUp (void) const +{ + return true; +} + +void +TapNetDevice::SetLinkChangeCallback (Callback callback) +{ +} + +bool +TapNetDevice::IsBroadcast (void) const +{ + return m_needsArp; +} + +Address +TapNetDevice::GetBroadcast (void) const +{ + return Mac48Address ("ff:ff:ff:ff:ff:ff"); +} + +bool +TapNetDevice::IsMulticast (void) const +{ + return false; +} + +Address TapNetDevice::GetMulticast (Ipv4Address multicastGroup) const +{ + return Mac48Address ("ff:ff:ff:ff:ff:ff"); +} + +Address TapNetDevice::GetMulticast (Ipv6Address addr) const +{ + return Mac48Address ("ff:ff:ff:ff:ff:ff"); +} + + +bool +TapNetDevice::IsPointToPoint (void) const +{ + return true; +} + +bool +TapNetDevice::Send (Ptr packet, const Address& dest, uint16_t protocolNumber) +{ + return SendFrom (packet, GetAddress (), dest, protocolNumber); +} + +bool +TapNetDevice::SendFrom (Ptr packet, const Address& source, const Address& dest, uint16_t protocolNumber) +{ + NS_FATAL_ERROR ("not implemented"); + if (m_sendCb (packet, source, dest, protocolNumber)) + { + m_txTrace (packet); + return true; + } + return false; +} + +Ptr +TapNetDevice::GetNode (void) const +{ + return m_node; +} + +void +TapNetDevice::SetNode (Ptr node) +{ + m_node = node; +} + +bool +TapNetDevice::NeedsArp (void) const +{ + return m_needsArp; +} + +void +TapNetDevice::SetReceiveCallback (NetDevice::ReceiveCallback cb) +{ + m_rxCallback = cb; +} + +void +TapNetDevice::SetPromiscReceiveCallback (NetDevice::PromiscReceiveCallback cb) +{ + m_promiscRxCallback = cb; +} + +bool +TapNetDevice::SupportsSendFrom () const +{ + return m_supportsSendFrom; +} + +bool TapNetDevice::IsBridge (void) const +{ + return false; +} + + +} // namespace ns3 diff --git a/src/devices/tap-net-device/tap-net-device.h b/src/devices/tap-net-device/tap-net-device.h new file mode 100644 index 000000000..38cffc0ac --- /dev/null +++ b/src/devices/tap-net-device/tap-net-device.h @@ -0,0 +1,166 @@ +/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ +/* + * Copyright (c) 2008,2009 INESC Porto + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation; + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Author: Gustavo J. A. M. Carneiro + */ + +#ifndef TAP_NET_DEVICE_H +#define TAP_NET_DEVICE_H + +#include "ns3/address.h" +#include "ns3/node.h" +#include "ns3/net-device.h" +#include "ns3/callback.h" +#include "ns3/packet.h" +#include "ns3/ptr.h" +#include "ns3/traced-callback.h" + +namespace ns3 { + + +/** + * \class TapNetDevice + * \brief A virtual device, similar to Linux TAP interfaces. + * + * A TapNetDevice is a "virtual" NetDevice implementation which + * delegates to a user callback (see method SetSendFromCallback()) the + * task of actually transmitting a packet. It also allows the user + * code to inject the packet as if it had been received by the + * TapNetDevice. Together, these features allow one to build tunnels. + * For instance, by transmitting packets into a UDP socket we end up + * building an IP-over-UDP-over-IP tunnel. + * + * The same thing could be accomplished by subclassing NetDevice + * directly. However, TapNetDevice is usually much simpler to program + * than a NetDevice subclass. + */ +class TapNetDevice : public NetDevice +{ +public: + typedef Callback, const Address&, const Address&, uint16_t> SendFromCallback; + + static TypeId GetTypeId (void); + TapNetDevice (); + + virtual ~TapNetDevice (); + + /** + * \brief Set the user callback to be called when a L2 packet is to be transmitted + * \param transmitCb the new transmit callback + */ + void SetSendFromCallback (SendFromCallback transmitCb); + + /** + * \brief Configure whether the virtual device needs ARP + * + * \param needsArp the the 'needs arp' value that will be returned + * by the NeedsArp() method. The method IsBroadcast() will also + * return this value. + */ + void SetNeedsArp (bool needsArp); + + /** + * \brief Configure whether the virtual device supports SendFrom + */ + void SetSupportsSendFrom (bool supportsSendFrom); + + /** + * \brief Configure the reported MTU for the virtual device. The + * default value is 65535. + * \return whether the MTU value was within legal bounds + */ + bool SetMtu (const uint16_t mtu); + + + /** + * \param p packet sent from below up to Network Device + * \param protocol Protocol type + * \param source the address of the sender of this packet. + * \returns true if the packet was forwarded successfully, + * false otherwise. + * + * Forward a "virtually received" packet up the node's protocol + * stack. + */ + bool Receive (Ptr packet, uint16_t protocol, const Address &source); + + + /** + * \param p packet sent from below up to Network Device + * \param protocol Protocol type + * \param source the address of the sender of this packet. + * \param destination the address of the receiver of this packet. + * \param packetType type of packet received (broadcast/multicast/unicast/otherhost) + * \returns true if the packet was forwarded successfully, false otherwise. + * + * Forward a "virtually received (in promiscuous mode)" packet up + * the node's protocol stack. + */ + bool PromiscReceive (Ptr packet, uint16_t protocol, + const Address &source, const Address &destination, + PacketType packetType); + + + // inherited from NetDevice base class. + virtual void SetName(const std::string name); + virtual std::string GetName(void) const; + virtual void SetIfIndex(const uint32_t index); + virtual uint32_t GetIfIndex(void) const; + virtual Ptr GetChannel (void) const; + virtual Address GetAddress (void) const; + virtual uint16_t GetMtu (void) const; + virtual bool IsLinkUp (void) const; + virtual void SetLinkChangeCallback (Callback callback); + virtual bool IsBroadcast (void) const; + virtual Address GetBroadcast (void) const; + virtual bool IsMulticast (void) const; + virtual Address GetMulticast (Ipv4Address multicastGroup) const; + virtual Address GetMulticast (Ipv6Address addr) const; + virtual bool IsPointToPoint (void) const; + virtual bool Send (Ptr packet, const Address& dest, uint16_t protocolNumber); + virtual bool SendFrom (Ptr packet, const Address& source, const Address& dest, uint16_t protocolNumber); + virtual Ptr GetNode (void) const; + virtual void SetNode (Ptr node); + virtual bool NeedsArp (void) const; + virtual void SetReceiveCallback (NetDevice::ReceiveCallback cb); + virtual void SetPromiscReceiveCallback (NetDevice::PromiscReceiveCallback cb); + virtual bool SupportsSendFrom () const; + virtual bool IsBridge (void) const; + +protected: + + virtual void DoDispose (void); + +private: + + SendFromCallback m_sendCb; + TracedCallback > m_rxTrace; + TracedCallback > m_txTrace; + Ptr m_node; + ReceiveCallback m_rxCallback; + PromiscReceiveCallback m_promiscRxCallback; + std::string m_name; + uint32_t m_index; + uint16_t m_mtu; + bool m_needsArp; + bool m_supportsSendFrom; +}; + +}; // namespace ns3 + +#endif + diff --git a/src/devices/tap-net-device/waf b/src/devices/tap-net-device/waf new file mode 100755 index 000000000..4283ec141 --- /dev/null +++ b/src/devices/tap-net-device/waf @@ -0,0 +1 @@ +exec "`dirname "$0"`"/../../../waf "$@" diff --git a/src/devices/tap-net-device/wscript b/src/devices/tap-net-device/wscript new file mode 100644 index 000000000..f8bad170c --- /dev/null +++ b/src/devices/tap-net-device/wscript @@ -0,0 +1,14 @@ +## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*- + + +def build(bld): + module = bld.create_ns3_module('tap-net-device', ['node']) + module.source = [ + 'tap-net-device.cc', + ] + headers = bld.new_task_gen('ns3header') + headers.module = 'tap-net-device' + headers.source = [ + 'tap-net-device.h', + ] + diff --git a/src/wscript b/src/wscript index f1517e2a3..97013e23f 100644 --- a/src/wscript +++ b/src/wscript @@ -23,6 +23,7 @@ all_modules = ( 'devices/emu', 'devices/bridge', 'devices/tap-bridge', + 'devices/tap-net-device', 'applications/onoff', 'applications/packet-sink', 'applications/udp-echo', From 7c33f161663fe76ca747626e0f25bd449ada9d75 Mon Sep 17 00:00:00 2001 From: "Gustavo J. A. M. Carneiro" Date: Sat, 30 May 2009 17:36:29 +0100 Subject: [PATCH 02/20] Remove TapNetDevice::[GS]etName; a couple of bug fixes. --- src/devices/tap-net-device/tap-net-device.cc | 15 +-------------- src/devices/tap-net-device/tap-net-device.h | 2 -- 2 files changed, 1 insertion(+), 16 deletions(-) diff --git a/src/devices/tap-net-device/tap-net-device.cc b/src/devices/tap-net-device/tap-net-device.cc index 871f9a799..86633fdad 100644 --- a/src/devices/tap-net-device/tap-net-device.cc +++ b/src/devices/tap-net-device/tap-net-device.cc @@ -120,18 +120,6 @@ TapNetDevice::PromiscReceive (Ptr packet, uint16_t protocol, } -void -TapNetDevice::SetName (const std::string name) -{ - m_name = name; -} - -std::string -TapNetDevice::GetName (void) const -{ - return m_name; -} - void TapNetDevice::SetIfIndex (const uint32_t index) { @@ -176,7 +164,7 @@ TapNetDevice::SetLinkChangeCallback (Callback callback) bool TapNetDevice::IsBroadcast (void) const { - return m_needsArp; + return true; } Address @@ -217,7 +205,6 @@ TapNetDevice::Send (Ptr packet, const Address& dest, uint16_t protocolNu bool TapNetDevice::SendFrom (Ptr packet, const Address& source, const Address& dest, uint16_t protocolNumber) { - NS_FATAL_ERROR ("not implemented"); if (m_sendCb (packet, source, dest, protocolNumber)) { m_txTrace (packet); diff --git a/src/devices/tap-net-device/tap-net-device.h b/src/devices/tap-net-device/tap-net-device.h index 38cffc0ac..df0963350 100644 --- a/src/devices/tap-net-device/tap-net-device.h +++ b/src/devices/tap-net-device/tap-net-device.h @@ -116,8 +116,6 @@ public: // inherited from NetDevice base class. - virtual void SetName(const std::string name); - virtual std::string GetName(void) const; virtual void SetIfIndex(const uint32_t index); virtual uint32_t GetIfIndex(void) const; virtual Ptr GetChannel (void) const; From 5839b484bb5eb5865a453306d221f54481b17efb Mon Sep 17 00:00:00 2001 From: "Gustavo J. A. M. Carneiro" Date: Sat, 30 May 2009 17:36:50 +0100 Subject: [PATCH 03/20] Add an example for TapNetDevice --- examples/tap-net-device.cc | 278 +++++++++++++++++++++++++++++++++++++ examples/wscript | 4 + 2 files changed, 282 insertions(+) create mode 100644 examples/tap-net-device.cc diff --git a/examples/tap-net-device.cc b/examples/tap-net-device.cc new file mode 100644 index 000000000..f0d21f66f --- /dev/null +++ b/examples/tap-net-device.cc @@ -0,0 +1,278 @@ +/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation; + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Based on simple-global-routing.cc + * ns-2 simple.tcl script (ported from ns-2) + * Originally authored by Steve McCanne, 12/19/1996 + */ + +// Port of ns-2/tcl/ex/simple.tcl to ns-3 +// +// Network topology +// +// n0 +// \ 5 Mb/s, 2ms +// \ 1.5Mb/s, 10ms +// n2 -------------------------n3 +// / +// / 5 Mb/s, 2ms +// n1 +// +// - all links are point-to-point links with indicated one-way BW/delay +// - CBR/UDP flows from n0 to n3, and from n3 to n1 +// - FTP/TCP flow from n0 to n3, starting at time 1.2 to time 1.35 sec. +// - UDP packet size of 210 bytes, with per-packet interval 0.00375 sec. +// (i.e., DataRate of 448,000 bps) +// - DropTail queues +// - Tracing of queues and packet receptions to file "simple-global-routing.tr" + +// Tunneling changes (relative to the simple-global-routing example): +// n0 will receive an extra virtual interface with address 11.0.0.1 +// n1 will also receive an extra virtual interface with the same address 11.0.0.1 +// n3 will receive an extra virtual interface with address 11.0.0.254 +// The flows will be between 11.0.0.x (tunnel) addresses instead of 10.1.x.y ones +// n3 will decide, on a per-packet basis, via random number, whether to +// send the packet to n0 or to n1. + +#include +#include +#include +#include + +#include "ns3/core-module.h" +#include "ns3/simulator-module.h" +#include "ns3/node-module.h" +#include "ns3/helper-module.h" +#include "ns3/global-route-manager.h" +#include "ns3/tap-net-device.h" + +using namespace ns3; + +NS_LOG_COMPONENT_DEFINE ("TapNetDeviceExample"); + +class Tunnel +{ + Ptr m_n3Socket; + Ptr m_n0Socket; + Ptr m_n1Socket; + Ipv4Address m_n3Address; + Ipv4Address m_n0Address; + Ipv4Address m_n1Address; + UniformVariable m_rng; + Ptr m_n0Tap; + Ptr m_n1Tap; + Ptr m_n3Tap; + + + bool + N0N1VirtualSend (Ptr packet, const Address& source, const Address& dest, uint16_t protocolNumber) + { + m_n3Socket->SendTo (packet, 0, InetSocketAddress (m_n3Address, 667)); + return true; + } + + bool + N3VirtualSend (Ptr packet, const Address& source, const Address& dest, uint16_t protocolNumber) + { + + if (m_rng.GetValue () < 0.25) + { + m_n0Socket->SendTo (packet, 0, InetSocketAddress (m_n0Address, 667)); + } + else + { + m_n1Socket->SendTo (packet, 0, InetSocketAddress (m_n1Address, 667)); + } + return true; + } + + void N3SocketRecv (Ptr socket) + { + Ptr packet = socket->Recv (65535, 0); + m_n3Tap->Receive (packet, 0x0800, Address ()); + } + + void N0SocketRecv (Ptr socket) + { + Ptr packet = socket->Recv (65535, 0); + m_n0Tap->Receive (packet, 0x0800, Address ()); + } + + void N1SocketRecv (Ptr socket) + { + Ptr packet = socket->Recv (65535, 0); + m_n0Tap->Receive (packet, 0x0800, Address ()); + } + +public: + + Tunnel (Ptr n3, Ptr n0, Ptr n1, + Ipv4Address n3Addr, Ipv4Address n0Addr, Ipv4Address n1Addr) + : m_n3Address (n3Addr), m_n0Address (n0Addr), m_n1Address (n1Addr) + { + m_n3Socket = Socket::CreateSocket (n3, TypeId::LookupByName ("ns3::UdpSocketFactory")); + m_n3Socket->Bind (InetSocketAddress (Ipv4Address::GetAny (), 667)); + m_n3Socket->SetRecvCallback (MakeCallback (&Tunnel::N3SocketRecv, this)); + + m_n0Socket = Socket::CreateSocket (n0, TypeId::LookupByName ("ns3::UdpSocketFactory")); + m_n0Socket->Bind (InetSocketAddress (Ipv4Address::GetAny (), 667)); + m_n0Socket->SetRecvCallback (MakeCallback (&Tunnel::N0SocketRecv, this)); + + m_n1Socket = Socket::CreateSocket (n1, TypeId::LookupByName ("ns3::UdpSocketFactory")); + m_n1Socket->Bind (InetSocketAddress (Ipv4Address::GetAny (), 667)); + m_n1Socket->SetRecvCallback (MakeCallback (&Tunnel::N1SocketRecv, this)); + + // n0 tap device + m_n0Tap = CreateObject (); + m_n0Tap->SetSendFromCallback (MakeCallback (&Tunnel::N0N1VirtualSend, this)); + n0->AddDevice (m_n0Tap); + Ptr ipv4 = n0->GetObject (); + uint32_t i = ipv4->AddInterface (m_n0Tap); + ipv4->AddAddress (i, Ipv4InterfaceAddress (Ipv4Address ("11.0.0.1"), Ipv4Mask ("255.255.255.0"))); + ipv4->SetUp (i); + + // n1 tap device + m_n1Tap = CreateObject (); + m_n1Tap->SetSendFromCallback (MakeCallback (&Tunnel::N0N1VirtualSend, this)); + n1->AddDevice (m_n1Tap); + ipv4 = n1->GetObject (); + i = ipv4->AddInterface (m_n1Tap); + ipv4->AddAddress (i, Ipv4InterfaceAddress (Ipv4Address ("11.0.0.1"), Ipv4Mask ("255.255.255.0"))); + ipv4->SetUp (i); + + // n3 tap device + m_n3Tap = CreateObject (); + m_n3Tap->SetSendFromCallback (MakeCallback (&Tunnel::N3VirtualSend, this)); + n3->AddDevice (m_n3Tap); + ipv4 = n3->GetObject (); + i = ipv4->AddInterface (m_n3Tap); + ipv4->AddAddress (i, Ipv4InterfaceAddress (Ipv4Address ("11.0.0.254"), Ipv4Mask ("255.255.255.0"))); + ipv4->SetUp (i); + + } + + +}; + + + +int +main (int argc, char *argv[]) +{ + // Users may find it convenient to turn on explicit debugging + // for selected modules; the below lines suggest how to do this +#if 0 + LogComponentEnable ("SimpleGlobalRoutingExample", LOG_LEVEL_INFO); +#endif + + // Set up some default values for the simulation. Use the + Config::SetDefault ("ns3::OnOffApplication::PacketSize", UintegerValue (210)); + Config::SetDefault ("ns3::OnOffApplication::DataRate", StringValue ("448kb/s")); + + //DefaultValue::Bind ("DropTailQueue::m_maxPackets", 30); + + // Allow the user to override any of the defaults and the above + // DefaultValue::Bind ()s at run-time, via command-line arguments + CommandLine cmd; + cmd.Parse (argc, argv); + + // Here, we will explicitly create four nodes. In more sophisticated + // topologies, we could configure a node factory. + NS_LOG_INFO ("Create nodes."); + NodeContainer c; + c.Create (4); + NodeContainer n0n2 = NodeContainer (c.Get(0), c.Get (2)); + NodeContainer n1n2 = NodeContainer (c.Get(1), c.Get (2)); + NodeContainer n3n2 = NodeContainer (c.Get(3), c.Get (2)); + + InternetStackHelper internet; + internet.Install (c); + + // We create the channels first without any IP addressing information + NS_LOG_INFO ("Create channels."); + PointToPointHelper p2p; + p2p.SetDeviceAttribute ("DataRate", StringValue ("5Mbps")); + p2p.SetChannelAttribute ("Delay", StringValue ("2ms")); + NetDeviceContainer d0d2 = p2p.Install (n0n2); + + NetDeviceContainer d1d2 = p2p.Install (n1n2); + + p2p.SetDeviceAttribute ("DataRate", StringValue ("1500kbps")); + p2p.SetChannelAttribute ("Delay", StringValue ("10ms")); + NetDeviceContainer d3d2 = p2p.Install (n3n2); + + // Later, we add IP addresses. + NS_LOG_INFO ("Assign IP Addresses."); + Ipv4AddressHelper ipv4; + ipv4.SetBase ("10.1.1.0", "255.255.255.0"); + Ipv4InterfaceContainer i0i2 = ipv4.Assign (d0d2); + + ipv4.SetBase ("10.1.2.0", "255.255.255.0"); + Ipv4InterfaceContainer i1i2 = ipv4.Assign (d1d2); + + ipv4.SetBase ("10.1.3.0", "255.255.255.0"); + Ipv4InterfaceContainer i3i2 = ipv4.Assign (d3d2); + + // Create router nodes, initialize routing database and set up the routing + // tables in the nodes. + GlobalRouteManager::PopulateRoutingTables (); + + // Add the tunnels + Tunnel tunnel (c.Get (3), c.Get (0), c.Get (1), + i3i2.GetAddress (0), i0i2.GetAddress (0), i1i2.GetAddress (0)); + + // Create the OnOff application to send UDP datagrams of size + // 210 bytes at a rate of 448 Kb/s + NS_LOG_INFO ("Create Applications."); + uint16_t port = 9; // Discard port (RFC 863) + OnOffHelper onoff ("ns3::UdpSocketFactory", + Address (InetSocketAddress (Ipv4Address ("11.0.0.254"), port))); + onoff.SetAttribute ("OnTime", RandomVariableValue (ConstantVariable (1))); + onoff.SetAttribute ("OffTime", RandomVariableValue (ConstantVariable (0))); + ApplicationContainer apps = onoff.Install (c.Get (0)); + apps.Start (Seconds (1.0)); + apps.Stop (Seconds (10.0)); + + // Create a packet sink to receive these packets + PacketSinkHelper sink ("ns3::UdpSocketFactory", + Address (InetSocketAddress (Ipv4Address::GetAny (), port))); + apps = sink.Install (c.Get (3)); + apps.Start (Seconds (1.0)); + apps.Stop (Seconds (10.0)); + + // Create a similar flow from n3 to n1, starting at time 1.1 seconds + onoff.SetAttribute ("Remote", + AddressValue (InetSocketAddress (Ipv4Address ("11.0.0.2"), port))); + apps = onoff.Install (c.Get (3)); + apps.Start (Seconds (1.1)); + apps.Stop (Seconds (10.0)); + + // Create a packet sink to receive these packets + apps = sink.Install (c.Get (1)); + apps.Start (Seconds (1.1)); + apps.Stop (Seconds (10.0)); + + std::ofstream ascii; + ascii.open ("tap-net-device.tr"); + PointToPointHelper::EnablePcapAll ("tap-net-device"); + PointToPointHelper::EnableAsciiAll (ascii); + + NS_LOG_INFO ("Run Simulation."); + Simulator::Run (); + Simulator::Destroy (); + NS_LOG_INFO ("Done."); + + return 0; +} diff --git a/examples/wscript b/examples/wscript index 03ea28855..0af2e4583 100644 --- a/examples/wscript +++ b/examples/wscript @@ -40,6 +40,10 @@ def build(bld): ['point-to-point', 'internet-stack', 'global-routing']) obj.source = 'simple-global-routing.cc' + obj = bld.create_ns3_program('tap-net-device', + ['point-to-point', 'internet-stack', 'global-routing', 'tap-net-device']) + obj.source = 'tap-net-device.cc' + obj = bld.create_ns3_program('simple-alternate-routing', ['point-to-point', 'internet-stack', 'global-routing']) obj.source = 'simple-alternate-routing.cc' From 05705c796ca0dac4da5450b3f0b74fe5769b96f5 Mon Sep 17 00:00:00 2001 From: "Gustavo J. A. M. Carneiro" Date: Tue, 2 Jun 2009 18:35:05 +0100 Subject: [PATCH 04/20] api docs fixes --- src/devices/tap-net-device/tap-net-device.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/devices/tap-net-device/tap-net-device.h b/src/devices/tap-net-device/tap-net-device.h index df0963350..2ee21a665 100644 --- a/src/devices/tap-net-device/tap-net-device.h +++ b/src/devices/tap-net-device/tap-net-device.h @@ -51,6 +51,10 @@ namespace ns3 { class TapNetDevice : public NetDevice { public: + /** + * Callback the be invoked when the TapNetDevice is asked to queue/transmit a packet. + * For more information, consult the documentation of NetDevice::SendFrom(). + */ typedef Callback, const Address&, const Address&, uint16_t> SendFromCallback; static TypeId GetTypeId (void); @@ -87,7 +91,7 @@ public: /** - * \param p packet sent from below up to Network Device + * \param packet packet sent from below up to Network Device * \param protocol Protocol type * \param source the address of the sender of this packet. * \returns true if the packet was forwarded successfully, @@ -100,7 +104,7 @@ public: /** - * \param p packet sent from below up to Network Device + * \param packet packet sent from below up to Network Device * \param protocol Protocol type * \param source the address of the sender of this packet. * \param destination the address of the receiver of this packet. From e5d8b2195492cb6ebbd6bff34cf7147db6af9457 Mon Sep 17 00:00:00 2001 From: "Gustavo J. A. M. Carneiro" Date: Tue, 9 Jun 2009 17:42:57 +0100 Subject: [PATCH 05/20] Rename TapNetDevice to VirtualNetDevice --- ...ap-net-device.cc => virtual-net-device.cc} | 16 ++-- examples/wscript | 6 +- .../virtual-net-device.cc} | 78 +++++++++---------- .../virtual-net-device.h} | 20 ++--- .../waf | 0 .../wscript | 8 +- src/wscript | 2 +- 7 files changed, 65 insertions(+), 65 deletions(-) rename examples/{tap-net-device.cc => virtual-net-device.cc} (96%) rename src/devices/{tap-net-device/tap-net-device.cc => virtual-net-device/virtual-net-device.cc} (58%) rename src/devices/{tap-net-device/tap-net-device.h => virtual-net-device/virtual-net-device.h} (91%) rename src/devices/{tap-net-device => virtual-net-device}/waf (100%) rename src/devices/{tap-net-device => virtual-net-device}/wscript (54%) diff --git a/examples/tap-net-device.cc b/examples/virtual-net-device.cc similarity index 96% rename from examples/tap-net-device.cc rename to examples/virtual-net-device.cc index f0d21f66f..86b945bf8 100644 --- a/examples/tap-net-device.cc +++ b/examples/virtual-net-device.cc @@ -56,11 +56,11 @@ #include "ns3/node-module.h" #include "ns3/helper-module.h" #include "ns3/global-route-manager.h" -#include "ns3/tap-net-device.h" +#include "ns3/virtual-net-device.h" using namespace ns3; -NS_LOG_COMPONENT_DEFINE ("TapNetDeviceExample"); +NS_LOG_COMPONENT_DEFINE ("VirtualNetDeviceExample"); class Tunnel { @@ -71,9 +71,9 @@ class Tunnel Ipv4Address m_n0Address; Ipv4Address m_n1Address; UniformVariable m_rng; - Ptr m_n0Tap; - Ptr m_n1Tap; - Ptr m_n3Tap; + Ptr m_n0Tap; + Ptr m_n1Tap; + Ptr m_n3Tap; bool @@ -135,7 +135,7 @@ public: m_n1Socket->SetRecvCallback (MakeCallback (&Tunnel::N1SocketRecv, this)); // n0 tap device - m_n0Tap = CreateObject (); + m_n0Tap = CreateObject (); m_n0Tap->SetSendFromCallback (MakeCallback (&Tunnel::N0N1VirtualSend, this)); n0->AddDevice (m_n0Tap); Ptr ipv4 = n0->GetObject (); @@ -144,7 +144,7 @@ public: ipv4->SetUp (i); // n1 tap device - m_n1Tap = CreateObject (); + m_n1Tap = CreateObject (); m_n1Tap->SetSendFromCallback (MakeCallback (&Tunnel::N0N1VirtualSend, this)); n1->AddDevice (m_n1Tap); ipv4 = n1->GetObject (); @@ -153,7 +153,7 @@ public: ipv4->SetUp (i); // n3 tap device - m_n3Tap = CreateObject (); + m_n3Tap = CreateObject (); m_n3Tap->SetSendFromCallback (MakeCallback (&Tunnel::N3VirtualSend, this)); n3->AddDevice (m_n3Tap); ipv4 = n3->GetObject (); diff --git a/examples/wscript b/examples/wscript index 5c920cefb..906355a4f 100644 --- a/examples/wscript +++ b/examples/wscript @@ -40,9 +40,9 @@ def build(bld): ['point-to-point', 'internet-stack', 'global-routing']) obj.source = 'simple-global-routing.cc' - obj = bld.create_ns3_program('tap-net-device', - ['point-to-point', 'internet-stack', 'global-routing', 'tap-net-device']) - obj.source = 'tap-net-device.cc' + obj = bld.create_ns3_program('virtual-net-device', + ['point-to-point', 'internet-stack', 'global-routing', 'virtual-net-device']) + obj.source = 'virtual-net-device.cc' obj = bld.create_ns3_program('simple-alternate-routing', ['point-to-point', 'internet-stack', 'global-routing']) diff --git a/src/devices/tap-net-device/tap-net-device.cc b/src/devices/virtual-net-device/virtual-net-device.cc similarity index 58% rename from src/devices/tap-net-device/tap-net-device.cc rename to src/devices/virtual-net-device/virtual-net-device.cc index 86633fdad..1834486a5 100644 --- a/src/devices/tap-net-device/tap-net-device.cc +++ b/src/devices/virtual-net-device/virtual-net-device.cc @@ -24,32 +24,32 @@ #include "ns3/mac48-address.h" #include "ns3/llc-snap-header.h" #include "ns3/error-model.h" -#include "tap-net-device.h" +#include "virtual-net-device.h" #include "ns3/channel.h" #include "ns3/trace-source-accessor.h" -NS_LOG_COMPONENT_DEFINE ("TapNetDevice"); +NS_LOG_COMPONENT_DEFINE ("VirtualNetDevice"); namespace ns3 { -NS_OBJECT_ENSURE_REGISTERED (TapNetDevice); +NS_OBJECT_ENSURE_REGISTERED (VirtualNetDevice); TypeId -TapNetDevice::GetTypeId (void) +VirtualNetDevice::GetTypeId (void) { - static TypeId tid = TypeId ("ns3::TapNetDevice") + static TypeId tid = TypeId ("ns3::VirtualNetDevice") .SetParent () - .AddConstructor () + .AddConstructor () .AddTraceSource ("Rx", "Received payload from the MAC layer.", - MakeTraceSourceAccessor (&TapNetDevice::m_rxTrace)) + MakeTraceSourceAccessor (&VirtualNetDevice::m_rxTrace)) .AddTraceSource ("Tx", "Send payload to the MAC layer.", - MakeTraceSourceAccessor (&TapNetDevice::m_txTrace)) + MakeTraceSourceAccessor (&VirtualNetDevice::m_txTrace)) ; return tid; } -TapNetDevice::TapNetDevice () +VirtualNetDevice::VirtualNetDevice () { m_needsArp = false; m_supportsSendFrom = true; @@ -58,45 +58,45 @@ TapNetDevice::TapNetDevice () void -TapNetDevice::SetSendFromCallback (SendFromCallback sendCb) +VirtualNetDevice::SetSendFromCallback (SendFromCallback sendCb) { m_sendCb = sendCb; } void -TapNetDevice::SetNeedsArp (bool needsArp) +VirtualNetDevice::SetNeedsArp (bool needsArp) { m_needsArp = needsArp; } void -TapNetDevice::SetSupportsSendFrom (bool supportsSendFrom) +VirtualNetDevice::SetSupportsSendFrom (bool supportsSendFrom) { m_supportsSendFrom = supportsSendFrom; } bool -TapNetDevice::SetMtu (const uint16_t mtu) +VirtualNetDevice::SetMtu (const uint16_t mtu) { m_mtu = mtu; return true; } -TapNetDevice::~TapNetDevice() +VirtualNetDevice::~VirtualNetDevice() { NS_LOG_FUNCTION_NOARGS (); } -void TapNetDevice::DoDispose() +void VirtualNetDevice::DoDispose() { NS_LOG_FUNCTION_NOARGS (); NetDevice::DoDispose (); } bool -TapNetDevice::Receive (Ptr packet, uint16_t protocol, const Address &address) +VirtualNetDevice::Receive (Ptr packet, uint16_t protocol, const Address &address) { if (m_rxCallback (this, packet, protocol, address)) { @@ -107,7 +107,7 @@ TapNetDevice::Receive (Ptr packet, uint16_t protocol, const Address &add } bool -TapNetDevice::PromiscReceive (Ptr packet, uint16_t protocol, +VirtualNetDevice::PromiscReceive (Ptr packet, uint16_t protocol, const Address &source, const Address &destination, PacketType packetType) { @@ -121,89 +121,89 @@ TapNetDevice::PromiscReceive (Ptr packet, uint16_t protocol, void -TapNetDevice::SetIfIndex (const uint32_t index) +VirtualNetDevice::SetIfIndex (const uint32_t index) { m_index = index; } uint32_t -TapNetDevice::GetIfIndex (void) const +VirtualNetDevice::GetIfIndex (void) const { return m_index; } Ptr -TapNetDevice::GetChannel (void) const +VirtualNetDevice::GetChannel (void) const { return Ptr (); } Address -TapNetDevice::GetAddress (void) const +VirtualNetDevice::GetAddress (void) const { return Mac48Address (); } uint16_t -TapNetDevice::GetMtu (void) const +VirtualNetDevice::GetMtu (void) const { return m_mtu; } bool -TapNetDevice::IsLinkUp (void) const +VirtualNetDevice::IsLinkUp (void) const { return true; } void -TapNetDevice::SetLinkChangeCallback (Callback callback) +VirtualNetDevice::SetLinkChangeCallback (Callback callback) { } bool -TapNetDevice::IsBroadcast (void) const +VirtualNetDevice::IsBroadcast (void) const { return true; } Address -TapNetDevice::GetBroadcast (void) const +VirtualNetDevice::GetBroadcast (void) const { return Mac48Address ("ff:ff:ff:ff:ff:ff"); } bool -TapNetDevice::IsMulticast (void) const +VirtualNetDevice::IsMulticast (void) const { return false; } -Address TapNetDevice::GetMulticast (Ipv4Address multicastGroup) const +Address VirtualNetDevice::GetMulticast (Ipv4Address multicastGroup) const { return Mac48Address ("ff:ff:ff:ff:ff:ff"); } -Address TapNetDevice::GetMulticast (Ipv6Address addr) const +Address VirtualNetDevice::GetMulticast (Ipv6Address addr) const { return Mac48Address ("ff:ff:ff:ff:ff:ff"); } bool -TapNetDevice::IsPointToPoint (void) const +VirtualNetDevice::IsPointToPoint (void) const { return true; } bool -TapNetDevice::Send (Ptr packet, const Address& dest, uint16_t protocolNumber) +VirtualNetDevice::Send (Ptr packet, const Address& dest, uint16_t protocolNumber) { return SendFrom (packet, GetAddress (), dest, protocolNumber); } bool -TapNetDevice::SendFrom (Ptr packet, const Address& source, const Address& dest, uint16_t protocolNumber) +VirtualNetDevice::SendFrom (Ptr packet, const Address& source, const Address& dest, uint16_t protocolNumber) { if (m_sendCb (packet, source, dest, protocolNumber)) { @@ -214,42 +214,42 @@ TapNetDevice::SendFrom (Ptr packet, const Address& source, const Address } Ptr -TapNetDevice::GetNode (void) const +VirtualNetDevice::GetNode (void) const { return m_node; } void -TapNetDevice::SetNode (Ptr node) +VirtualNetDevice::SetNode (Ptr node) { m_node = node; } bool -TapNetDevice::NeedsArp (void) const +VirtualNetDevice::NeedsArp (void) const { return m_needsArp; } void -TapNetDevice::SetReceiveCallback (NetDevice::ReceiveCallback cb) +VirtualNetDevice::SetReceiveCallback (NetDevice::ReceiveCallback cb) { m_rxCallback = cb; } void -TapNetDevice::SetPromiscReceiveCallback (NetDevice::PromiscReceiveCallback cb) +VirtualNetDevice::SetPromiscReceiveCallback (NetDevice::PromiscReceiveCallback cb) { m_promiscRxCallback = cb; } bool -TapNetDevice::SupportsSendFrom () const +VirtualNetDevice::SupportsSendFrom () const { return m_supportsSendFrom; } -bool TapNetDevice::IsBridge (void) const +bool VirtualNetDevice::IsBridge (void) const { return false; } diff --git a/src/devices/tap-net-device/tap-net-device.h b/src/devices/virtual-net-device/virtual-net-device.h similarity index 91% rename from src/devices/tap-net-device/tap-net-device.h rename to src/devices/virtual-net-device/virtual-net-device.h index 2ee21a665..53e78c3a4 100644 --- a/src/devices/tap-net-device/tap-net-device.h +++ b/src/devices/virtual-net-device/virtual-net-device.h @@ -18,8 +18,8 @@ * Author: Gustavo J. A. M. Carneiro */ -#ifndef TAP_NET_DEVICE_H -#define TAP_NET_DEVICE_H +#ifndef VIRTUAL_NET_DEVICE_H +#define VIRTUAL_NET_DEVICE_H #include "ns3/address.h" #include "ns3/node.h" @@ -33,34 +33,34 @@ namespace ns3 { /** - * \class TapNetDevice + * \class VirtualNetDevice * \brief A virtual device, similar to Linux TAP interfaces. * - * A TapNetDevice is a "virtual" NetDevice implementation which + * A VirtualNetDevice is a "virtual" NetDevice implementation which * delegates to a user callback (see method SetSendFromCallback()) the * task of actually transmitting a packet. It also allows the user * code to inject the packet as if it had been received by the - * TapNetDevice. Together, these features allow one to build tunnels. + * VirtualNetDevice. Together, these features allow one to build tunnels. * For instance, by transmitting packets into a UDP socket we end up * building an IP-over-UDP-over-IP tunnel. * * The same thing could be accomplished by subclassing NetDevice - * directly. However, TapNetDevice is usually much simpler to program + * directly. However, VirtualNetDevice is usually much simpler to program * than a NetDevice subclass. */ -class TapNetDevice : public NetDevice +class VirtualNetDevice : public NetDevice { public: /** - * Callback the be invoked when the TapNetDevice is asked to queue/transmit a packet. + * Callback the be invoked when the VirtualNetDevice is asked to queue/transmit a packet. * For more information, consult the documentation of NetDevice::SendFrom(). */ typedef Callback, const Address&, const Address&, uint16_t> SendFromCallback; static TypeId GetTypeId (void); - TapNetDevice (); + VirtualNetDevice (); - virtual ~TapNetDevice (); + virtual ~VirtualNetDevice (); /** * \brief Set the user callback to be called when a L2 packet is to be transmitted diff --git a/src/devices/tap-net-device/waf b/src/devices/virtual-net-device/waf similarity index 100% rename from src/devices/tap-net-device/waf rename to src/devices/virtual-net-device/waf diff --git a/src/devices/tap-net-device/wscript b/src/devices/virtual-net-device/wscript similarity index 54% rename from src/devices/tap-net-device/wscript rename to src/devices/virtual-net-device/wscript index f8bad170c..f11b37c20 100644 --- a/src/devices/tap-net-device/wscript +++ b/src/devices/virtual-net-device/wscript @@ -2,13 +2,13 @@ def build(bld): - module = bld.create_ns3_module('tap-net-device', ['node']) + module = bld.create_ns3_module('virtual-net-device', ['node']) module.source = [ - 'tap-net-device.cc', + 'virtual-net-device.cc', ] headers = bld.new_task_gen('ns3header') - headers.module = 'tap-net-device' + headers.module = 'virtual-net-device' headers.source = [ - 'tap-net-device.h', + 'virtual-net-device.h', ] diff --git a/src/wscript b/src/wscript index ffcfdd9b3..3d57ed021 100644 --- a/src/wscript +++ b/src/wscript @@ -23,7 +23,7 @@ all_modules = ( 'devices/emu', 'devices/bridge', 'devices/tap-bridge', - 'devices/tap-net-device', + 'devices/virtual-net-device', 'applications/onoff', 'applications/packet-sink', 'applications/udp-echo', From 14167f7052967715f5acc7078ba242d4870bcad0 Mon Sep 17 00:00:00 2001 From: "Gustavo J. A. M. Carneiro" Date: Tue, 9 Jun 2009 17:48:51 +0100 Subject: [PATCH 06/20] cleanup virtual netdevice example --- examples/virtual-net-device.cc | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/examples/virtual-net-device.cc b/examples/virtual-net-device.cc index 86b945bf8..9f1fa51a6 100644 --- a/examples/virtual-net-device.cc +++ b/examples/virtual-net-device.cc @@ -18,8 +18,6 @@ * Originally authored by Steve McCanne, 12/19/1996 */ -// Port of ns-2/tcl/ex/simple.tcl to ns-3 -// // Network topology // // n0 @@ -36,7 +34,7 @@ // - UDP packet size of 210 bytes, with per-packet interval 0.00375 sec. // (i.e., DataRate of 448,000 bps) // - DropTail queues -// - Tracing of queues and packet receptions to file "simple-global-routing.tr" +// - Tracing of queues and packet receptions to file "virtual-net-device.tr" // Tunneling changes (relative to the simple-global-routing example): // n0 will receive an extra virtual interface with address 11.0.0.1 @@ -45,6 +43,10 @@ // The flows will be between 11.0.0.x (tunnel) addresses instead of 10.1.x.y ones // n3 will decide, on a per-packet basis, via random number, whether to // send the packet to n0 or to n1. +// +// Note: here we create a tunnel where IP packets are tunneled over +// UDP/IP, but tunneling directly IP-over-IP would also be possible; +// see src/node/ipv4-raw-socket-factory.h. #include #include @@ -174,7 +176,7 @@ main (int argc, char *argv[]) // Users may find it convenient to turn on explicit debugging // for selected modules; the below lines suggest how to do this #if 0 - LogComponentEnable ("SimpleGlobalRoutingExample", LOG_LEVEL_INFO); + LogComponentEnable ("VirtualNetDeviceExample", LOG_LEVEL_INFO); #endif // Set up some default values for the simulation. Use the @@ -265,8 +267,8 @@ main (int argc, char *argv[]) apps.Stop (Seconds (10.0)); std::ofstream ascii; - ascii.open ("tap-net-device.tr"); - PointToPointHelper::EnablePcapAll ("tap-net-device"); + ascii.open ("virtual-net-device.tr"); + PointToPointHelper::EnablePcapAll ("virtual-net-device"); PointToPointHelper::EnableAsciiAll (ascii); NS_LOG_INFO ("Run Simulation."); From 858f8d61f1e692f177fd410a5e3990744e290de0 Mon Sep 17 00:00:00 2001 From: "Gustavo J. A. M. Carneiro" Date: Tue, 9 Jun 2009 18:00:24 +0100 Subject: [PATCH 07/20] Make the value returned by VirtualNetDevice::IsPointToPoint configurable. --- .../virtual-net-device/virtual-net-device.cc | 9 ++++++++- src/devices/virtual-net-device/virtual-net-device.h | 13 +++++++++++-- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/devices/virtual-net-device/virtual-net-device.cc b/src/devices/virtual-net-device/virtual-net-device.cc index 1834486a5..e6acd7a61 100644 --- a/src/devices/virtual-net-device/virtual-net-device.cc +++ b/src/devices/virtual-net-device/virtual-net-device.cc @@ -54,6 +54,7 @@ VirtualNetDevice::VirtualNetDevice () m_needsArp = false; m_supportsSendFrom = true; m_mtu = 65535; + m_isPointToPoint = true; } @@ -75,6 +76,12 @@ VirtualNetDevice::SetSupportsSendFrom (bool supportsSendFrom) m_supportsSendFrom = supportsSendFrom; } +void +VirtualNetDevice::SetIsPointToPoint (bool isPointToPoint) +{ + m_isPointToPoint = isPointToPoint; +} + bool VirtualNetDevice::SetMtu (const uint16_t mtu) { @@ -193,7 +200,7 @@ Address VirtualNetDevice::GetMulticast (Ipv6Address addr) const bool VirtualNetDevice::IsPointToPoint (void) const { - return true; + return m_isPointToPoint; } bool diff --git a/src/devices/virtual-net-device/virtual-net-device.h b/src/devices/virtual-net-device/virtual-net-device.h index 53e78c3a4..ea341440e 100644 --- a/src/devices/virtual-net-device/virtual-net-device.h +++ b/src/devices/virtual-net-device/virtual-net-device.h @@ -34,7 +34,7 @@ namespace ns3 { /** * \class VirtualNetDevice - * \brief A virtual device, similar to Linux TAP interfaces. + * \brief A virtual device, similar to Linux TUN/TAP interfaces. * * A VirtualNetDevice is a "virtual" NetDevice implementation which * delegates to a user callback (see method SetSendFromCallback()) the @@ -42,7 +42,7 @@ namespace ns3 { * code to inject the packet as if it had been received by the * VirtualNetDevice. Together, these features allow one to build tunnels. * For instance, by transmitting packets into a UDP socket we end up - * building an IP-over-UDP-over-IP tunnel. + * building an IP-over-UDP-over-IP tunnel, or IP-over-IP tunnels. * * The same thing could be accomplished by subclassing NetDevice * directly. However, VirtualNetDevice is usually much simpler to program @@ -77,6 +77,14 @@ public: */ void SetNeedsArp (bool needsArp); + /** + * \brief Configure whether the virtual device is point-to-point + * + * \param isPointToPoint the value that should be returned by the + * IsPointToPoint method for this instance. + */ + void SetIsPointToPoint (bool isPointToPoint); + /** * \brief Configure whether the virtual device supports SendFrom */ @@ -160,6 +168,7 @@ private: uint16_t m_mtu; bool m_needsArp; bool m_supportsSendFrom; + bool m_isPointToPoint; }; }; // namespace ns3 From 00d790a27b5891e7a12288077c6a830898f715b4 Mon Sep 17 00:00:00 2001 From: "Gustavo J. A. M. Carneiro" Date: Thu, 11 Jun 2009 16:02:10 +0100 Subject: [PATCH 08/20] VirtualNetDevice: Single Receive() (promisc. one); add trace sources to align better with CsmaNetDevice. Add SetAddress() --- examples/virtual-net-device.cc | 15 ++-- .../virtual-net-device/virtual-net-device.cc | 81 +++++++++++++------ .../virtual-net-device/virtual-net-device.h | 44 +++++----- 3 files changed, 88 insertions(+), 52 deletions(-) diff --git a/examples/virtual-net-device.cc b/examples/virtual-net-device.cc index 9f1fa51a6..a482d9dff 100644 --- a/examples/virtual-net-device.cc +++ b/examples/virtual-net-device.cc @@ -103,19 +103,19 @@ class Tunnel void N3SocketRecv (Ptr socket) { Ptr packet = socket->Recv (65535, 0); - m_n3Tap->Receive (packet, 0x0800, Address ()); + m_n3Tap->Receive (packet, 0x0800, m_n3Tap->GetAddress (), m_n3Tap->GetAddress (), NetDevice::PACKET_HOST); } void N0SocketRecv (Ptr socket) { Ptr packet = socket->Recv (65535, 0); - m_n0Tap->Receive (packet, 0x0800, Address ()); + m_n0Tap->Receive (packet, 0x0800, m_n0Tap->GetAddress (), m_n0Tap->GetAddress (), NetDevice::PACKET_HOST); } void N1SocketRecv (Ptr socket) { Ptr packet = socket->Recv (65535, 0); - m_n0Tap->Receive (packet, 0x0800, Address ()); + m_n1Tap->Receive (packet, 0x0800, m_n1Tap->GetAddress (), m_n1Tap->GetAddress (), NetDevice::PACKET_HOST); } public: @@ -138,7 +138,8 @@ public: // n0 tap device m_n0Tap = CreateObject (); - m_n0Tap->SetSendFromCallback (MakeCallback (&Tunnel::N0N1VirtualSend, this)); + m_n0Tap->SetAddress (Mac48Address ("11:00:01:02:03:01")); + m_n0Tap->SetSendCallback (MakeCallback (&Tunnel::N0N1VirtualSend, this)); n0->AddDevice (m_n0Tap); Ptr ipv4 = n0->GetObject (); uint32_t i = ipv4->AddInterface (m_n0Tap); @@ -147,7 +148,8 @@ public: // n1 tap device m_n1Tap = CreateObject (); - m_n1Tap->SetSendFromCallback (MakeCallback (&Tunnel::N0N1VirtualSend, this)); + m_n1Tap->SetAddress (Mac48Address ("11:00:01:02:03:02")); + m_n1Tap->SetSendCallback (MakeCallback (&Tunnel::N0N1VirtualSend, this)); n1->AddDevice (m_n1Tap); ipv4 = n1->GetObject (); i = ipv4->AddInterface (m_n1Tap); @@ -156,7 +158,8 @@ public: // n3 tap device m_n3Tap = CreateObject (); - m_n3Tap->SetSendFromCallback (MakeCallback (&Tunnel::N3VirtualSend, this)); + m_n3Tap->SetAddress (Mac48Address ("11:00:01:02:03:04")); + m_n3Tap->SetSendCallback (MakeCallback (&Tunnel::N3VirtualSend, this)); n3->AddDevice (m_n3Tap); ipv4 = n3->GetObject (); i = ipv4->AddInterface (m_n3Tap); diff --git a/src/devices/virtual-net-device/virtual-net-device.cc b/src/devices/virtual-net-device/virtual-net-device.cc index e6acd7a61..c97ad98fb 100644 --- a/src/devices/virtual-net-device/virtual-net-device.cc +++ b/src/devices/virtual-net-device/virtual-net-device.cc @@ -41,10 +41,26 @@ VirtualNetDevice::GetTypeId (void) static TypeId tid = TypeId ("ns3::VirtualNetDevice") .SetParent () .AddConstructor () - .AddTraceSource ("Rx", "Received payload from the MAC layer.", - MakeTraceSourceAccessor (&VirtualNetDevice::m_rxTrace)) - .AddTraceSource ("Tx", "Send payload to the MAC layer.", - MakeTraceSourceAccessor (&VirtualNetDevice::m_txTrace)) + .AddTraceSource ("MacTx", + "Trace source indicating a packet has arrived for transmission by this device", + MakeTraceSourceAccessor (&VirtualNetDevice::m_macTxTrace)) + .AddTraceSource ("MacPromiscRx", + "A packet has been received by this device, has been passed up from the physical layer " + "and is being forwarded up the local protocol stack. This is a promiscuous trace,", + MakeTraceSourceAccessor (&VirtualNetDevice::m_macPromiscRxTrace)) + .AddTraceSource ("MacRx", + "A packet has been received by this device, has been passed up from the physical layer " + "and is being forwarded up the local protocol stack. This is a non-promiscuous trace,", + MakeTraceSourceAccessor (&VirtualNetDevice::m_macRxTrace)) + // + // Trace sources designed to simulate a packet sniffer facility (tcpdump). + // + .AddTraceSource ("Sniffer", + "Trace source simulating a non-promiscuous packet sniffer attached to the device", + MakeTraceSourceAccessor (&VirtualNetDevice::m_snifferTrace)) + .AddTraceSource ("PromiscSniffer", + "Trace source simulating a promiscuous packet sniffer attached to the device", + MakeTraceSourceAccessor (&VirtualNetDevice::m_promiscSnifferTrace)) ; return tid; } @@ -59,7 +75,7 @@ VirtualNetDevice::VirtualNetDevice () void -VirtualNetDevice::SetSendFromCallback (SendFromCallback sendCb) +VirtualNetDevice::SetSendCallback (SendCallback sendCb) { m_sendCb = sendCb; } @@ -103,27 +119,34 @@ void VirtualNetDevice::DoDispose() } bool -VirtualNetDevice::Receive (Ptr packet, uint16_t protocol, const Address &address) +VirtualNetDevice::Receive (Ptr packet, uint16_t protocol, + const Address &source, const Address &destination, + PacketType packetType) { - if (m_rxCallback (this, packet, protocol, address)) + // + // For all kinds of packetType we receive, we hit the promiscuous sniffer + // hook and pass a copy up to the promiscuous callback. Pass a copy to + // make sure that nobody messes with our packet. + // + m_promiscSnifferTrace (packet); + if (!m_promiscRxCallback.IsNull ()) { - m_rxTrace (packet); - return true; + m_macPromiscRxTrace (packet); + m_promiscRxCallback (this, packet, protocol, source, destination, packetType); } - return false; -} -bool -VirtualNetDevice::PromiscReceive (Ptr packet, uint16_t protocol, - const Address &source, const Address &destination, - PacketType packetType) -{ - if (m_promiscRxCallback (this, packet, protocol, source, destination, packetType)) + // + // If this packet is not destined for some other host, it must be for us + // as either a broadcast, multicast or unicast. We need to hit the mac + // packet received trace hook and forward the packet up the stack. + // + if (packetType != PACKET_OTHERHOST) { - m_rxTrace (packet); - return true; + m_snifferTrace (packet); + m_macRxTrace (packet); + return m_rxCallback (this, packet, protocol, source); } - return false; + return true; } @@ -148,7 +171,13 @@ VirtualNetDevice::GetChannel (void) const Address VirtualNetDevice::GetAddress (void) const { - return Mac48Address (); + return m_myAddress; +} + +void +VirtualNetDevice::SetAddress (Address addr) +{ + m_myAddress = addr; } uint16_t @@ -206,15 +235,21 @@ VirtualNetDevice::IsPointToPoint (void) const bool VirtualNetDevice::Send (Ptr packet, const Address& dest, uint16_t protocolNumber) { - return SendFrom (packet, GetAddress (), dest, protocolNumber); + m_macTxTrace (packet); + if (m_sendCb (packet, GetAddress (), dest, protocolNumber)) + { + return true; + } + return false; } bool VirtualNetDevice::SendFrom (Ptr packet, const Address& source, const Address& dest, uint16_t protocolNumber) { + NS_ASSERT (m_supportsSendFrom); + m_macTxTrace (packet); if (m_sendCb (packet, source, dest, protocolNumber)) { - m_txTrace (packet); return true; } return false; diff --git a/src/devices/virtual-net-device/virtual-net-device.h b/src/devices/virtual-net-device/virtual-net-device.h index ea341440e..0f34f494c 100644 --- a/src/devices/virtual-net-device/virtual-net-device.h +++ b/src/devices/virtual-net-device/virtual-net-device.h @@ -37,7 +37,7 @@ namespace ns3 { * \brief A virtual device, similar to Linux TUN/TAP interfaces. * * A VirtualNetDevice is a "virtual" NetDevice implementation which - * delegates to a user callback (see method SetSendFromCallback()) the + * delegates to a user callback (see method SetSendCallback()) the * task of actually transmitting a packet. It also allows the user * code to inject the packet as if it had been received by the * VirtualNetDevice. Together, these features allow one to build tunnels. @@ -55,7 +55,7 @@ public: * Callback the be invoked when the VirtualNetDevice is asked to queue/transmit a packet. * For more information, consult the documentation of NetDevice::SendFrom(). */ - typedef Callback, const Address&, const Address&, uint16_t> SendFromCallback; + typedef Callback, const Address&, const Address&, uint16_t> SendCallback; static TypeId GetTypeId (void); VirtualNetDevice (); @@ -66,7 +66,7 @@ public: * \brief Set the user callback to be called when a L2 packet is to be transmitted * \param transmitCb the new transmit callback */ - void SetSendFromCallback (SendFromCallback transmitCb); + void SetSendCallback (SendCallback transmitCb); /** * \brief Configure whether the virtual device needs ARP @@ -98,19 +98,6 @@ public: bool SetMtu (const uint16_t mtu); - /** - * \param packet packet sent from below up to Network Device - * \param protocol Protocol type - * \param source the address of the sender of this packet. - * \returns true if the packet was forwarded successfully, - * false otherwise. - * - * Forward a "virtually received" packet up the node's protocol - * stack. - */ - bool Receive (Ptr packet, uint16_t protocol, const Address &source); - - /** * \param packet packet sent from below up to Network Device * \param protocol Protocol type @@ -119,14 +106,21 @@ public: * \param packetType type of packet received (broadcast/multicast/unicast/otherhost) * \returns true if the packet was forwarded successfully, false otherwise. * - * Forward a "virtually received (in promiscuous mode)" packet up + * Forward a "virtually received" packet up * the node's protocol stack. */ - bool PromiscReceive (Ptr packet, uint16_t protocol, - const Address &source, const Address &destination, - PacketType packetType); + bool Receive (Ptr packet, uint16_t protocol, + const Address &source, const Address &destination, + PacketType packetType); + /** + * Set the MAC address of the the network device. + * + * \param addr The Address to use as the address of the device. + */ + void SetAddress (Address addr); + // inherited from NetDevice base class. virtual void SetIfIndex(const uint32_t index); virtual uint32_t GetIfIndex(void) const; @@ -157,9 +151,13 @@ protected: private: - SendFromCallback m_sendCb; - TracedCallback > m_rxTrace; - TracedCallback > m_txTrace; + Address m_myAddress; + SendCallback m_sendCb; + TracedCallback > m_macRxTrace; + TracedCallback > m_macTxTrace; + TracedCallback > m_macPromiscRxTrace; + TracedCallback > m_snifferTrace; + TracedCallback > m_promiscSnifferTrace; Ptr m_node; ReceiveCallback m_rxCallback; PromiscReceiveCallback m_promiscRxCallback; From 608435583cfc6becd00b5f18e30c11e269f0aef3 Mon Sep 17 00:00:00 2001 From: "Gustavo J. A. M. Carneiro" Date: Thu, 11 Jun 2009 16:12:11 +0100 Subject: [PATCH 09/20] Remove packet tags before reinjecting the packet into the stack --- examples/virtual-net-device.cc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/examples/virtual-net-device.cc b/examples/virtual-net-device.cc index a482d9dff..3683bffad 100644 --- a/examples/virtual-net-device.cc +++ b/examples/virtual-net-device.cc @@ -103,18 +103,21 @@ class Tunnel void N3SocketRecv (Ptr socket) { Ptr packet = socket->Recv (65535, 0); + packet->RemoveAllPacketTags (); m_n3Tap->Receive (packet, 0x0800, m_n3Tap->GetAddress (), m_n3Tap->GetAddress (), NetDevice::PACKET_HOST); } void N0SocketRecv (Ptr socket) { Ptr packet = socket->Recv (65535, 0); + packet->RemoveAllPacketTags (); m_n0Tap->Receive (packet, 0x0800, m_n0Tap->GetAddress (), m_n0Tap->GetAddress (), NetDevice::PACKET_HOST); } void N1SocketRecv (Ptr socket) { Ptr packet = socket->Recv (65535, 0); + packet->RemoveAllPacketTags (); m_n1Tap->Receive (packet, 0x0800, m_n1Tap->GetAddress (), m_n1Tap->GetAddress (), NetDevice::PACKET_HOST); } From 701f1e4285fea92dd6cf7a71f73c0c433be74cf5 Mon Sep 17 00:00:00 2001 From: "Gustavo J. A. M. Carneiro" Date: Fri, 12 Jun 2009 10:31:19 +0100 Subject: [PATCH 10/20] Don't remove all tags, only the SocketAddressTag. --- examples/virtual-net-device.cc | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/examples/virtual-net-device.cc b/examples/virtual-net-device.cc index 3683bffad..5b63c87c1 100644 --- a/examples/virtual-net-device.cc +++ b/examples/virtual-net-device.cc @@ -103,21 +103,24 @@ class Tunnel void N3SocketRecv (Ptr socket) { Ptr packet = socket->Recv (65535, 0); - packet->RemoveAllPacketTags (); + SocketAddressTag socketAddressTag; + packet->RemovePacketTag (socketAddressTag); m_n3Tap->Receive (packet, 0x0800, m_n3Tap->GetAddress (), m_n3Tap->GetAddress (), NetDevice::PACKET_HOST); } void N0SocketRecv (Ptr socket) { Ptr packet = socket->Recv (65535, 0); - packet->RemoveAllPacketTags (); + SocketAddressTag socketAddressTag; + packet->RemovePacketTag (socketAddressTag); m_n0Tap->Receive (packet, 0x0800, m_n0Tap->GetAddress (), m_n0Tap->GetAddress (), NetDevice::PACKET_HOST); } void N1SocketRecv (Ptr socket) { Ptr packet = socket->Recv (65535, 0); - packet->RemoveAllPacketTags (); + SocketAddressTag socketAddressTag; + packet->RemovePacketTag (socketAddressTag); m_n1Tap->Receive (packet, 0x0800, m_n1Tap->GetAddress (), m_n1Tap->GetAddress (), NetDevice::PACKET_HOST); } From 1fd46789b4bb0bf7915978b997ad58120b629fc5 Mon Sep 17 00:00:00 2001 From: "Gustavo J. A. M. Carneiro" Date: Wed, 17 Jun 2009 11:26:36 +0100 Subject: [PATCH 11/20] Bug #594: cygwin won't build. --- bindings/python/wscript | 2 ++ wscript | 2 ++ 2 files changed, 4 insertions(+) diff --git a/bindings/python/wscript b/bindings/python/wscript index bb5c0a50e..aaad25af6 100644 --- a/bindings/python/wscript +++ b/bindings/python/wscript @@ -439,6 +439,8 @@ def build(bld): bindgen.name = "pybindgen-command" pymod = bld.new_task_gen('cxx', 'shlib', 'pyext') + if sys.platform == 'cygwin': + pymod.features.append('implib') # workaround for WAF bug #472 pymod.source = ['ns3module.cc', 'ns3module_helpers.cc'] pymod.includes = '.' for module in scanned_modules: diff --git a/wscript b/wscript index e0dda6565..4667ff6fd 100644 --- a/wscript +++ b/wscript @@ -498,6 +498,8 @@ def build(bld): lib.target = 'ns3' if lib.env['CXX_NAME'] == 'gcc' and env['WL_SONAME_SUPPORTED']: lib.env.append_value('LINKFLAGS', '-Wl,--soname=%s' % ccroot.get_target_name(lib)) + if sys.platform == 'cygwin': + lib.features.append('implib') # workaround for WAF bug #472 if env['NS3_ENABLED_MODULES']: lib.add_objects = list(modules) From e66efe0eaf25dac344b8bb085b34359eac8b27c7 Mon Sep 17 00:00:00 2001 From: Mathieu Lacage Date: Wed, 17 Jun 2009 17:05:51 +0200 Subject: [PATCH 12/20] remove dead code --- utils/mobility-generator.cc | 66 --------- utils/mobility-visualizer-model.cc | 140 ------------------ utils/mobility-visualizer-view.cc | 218 ----------------------------- utils/mobility-visualizer.h | 23 --- utils/wscript | 15 -- wscript | 1 - 6 files changed, 463 deletions(-) delete mode 100644 utils/mobility-generator.cc delete mode 100644 utils/mobility-visualizer-model.cc delete mode 100644 utils/mobility-visualizer-view.cc delete mode 100644 utils/mobility-visualizer.h diff --git a/utils/mobility-generator.cc b/utils/mobility-generator.cc deleted file mode 100644 index 3d1651b49..000000000 --- a/utils/mobility-generator.cc +++ /dev/null @@ -1,66 +0,0 @@ -/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ -/* - * Copyright (c) 2007 INRIA - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation; - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Author: Mathieu Lacage - */ - -#include "ns3/ns2-mobility-file-topology.h" -#include "ns3/object.h" -#include "ns3/simulator.h" -#include "ns3/mobility-model-notifier.h" -#include - -using namespace ns3; - -static void -CourseChange (Ptr position) -{ - Position pos = position->Get (); - std::cout << Simulator::Now () << ", pos=" << position << ", x=" << pos.x << ", y=" << pos.y - << ", z=" << pos.z << std::endl; -} - -int main (int argc, char *argv[]) -{ - std::vector > objects; - while (argc > 0) - { - if (strncmp (*argv, "--n=", strlen ("--n=")) == 0) - { - uint32_t n = atoi (*argv + strlen ("--n=")); - for (uint32_t i = 0; i < n; i++) - { - Ptr notifier = CreateObject (); - notifier->RegisterListener (MakeCallback (&CourseChange)); - objects.push_back (notifier); - } - } - else if (strncmp (*argv, "--ns2-topology=", - strlen ("--ns2-topology=")) == 0) - { - const char *filename = *argv + strlen ("--ns2-topology="); - Ns2MobilityFileTopology topology (filename); - topology.Layout (objects.begin (), objects.end ()); - } - argc--; - argv++; - } - - Simulator::Run (); - Simulator::Destroy (); - return 0; -} diff --git a/utils/mobility-visualizer-model.cc b/utils/mobility-visualizer-model.cc deleted file mode 100644 index cd503da63..000000000 --- a/utils/mobility-visualizer-model.cc +++ /dev/null @@ -1,140 +0,0 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ - -#include - -#include "ns3/ptr.h" -#include "ns3/mobility-model.h" -#include "ns3/mobility-model-notifier.h" -#include "ns3/position-allocator.h" -#include "ns3/default-value.h" -#include "ns3/command-line.h" -#include "ns3/command-line.h" -#include "ns3/simulator.h" -#include "ns3/nstime.h" -#include "ns3/node.h" -#include "ns3/node-list.h" -#include "ns3/rectangle-default-value.h" -#include "ns3/type-id-default-value.h" -#include "ns3/mobility-helper.h" - -#include "mobility-visualizer.h" - -using namespace ns3; - -static Time g_sampleInterval = Seconds (SAMPLE_INTERVAL); -static uint32_t g_numNodes = 10; - -template -static const T* DefaultValueListGet (const std::string &name) -{ - for (DefaultValueList::Iterator iter = DefaultValueList::Begin (); - iter != DefaultValueList::End (); iter++) - { - const DefaultValueBase *value = *iter; - if (value->GetName () == name) - { - return dynamic_cast (value); - } - } - return NULL; -} - - - -static void -Sample () -{ - - ViewUpdateData *data = new ViewUpdateData; - for (NodeList::Iterator nodeIter = NodeList::Begin (); nodeIter != NodeList::End (); nodeIter++) - { - Ptr node = *nodeIter; - Ptr mobility = node->GetObject (); - Vector pos = mobility->GetPosition (); - Vector vel = mobility->GetVelocity (); - - NodeUpdate update; - update.node = PeekPointer (node); - update.x = pos.x; - update.y = pos.y; - update.vx = vel.x; - update.vy = vel.y; - data->updateList.push_back (update); - } - data->time = Simulator::Now ().GetSeconds (); - view_update (data); - Simulator::Schedule (g_sampleInterval, Sample); -} - - - -int model_init (int argc, char *argv[], double *x1, double *y1, double *x2, double *y2) -{ - DefaultValue::Bind ("RandomWalk2dMode", "Time"); - DefaultValue::Bind ("RandomWalk2dTime", "5s"); - DefaultValue::Bind ("RandomWalk2dSpeed", "Constant:20.0"); - DefaultValue::Bind ("RandomDirection2dSpeed", "Uniform:10.0:20.0"); - DefaultValue::Bind ("RandomWalk2dBounds", "0:400:0:300"); - DefaultValue::Bind ("RandomDirection2dArea", "0:400:0:300"); - DefaultValue::Bind ("RandomWaypointSpeed", "Uniform:10:30"); - -// DefaultValue::Bind ("RandomDiscPositionX", "100"); -// DefaultValue::Bind ("RandomDiscPositionY", "50"); -// DefaultValue::Bind ("RandomDiscPositionRho", "Uniform:0:30"); - - DefaultValue::Bind ("RandomTopologyPositionType", "RandomRectanglePosition"); - DefaultValue::Bind ("RandomTopologyMobilityType", "RandomWalkMobilityModel"); - -// CommandLine::AddArgValue ("sample-interval","sample interval", g_sampleInterval); -// CommandLine::AddArgValue ("num-nodes","number of nodes", g_numNodes); - - CommandLine::Parse (argc, argv); - - MobilityHelper mobility; - - for (uint32_t i = 0; i < g_numNodes; i++) - { - Ptr node = CreateObject (); - } - - mobility.EnableNotifier (); - mobility.Layout (NodeList::Begin (), NodeList::End ()); - - Simulator::Schedule (g_sampleInterval, Sample); - - // XXX: The following is not really going to work with the params. - - if (mobility.GetMobilityModelType () == "RandomWalk2dMobilityModel") - { - Rectangle bounds = DefaultValueListGet ("RandomWalk2dBounds")->GetValue (); - *x1 = bounds.xMin; - *y1 = bounds.yMin; - *x2 = bounds.xMax; - *y2 = bounds.yMax; - std::cout << "RECT " << bounds.xMin << " " << bounds.xMax << " " - << bounds.yMin << " " << bounds.yMax << std::endl; - } - else if (mobility.GetMobilityModelType () == "RandomDirection2dMobilityModel") - { - Rectangle bounds = DefaultValueListGet ("RandomDirection2dArea")->GetValue (); - *x1 = bounds.xMin; - *y1 = bounds.yMin; - *x2 = bounds.xMax; - *y2 = bounds.yMax; - std::cout << "RECT " << bounds.xMin << " " << bounds.xMax << " " - << bounds.yMin << " " << bounds.yMax << std::endl; - } - else if (mobility.GetMobilityModelType () == "RandomWaypointMobilityModel") - { - std::cerr << "bounds for RandomWaypointMobilityModel not implemented" << std::endl; - //ClassId posType = DefaultValueList::Get ("RandomWaypointPosition")->GetValue (); - std::cout << "?" << std::endl; // too hard to represent an abstract/probabilistic model graphically - } - else - { - NS_FATAL_ERROR ("mobility type " << mobility.GetMobilityModelType () << " not supported"); - } - - std::cerr << g_sampleInterval << std::endl; - return 0; -} diff --git a/utils/mobility-visualizer-view.cc b/utils/mobility-visualizer-view.cc deleted file mode 100644 index c1370856b..000000000 --- a/utils/mobility-visualizer-view.cc +++ /dev/null @@ -1,218 +0,0 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ - -#include - -#include -#include - -#include "mobility-visualizer.h" -#include -#include "ns3/simulator.h" - -#define MAX_QUEUE_LENGTH 100 -#define MAX_EVENTS 20 -#define LOOKAHEAD_SECONDS 10 - -GtkWidget *g_canvas; - -int model_init (int argc, char *argv[]); - -struct Node -{ - GooCanvasItem *m_item; - GooCanvasItem *m_vector; - void create () - { - GooCanvasItem *root = goo_canvas_get_root_item (GOO_CANVAS (g_canvas)); - m_item = goo_canvas_ellipse_new (root, 0, 0, 2.0, 2.0, - "line_width", 0.5, - "stroke_color", "black", - "fill_color", "red", - NULL); - - m_vector = goo_canvas_polyline_new (root, FALSE, 0, - "line_width", 0.3, - "stroke_color", "black", - "end-arrow", TRUE, - "arrow-length", 10.0, - "arrow-width", 10.0, - NULL); - - } - - - void update (double x, double y, double vx, double vy) - { - g_object_set (m_item, "center_x", x, "center_y", y, NULL); - - if (vx == 0 && vy == 0) - { - GooCanvasPoints *points = goo_canvas_points_new (0); - g_object_set (m_vector, "points", points, NULL); - goo_canvas_points_unref (points); - } - else - { - GooCanvasPoints *points = goo_canvas_points_new (2); - - points->coords[0] = x; - points->coords[1] = y; - points->coords[2] = x + vx; - points->coords[3] = y + vy; - - g_object_set (m_vector, "points", points, NULL); - goo_canvas_points_unref (points); - } - } -}; - -std::map g_nodes; - -GTimeVal initialTime = {-1, -1}; -gboolean firstTime = TRUE; -double g_lookaheadTime = 0; -GStaticMutex g_lookaheadTimeMux = G_STATIC_MUTEX_INIT; -ViewUpdateData *g_nextData = NULL; - - -GAsyncQueue *queue; - -#define TIME_SCALE 1 - -double get_current_time () -{ - GTimeVal currTime; - g_get_current_time (&currTime); - GTimeVal relativeTime; - relativeTime.tv_sec = currTime.tv_sec - initialTime.tv_sec + LOOKAHEAD_SECONDS; - relativeTime.tv_usec = currTime.tv_usec; - g_time_val_add (&relativeTime, -initialTime.tv_usec); - return (relativeTime.tv_sec + 1.0e-6*relativeTime.tv_usec)*TIME_SCALE; -} - -// called from the simulation thread -void view_update (ViewUpdateData *updateData) -{ - while ((g_static_mutex_lock (&g_lookaheadTimeMux), g_lookaheadTime) != 0 and updateData->time >= g_lookaheadTime) - { - g_static_mutex_unlock (&g_lookaheadTimeMux); - g_usleep ((gulong) 10e3); - } - g_static_mutex_unlock (&g_lookaheadTimeMux); - g_async_queue_push (queue, updateData); -} - -void view_update_process (ViewUpdateData *updateData) -{ - for (std::vector::const_iterator update - = updateData->updateList.begin (); - update != updateData->updateList.end (); - update++) - { - if (g_nodes.find (update->node) == g_nodes.end ()) - { - g_nodes[update->node].create (); - } - g_nodes[update->node].update (update->x, update->y, update->vx, update->vy); - } - delete updateData; -} - -gboolean view_update_consumer () -{ - if (firstTime) - { - firstTime = FALSE; - g_get_current_time (&initialTime); - } - - double now = get_current_time (); - g_static_mutex_lock (&g_lookaheadTimeMux); - g_lookaheadTime = now + LOOKAHEAD_SECONDS; - g_static_mutex_unlock (&g_lookaheadTimeMux); - - if (!g_nextData) - g_nextData = (ViewUpdateData *) g_async_queue_try_pop (queue); - - if (!g_nextData) - return TRUE; - - if (g_nextData->time > now) - return TRUE; - - do - { - view_update_process (g_nextData); - g_nextData = (ViewUpdateData *) g_async_queue_try_pop (queue); - } - while (g_nextData && g_nextData->time <= now); - - return TRUE; -} - -void zoom_changed (GtkAdjustment *adj) -{ - goo_canvas_set_scale (GOO_CANVAS (g_canvas), gtk_adjustment_get_value (adj)); -} - -int main (int argc, char *argv[]) -{ - g_thread_init (NULL); - gtk_init (&argc, &argv); - double x1 = 0, y1 = 0, x2 = 0, y2 = 0; - - model_init (argc, argv, &x1, &y1, &x2, &y2); - - GtkWidget *window = gtk_window_new (GTK_WINDOW_TOPLEVEL); - gtk_window_set_default_size (GTK_WINDOW (window), 640, 600); - gtk_widget_show (window); - g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL); - - GtkWidget *scrolled_win = gtk_scrolled_window_new (NULL, NULL); - gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled_win), GTK_SHADOW_IN); - gtk_widget_show (scrolled_win); - - GtkWidget *vbox = gtk_vbox_new (FALSE, 4); - gtk_widget_show (vbox); - gtk_box_pack_start (GTK_BOX (vbox), scrolled_win, 1, 1, 4); - gtk_container_add (GTK_CONTAINER (window), vbox); - - GtkWidget *hbox = gtk_hbox_new (FALSE, 4); - gtk_widget_show (hbox); - gtk_box_pack_start (GTK_BOX (vbox), hbox, false, false, 4); - - GtkObject *zoom = gtk_adjustment_new (3.0, 0.1, 10.0, 0.2, 1.0, 1.0); - gtk_box_pack_start(GTK_BOX (hbox), - GTK_WIDGET (g_object_new (GTK_TYPE_SPIN_BUTTON, "adjustment", zoom, - "visible", true, "digits", 2, NULL)), - false, false, 4); - - g_canvas = goo_canvas_new (); - gtk_widget_set_size_request (GTK_WIDGET (g_canvas), 600, 450); - goo_canvas_set_bounds (GOO_CANVAS (g_canvas), -500, -500, 500, 500); - g_signal_connect (zoom, "value-changed", G_CALLBACK (zoom_changed), NULL); - gtk_adjustment_value_changed (GTK_ADJUSTMENT (zoom)); - gtk_widget_show (g_canvas); - gtk_container_add (GTK_CONTAINER (scrolled_win), g_canvas); - - goo_canvas_scroll_to (GOO_CANVAS (g_canvas), 0, 0); - - // create the bounds rectangle - if (x1 != x2) - { - GooCanvasItem *item = - goo_canvas_rect_new (goo_canvas_get_root_item (GOO_CANVAS (g_canvas)), - x1, y1, x2-x1, y2-y1, NULL); - g_object_set (item, "line-width", 1.0, "stroke-color", "grey", NULL); - } - - queue = g_async_queue_new (); - - g_timeout_add ((guint) (SAMPLE_INTERVAL*1000), (GSourceFunc) view_update_consumer, NULL); - - g_thread_create (GThreadFunc (ns3::Simulator::Run), NULL, FALSE, NULL); - - gtk_main (); - - return 0; -} diff --git a/utils/mobility-visualizer.h b/utils/mobility-visualizer.h deleted file mode 100644 index 634847c3c..000000000 --- a/utils/mobility-visualizer.h +++ /dev/null @@ -1,23 +0,0 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ -#include - -int model_init (int argc, char *argv[], double *x1, double *y1, double *x2, double *y2); - -struct NodeUpdate -{ - void *node; - double x; - double y; - double vx; - double vy; -}; - -struct ViewUpdateData -{ - std::vector updateList; - double time; -}; - -void view_update (ViewUpdateData *updateData); - -#define SAMPLE_INTERVAL (1.0/30) diff --git a/utils/wscript b/utils/wscript index 07e880b7c..389cc25f8 100644 --- a/utils/wscript +++ b/utils/wscript @@ -1,11 +1,6 @@ ## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*- import os.path -def configure(conf): - conf.env['ENABLE_MOBILITY_VISUALIZER'] = conf.pkg_check_modules( - 'MOBILITY_VISUALIZER', 'goocanvas gthread-2.0', mandatory=False) - - def build(bld): env = bld.env @@ -25,13 +20,3 @@ def build(bld): ['internet-stack', 'csma-cd', 'point-to-point']) obj.source = 'print-introspected-doxygen.cc' -# XXX: disable mobility visualizer code temporarily. - env['ENABLE_MOBILITY_VISUALIZER'] = '' - if env['ENABLE_MOBILITY_VISUALIZER']: - obj = bld.create_ns3_program('mobility-visualizer', - ['internet-stack', 'mobility']) - obj.source = ['mobility-visualizer-model.cc', 'mobility-visualizer-view.cc'] - obj.uselib = 'MOBILITY_VISUALIZER' - if os.path.basename(obj.env['CXX']).startswith("g++"): - obj.env.append_value('CXXFLAGS', '-fno-strict-aliasing') - diff --git a/wscript b/wscript index 4667ff6fd..739600784 100644 --- a/wscript +++ b/wscript @@ -273,7 +273,6 @@ def configure(conf): env['WL_SONAME_SUPPORTED'] = True conf.sub_config('src') - conf.sub_config('utils') conf.sub_config('bindings/python') if Options.options.enable_modules: From 8f565ad9dd6e579cf8a0a353f457b1ce8d2a5884 Mon Sep 17 00:00:00 2001 From: fmoatamr Date: Thu, 18 Jun 2009 11:43:40 +0200 Subject: [PATCH 13/20] Bug 589: UdpSocketImpl unit test is leaking --- src/internet-stack/udp-test.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/internet-stack/udp-test.cc b/src/internet-stack/udp-test.cc index 8b51e0652..1387d0cac 100644 --- a/src/internet-stack/udp-test.cc +++ b/src/internet-stack/udp-test.cc @@ -251,8 +251,8 @@ InetSocketAddress (Ipv4Address("255.255.255.255"), 1234)), 123); NS_TEST_ASSERT_EQUAL (m_receivedPacket->GetSize (), 123); NS_TEST_ASSERT_EQUAL (m_receivedPacket2->GetSize (), 123); - m_receivedPacket->RemoveAllByteTags (); - m_receivedPacket2->RemoveAllByteTags (); + m_receivedPacket = 0; + m_receivedPacket2 = 0; Simulator::Destroy (); From 6282187a57049b37141a2f5bf8c6b994c1525384 Mon Sep 17 00:00:00 2001 From: Mathieu Lacage Date: Fri, 19 Jun 2009 08:36:48 +0200 Subject: [PATCH 14/20] kill unused method --- bindings/python/callbacks_list.py | 1 + bindings/python/ns3_module_simulator.py | 15 - bindings/python/ns3modulegen_generated.py | 678 ++++++++++++---------- src/simulator/default-simulator-impl.cc | 7 - src/simulator/default-simulator-impl.h | 1 - src/simulator/realtime-simulator-impl.cc | 7 - src/simulator/realtime-simulator-impl.h | 1 - src/simulator/simulator-impl.h | 1 - 8 files changed, 357 insertions(+), 354 deletions(-) diff --git a/bindings/python/callbacks_list.py b/bindings/python/callbacks_list.py index f18b3fc1e..0058d7106 100644 --- a/bindings/python/callbacks_list.py +++ b/bindings/python/callbacks_list.py @@ -1,5 +1,6 @@ callback_classes = [ ['void', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty'], + ['bool', 'ns3::Ptr', 'ns3::Address const&', 'ns3::Address const&', 'unsigned short', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty'], ['void', 'ns3::Ptr', 'ns3::Mac48Address', 'ns3::Mac48Address', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty'], ['void', 'ns3::Ptr', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty'], ['void', 'ns3::Ptr', 'unsigned int', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty'], diff --git a/bindings/python/ns3_module_simulator.py b/bindings/python/ns3_module_simulator.py index d292314e3..6f9b8e369 100644 --- a/bindings/python/ns3_module_simulator.py +++ b/bindings/python/ns3_module_simulator.py @@ -836,11 +836,6 @@ def register_Ns3SimulatorImpl_methods(root_module, cls): 'void', [param('ns3::Ptr< ns3::Scheduler >', 'scheduler')], is_pure_virtual=True, is_virtual=True) - ## simulator-impl.h: ns3::Ptr ns3::SimulatorImpl::GetScheduler() const [member function] - cls.add_method('GetScheduler', - 'ns3::Ptr< ns3::Scheduler >', - [], - is_pure_virtual=True, is_const=True, is_virtual=True) return def register_Ns3Synchronizer_methods(root_module, cls): @@ -1205,11 +1200,6 @@ def register_Ns3DefaultSimulatorImpl_methods(root_module, cls): 'void', [param('ns3::Ptr< ns3::Scheduler >', 'scheduler')], is_virtual=True) - ## default-simulator-impl.h: ns3::Ptr ns3::DefaultSimulatorImpl::GetScheduler() const [member function] - cls.add_method('GetScheduler', - 'ns3::Ptr< ns3::Scheduler >', - [], - is_const=True, is_virtual=True) return def register_Ns3HeapScheduler_methods(root_module, cls): @@ -1450,11 +1440,6 @@ def register_Ns3RealtimeSimulatorImpl_methods(root_module, cls): 'void', [param('ns3::Ptr< ns3::Scheduler >', 'scheduler')], is_virtual=True) - ## realtime-simulator-impl.h: ns3::Ptr ns3::RealtimeSimulatorImpl::GetScheduler() const [member function] - cls.add_method('GetScheduler', - 'ns3::Ptr< ns3::Scheduler >', - [], - is_const=True, is_virtual=True) ## realtime-simulator-impl.h: void ns3::RealtimeSimulatorImpl::ScheduleRealtime(ns3::Time const & time, ns3::EventImpl * event) [member function] cls.add_method('ScheduleRealtime', 'void', diff --git a/bindings/python/ns3modulegen_generated.py b/bindings/python/ns3modulegen_generated.py index 323510a4d..e63ea677b 100644 --- a/bindings/python/ns3modulegen_generated.py +++ b/bindings/python/ns3modulegen_generated.py @@ -16,19 +16,20 @@ import ns3_module_core import ns3_module_simulator import ns3_module_mobility import ns3_module_common -import ns3_module_node import ns3_module_contrib -import ns3_module_point_to_point -import ns3_module_stats +import ns3_module_node import ns3_module_tap_bridge -import ns3_module_internet_stack -import ns3_module_wifi -import ns3_module_csma -import ns3_module_emu -import ns3_module_bridge -import ns3_module_onoff -import ns3_module_packet_sink import ns3_module_v4ping +import ns3_module_packet_sink +import ns3_module_stats +import ns3_module_virtual_net_device +import ns3_module_onoff +import ns3_module_internet_stack +import ns3_module_point_to_point +import ns3_module_csma +import ns3_module_bridge +import ns3_module_wifi +import ns3_module_emu import ns3_module_global_routing import ns3_module_udp_echo import ns3_module_olsr @@ -85,17 +86,6 @@ def register_types(module): ns3_module_common__local.register_types(module) root_module.end_section('ns3_module_common') - root_module.begin_section('ns3_module_node') - ns3_module_node.register_types(module) - - try: - import ns3_module_node__local - except ImportError: - pass - else: - ns3_module_node__local.register_types(module) - - root_module.end_section('ns3_module_node') root_module.begin_section('ns3_module_contrib') ns3_module_contrib.register_types(module) @@ -107,28 +97,17 @@ def register_types(module): ns3_module_contrib__local.register_types(module) root_module.end_section('ns3_module_contrib') - root_module.begin_section('ns3_module_point_to_point') - ns3_module_point_to_point.register_types(module) + root_module.begin_section('ns3_module_node') + ns3_module_node.register_types(module) try: - import ns3_module_point_to_point__local + import ns3_module_node__local except ImportError: pass else: - ns3_module_point_to_point__local.register_types(module) + ns3_module_node__local.register_types(module) - root_module.end_section('ns3_module_point_to_point') - root_module.begin_section('ns3_module_stats') - ns3_module_stats.register_types(module) - - try: - import ns3_module_stats__local - except ImportError: - pass - else: - ns3_module_stats__local.register_types(module) - - root_module.end_section('ns3_module_stats') + root_module.end_section('ns3_module_node') root_module.begin_section('ns3_module_tap_bridge') ns3_module_tap_bridge.register_types(module) @@ -140,83 +119,6 @@ def register_types(module): ns3_module_tap_bridge__local.register_types(module) root_module.end_section('ns3_module_tap_bridge') - root_module.begin_section('ns3_module_internet_stack') - ns3_module_internet_stack.register_types(module) - - try: - import ns3_module_internet_stack__local - except ImportError: - pass - else: - ns3_module_internet_stack__local.register_types(module) - - root_module.end_section('ns3_module_internet_stack') - root_module.begin_section('ns3_module_wifi') - ns3_module_wifi.register_types(module) - - try: - import ns3_module_wifi__local - except ImportError: - pass - else: - ns3_module_wifi__local.register_types(module) - - root_module.end_section('ns3_module_wifi') - root_module.begin_section('ns3_module_csma') - ns3_module_csma.register_types(module) - - try: - import ns3_module_csma__local - except ImportError: - pass - else: - ns3_module_csma__local.register_types(module) - - root_module.end_section('ns3_module_csma') - root_module.begin_section('ns3_module_emu') - ns3_module_emu.register_types(module) - - try: - import ns3_module_emu__local - except ImportError: - pass - else: - ns3_module_emu__local.register_types(module) - - root_module.end_section('ns3_module_emu') - root_module.begin_section('ns3_module_bridge') - ns3_module_bridge.register_types(module) - - try: - import ns3_module_bridge__local - except ImportError: - pass - else: - ns3_module_bridge__local.register_types(module) - - root_module.end_section('ns3_module_bridge') - root_module.begin_section('ns3_module_onoff') - ns3_module_onoff.register_types(module) - - try: - import ns3_module_onoff__local - except ImportError: - pass - else: - ns3_module_onoff__local.register_types(module) - - root_module.end_section('ns3_module_onoff') - root_module.begin_section('ns3_module_packet_sink') - ns3_module_packet_sink.register_types(module) - - try: - import ns3_module_packet_sink__local - except ImportError: - pass - else: - ns3_module_packet_sink__local.register_types(module) - - root_module.end_section('ns3_module_packet_sink') root_module.begin_section('ns3_module_v4ping') ns3_module_v4ping.register_types(module) @@ -228,6 +130,116 @@ def register_types(module): ns3_module_v4ping__local.register_types(module) root_module.end_section('ns3_module_v4ping') + root_module.begin_section('ns3_module_packet_sink') + ns3_module_packet_sink.register_types(module) + + try: + import ns3_module_packet_sink__local + except ImportError: + pass + else: + ns3_module_packet_sink__local.register_types(module) + + root_module.end_section('ns3_module_packet_sink') + root_module.begin_section('ns3_module_stats') + ns3_module_stats.register_types(module) + + try: + import ns3_module_stats__local + except ImportError: + pass + else: + ns3_module_stats__local.register_types(module) + + root_module.end_section('ns3_module_stats') + root_module.begin_section('ns3_module_virtual_net_device') + ns3_module_virtual_net_device.register_types(module) + + try: + import ns3_module_virtual_net_device__local + except ImportError: + pass + else: + ns3_module_virtual_net_device__local.register_types(module) + + root_module.end_section('ns3_module_virtual_net_device') + root_module.begin_section('ns3_module_onoff') + ns3_module_onoff.register_types(module) + + try: + import ns3_module_onoff__local + except ImportError: + pass + else: + ns3_module_onoff__local.register_types(module) + + root_module.end_section('ns3_module_onoff') + root_module.begin_section('ns3_module_internet_stack') + ns3_module_internet_stack.register_types(module) + + try: + import ns3_module_internet_stack__local + except ImportError: + pass + else: + ns3_module_internet_stack__local.register_types(module) + + root_module.end_section('ns3_module_internet_stack') + root_module.begin_section('ns3_module_point_to_point') + ns3_module_point_to_point.register_types(module) + + try: + import ns3_module_point_to_point__local + except ImportError: + pass + else: + ns3_module_point_to_point__local.register_types(module) + + root_module.end_section('ns3_module_point_to_point') + root_module.begin_section('ns3_module_csma') + ns3_module_csma.register_types(module) + + try: + import ns3_module_csma__local + except ImportError: + pass + else: + ns3_module_csma__local.register_types(module) + + root_module.end_section('ns3_module_csma') + root_module.begin_section('ns3_module_bridge') + ns3_module_bridge.register_types(module) + + try: + import ns3_module_bridge__local + except ImportError: + pass + else: + ns3_module_bridge__local.register_types(module) + + root_module.end_section('ns3_module_bridge') + root_module.begin_section('ns3_module_wifi') + ns3_module_wifi.register_types(module) + + try: + import ns3_module_wifi__local + except ImportError: + pass + else: + ns3_module_wifi__local.register_types(module) + + root_module.end_section('ns3_module_wifi') + root_module.begin_section('ns3_module_emu') + ns3_module_emu.register_types(module) + + try: + import ns3_module_emu__local + except ImportError: + pass + else: + ns3_module_emu__local.register_types(module) + + root_module.end_section('ns3_module_emu') root_module.begin_section('ns3_module_global_routing') ns3_module_global_routing.register_types(module) @@ -372,17 +384,6 @@ def register_methods(root_module): ns3_module_common__local.register_methods(root_module) root_module.end_section('ns3_module_common') - root_module.begin_section('ns3_module_node') - ns3_module_node.register_methods(root_module) - - try: - import ns3_module_node__local - except ImportError: - pass - else: - ns3_module_node__local.register_methods(root_module) - - root_module.end_section('ns3_module_node') root_module.begin_section('ns3_module_contrib') ns3_module_contrib.register_methods(root_module) @@ -394,28 +395,17 @@ def register_methods(root_module): ns3_module_contrib__local.register_methods(root_module) root_module.end_section('ns3_module_contrib') - root_module.begin_section('ns3_module_point_to_point') - ns3_module_point_to_point.register_methods(root_module) + root_module.begin_section('ns3_module_node') + ns3_module_node.register_methods(root_module) try: - import ns3_module_point_to_point__local + import ns3_module_node__local except ImportError: pass else: - ns3_module_point_to_point__local.register_methods(root_module) + ns3_module_node__local.register_methods(root_module) - root_module.end_section('ns3_module_point_to_point') - root_module.begin_section('ns3_module_stats') - ns3_module_stats.register_methods(root_module) - - try: - import ns3_module_stats__local - except ImportError: - pass - else: - ns3_module_stats__local.register_methods(root_module) - - root_module.end_section('ns3_module_stats') + root_module.end_section('ns3_module_node') root_module.begin_section('ns3_module_tap_bridge') ns3_module_tap_bridge.register_methods(root_module) @@ -427,83 +417,6 @@ def register_methods(root_module): ns3_module_tap_bridge__local.register_methods(root_module) root_module.end_section('ns3_module_tap_bridge') - root_module.begin_section('ns3_module_internet_stack') - ns3_module_internet_stack.register_methods(root_module) - - try: - import ns3_module_internet_stack__local - except ImportError: - pass - else: - ns3_module_internet_stack__local.register_methods(root_module) - - root_module.end_section('ns3_module_internet_stack') - root_module.begin_section('ns3_module_wifi') - ns3_module_wifi.register_methods(root_module) - - try: - import ns3_module_wifi__local - except ImportError: - pass - else: - ns3_module_wifi__local.register_methods(root_module) - - root_module.end_section('ns3_module_wifi') - root_module.begin_section('ns3_module_csma') - ns3_module_csma.register_methods(root_module) - - try: - import ns3_module_csma__local - except ImportError: - pass - else: - ns3_module_csma__local.register_methods(root_module) - - root_module.end_section('ns3_module_csma') - root_module.begin_section('ns3_module_emu') - ns3_module_emu.register_methods(root_module) - - try: - import ns3_module_emu__local - except ImportError: - pass - else: - ns3_module_emu__local.register_methods(root_module) - - root_module.end_section('ns3_module_emu') - root_module.begin_section('ns3_module_bridge') - ns3_module_bridge.register_methods(root_module) - - try: - import ns3_module_bridge__local - except ImportError: - pass - else: - ns3_module_bridge__local.register_methods(root_module) - - root_module.end_section('ns3_module_bridge') - root_module.begin_section('ns3_module_onoff') - ns3_module_onoff.register_methods(root_module) - - try: - import ns3_module_onoff__local - except ImportError: - pass - else: - ns3_module_onoff__local.register_methods(root_module) - - root_module.end_section('ns3_module_onoff') - root_module.begin_section('ns3_module_packet_sink') - ns3_module_packet_sink.register_methods(root_module) - - try: - import ns3_module_packet_sink__local - except ImportError: - pass - else: - ns3_module_packet_sink__local.register_methods(root_module) - - root_module.end_section('ns3_module_packet_sink') root_module.begin_section('ns3_module_v4ping') ns3_module_v4ping.register_methods(root_module) @@ -515,6 +428,116 @@ def register_methods(root_module): ns3_module_v4ping__local.register_methods(root_module) root_module.end_section('ns3_module_v4ping') + root_module.begin_section('ns3_module_packet_sink') + ns3_module_packet_sink.register_methods(root_module) + + try: + import ns3_module_packet_sink__local + except ImportError: + pass + else: + ns3_module_packet_sink__local.register_methods(root_module) + + root_module.end_section('ns3_module_packet_sink') + root_module.begin_section('ns3_module_stats') + ns3_module_stats.register_methods(root_module) + + try: + import ns3_module_stats__local + except ImportError: + pass + else: + ns3_module_stats__local.register_methods(root_module) + + root_module.end_section('ns3_module_stats') + root_module.begin_section('ns3_module_virtual_net_device') + ns3_module_virtual_net_device.register_methods(root_module) + + try: + import ns3_module_virtual_net_device__local + except ImportError: + pass + else: + ns3_module_virtual_net_device__local.register_methods(root_module) + + root_module.end_section('ns3_module_virtual_net_device') + root_module.begin_section('ns3_module_onoff') + ns3_module_onoff.register_methods(root_module) + + try: + import ns3_module_onoff__local + except ImportError: + pass + else: + ns3_module_onoff__local.register_methods(root_module) + + root_module.end_section('ns3_module_onoff') + root_module.begin_section('ns3_module_internet_stack') + ns3_module_internet_stack.register_methods(root_module) + + try: + import ns3_module_internet_stack__local + except ImportError: + pass + else: + ns3_module_internet_stack__local.register_methods(root_module) + + root_module.end_section('ns3_module_internet_stack') + root_module.begin_section('ns3_module_point_to_point') + ns3_module_point_to_point.register_methods(root_module) + + try: + import ns3_module_point_to_point__local + except ImportError: + pass + else: + ns3_module_point_to_point__local.register_methods(root_module) + + root_module.end_section('ns3_module_point_to_point') + root_module.begin_section('ns3_module_csma') + ns3_module_csma.register_methods(root_module) + + try: + import ns3_module_csma__local + except ImportError: + pass + else: + ns3_module_csma__local.register_methods(root_module) + + root_module.end_section('ns3_module_csma') + root_module.begin_section('ns3_module_bridge') + ns3_module_bridge.register_methods(root_module) + + try: + import ns3_module_bridge__local + except ImportError: + pass + else: + ns3_module_bridge__local.register_methods(root_module) + + root_module.end_section('ns3_module_bridge') + root_module.begin_section('ns3_module_wifi') + ns3_module_wifi.register_methods(root_module) + + try: + import ns3_module_wifi__local + except ImportError: + pass + else: + ns3_module_wifi__local.register_methods(root_module) + + root_module.end_section('ns3_module_wifi') + root_module.begin_section('ns3_module_emu') + ns3_module_emu.register_methods(root_module) + + try: + import ns3_module_emu__local + except ImportError: + pass + else: + ns3_module_emu__local.register_methods(root_module) + + root_module.end_section('ns3_module_emu') root_module.begin_section('ns3_module_global_routing') ns3_module_global_routing.register_methods(root_module) @@ -607,17 +630,6 @@ def register_functions(root_module): ns3_module_common__local.register_functions(root_module) root_module.end_section('ns3_module_common') - root_module.begin_section('ns3_module_node') - ns3_module_node.register_functions(root_module) - - try: - import ns3_module_node__local - except ImportError: - pass - else: - ns3_module_node__local.register_functions(root_module) - - root_module.end_section('ns3_module_node') root_module.begin_section('ns3_module_contrib') ns3_module_contrib.register_functions(root_module) @@ -629,28 +641,17 @@ def register_functions(root_module): ns3_module_contrib__local.register_functions(root_module) root_module.end_section('ns3_module_contrib') - root_module.begin_section('ns3_module_point_to_point') - ns3_module_point_to_point.register_functions(root_module) + root_module.begin_section('ns3_module_node') + ns3_module_node.register_functions(root_module) try: - import ns3_module_point_to_point__local + import ns3_module_node__local except ImportError: pass else: - ns3_module_point_to_point__local.register_functions(root_module) + ns3_module_node__local.register_functions(root_module) - root_module.end_section('ns3_module_point_to_point') - root_module.begin_section('ns3_module_stats') - ns3_module_stats.register_functions(root_module) - - try: - import ns3_module_stats__local - except ImportError: - pass - else: - ns3_module_stats__local.register_functions(root_module) - - root_module.end_section('ns3_module_stats') + root_module.end_section('ns3_module_node') root_module.begin_section('ns3_module_tap_bridge') ns3_module_tap_bridge.register_functions(root_module) @@ -662,83 +663,6 @@ def register_functions(root_module): ns3_module_tap_bridge__local.register_functions(root_module) root_module.end_section('ns3_module_tap_bridge') - root_module.begin_section('ns3_module_internet_stack') - ns3_module_internet_stack.register_functions(root_module) - - try: - import ns3_module_internet_stack__local - except ImportError: - pass - else: - ns3_module_internet_stack__local.register_functions(root_module) - - root_module.end_section('ns3_module_internet_stack') - root_module.begin_section('ns3_module_wifi') - ns3_module_wifi.register_functions(root_module) - - try: - import ns3_module_wifi__local - except ImportError: - pass - else: - ns3_module_wifi__local.register_functions(root_module) - - root_module.end_section('ns3_module_wifi') - root_module.begin_section('ns3_module_csma') - ns3_module_csma.register_functions(root_module) - - try: - import ns3_module_csma__local - except ImportError: - pass - else: - ns3_module_csma__local.register_functions(root_module) - - root_module.end_section('ns3_module_csma') - root_module.begin_section('ns3_module_emu') - ns3_module_emu.register_functions(root_module) - - try: - import ns3_module_emu__local - except ImportError: - pass - else: - ns3_module_emu__local.register_functions(root_module) - - root_module.end_section('ns3_module_emu') - root_module.begin_section('ns3_module_bridge') - ns3_module_bridge.register_functions(root_module) - - try: - import ns3_module_bridge__local - except ImportError: - pass - else: - ns3_module_bridge__local.register_functions(root_module) - - root_module.end_section('ns3_module_bridge') - root_module.begin_section('ns3_module_onoff') - ns3_module_onoff.register_functions(root_module) - - try: - import ns3_module_onoff__local - except ImportError: - pass - else: - ns3_module_onoff__local.register_functions(root_module) - - root_module.end_section('ns3_module_onoff') - root_module.begin_section('ns3_module_packet_sink') - ns3_module_packet_sink.register_functions(root_module) - - try: - import ns3_module_packet_sink__local - except ImportError: - pass - else: - ns3_module_packet_sink__local.register_functions(root_module) - - root_module.end_section('ns3_module_packet_sink') root_module.begin_section('ns3_module_v4ping') ns3_module_v4ping.register_functions(root_module) @@ -750,6 +674,116 @@ def register_functions(root_module): ns3_module_v4ping__local.register_functions(root_module) root_module.end_section('ns3_module_v4ping') + root_module.begin_section('ns3_module_packet_sink') + ns3_module_packet_sink.register_functions(root_module) + + try: + import ns3_module_packet_sink__local + except ImportError: + pass + else: + ns3_module_packet_sink__local.register_functions(root_module) + + root_module.end_section('ns3_module_packet_sink') + root_module.begin_section('ns3_module_stats') + ns3_module_stats.register_functions(root_module) + + try: + import ns3_module_stats__local + except ImportError: + pass + else: + ns3_module_stats__local.register_functions(root_module) + + root_module.end_section('ns3_module_stats') + root_module.begin_section('ns3_module_virtual_net_device') + ns3_module_virtual_net_device.register_functions(root_module) + + try: + import ns3_module_virtual_net_device__local + except ImportError: + pass + else: + ns3_module_virtual_net_device__local.register_functions(root_module) + + root_module.end_section('ns3_module_virtual_net_device') + root_module.begin_section('ns3_module_onoff') + ns3_module_onoff.register_functions(root_module) + + try: + import ns3_module_onoff__local + except ImportError: + pass + else: + ns3_module_onoff__local.register_functions(root_module) + + root_module.end_section('ns3_module_onoff') + root_module.begin_section('ns3_module_internet_stack') + ns3_module_internet_stack.register_functions(root_module) + + try: + import ns3_module_internet_stack__local + except ImportError: + pass + else: + ns3_module_internet_stack__local.register_functions(root_module) + + root_module.end_section('ns3_module_internet_stack') + root_module.begin_section('ns3_module_point_to_point') + ns3_module_point_to_point.register_functions(root_module) + + try: + import ns3_module_point_to_point__local + except ImportError: + pass + else: + ns3_module_point_to_point__local.register_functions(root_module) + + root_module.end_section('ns3_module_point_to_point') + root_module.begin_section('ns3_module_csma') + ns3_module_csma.register_functions(root_module) + + try: + import ns3_module_csma__local + except ImportError: + pass + else: + ns3_module_csma__local.register_functions(root_module) + + root_module.end_section('ns3_module_csma') + root_module.begin_section('ns3_module_bridge') + ns3_module_bridge.register_functions(root_module) + + try: + import ns3_module_bridge__local + except ImportError: + pass + else: + ns3_module_bridge__local.register_functions(root_module) + + root_module.end_section('ns3_module_bridge') + root_module.begin_section('ns3_module_wifi') + ns3_module_wifi.register_functions(root_module) + + try: + import ns3_module_wifi__local + except ImportError: + pass + else: + ns3_module_wifi__local.register_functions(root_module) + + root_module.end_section('ns3_module_wifi') + root_module.begin_section('ns3_module_emu') + ns3_module_emu.register_functions(root_module) + + try: + import ns3_module_emu__local + except ImportError: + pass + else: + ns3_module_emu__local.register_functions(root_module) + + root_module.end_section('ns3_module_emu') root_module.begin_section('ns3_module_global_routing') ns3_module_global_routing.register_functions(root_module) diff --git a/src/simulator/default-simulator-impl.cc b/src/simulator/default-simulator-impl.cc index bf3cd2105..eb619d56a 100644 --- a/src/simulator/default-simulator-impl.cc +++ b/src/simulator/default-simulator-impl.cc @@ -99,13 +99,6 @@ DefaultSimulatorImpl::SetScheduler (Ptr scheduler) m_events = scheduler; } -Ptr -DefaultSimulatorImpl::GetScheduler (void) const -{ - return m_events; -} - - void DefaultSimulatorImpl::ProcessOneEvent (void) { diff --git a/src/simulator/default-simulator-impl.h b/src/simulator/default-simulator-impl.h index 3b31d4c75..4811a57a1 100644 --- a/src/simulator/default-simulator-impl.h +++ b/src/simulator/default-simulator-impl.h @@ -57,7 +57,6 @@ public: virtual Time GetDelayLeft (const EventId &id) const; virtual Time GetMaximumSimulationTime (void) const; virtual void SetScheduler (Ptr scheduler); - virtual Ptr GetScheduler (void) const; private: void ProcessOneEvent (void); diff --git a/src/simulator/realtime-simulator-impl.cc b/src/simulator/realtime-simulator-impl.cc index fd26901a2..9443db38f 100644 --- a/src/simulator/realtime-simulator-impl.cc +++ b/src/simulator/realtime-simulator-impl.cc @@ -141,13 +141,6 @@ RealtimeSimulatorImpl::SetScheduler (Ptr scheduler) } } -Ptr -RealtimeSimulatorImpl::GetScheduler (void) const -{ - NS_LOG_FUNCTION_NOARGS (); - return m_events; -} - void RealtimeSimulatorImpl::ProcessOneEvent (void) { diff --git a/src/simulator/realtime-simulator-impl.h b/src/simulator/realtime-simulator-impl.h index 578901e6b..8a3becd57 100644 --- a/src/simulator/realtime-simulator-impl.h +++ b/src/simulator/realtime-simulator-impl.h @@ -67,7 +67,6 @@ public: virtual Time GetDelayLeft (const EventId &id) const; virtual Time GetMaximumSimulationTime (void) const; virtual void SetScheduler (Ptr scheduler); - virtual Ptr GetScheduler (void) const; void ScheduleRealtime (Time const &time, EventImpl *event); void ScheduleRealtimeNow (EventImpl *event); diff --git a/src/simulator/simulator-impl.h b/src/simulator/simulator-impl.h index 150b52387..4479b23bb 100644 --- a/src/simulator/simulator-impl.h +++ b/src/simulator/simulator-impl.h @@ -50,7 +50,6 @@ public: virtual Time GetDelayLeft (const EventId &id) const = 0; virtual Time GetMaximumSimulationTime (void) const = 0; virtual void SetScheduler (Ptr scheduler) = 0; - virtual Ptr GetScheduler (void) const = 0; }; } // namespace ns3 From 0d5554a509f440f7d9b0b2a98f1cc21dae931d37 Mon Sep 17 00:00:00 2001 From: Mathieu Lacage Date: Fri, 19 Jun 2009 08:43:58 +0200 Subject: [PATCH 15/20] make CreateObject<> behave like Create<>: use positional constructor arguments rather than attribute lists. --- .../ns3modulegen_core_customizations.py | 6 +- examples/csma-packet-socket.cc | 2 +- examples/simple-error-model.cc | 2 +- examples/tcp-nsc-lfn.cc | 4 +- src/core/attribute-test.cc | 8 +-- src/core/object.h | 71 +++++++++++++++++-- src/helper/mobility-helper.cc | 4 +- 7 files changed, 77 insertions(+), 20 deletions(-) diff --git a/bindings/python/ns3modulegen_core_customizations.py b/bindings/python/ns3modulegen_core_customizations.py index 8ad75632f..194d99599 100644 --- a/bindings/python/ns3modulegen_core_customizations.py +++ b/bindings/python/ns3modulegen_core_customizations.py @@ -325,7 +325,7 @@ static ns3::TypeId GetTypeId (void) "NS_OBJECT_ENSURE_REGISTERED (%s);" % helper_class.name) Object.add_helper_class_hook(helper_class_hook) - ## Replace all class constructors with a generic constructor based on CreateObject (AttributeList) + ## Replace all class constructors with a generic constructor based on CreateObjectWithAttributes (AttributeList) module.header.writeln(''' namespace ns3 { @@ -357,7 +357,7 @@ Ptr CreateObjectPython (PyObject *pyobj, const AttributeList &attributes) if construct_name and not cls.helper_class: construct_code = ''' - ns3::Ptr< %(CONSTRUCT_NAME)s > obj = ns3::CreateObject< %(CONSTRUCT_NAME)s > (attrList); + ns3::Ptr< %(CONSTRUCT_NAME)s > obj = ns3::CreateObjectWithAttributes< %(CONSTRUCT_NAME)s > (attrList); obj->Ref (); self->obj = ns3::PeekPointer (obj); ''' % dict (CONSTRUCT_NAME=construct_name) @@ -393,7 +393,7 @@ Ptr CreateObjectPython (PyObject *pyobj, const AttributeList &attributes) obj->Ref (); self->obj = ns3::PeekPointer (obj); } else { - ns3::Ptr< %(CONSTRUCT_NAME)s > obj = ns3::CreateObject< %(CONSTRUCT_NAME)s > (attrList); + ns3::Ptr< %(CONSTRUCT_NAME)s > obj = ns3::CreateObjectWithAttributes< %(CONSTRUCT_NAME)s > (attrList); obj->Ref (); self->obj = ns3::PeekPointer (obj); } diff --git a/examples/csma-packet-socket.cc b/examples/csma-packet-socket.cc index c75035642..fa24b3d0b 100644 --- a/examples/csma-packet-socket.cc +++ b/examples/csma-packet-socket.cc @@ -72,7 +72,7 @@ main (int argc, char *argv[]) // create the shared medium used by all csma devices. NS_LOG_INFO ("Create channels."); - Ptr channel = CreateObject ( + Ptr channel = CreateObjectWithAttributes ( "DataRate", DataRateValue (DataRate(5000000)), "Delay", TimeValue (MilliSeconds(2))); diff --git a/examples/simple-error-model.cc b/examples/simple-error-model.cc index c43664dbd..2751c0303 100644 --- a/examples/simple-error-model.cc +++ b/examples/simple-error-model.cc @@ -153,7 +153,7 @@ main (int argc, char *argv[]) // // Create an ErrorModel based on the implementation (constructor) // specified by the default classId - Ptr em = CreateObject ("RanVar", RandomVariableValue (UniformVariable (0.0, 1.0)), + Ptr em = CreateObjectWithAttributes ("RanVar", RandomVariableValue (UniformVariable (0.0, 1.0)), "ErrorRate", DoubleValue (0.001)); d3d2.Get (0)->SetAttribute ("ReceiveErrorModel", PointerValue (em)); diff --git a/examples/tcp-nsc-lfn.cc b/examples/tcp-nsc-lfn.cc index 93a67774b..0bb6fc685 100644 --- a/examples/tcp-nsc-lfn.cc +++ b/examples/tcp-nsc-lfn.cc @@ -109,9 +109,9 @@ int main (int argc, char *argv[]) DoubleValue rate(errRate); RandomVariableValue u01(UniformVariable (0.0, 1.0)); Ptr em1 = - CreateObject ("RanVar", u01, "ErrorRate", rate); + CreateObjectWithAttributes ("RanVar", u01, "ErrorRate", rate); Ptr em2 = - CreateObject ("RanVar", u01, "ErrorRate", rate); + CreateObjectWithAttributes ("RanVar", u01, "ErrorRate", rate); // This enables the specified errRate on both link endpoints. p2pInterfaces.Get(0)->SetAttribute("ReceiveErrorModel", PointerValue (em1)); diff --git a/src/core/attribute-test.cc b/src/core/attribute-test.cc index b0c3bf74f..46adf84d4 100644 --- a/src/core/attribute-test.cc +++ b/src/core/attribute-test.cc @@ -279,7 +279,7 @@ AttributeTest::RunTests (void) AttributeList params; Ptr p; NS_TEST_ASSERT (params.SetFailSafe ("ns3::AttributeObjectTest::TestBoolName", StringValue ("false"))); - p = CreateObject (params); + p = CreateObjectWithAttributes (params); CHECK_GET_STR (p, "TestBoolName", "false"); CHECK_GET_PARAM (p, "TestBoolName", BooleanValue, false); @@ -291,11 +291,11 @@ AttributeTest::RunTests (void) CHECK_GET_STR (p, "TestBoolName", "false"); CHECK_GET_PARAM (p, "TestBoolName", BooleanValue, false); - p = CreateObject ("TestBoolName", StringValue ("true")); + p = CreateObjectWithAttributes ("TestBoolName", StringValue ("true")); CHECK_GET_STR (p, "TestBoolName", "true"); CHECK_GET_PARAM (p, "TestBoolName", BooleanValue, true); - p = CreateObject ("TestBoolName", BooleanValue (true)); + p = CreateObjectWithAttributes ("TestBoolName", BooleanValue (true)); CHECK_GET_STR (p, "TestBoolName", "true"); CHECK_GET_PARAM (p, "TestBoolName", BooleanValue, true); @@ -502,7 +502,7 @@ AttributeTest::RunTests (void) Ptr x = ptr.Get (); NS_TEST_ASSERT (x == 0); - p = CreateObject ("Pointer", PointerValue (Create ())); + p = CreateObjectWithAttributes ("Pointer", PointerValue (Create ())); NS_TEST_ASSERT (p != 0); derived = 0; p->GetAttribute ("Pointer", ptr); diff --git a/src/core/object.h b/src/core/object.h index 8cf1120d2..721c7453b 100644 --- a/src/core/object.h +++ b/src/core/object.h @@ -200,7 +200,7 @@ protected: private: template - friend Ptr CreateObject (const AttributeList &attributes); + friend Ptr CreateObjectWithAttributes (const AttributeList &attributes); template friend Ptr CopyObject (Ptr object); template @@ -209,6 +209,8 @@ private: // by our python bindings to call the protected ObjectBase::Construct // method. friend void PythonCompleteConstruct (Ptr object, TypeId typeId, const AttributeList &attributes); + template + friend Ptr CompleteConstruct (T *object); friend class ObjectFactory; friend class AggregateIterator; @@ -290,7 +292,7 @@ Ptr CopyObject (Ptr object); * it with a set of attributes. */ template -Ptr CreateObject (const AttributeList &attributes); +Ptr CreateObjectWithAttributes (const AttributeList &attributes); /** * \param n1 name of attribute @@ -318,7 +320,7 @@ Ptr CreateObject (const AttributeList &attributes); */ template Ptr -CreateObject (std::string n1 = "", const AttributeValue & v1 = EmptyAttributeValue (), +CreateObjectWithAttributes (std::string n1 = "", const AttributeValue & v1 = EmptyAttributeValue (), std::string n2 = "", const AttributeValue & v2 = EmptyAttributeValue (), std::string n3 = "", const AttributeValue & v3 = EmptyAttributeValue (), std::string n4 = "", const AttributeValue & v4 = EmptyAttributeValue (), @@ -398,9 +400,15 @@ Ptr CopyObject (Ptr object) return p; } - template -Ptr CreateObject (const AttributeList &attributes) +Ptr CompleteConstruct (T *p) +{ + p->SetTypeId (T::GetTypeId ()); + p->Object::Construct (AttributeList()); + return Ptr (p, false); +} +template +Ptr CreateObjectWithAttributes (const AttributeList &attributes) { Ptr p = Ptr (new T (), false); p->SetTypeId (T::GetTypeId ()); @@ -410,7 +418,7 @@ Ptr CreateObject (const AttributeList &attributes) template Ptr -CreateObject (std::string n1 , const AttributeValue & v1, +CreateObjectWithAttributes (std::string n1 , const AttributeValue & v1, std::string n2 , const AttributeValue & v2, std::string n3 , const AttributeValue & v3, std::string n4 , const AttributeValue & v4, @@ -467,9 +475,58 @@ CreateObject (std::string n1 , const AttributeValue & v1, } attributes.SetWithTid (T::GetTypeId (), n9, v9); end: - return CreateObject (attributes); + return CreateObjectWithAttributes (attributes); } +template +Ptr CreateObject (void) +{ + return CompleteConstruct (new T ()); +} + +template +Ptr CreateObject (T1 a1) +{ + return CompleteConstruct (new T (a1)); +} + +template +Ptr CreateObject (T1 a1, T2 a2) +{ + return CompleteConstruct (new T (a1,a2)); +} + +template +Ptr CreateObject (T1 a1, T2 a2, T3 a3) +{ + return CompleteConstruct (new T (a1,a2,a3)); +} + +template +Ptr CreateObject (T1 a1, T2 a2, T3 a3, T4 a4) +{ + return CompleteConstruct (new T (a1,a2,a3,a4)); +} + +template +Ptr CreateObject (T1 a1, T2 a2, T3 a3, T4 a4, T5 a5) +{ + return CompleteConstruct (new T (a1,a2,a3,a4,a5)); +} + +template +Ptr CreateObject (T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6) +{ + return CompleteConstruct (new T (a1,a2,a3,a4,a5,a6)); +} + +template +Ptr CreateObject (T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6, T7 a7) +{ + return CompleteConstruct (new T (a1,a2,a3,a4,a5,a6,a7)); +} + + } // namespace ns3 #endif /* OBJECT_H */ diff --git a/src/helper/mobility-helper.cc b/src/helper/mobility-helper.cc index bca62db35..8cfe13bd4 100644 --- a/src/helper/mobility-helper.cc +++ b/src/helper/mobility-helper.cc @@ -34,7 +34,7 @@ NS_LOG_COMPONENT_DEFINE ("MobilityHelper"); MobilityHelper::MobilityHelper () { - m_position = CreateObject + m_position = CreateObjectWithAttributes ("X", RandomVariableValue (ConstantVariable (0.0)), "Y", RandomVariableValue (ConstantVariable (0.0))); m_mobility.SetTypeId ("ns3::ConstantPositionMobilityModel"); @@ -147,7 +147,7 @@ MobilityHelper::Install (Ptr node) const // we need to setup a hierarchical mobility model Ptr parent = m_mobilityStack.back (); Ptr hierarchical = - CreateObject ("Child", PointerValue (model), + CreateObjectWithAttributes ("Child", PointerValue (model), "Parent", PointerValue (parent)); object->AggregateObject (hierarchical); NS_LOG_DEBUG ("node="< Date: Fri, 19 Jun 2009 09:04:27 +0200 Subject: [PATCH 17/20] bug 585: NAV bug --- src/devices/wifi/mac-low.cc | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/devices/wifi/mac-low.cc b/src/devices/wifi/mac-low.cc index 30fda0099..6946e7e75 100644 --- a/src/devices/wifi/mac-low.cc +++ b/src/devices/wifi/mac-low.cc @@ -868,13 +868,6 @@ MacLow::ForwardDown (Ptr packet, WifiMacHeader const* hdr, ", duration=" << hdr->GetDuration () << ", seq=0x"<< std::hex << m_currentHdr.GetSequenceControl () << std::dec); m_phy->SendPacket (packet, txMode, WIFI_PREAMBLE_LONG, 0); - /* - * We have to notify the NAV of transmitted packets because of the 802.11e - * requirement from section 9.9.1.4 that each EDCAF update its NAV from the - * transmission of any other EDCAF within the same QSTA. - */ - Time txDuration = m_phy->CalculateTxDuration (packet->GetSize (), txMode, WIFI_PREAMBLE_LONG); - Simulator::Schedule (txDuration, &MacLow::NotifyNav, this, *hdr, txMode, WIFI_PREAMBLE_LONG); } void From c79635f21e40c554ca14fb349752afd438507aee Mon Sep 17 00:00:00 2001 From: Tommaso Pecorella Date: Fri, 19 Jun 2009 09:06:35 +0200 Subject: [PATCH 18/20] bug 562: bug in TagBuffer::WriteU64 --- src/common/tag-buffer.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/tag-buffer.cc b/src/common/tag-buffer.cc index bb086125d..8d441e570 100644 --- a/src/common/tag-buffer.cc +++ b/src/common/tag-buffer.cc @@ -99,7 +99,7 @@ TagBuffer::WriteU64 (uint64_t data) WriteU8 ((data >> 32) & 0xff); WriteU8 ((data >> 40) & 0xff); WriteU8 ((data >> 48) & 0xff); - WriteU8 ((data >> 54) & 0xff); + WriteU8 ((data >> 56) & 0xff); } void TagBuffer::WriteDouble (double v) From e8a4113e96e555d085872e1236a2699c265ccc97 Mon Sep 17 00:00:00 2001 From: Mathieu Lacage Date: Fri, 19 Jun 2009 09:13:29 +0200 Subject: [PATCH 19/20] bug 491: It is painful to enable all checksums --- src/internet-stack/icmpv4-l4-protocol.cc | 7 +------ src/internet-stack/icmpv4-l4-protocol.h | 1 - src/internet-stack/ipv4-l3-protocol.cc | 9 ++------- src/internet-stack/ipv4-l3-protocol.h | 1 - src/internet-stack/tcp-l4-protocol.cc | 11 +++-------- src/internet-stack/tcp-l4-protocol.h | 2 -- src/internet-stack/udp-l4-protocol.cc | 11 +++-------- src/internet-stack/udp-l4-protocol.h | 1 - src/node/node.cc | 15 +++++++++++++++ src/node/node.h | 6 ++++++ 10 files changed, 30 insertions(+), 34 deletions(-) diff --git a/src/internet-stack/icmpv4-l4-protocol.cc b/src/internet-stack/icmpv4-l4-protocol.cc index 49dfc2dcd..e5b8c9a28 100644 --- a/src/internet-stack/icmpv4-l4-protocol.cc +++ b/src/internet-stack/icmpv4-l4-protocol.cc @@ -26,11 +26,6 @@ Icmpv4L4Protocol::GetTypeId (void) static TypeId tid = TypeId ("ns3::Icmpv4L4Protocol") .SetParent () .AddConstructor () - .AddAttribute ("CalcChecksum", - "Control whether the icmp header checksum is calculated and stored in outgoing icmpv4 headers", - BooleanValue (false), - MakeBooleanAccessor (&Icmpv4L4Protocol::m_calcChecksum), - MakeBooleanChecker ()) ; return tid; } @@ -111,7 +106,7 @@ Icmpv4L4Protocol::SendMessage (Ptr packet, Ipv4Address source, Ipv4Addre Icmpv4Header icmp; icmp.SetType (type); icmp.SetCode (code); - if (m_calcChecksum) + if (Node::ChecksumEnabled ()) { icmp.EnableChecksum (); } diff --git a/src/internet-stack/icmpv4-l4-protocol.h b/src/internet-stack/icmpv4-l4-protocol.h index d9f328c30..27c834279 100644 --- a/src/internet-stack/icmpv4-l4-protocol.h +++ b/src/internet-stack/icmpv4-l4-protocol.h @@ -60,7 +60,6 @@ private: virtual void DoDispose (void); Ptr m_node; - bool m_calcChecksum; }; } // namespace ns3 diff --git a/src/internet-stack/ipv4-l3-protocol.cc b/src/internet-stack/ipv4-l3-protocol.cc index b3d635157..d9799fe70 100644 --- a/src/internet-stack/ipv4-l3-protocol.cc +++ b/src/internet-stack/ipv4-l3-protocol.cc @@ -61,11 +61,6 @@ Ipv4L3Protocol::GetTypeId (void) UintegerValue (64), MakeUintegerAccessor (&Ipv4L3Protocol::m_defaultTtl), MakeUintegerChecker ()) - .AddAttribute ("CalcChecksum", "If true, we calculate the checksum of outgoing packets" - " and verify the checksum of incoming packets.", - BooleanValue (false), - MakeBooleanAccessor (&Ipv4L3Protocol::m_calcChecksum), - MakeBooleanChecker ()) .AddTraceSource ("Tx", "Send ipv4 packet to outgoing interface.", MakeTraceSourceAccessor (&Ipv4L3Protocol::m_txTrace)) .AddTraceSource ("Rx", "Receive ipv4 packet from incoming interface.", @@ -422,7 +417,7 @@ Ipv4L3Protocol::Receive( Ptr device, Ptr p, uint16_t pr } Ipv4Header ipHeader; - if (m_calcChecksum) + if (Node::ChecksumEnabled ()) { ipHeader.EnableChecksum (); } @@ -609,7 +604,7 @@ Ipv4L3Protocol::BuildHeader ( ipHeader.SetIdentification (m_identification); m_identification ++; } - if (m_calcChecksum) + if (Node::ChecksumEnabled ()) { ipHeader.EnableChecksum (); } diff --git a/src/internet-stack/ipv4-l3-protocol.h b/src/internet-stack/ipv4-l3-protocol.h index 9b371a209..ae26ba232 100644 --- a/src/internet-stack/ipv4-l3-protocol.h +++ b/src/internet-stack/ipv4-l3-protocol.h @@ -211,7 +211,6 @@ private: Ipv4InterfaceList m_interfaces; uint32_t m_nInterfaces; uint8_t m_defaultTtl; - bool m_calcChecksum; uint16_t m_identification; Ptr m_node; TracedCallback, uint32_t> m_txTrace; diff --git a/src/internet-stack/tcp-l4-protocol.cc b/src/internet-stack/tcp-l4-protocol.cc index 92d0e2543..b133573a4 100644 --- a/src/internet-stack/tcp-l4-protocol.cc +++ b/src/internet-stack/tcp-l4-protocol.cc @@ -332,11 +332,6 @@ TcpL4Protocol::GetTypeId (void) ObjectFactoryValue (GetDefaultRttEstimatorFactory ()), MakeObjectFactoryAccessor (&TcpL4Protocol::m_rttFactory), MakeObjectFactoryChecker ()) - .AddAttribute ("CalcChecksum", "If true, we calculate the checksum of outgoing packets" - " and verify the checksum of incoming packets.", - BooleanValue (false), - MakeBooleanAccessor (&TcpL4Protocol::m_calcChecksum), - MakeBooleanChecker ()) .AddAttribute ("SocketList", "The list of sockets associated to this protocol.", ObjectVectorValue (), MakeObjectVectorAccessor (&TcpL4Protocol::m_sockets), @@ -477,7 +472,7 @@ TcpL4Protocol::Receive (Ptr packet, NS_LOG_FUNCTION (this << packet << source << destination << incomingInterface); TcpHeader tcpHeader; - if(m_calcChecksum) + if(Node::ChecksumEnabled ()) { tcpHeader.EnableChecksums(); tcpHeader.InitializeChecksum (source, destination, PROT_NUMBER); @@ -529,7 +524,7 @@ TcpL4Protocol::Send (Ptr packet, TcpHeader tcpHeader; tcpHeader.SetDestinationPort (dport); tcpHeader.SetSourcePort (sport); - if(m_calcChecksum) + if(Node::ChecksumEnabled ()) { tcpHeader.EnableChecksums(); } @@ -571,7 +566,7 @@ TcpL4Protocol::SendPacket (Ptr packet, TcpHeader outgoingHeader, outgoingHeader.SetLength (5); //header length in units of 32bit words /* outgoingHeader.SetUrgentPointer (0); //XXX */ - if(m_calcChecksum) + if(Node::ChecksumEnabled ()) { outgoingHeader.EnableChecksums(); } diff --git a/src/internet-stack/tcp-l4-protocol.h b/src/internet-stack/tcp-l4-protocol.h index f0e7e73b3..b610471c7 100644 --- a/src/internet-stack/tcp-l4-protocol.h +++ b/src/internet-stack/tcp-l4-protocol.h @@ -124,8 +124,6 @@ private: Ipv4Address, Ipv4Address); static ObjectFactory GetDefaultRttEstimatorFactory (void); - bool m_goodChecksum; - bool m_calcChecksum; std::vector > m_sockets; }; diff --git a/src/internet-stack/udp-l4-protocol.cc b/src/internet-stack/udp-l4-protocol.cc index f65a4228b..2f3bf9fc3 100644 --- a/src/internet-stack/udp-l4-protocol.cc +++ b/src/internet-stack/udp-l4-protocol.cc @@ -48,11 +48,6 @@ UdpL4Protocol::GetTypeId (void) static TypeId tid = TypeId ("ns3::UdpL4Protocol") .SetParent () .AddConstructor () - .AddAttribute ("CalcChecksum", "If true, we calculate the checksum of outgoing packets" - " and verify the checksum of incoming packets.", - BooleanValue (false), - MakeBooleanAccessor (&UdpL4Protocol::m_calcChecksum), - MakeBooleanChecker ()) ; return tid; } @@ -204,7 +199,7 @@ UdpL4Protocol::Receive(Ptr packet, { NS_LOG_FUNCTION (this << packet << source << destination); UdpHeader udpHeader; - if(m_calcChecksum) + if(Node::ChecksumEnabled ()) { udpHeader.EnableChecksums(); } @@ -243,7 +238,7 @@ UdpL4Protocol::Send (Ptr packet, NS_LOG_FUNCTION (this << packet << saddr << daddr << sport << dport); UdpHeader udpHeader; - if(m_calcChecksum) + if(Node::ChecksumEnabled ()) { udpHeader.EnableChecksums(); udpHeader.InitializeChecksum (saddr, @@ -272,7 +267,7 @@ UdpL4Protocol::Send (Ptr packet, NS_LOG_FUNCTION (this << packet << saddr << daddr << sport << dport); UdpHeader udpHeader; - if(m_calcChecksum) + if(Node::ChecksumEnabled ()) { udpHeader.EnableChecksums(); udpHeader.InitializeChecksum (saddr, diff --git a/src/internet-stack/udp-l4-protocol.h b/src/internet-stack/udp-l4-protocol.h index faf406ed6..50794d2c2 100644 --- a/src/internet-stack/udp-l4-protocol.h +++ b/src/internet-stack/udp-l4-protocol.h @@ -118,7 +118,6 @@ protected: private: Ptr m_node; Ipv4EndPointDemux *m_endPoints; - bool m_calcChecksum; }; }; // namespace ns3 diff --git a/src/node/node.cc b/src/node/node.cc index bdc7d1c35..90922de60 100644 --- a/src/node/node.cc +++ b/src/node/node.cc @@ -28,6 +28,8 @@ #include "ns3/uinteger.h" #include "ns3/log.h" #include "ns3/assert.h" +#include "ns3/global-value.h" +#include "ns3/boolean.h" NS_LOG_COMPONENT_DEFINE ("Node"); @@ -35,6 +37,11 @@ namespace ns3{ NS_OBJECT_ENSURE_REGISTERED (Node); +GlobalValue g_checksumEnabled = GlobalValue ("ChecksumEnabled", + "A global switch to enable all checksums for all protocols", + BooleanValue (false), + MakeBooleanChecker ()); + TypeId Node::GetTypeId (void) { @@ -222,6 +229,14 @@ Node::UnregisterProtocolHandler (ProtocolHandler handler) } } +bool +Node::ChecksumEnabled (void) +{ + BooleanValue val; + g_checksumEnabled.GetValue (val); + return val.Get (); +} + bool Node::PromiscReceiveFromDevice (Ptr device, Ptr packet, uint16_t protocol, const Address &from, const Address &to, NetDevice::PacketType packetType) diff --git a/src/node/node.h b/src/node/node.h index b740a175b..2ce67b530 100644 --- a/src/node/node.h +++ b/src/node/node.h @@ -172,6 +172,12 @@ public: */ void UnregisterProtocolHandler (ProtocolHandler handler); + + /** + * \returns true if checksums are enabled, false otherwise. + */ + static bool ChecksumEnabled (void); + protected: /** From a202b567d1fc83ef9079d8efe060dd09d45be53f Mon Sep 17 00:00:00 2001 From: Mathieu Lacage Date: Fri, 19 Jun 2009 09:17:08 +0200 Subject: [PATCH 20/20] forgot to add bindings for new module --- .../python/ns3_module_virtual_net_device.py | 242 ++++++++++++++++++ 1 file changed, 242 insertions(+) create mode 100644 bindings/python/ns3_module_virtual_net_device.py diff --git a/bindings/python/ns3_module_virtual_net_device.py b/bindings/python/ns3_module_virtual_net_device.py new file mode 100644 index 000000000..c13e0e6c7 --- /dev/null +++ b/bindings/python/ns3_module_virtual_net_device.py @@ -0,0 +1,242 @@ +from pybindgen import Module, FileCodeSink, param, retval, cppclass, typehandlers + +def register_types(module): + root_module = module.get_root() + + ## virtual-net-device.h: ns3::VirtualNetDevice [class] + module.add_class('VirtualNetDevice', parent=root_module['ns3::NetDevice']) + + ## Register a nested module for the namespace Config + + nested_module = module.add_cpp_namespace('Config') + register_types_ns3_Config(nested_module) + + + ## Register a nested module for the namespace TimeStepPrecision + + nested_module = module.add_cpp_namespace('TimeStepPrecision') + register_types_ns3_TimeStepPrecision(nested_module) + + + ## Register a nested module for the namespace addressUtils + + nested_module = module.add_cpp_namespace('addressUtils') + register_types_ns3_addressUtils(nested_module) + + + ## Register a nested module for the namespace internal + + nested_module = module.add_cpp_namespace('internal') + register_types_ns3_internal(nested_module) + + + ## Register a nested module for the namespace olsr + + nested_module = module.add_cpp_namespace('olsr') + register_types_ns3_olsr(nested_module) + + +def register_types_ns3_Config(module): + root_module = module.get_root() + + +def register_types_ns3_TimeStepPrecision(module): + root_module = module.get_root() + + +def register_types_ns3_addressUtils(module): + root_module = module.get_root() + + +def register_types_ns3_internal(module): + root_module = module.get_root() + + +def register_types_ns3_olsr(module): + root_module = module.get_root() + + +def register_methods(root_module): + register_Ns3VirtualNetDevice_methods(root_module, root_module['ns3::VirtualNetDevice']) + return + +def register_Ns3VirtualNetDevice_methods(root_module, cls): + ## virtual-net-device.h: ns3::VirtualNetDevice::VirtualNetDevice(ns3::VirtualNetDevice const & arg0) [copy constructor] + cls.add_constructor([param('ns3::VirtualNetDevice const &', 'arg0')]) + ## virtual-net-device.h: static ns3::TypeId ns3::VirtualNetDevice::GetTypeId() [member function] + cls.add_method('GetTypeId', + 'ns3::TypeId', + [], + is_static=True) + ## virtual-net-device.h: ns3::VirtualNetDevice::VirtualNetDevice() [constructor] + cls.add_constructor([]) + ## virtual-net-device.h: void ns3::VirtualNetDevice::SetSendCallback(ns3::Callback, ns3::Address const&, ns3::Address const&, unsigned short, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty> transmitCb) [member function] + cls.add_method('SetSendCallback', + 'void', + [param('ns3::Callback< bool, ns3::Ptr< ns3::Packet >, ns3::Address const &, ns3::Address const &, unsigned short, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty >', 'transmitCb')]) + ## virtual-net-device.h: void ns3::VirtualNetDevice::SetNeedsArp(bool needsArp) [member function] + cls.add_method('SetNeedsArp', + 'void', + [param('bool', 'needsArp')]) + ## virtual-net-device.h: void ns3::VirtualNetDevice::SetIsPointToPoint(bool isPointToPoint) [member function] + cls.add_method('SetIsPointToPoint', + 'void', + [param('bool', 'isPointToPoint')]) + ## virtual-net-device.h: void ns3::VirtualNetDevice::SetSupportsSendFrom(bool supportsSendFrom) [member function] + cls.add_method('SetSupportsSendFrom', + 'void', + [param('bool', 'supportsSendFrom')]) + ## virtual-net-device.h: bool ns3::VirtualNetDevice::SetMtu(uint16_t const mtu) [member function] + cls.add_method('SetMtu', + 'bool', + [param('uint16_t const', 'mtu')], + is_virtual=True) + ## virtual-net-device.h: bool ns3::VirtualNetDevice::Receive(ns3::Ptr packet, uint16_t protocol, ns3::Address const & source, ns3::Address const & destination, ns3::NetDevice::PacketType packetType) [member function] + cls.add_method('Receive', + 'bool', + [param('ns3::Ptr< ns3::Packet >', 'packet'), param('uint16_t', 'protocol'), param('ns3::Address const &', 'source'), param('ns3::Address const &', 'destination'), param('ns3::NetDevice::PacketType', 'packetType')]) + ## virtual-net-device.h: void ns3::VirtualNetDevice::SetAddress(ns3::Address addr) [member function] + cls.add_method('SetAddress', + 'void', + [param('ns3::Address', 'addr')]) + ## virtual-net-device.h: void ns3::VirtualNetDevice::SetIfIndex(uint32_t const index) [member function] + cls.add_method('SetIfIndex', + 'void', + [param('uint32_t const', 'index')], + is_virtual=True) + ## virtual-net-device.h: uint32_t ns3::VirtualNetDevice::GetIfIndex() const [member function] + cls.add_method('GetIfIndex', + 'uint32_t', + [], + is_const=True, is_virtual=True) + ## virtual-net-device.h: ns3::Ptr ns3::VirtualNetDevice::GetChannel() const [member function] + cls.add_method('GetChannel', + 'ns3::Ptr< ns3::Channel >', + [], + is_const=True, is_virtual=True) + ## virtual-net-device.h: ns3::Address ns3::VirtualNetDevice::GetAddress() const [member function] + cls.add_method('GetAddress', + 'ns3::Address', + [], + is_const=True, is_virtual=True) + ## virtual-net-device.h: uint16_t ns3::VirtualNetDevice::GetMtu() const [member function] + cls.add_method('GetMtu', + 'uint16_t', + [], + is_const=True, is_virtual=True) + ## virtual-net-device.h: bool ns3::VirtualNetDevice::IsLinkUp() const [member function] + cls.add_method('IsLinkUp', + 'bool', + [], + is_const=True, is_virtual=True) + ## virtual-net-device.h: void ns3::VirtualNetDevice::SetLinkChangeCallback(ns3::Callback callback) [member function] + cls.add_method('SetLinkChangeCallback', + 'void', + [param('ns3::Callback< void, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty >', 'callback')], + is_virtual=True) + ## virtual-net-device.h: bool ns3::VirtualNetDevice::IsBroadcast() const [member function] + cls.add_method('IsBroadcast', + 'bool', + [], + is_const=True, is_virtual=True) + ## virtual-net-device.h: ns3::Address ns3::VirtualNetDevice::GetBroadcast() const [member function] + cls.add_method('GetBroadcast', + 'ns3::Address', + [], + is_const=True, is_virtual=True) + ## virtual-net-device.h: bool ns3::VirtualNetDevice::IsMulticast() const [member function] + cls.add_method('IsMulticast', + 'bool', + [], + is_const=True, is_virtual=True) + ## virtual-net-device.h: ns3::Address ns3::VirtualNetDevice::GetMulticast(ns3::Ipv4Address multicastGroup) const [member function] + cls.add_method('GetMulticast', + 'ns3::Address', + [param('ns3::Ipv4Address', 'multicastGroup')], + is_const=True, is_virtual=True) + ## virtual-net-device.h: ns3::Address ns3::VirtualNetDevice::GetMulticast(ns3::Ipv6Address addr) const [member function] + cls.add_method('GetMulticast', + 'ns3::Address', + [param('ns3::Ipv6Address', 'addr')], + is_const=True, is_virtual=True) + ## virtual-net-device.h: bool ns3::VirtualNetDevice::IsPointToPoint() const [member function] + cls.add_method('IsPointToPoint', + 'bool', + [], + is_const=True, is_virtual=True) + ## virtual-net-device.h: bool ns3::VirtualNetDevice::Send(ns3::Ptr packet, ns3::Address const & dest, uint16_t protocolNumber) [member function] + cls.add_method('Send', + 'bool', + [param('ns3::Ptr< ns3::Packet >', 'packet'), param('ns3::Address const &', 'dest'), param('uint16_t', 'protocolNumber')], + is_virtual=True) + ## virtual-net-device.h: bool ns3::VirtualNetDevice::SendFrom(ns3::Ptr packet, ns3::Address const & source, ns3::Address const & dest, uint16_t protocolNumber) [member function] + cls.add_method('SendFrom', + 'bool', + [param('ns3::Ptr< ns3::Packet >', 'packet'), param('ns3::Address const &', 'source'), param('ns3::Address const &', 'dest'), param('uint16_t', 'protocolNumber')], + is_virtual=True) + ## virtual-net-device.h: ns3::Ptr ns3::VirtualNetDevice::GetNode() const [member function] + cls.add_method('GetNode', + 'ns3::Ptr< ns3::Node >', + [], + is_const=True, is_virtual=True) + ## virtual-net-device.h: void ns3::VirtualNetDevice::SetNode(ns3::Ptr node) [member function] + cls.add_method('SetNode', + 'void', + [param('ns3::Ptr< ns3::Node >', 'node')], + is_virtual=True) + ## virtual-net-device.h: bool ns3::VirtualNetDevice::NeedsArp() const [member function] + cls.add_method('NeedsArp', + 'bool', + [], + is_const=True, is_virtual=True) + ## virtual-net-device.h: void ns3::VirtualNetDevice::SetReceiveCallback(ns3::Callback, ns3::Ptr, unsigned short, ns3::Address const&, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty> cb) [member function] + cls.add_method('SetReceiveCallback', + 'void', + [param('ns3::Callback< bool, ns3::Ptr< ns3::NetDevice >, ns3::Ptr< ns3::Packet const >, unsigned short, ns3::Address const &, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty >', 'cb')], + is_virtual=True) + ## virtual-net-device.h: void ns3::VirtualNetDevice::SetPromiscReceiveCallback(ns3::Callback, ns3::Ptr, unsigned short, ns3::Address const&, ns3::Address const&, ns3::NetDevice::PacketType, ns3::empty, ns3::empty, ns3::empty> cb) [member function] + cls.add_method('SetPromiscReceiveCallback', + 'void', + [param('ns3::Callback< bool, ns3::Ptr< ns3::NetDevice >, ns3::Ptr< ns3::Packet const >, unsigned short, ns3::Address const &, ns3::Address const &, ns3::NetDevice::PacketType, ns3::empty, ns3::empty, ns3::empty >', 'cb')], + is_virtual=True) + ## virtual-net-device.h: bool ns3::VirtualNetDevice::SupportsSendFrom() const [member function] + cls.add_method('SupportsSendFrom', + 'bool', + [], + is_const=True, is_virtual=True) + ## virtual-net-device.h: bool ns3::VirtualNetDevice::IsBridge() const [member function] + cls.add_method('IsBridge', + 'bool', + [], + is_const=True, is_virtual=True) + ## virtual-net-device.h: void ns3::VirtualNetDevice::DoDispose() [member function] + cls.add_method('DoDispose', + 'void', + [], + visibility='protected', is_virtual=True) + return + +def register_functions(root_module): + module = root_module + register_functions_ns3_Config(module.get_submodule('Config'), root_module) + register_functions_ns3_TimeStepPrecision(module.get_submodule('TimeStepPrecision'), root_module) + register_functions_ns3_addressUtils(module.get_submodule('addressUtils'), root_module) + register_functions_ns3_internal(module.get_submodule('internal'), root_module) + register_functions_ns3_olsr(module.get_submodule('olsr'), root_module) + return + +def register_functions_ns3_Config(module, root_module): + return + +def register_functions_ns3_TimeStepPrecision(module, root_module): + return + +def register_functions_ns3_addressUtils(module, root_module): + return + +def register_functions_ns3_internal(module, root_module): + return + +def register_functions_ns3_olsr(module, root_module): + return +