--- a/CHANGES.html Sat Sep 06 06:57:27 2014 +0200
+++ b/CHANGES.html Sat Sep 06 07:08:49 2014 +0200
@@ -89,6 +89,8 @@
SetFfrAlgorithmType and SetFfrAlgorithmAttribute</li>
</ul>
</li>
+ <li> A new SimpleNetDeviceHelper can now be used to install SimpleNetDevices.
+ </li>
</ul>
<h2>Changes to existing API:</h2>
@@ -274,6 +276,10 @@
value class that represents simulation time; the largest unit prior to
this addition was Second.
</li>
+ <li> SimpleNetDevice and SimpleChannel are not so simple anymore. SimpleNetDevice can be now a
+ Broadcast or PointToPoint NetDevice, it can have a limited bandwidth and it uses an output
+ queue.
+ </li>
</ul>
<h2>Changes to build system:</h2>
--- a/RELEASE_NOTES Sat Sep 06 06:57:27 2014 +0200
+++ b/RELEASE_NOTES Sat Sep 06 07:08:49 2014 +0200
@@ -39,7 +39,12 @@
- updated RadioEnvironmentMapHelper. Now RadioEnvironmentMap can be generated
for Data or Control channel and for specified RbId, what is helpful when
using FR algorithms
-
+- SimpleNetDevice and SimpleChannel are not so simple anymore.
+ SimpleNetDevice can be now a Broadcast or PointToPoint NetDevice,
+ it can have a limited bandwidth and it uses an output queue.
+- SimpleNetDevice and SimpleChannel can be installed in a node through
+ an helper: SimpleNetDeviceHelper.
+
Bugs fixed
----------
--- a/src/internet/test/ipv4-fragmentation-test.cc Sat Sep 06 06:57:27 2014 +0200
+++ b/src/internet/test/ipv4-fragmentation-test.cc Sat Sep 06 07:08:49 2014 +0200
@@ -30,6 +30,7 @@
#include "ns3/simulator.h"
#include "error-channel.h"
#include "ns3/simple-net-device.h"
+#include "ns3/simple-net-device-helper.h"
#include "ns3/drop-tail-queue.h"
#include "ns3/socket.h"
#include "ns3/udp-socket.h"
@@ -45,6 +46,7 @@
#include "ns3/ipv4-list-routing.h"
#include "ns3/ipv4-static-routing.h"
#include "ns3/udp-l4-protocol.h"
+#include "ns3/internet-stack-helper.h"
#include <string>
#include <limits>
@@ -74,29 +76,6 @@
uint64_t getToken () { return token; }
};
-static void
-AddInternetStack (Ptr<Node> node)
-{
- //ARP
- Ptr<ArpL3Protocol> arp = CreateObject<ArpL3Protocol> ();
- node->AggregateObject(arp);
- //IPV4
- Ptr<Ipv4L3Protocol> ipv4 = CreateObject<Ipv4L3Protocol> ();
- //Routing for Ipv4
- Ptr<Ipv4ListRouting> ipv4Routing = CreateObject<Ipv4ListRouting> ();
- ipv4->SetRoutingProtocol (ipv4Routing);
- Ptr<Ipv4StaticRouting> ipv4staticRouting = CreateObject<Ipv4StaticRouting> ();
- ipv4Routing->AddRoutingProtocol (ipv4staticRouting, 0);
- node->AggregateObject(ipv4);
- //ICMP
- Ptr<Icmpv4L4Protocol> icmp = CreateObject<Icmpv4L4Protocol> ();
- node->AggregateObject(icmp);
- // //Ipv4Raw
- Ptr<UdpL4Protocol> udp = CreateObject<UdpL4Protocol> ();
- node->AggregateObject(udp);
-}
-
-
class Ipv4FragmentationTest: public TestCase
{
Ptr<Packet> m_sentPacketClient;
@@ -283,52 +262,52 @@
// Create topology
- // Receiver Node
+ // Receiver Node
Ptr<Node> serverNode = CreateObject<Node> ();
- AddInternetStack (serverNode);
- Ptr<SimpleNetDevice> serverDev;
- Ptr<BinaryErrorModel> serverDevErrorModel = CreateObject<BinaryErrorModel> ();
- {
- serverDev = CreateObject<SimpleNetDevice> ();
- serverDev->SetAddress (Mac48Address::ConvertFrom (Mac48Address::Allocate ()));
- serverDev->SetMtu(1500);
- serverDev->SetReceiveErrorModel(serverDevErrorModel);
- serverDevErrorModel->Disable();
- serverNode->AddDevice (serverDev);
- Ptr<Ipv4> ipv4 = serverNode->GetObject<Ipv4> ();
- uint32_t netdev_idx = ipv4->AddInterface (serverDev);
- Ipv4InterfaceAddress ipv4Addr = Ipv4InterfaceAddress (Ipv4Address ("10.0.0.1"), Ipv4Mask (0xffff0000U));
- ipv4->AddAddress (netdev_idx, ipv4Addr);
- ipv4->SetUp (netdev_idx);
- }
- StartServer(serverNode);
-
// Sender Node
Ptr<Node> clientNode = CreateObject<Node> ();
- AddInternetStack (clientNode);
- Ptr<SimpleNetDevice> clientDev;
+
+ NodeContainer nodes (serverNode, clientNode);
+
+ Ptr<ErrorChannel> channel = CreateObject<ErrorChannel> ();
+ channel->SetJumpingTime (Seconds (0.5));
+
+ SimpleNetDeviceHelper helperChannel;
+ helperChannel.SetNetDevicePointToPointMode (true);
+ NetDeviceContainer net = helperChannel.Install (nodes, channel);
+
+ InternetStackHelper internet;
+ internet.Install (nodes);
+
+ Ptr<Ipv4> ipv4;
+ uint32_t netdev_idx;
+ Ipv4InterfaceAddress ipv4Addr;
+
+ // Receiver Node
+ ipv4 = serverNode->GetObject<Ipv4> ();
+ netdev_idx = ipv4->AddInterface (net.Get (0));
+ ipv4Addr = Ipv4InterfaceAddress (Ipv4Address ("10.0.0.1"), Ipv4Mask (0xffff0000U));
+ ipv4->AddAddress (netdev_idx, ipv4Addr);
+ ipv4->SetUp (netdev_idx);
+ Ptr<BinaryErrorModel> serverDevErrorModel = CreateObject<BinaryErrorModel> ();
+ Ptr<SimpleNetDevice> serverDev = DynamicCast<SimpleNetDevice> (net.Get (0));
+ serverDevErrorModel->Disable ();
+ serverDev->SetMtu(1500);
+ serverDev->SetReceiveErrorModel (serverDevErrorModel);
+ StartServer (serverNode);
+
+ // Sender Node
+ ipv4 = clientNode->GetObject<Ipv4> ();
+ netdev_idx = ipv4->AddInterface (net.Get (1));
+ ipv4Addr = Ipv4InterfaceAddress (Ipv4Address ("10.0.0.2"), Ipv4Mask (0xffff0000U));
+ ipv4->AddAddress (netdev_idx, ipv4Addr);
+ ipv4->SetUp (netdev_idx);
Ptr<BinaryErrorModel> clientDevErrorModel = CreateObject<BinaryErrorModel> ();
- {
- clientDev = CreateObject<SimpleNetDevice> ();
- clientDev->SetAddress (Mac48Address::ConvertFrom (Mac48Address::Allocate ()));
- clientDev->SetMtu(1000);
- clientDev->SetReceiveErrorModel(clientDevErrorModel);
- clientDevErrorModel->Disable();
- clientNode->AddDevice (clientDev);
- Ptr<Ipv4> ipv4 = clientNode->GetObject<Ipv4> ();
- uint32_t netdev_idx = ipv4->AddInterface (clientDev);
- Ipv4InterfaceAddress ipv4Addr = Ipv4InterfaceAddress (Ipv4Address ("10.0.0.2"), Ipv4Mask (0xffff0000U));
- ipv4->AddAddress (netdev_idx, ipv4Addr);
- ipv4->SetUp (netdev_idx);
- }
- StartClient(clientNode);
-
- // link the two nodes
- Ptr<ErrorChannel> channel = CreateObject<ErrorChannel> ();
- serverDev->SetChannel (channel);
- clientDev->SetChannel (channel);
- channel->SetJumpingTime(Seconds(0.5));
-
+ Ptr<SimpleNetDevice> clientDev = DynamicCast<SimpleNetDevice> (net.Get (1));
+ clientDevErrorModel->Disable ();
+ clientDev->SetMtu(1500);
+ clientDev->SetReceiveErrorModel (clientDevErrorModel);
+ StartClient (clientNode);
// some small packets, some rather big ones
uint32_t packetSizes[5] = {1000, 2000, 5000, 10000, 65000};
--- a/src/internet/test/ipv4-raw-test.cc Sat Sep 06 06:57:27 2014 +0200
+++ b/src/internet/test/ipv4-raw-test.cc Sat Sep 06 07:08:49 2014 +0200
@@ -27,6 +27,7 @@
#include "ns3/simulator.h"
#include "ns3/simple-channel.h"
#include "ns3/simple-net-device.h"
+#include "ns3/simple-net-device-helper.h"
#include "ns3/drop-tail-queue.h"
#include "ns3/socket.h"
@@ -40,6 +41,7 @@
#include "ns3/icmpv4-l4-protocol.h"
#include "ns3/ipv4-list-routing.h"
#include "ns3/ipv4-static-routing.h"
+#include "ns3/internet-stack-helper.h"
#include <string>
#include <limits>
@@ -49,28 +51,6 @@
using namespace ns3;
-static void
-AddInternetStack (Ptr<Node> node)
-{
- //ARP
- Ptr<ArpL3Protocol> arp = CreateObject<ArpL3Protocol> ();
- node->AggregateObject (arp);
- //IPV4
- Ptr<Ipv4L3Protocol> ipv4 = CreateObject<Ipv4L3Protocol> ();
- //Routing for Ipv4
- Ptr<Ipv4ListRouting> ipv4Routing = CreateObject<Ipv4ListRouting> ();
- ipv4->SetRoutingProtocol (ipv4Routing);
- Ptr<Ipv4StaticRouting> ipv4staticRouting = CreateObject<Ipv4StaticRouting> ();
- ipv4Routing->AddRoutingProtocol (ipv4staticRouting, 0);
- node->AggregateObject (ipv4);
- //ICMP
- Ptr<Icmpv4L4Protocol> icmp = CreateObject<Icmpv4L4Protocol> ();
- node->AggregateObject (icmp);
- // //Ipv4Raw
- // Ptr<Ipv4UdpL4Protocol> udp = CreateObject<UdpL4Protocol> ();
- // node->AggregateObject(udp);
-}
-
class Ipv4RawSocketImplTest : public TestCase
{
@@ -181,65 +161,49 @@
// Receiver Node
Ptr<Node> rxNode = CreateObject<Node> ();
- AddInternetStack (rxNode);
- Ptr<SimpleNetDevice> rxDev1, rxDev2;
- { // first interface
- rxDev1 = CreateObject<SimpleNetDevice> ();
- rxDev1->SetAddress (Mac48Address::ConvertFrom (Mac48Address::Allocate ()));
- rxNode->AddDevice (rxDev1);
- Ptr<Ipv4> ipv4 = rxNode->GetObject<Ipv4> ();
- uint32_t netdev_idx = ipv4->AddInterface (rxDev1);
- Ipv4InterfaceAddress ipv4Addr = Ipv4InterfaceAddress (Ipv4Address ("10.0.0.1"), Ipv4Mask (0xffff0000U));
- ipv4->AddAddress (netdev_idx, ipv4Addr);
- ipv4->SetUp (netdev_idx);
- }
-
- { // second interface
- rxDev2 = CreateObject<SimpleNetDevice> ();
- rxDev2->SetAddress (Mac48Address::ConvertFrom (Mac48Address::Allocate ()));
- rxNode->AddDevice (rxDev2);
- Ptr<Ipv4> ipv4 = rxNode->GetObject<Ipv4> ();
- uint32_t netdev_idx = ipv4->AddInterface (rxDev2);
- Ipv4InterfaceAddress ipv4Addr = Ipv4InterfaceAddress (Ipv4Address ("10.0.1.1"), Ipv4Mask (0xffff0000U));
- ipv4->AddAddress (netdev_idx, ipv4Addr);
- ipv4->SetUp (netdev_idx);
- }
-
// Sender Node
Ptr<Node> txNode = CreateObject<Node> ();
- AddInternetStack (txNode);
- Ptr<SimpleNetDevice> txDev1;
- {
- txDev1 = CreateObject<SimpleNetDevice> ();
- txDev1->SetAddress (Mac48Address::ConvertFrom (Mac48Address::Allocate ()));
- txNode->AddDevice (txDev1);
- Ptr<Ipv4> ipv4 = txNode->GetObject<Ipv4> ();
- uint32_t netdev_idx = ipv4->AddInterface (txDev1);
- Ipv4InterfaceAddress ipv4Addr = Ipv4InterfaceAddress (Ipv4Address ("10.0.0.2"), Ipv4Mask (0xffff0000U));
- ipv4->AddAddress (netdev_idx, ipv4Addr);
- ipv4->SetUp (netdev_idx);
- }
- Ptr<SimpleNetDevice> txDev2;
- {
- txDev2 = CreateObject<SimpleNetDevice> ();
- txDev2->SetAddress (Mac48Address::ConvertFrom (Mac48Address::Allocate ()));
- txNode->AddDevice (txDev2);
- Ptr<Ipv4> ipv4 = txNode->GetObject<Ipv4> ();
- uint32_t netdev_idx = ipv4->AddInterface (txDev2);
- Ipv4InterfaceAddress ipv4Addr = Ipv4InterfaceAddress (Ipv4Address ("10.0.1.2"), Ipv4Mask (0xffff0000U));
- ipv4->AddAddress (netdev_idx, ipv4Addr);
- ipv4->SetUp (netdev_idx);
- }
+
+ NodeContainer nodes (rxNode, txNode);
+
+ SimpleNetDeviceHelper helperChannel1;
+ helperChannel1.SetNetDevicePointToPointMode (true);
+ NetDeviceContainer net1 = helperChannel1.Install (nodes);
+
+ SimpleNetDeviceHelper helperChannel2;
+ helperChannel2.SetNetDevicePointToPointMode (true);
+ NetDeviceContainer net2 = helperChannel2.Install (nodes);
+
+ InternetStackHelper internet;
+ internet.Install (nodes);
+
+ Ptr<Ipv4> ipv4;
+ uint32_t netdev_idx;
+ Ipv4InterfaceAddress ipv4Addr;
- // link the two nodes
- Ptr<SimpleChannel> channel1 = CreateObject<SimpleChannel> ();
- rxDev1->SetChannel (channel1);
- txDev1->SetChannel (channel1);
+ // Receiver Node
+ ipv4 = rxNode->GetObject<Ipv4> ();
+ netdev_idx = ipv4->AddInterface (net1.Get (0));
+ ipv4Addr = Ipv4InterfaceAddress (Ipv4Address ("10.0.0.1"), Ipv4Mask (0xffff0000U));
+ ipv4->AddAddress (netdev_idx, ipv4Addr);
+ ipv4->SetUp (netdev_idx);
+
+ netdev_idx = ipv4->AddInterface (net2.Get (0));
+ ipv4Addr = Ipv4InterfaceAddress (Ipv4Address ("10.0.1.1"), Ipv4Mask (0xffff0000U));
+ ipv4->AddAddress (netdev_idx, ipv4Addr);
+ ipv4->SetUp (netdev_idx);
- Ptr<SimpleChannel> channel2 = CreateObject<SimpleChannel> ();
- rxDev2->SetChannel (channel2);
- txDev2->SetChannel (channel2);
+ // Sender Node
+ ipv4 = txNode->GetObject<Ipv4> ();
+ netdev_idx = ipv4->AddInterface (net1.Get (1));
+ ipv4Addr = Ipv4InterfaceAddress (Ipv4Address ("10.0.0.2"), Ipv4Mask (0xffff0000U));
+ ipv4->AddAddress (netdev_idx, ipv4Addr);
+ ipv4->SetUp (netdev_idx);
+ netdev_idx = ipv4->AddInterface (net2.Get (1));
+ ipv4Addr = Ipv4InterfaceAddress (Ipv4Address ("10.0.1.2"), Ipv4Mask (0xffff0000U));
+ ipv4->AddAddress (netdev_idx, ipv4Addr);
+ ipv4->SetUp (netdev_idx);
// Create the IPv4 Raw sockets
Ptr<SocketFactory> rxSocketFactory = rxNode->GetObject<Ipv4RawSocketFactory> ();
--- a/src/internet/test/ipv6-forwarding-test.cc Sat Sep 06 06:57:27 2014 +0200
+++ b/src/internet/test/ipv6-forwarding-test.cc Sat Sep 06 07:08:49 2014 +0200
@@ -24,6 +24,7 @@
#include "ns3/simulator.h"
#include "ns3/simple-channel.h"
#include "ns3/simple-net-device.h"
+#include "ns3/simple-net-device-helper.h"
#include "ns3/drop-tail-queue.h"
#include "ns3/socket.h"
#include "ns3/boolean.h"
@@ -36,35 +37,15 @@
#include "ns3/icmpv6-l4-protocol.h"
#include "ns3/udp-l4-protocol.h"
#include "ns3/ipv6-static-routing.h"
+#include "ns3/internet-stack-helper.h"
+#include "ns3/ipv6-address-helper.h"
+#include "ns3/ipv6-routing-helper.h"
#include <string>
#include <limits>
using namespace ns3;
-static void
-AddInternetStack6 (Ptr<Node> node)
-{
- //IPV6
- Ptr<Ipv6L3Protocol> ipv6 = CreateObject<Ipv6L3Protocol> ();
- //Routing for Ipv6
- Ptr<Ipv6StaticRouting> ipv6Routing = CreateObject<Ipv6StaticRouting> ();
- ipv6->SetRoutingProtocol (ipv6Routing);
- node->AggregateObject (ipv6);
- node->AggregateObject (ipv6Routing);
- //ICMP
- Ptr<Icmpv6L4Protocol> icmp = CreateObject<Icmpv6L4Protocol> ();
- node->AggregateObject (icmp);
- //Ipv6 Extensions
- ipv6->RegisterExtensions ();
- ipv6->RegisterOptions ();
- //UDP
- Ptr<UdpL4Protocol> udp = CreateObject<UdpL4Protocol> ();
- node->AggregateObject (udp);
-}
-
-
-
class Ipv6ForwardingTest : public TestCase
{
Ptr<Packet> m_receivedPacket;
@@ -79,7 +60,7 @@
};
Ipv6ForwardingTest::Ipv6ForwardingTest ()
- : TestCase ("UDP6 socket implementation")
+ : TestCase ("IPv6 forwarding")
{
}
@@ -118,72 +99,65 @@
// Receiver Node
Ptr<Node> rxNode = CreateObject<Node> ();
- AddInternetStack6 (rxNode);
- Ptr<SimpleNetDevice> rxDev;
- { // first interface
- rxDev = CreateObject<SimpleNetDevice> ();
- rxDev->SetAddress (Mac48Address::ConvertFrom (Mac48Address::Allocate ()));
- rxNode->AddDevice (rxDev);
- Ptr<Ipv6> ipv6 = rxNode->GetObject<Ipv6> ();
- uint32_t netdev_idx = ipv6->AddInterface (rxDev);
- Ipv6InterfaceAddress ipv6Addr = Ipv6InterfaceAddress (Ipv6Address ("2001:1::2"), Ipv6Prefix (64));
- ipv6->AddAddress (netdev_idx, ipv6Addr);
- ipv6->SetUp (netdev_idx);
- }
-
// Forwarding Node
Ptr<Node> fwNode = CreateObject<Node> ();
- AddInternetStack6 (fwNode);
- Ptr<SimpleNetDevice> fwDev1, fwDev2;
- { // first interface
- fwDev1 = CreateObject<SimpleNetDevice> ();
- fwDev1->SetAddress (Mac48Address::ConvertFrom (Mac48Address::Allocate ()));
- fwNode->AddDevice (fwDev1);
- Ptr<Ipv6> ipv6 = fwNode->GetObject<Ipv6> ();
- uint32_t netdev_idx = ipv6->AddInterface (fwDev1);
- Ipv6InterfaceAddress ipv6Addr = Ipv6InterfaceAddress (Ipv6Address ("2001:1::1"), Ipv6Prefix (64));
- ipv6->AddAddress (netdev_idx, ipv6Addr);
- ipv6->SetUp (netdev_idx);
- }
-
- Ipv6Address nextHop;
- { // second interface
- fwDev2 = CreateObject<SimpleNetDevice> ();
- fwDev2->SetAddress (Mac48Address::ConvertFrom (Mac48Address::Allocate ()));
- fwNode->AddDevice (fwDev2);
- Ptr<Ipv6> ipv6 = fwNode->GetObject<Ipv6> ();
- uint32_t netdev_idx = ipv6->AddInterface (fwDev2);
- Ipv6InterfaceAddress ipv6Addr = Ipv6InterfaceAddress (Ipv6Address ("2001:2::1"), Ipv6Prefix (64));
- nextHop = ipv6->GetAddress(netdev_idx, 0).GetAddress();
- ipv6->AddAddress (netdev_idx, ipv6Addr);
- ipv6->SetUp (netdev_idx);
- }
-
// Sender Node
Ptr<Node> txNode = CreateObject<Node> ();
- AddInternetStack6 (txNode);
- Ptr<SimpleNetDevice> txDev;
- {
- txDev = CreateObject<SimpleNetDevice> ();
- txDev->SetAddress (Mac48Address::ConvertFrom (Mac48Address::Allocate ()));
- txNode->AddDevice (txDev);
- Ptr<Ipv6> ipv6 = txNode->GetObject<Ipv6> ();
- uint32_t netdev_idx = ipv6->AddInterface (txDev);
- Ipv6InterfaceAddress ipv6Addr = Ipv6InterfaceAddress (Ipv6Address ("2001:2::2"), Ipv6Prefix (64));
- ipv6->AddAddress (netdev_idx, ipv6Addr);
- ipv6->SetUp (netdev_idx);
- Ptr<Ipv6StaticRouting> ipv6StaticRouting = txNode->GetObject<Ipv6StaticRouting> ();
- ipv6StaticRouting->SetDefaultRoute(nextHop, netdev_idx);
- }
+
+ NodeContainer net1nodes (rxNode, fwNode);
+ NodeContainer net2nodes (fwNode, txNode);
+ NodeContainer nodes (rxNode, fwNode, txNode);
+
+ SimpleNetDeviceHelper helperChannel1;
+ helperChannel1.SetNetDevicePointToPointMode (true);
+ NetDeviceContainer net1 = helperChannel1.Install (net1nodes);
+
+ SimpleNetDeviceHelper helperChannel2;
+ helperChannel2.SetNetDevicePointToPointMode (true);
+ NetDeviceContainer net2 = helperChannel2.Install (net2nodes);
+
+ InternetStackHelper internetv6;
+ internetv6.Install (nodes);
+
+ txNode->GetObject<Icmpv6L4Protocol> ()->SetAttribute ("DAD", BooleanValue (false));
+ fwNode->GetObject<Icmpv6L4Protocol> ()->SetAttribute ("DAD", BooleanValue (false));
+ rxNode->GetObject<Icmpv6L4Protocol> ()->SetAttribute ("DAD", BooleanValue (false));
+
+ Ipv6AddressHelper ipv6helper;
+ Ipv6InterfaceContainer iic1 = ipv6helper.AssignWithoutAddress (net1);
+ Ipv6InterfaceContainer iic2 = ipv6helper.AssignWithoutAddress (net2);
- // link the two nodes
- Ptr<SimpleChannel> channel1 = CreateObject<SimpleChannel> ();
- rxDev->SetChannel (channel1);
- fwDev1->SetChannel (channel1);
+ Ptr<NetDevice> device;
+ Ptr<Ipv6> ipv6;
+ int32_t ifIndex;
+ Ipv6InterfaceAddress ipv6Addr;
+
+ ipv6 = rxNode->GetObject<Ipv6> ();
+ device = net1.Get (0);
+ ifIndex = ipv6->GetInterfaceForDevice (device);
+ ipv6Addr = Ipv6InterfaceAddress (Ipv6Address ("2001:1::2"), Ipv6Prefix (64));
+ ipv6->AddAddress (ifIndex, ipv6Addr);
- Ptr<SimpleChannel> channel2 = CreateObject<SimpleChannel> ();
- fwDev2->SetChannel (channel2);
- txDev->SetChannel (channel2);
+ ipv6 = fwNode->GetObject<Ipv6> ();
+ device = net1.Get (1);
+ ifIndex = ipv6->GetInterfaceForDevice (device);
+ ipv6Addr = Ipv6InterfaceAddress (Ipv6Address ("2001:1::1"), Ipv6Prefix (64));
+ ipv6->AddAddress (ifIndex, ipv6Addr);
+
+ device = net2.Get (0);
+ ifIndex = ipv6->GetInterfaceForDevice (device);
+ ipv6Addr = Ipv6InterfaceAddress (Ipv6Address ("2001:2::1"), Ipv6Prefix (64));
+ ipv6->AddAddress (ifIndex, ipv6Addr);
+
+ ipv6 = txNode->GetObject<Ipv6> ();
+ device = net2.Get (1);
+ ifIndex = ipv6->GetInterfaceForDevice (device);
+ ipv6Addr = Ipv6InterfaceAddress (Ipv6Address ("2001:2::2"), Ipv6Prefix (64));
+ ipv6->AddAddress (ifIndex, ipv6Addr);
+
+ // Setup at least a route from the sender.
+ Ptr<Ipv6StaticRouting> ipv6StaticRouting = Ipv6RoutingHelper::GetRouting <Ipv6StaticRouting> (txNode->GetObject<Ipv6> ()->GetRoutingProtocol ());
+ ipv6StaticRouting->SetDefaultRoute (Ipv6Address ("2001:2::1"), ifIndex);
// Create the UDP sockets
Ptr<SocketFactory> rxSocketFactory = rxNode->GetObject<UdpSocketFactory> ();
@@ -204,7 +178,7 @@
m_receivedPacket->RemoveAllByteTags ();
m_receivedPacket = 0;
- Ptr<Ipv6> ipv6 = fwNode->GetObject<Ipv6> ();
+ ipv6 = fwNode->GetObject<Ipv6> ();
ipv6->SetAttribute("IpForward", BooleanValue (true));
SendData (txSocket, "2001:1::2");
NS_TEST_EXPECT_MSG_EQ (m_receivedPacket->GetSize (), 123, "IPv6 Forwarding on");
--- a/src/internet/test/ipv6-raw-test.cc Sat Sep 06 06:57:27 2014 +0200
+++ b/src/internet/test/ipv6-raw-test.cc Sat Sep 06 07:08:49 2014 +0200
@@ -27,19 +27,23 @@
#include "ns3/simulator.h"
#include "ns3/simple-channel.h"
#include "ns3/simple-net-device.h"
+#include "ns3/simple-net-device-helper.h"
#include "ns3/drop-tail-queue.h"
#include "ns3/socket.h"
#include "ns3/log.h"
#include "ns3/node.h"
+#include "ns3/node-container.h"
#include "ns3/inet6-socket-address.h"
#include "ns3/boolean.h"
#include "ns3/uinteger.h"
+#include "ns3/internet-stack-helper.h"
#include "ns3/ipv6-l3-protocol.h"
#include "ns3/icmpv6-l4-protocol.h"
#include "ns3/ipv6-list-routing.h"
#include "ns3/ipv6-static-routing.h"
+#include "ns3/ipv6-address-helper.h"
#include <string>
#include <limits>
@@ -49,25 +53,6 @@
using namespace ns3;
-static void
-AddInternetStack (Ptr<Node> node)
-{
- Ptr<Ipv6L3Protocol> ipv6 = CreateObject<Ipv6L3Protocol> ();
- Ptr<Icmpv6L4Protocol> icmpv6 = CreateObject<Icmpv6L4Protocol> ();
- node->AggregateObject (ipv6);
- node->AggregateObject (icmpv6);
- ipv6->Insert (icmpv6);
- icmpv6->SetAttribute ("DAD", BooleanValue (false));
-
- //Routing for Ipv6
- Ptr<Ipv6ListRouting> ipv6Routing = CreateObject<Ipv6ListRouting> ();
- ipv6->SetRoutingProtocol (ipv6Routing);
- Ptr<Ipv6StaticRouting> ipv6staticRouting = CreateObject<Ipv6StaticRouting> (); ipv6Routing->AddRoutingProtocol (ipv6staticRouting, 0);
- /* register IPv6 extensions and options */
- ipv6->RegisterExtensions (); ipv6->RegisterOptions ();
-}
-
-
class Ipv6RawSocketImplTest : public TestCase
{
Ptr<Packet> m_receivedPacket;
@@ -121,7 +106,7 @@
m_receivedPacket2 = socket->RecvFrom (std::numeric_limits<uint32_t>::max (), 0, addr);
NS_ASSERT (availableData == m_receivedPacket2->GetSize ());
Inet6SocketAddress v6addr = Inet6SocketAddress::ConvertFrom (addr);
- NS_TEST_EXPECT_MSG_EQ (v6addr.GetIpv6 (),Ipv6Address ("2001:0db8:0000:0000:0000:0000:0000:0002"), "recvfrom");
+ NS_TEST_EXPECT_MSG_EQ (v6addr.GetIpv6 (), Ipv6Address ("2001:db8::2"), "recvfrom");
}
void
@@ -149,65 +134,55 @@
// Receiver Node
Ptr<Node> rxNode = CreateObject<Node> ();
- AddInternetStack (rxNode);
- Ptr<SimpleNetDevice> rxDev1, rxDev2;
- { // first interface
- rxDev1 = CreateObject<SimpleNetDevice> ();
- rxDev1->SetAddress (Mac48Address::ConvertFrom (Mac48Address::Allocate ()));
- rxNode->AddDevice (rxDev1);
- Ptr<Ipv6> ipv6 = rxNode->GetObject<Ipv6> ();
- uint32_t netdev_idx = ipv6->AddInterface (rxDev1);
- Ipv6InterfaceAddress ipv6Addr = Ipv6InterfaceAddress (Ipv6Address ("2001:db8:0::1"), Ipv6Prefix (64));
- ipv6->AddAddress (netdev_idx, ipv6Addr);
- ipv6->SetUp (netdev_idx);
- }
-
- { // second interface
- rxDev2 = CreateObject<SimpleNetDevice> ();
- rxDev2->SetAddress (Mac48Address::ConvertFrom (Mac48Address::Allocate ()));
- rxNode->AddDevice (rxDev2);
- Ptr<Ipv6> ipv6 = rxNode->GetObject<Ipv6> ();
- uint32_t netdev_idx = ipv6->AddInterface (rxDev2);
- Ipv6InterfaceAddress ipv6Addr = Ipv6InterfaceAddress (Ipv6Address ("2001:db8:1::1"), Ipv6Prefix (64));
- ipv6->AddAddress (netdev_idx, ipv6Addr);
- ipv6->SetUp (netdev_idx);
- }
-
// Sender Node
Ptr<Node> txNode = CreateObject<Node> ();
- AddInternetStack (txNode);
- Ptr<SimpleNetDevice> txDev1;
- {
- txDev1 = CreateObject<SimpleNetDevice> ();
- txDev1->SetAddress (Mac48Address::ConvertFrom (Mac48Address::Allocate ()));
- txNode->AddDevice (txDev1);
- Ptr<Ipv6> ipv6 = txNode->GetObject<Ipv6> ();
- uint32_t netdev_idx = ipv6->AddInterface (txDev1);
- Ipv6InterfaceAddress ipv6Addr = Ipv6InterfaceAddress (Ipv6Address ("2001:db8:0::2"), Ipv6Prefix (64));
- ipv6->AddAddress (netdev_idx, ipv6Addr);
- ipv6->SetUp (netdev_idx);
- }
- Ptr<SimpleNetDevice> txDev2;
- {
- txDev2 = CreateObject<SimpleNetDevice> ();
- txDev2->SetAddress (Mac48Address::ConvertFrom (Mac48Address::Allocate ()));
- txNode->AddDevice (txDev2);
- Ptr<Ipv6> ipv6 = txNode->GetObject<Ipv6> ();
- uint32_t netdev_idx = ipv6->AddInterface (txDev2);
- Ipv6InterfaceAddress ipv6Addr = Ipv6InterfaceAddress (Ipv6Address ("2001:db8:1::2"), Ipv6Prefix (64));
- ipv6->AddAddress (netdev_idx, ipv6Addr);
- ipv6->SetUp (netdev_idx);
- }
+
+ NodeContainer nodes (rxNode, txNode);
+
+ SimpleNetDeviceHelper helperChannel1;
+ helperChannel1.SetNetDevicePointToPointMode (true);
+ NetDeviceContainer net1 = helperChannel1.Install (nodes);
+
+ SimpleNetDeviceHelper helperChannel2;
+ helperChannel2.SetNetDevicePointToPointMode (true);
+ NetDeviceContainer net2 = helperChannel2.Install (nodes);
+
+ InternetStackHelper internetv6;
+ internetv6.Install (nodes);
+
+ txNode->GetObject<Icmpv6L4Protocol> ()->SetAttribute ("DAD", BooleanValue (false));
+ rxNode->GetObject<Icmpv6L4Protocol> ()->SetAttribute ("DAD", BooleanValue (false));
+
+ Ipv6AddressHelper ipv6helper;
+ Ipv6InterfaceContainer iic1 = ipv6helper.AssignWithoutAddress (net1);
+ Ipv6InterfaceContainer iic2 = ipv6helper.AssignWithoutAddress (net2);
- // link the two nodes
- Ptr<SimpleChannel> channel1 = CreateObject<SimpleChannel> ();
- rxDev1->SetChannel (channel1);
- txDev1->SetChannel (channel1);
+ Ptr<NetDevice> device;
+ Ptr<Ipv6> ipv6;
+ int32_t ifIndex;
+ Ipv6InterfaceAddress ipv6Addr;
+
+ ipv6 = rxNode->GetObject<Ipv6> ();
+ device = net1.Get (0);
+ ifIndex = ipv6->GetInterfaceForDevice (device);
+ ipv6Addr = Ipv6InterfaceAddress (Ipv6Address ("2001:db8::1"), Ipv6Prefix (64));
+ ipv6->AddAddress (ifIndex, ipv6Addr);
- Ptr<SimpleChannel> channel2 = CreateObject<SimpleChannel> ();
- rxDev2->SetChannel (channel2);
- txDev2->SetChannel (channel2);
+ device = net2.Get (0);
+ ifIndex = ipv6->GetInterfaceForDevice (device);
+ ipv6Addr = Ipv6InterfaceAddress (Ipv6Address ("2001:db8:1::3"), Ipv6Prefix (64));
+ ipv6->AddAddress (ifIndex, ipv6Addr);
+ ipv6 = txNode->GetObject<Ipv6> ();
+ device = net1.Get (1);
+ ifIndex = ipv6->GetInterfaceForDevice (device);
+ ipv6Addr = Ipv6InterfaceAddress (Ipv6Address ("2001:db8::2"), Ipv6Prefix (64));
+ ipv6->AddAddress (ifIndex, ipv6Addr);
+
+ device = net2.Get (1);
+ ifIndex = ipv6->GetInterfaceForDevice (device);
+ ipv6Addr = Ipv6InterfaceAddress (Ipv6Address ("2001:db8:1::4"), Ipv6Prefix (64));
+ ipv6->AddAddress (ifIndex, ipv6Addr);
// Create the Ipv6 Raw sockets
Ptr<SocketFactory> rxSocketFactory = rxNode->GetObject<Ipv6RawSocketFactory> ();
@@ -219,7 +194,7 @@
Ptr<Socket> rxSocket2 = rxSocketFactory->CreateSocket ();
rxSocket2->SetRecvCallback (MakeCallback (&Ipv6RawSocketImplTest::ReceivePkt2, this));
rxSocket2->SetAttribute ("Protocol", UintegerValue (Ipv6Header::IPV6_ICMPV6));
- NS_TEST_EXPECT_MSG_EQ (rxSocket2->Bind (Inet6SocketAddress (Ipv6Address ("2001:db8:1::1"), 0)), 0, "trivial");
+ NS_TEST_EXPECT_MSG_EQ (rxSocket2->Bind (Inet6SocketAddress (Ipv6Address ("2001:db8:1::3"), 0)), 0, "trivial");
Ptr<SocketFactory> txSocketFactory = txNode->GetObject<Ipv6RawSocketFactory> ();
Ptr<Socket> txSocket = txSocketFactory->CreateSocket ();
@@ -228,15 +203,15 @@
// ------ Now the tests ------------
// Unicast test
- SendData (txSocket, "2001:db8:0::1");
- NS_TEST_EXPECT_MSG_EQ (m_receivedPacket->GetSize (), 163, "recv: 2001:db8:0::1");
+ SendData (txSocket, "2001:db8::1");
+ NS_TEST_EXPECT_MSG_EQ (m_receivedPacket->GetSize (), 163, "recv: 2001:db8::1");
NS_TEST_EXPECT_MSG_EQ (m_receivedPacket2->GetSize (), 0, "second interface should not receive it");
m_receivedPacket->RemoveAllByteTags ();
m_receivedPacket2->RemoveAllByteTags ();
// Simple Link-local multicast test
- txSocket->Bind (Inet6SocketAddress (Ipv6Address ("2001:db8:0::2"), 0));
+ txSocket->Bind (Inet6SocketAddress (Ipv6Address ("2001:db8::2"), 0));
SendData (txSocket, "ff02::1");
NS_TEST_EXPECT_MSG_EQ (m_receivedPacket->GetSize (), 163, "recv: ff02::1");
NS_TEST_EXPECT_MSG_EQ (m_receivedPacket2->GetSize (), 0, "second socket should not receive it (it is bound specifically to the second interface's address");
--- a/src/internet/test/udp-test.cc Sat Sep 06 06:57:27 2014 +0200
+++ b/src/internet/test/udp-test.cc Sat Sep 06 07:08:49 2014 +0200
@@ -28,13 +28,16 @@
#include "ns3/simulator.h"
#include "ns3/simple-channel.h"
#include "ns3/simple-net-device.h"
+#include "ns3/simple-net-device-helper.h"
#include "ns3/drop-tail-queue.h"
#include "ns3/socket.h"
+#include "ns3/boolean.h"
#include "ns3/log.h"
#include "ns3/node.h"
#include "ns3/inet-socket-address.h"
#include "ns3/inet6-socket-address.h"
+#include "ns3/internet-stack-helper.h"
#include "ns3/arp-l3-protocol.h"
#include "ns3/ipv4-l3-protocol.h"
@@ -47,62 +50,13 @@
#include "ns3/ipv4-static-routing.h"
#include "ns3/ipv6-list-routing.h"
#include "ns3/ipv6-static-routing.h"
+#include "ns3/ipv6-address-helper.h"
#include <string>
#include <limits>
using namespace ns3;
-static void
-AddInternetStack (Ptr<Node> node)
-{
- //ARP
- Ptr<ArpL3Protocol> arp = CreateObject<ArpL3Protocol> ();
- node->AggregateObject (arp);
- //IPV4
- Ptr<Ipv4L3Protocol> ipv4 = CreateObject<Ipv4L3Protocol> ();
- //Routing for Ipv4
- Ptr<Ipv4ListRouting> ipv4Routing = CreateObject<Ipv4ListRouting> ();
- ipv4->SetRoutingProtocol (ipv4Routing);
- Ptr<Ipv4StaticRouting> ipv4staticRouting = CreateObject<Ipv4StaticRouting> ();
- ipv4Routing->AddRoutingProtocol (ipv4staticRouting, 0);
- node->AggregateObject (ipv4);
- //ICMP
- Ptr<Icmpv4L4Protocol> icmp = CreateObject<Icmpv4L4Protocol> ();
- node->AggregateObject (icmp);
- //UDP
- Ptr<UdpL4Protocol> udp = CreateObject<UdpL4Protocol> ();
- node->AggregateObject (udp);
- //TCP
- Ptr<TcpL4Protocol> tcp = CreateObject<TcpL4Protocol> ();
- node->AggregateObject (tcp);
-}
-
-static void
-AddInternetStack6 (Ptr<Node> node)
-{
- //IPV6
- Ptr<Ipv6L3Protocol> ipv6 = CreateObject<Ipv6L3Protocol> ();
- //Routing for Ipv6
- Ptr<Ipv6ListRouting> ipv6Routing = CreateObject<Ipv6ListRouting> ();
- ipv6->SetRoutingProtocol (ipv6Routing);
- Ptr<Ipv6StaticRouting> ipv6staticRouting = CreateObject<Ipv6StaticRouting> ();
- ipv6Routing->AddRoutingProtocol (ipv6staticRouting, 0);
- node->AggregateObject (ipv6);
- //ICMP
- Ptr<Icmpv6L4Protocol> icmp = CreateObject<Icmpv6L4Protocol> ();
- node->AggregateObject (icmp);
- //Ipv6 Extensions
- ipv6->RegisterExtensions ();
- ipv6->RegisterOptions ();
- //UDP
- Ptr<UdpL4Protocol> udp = CreateObject<UdpL4Protocol> ();
- node->AggregateObject (udp);
- //TCP
- Ptr<TcpL4Protocol> tcp = CreateObject<TcpL4Protocol> ();
- node->AggregateObject (tcp);
-}
-
class UdpSocketLoopbackTest : public TestCase
{
@@ -131,7 +85,8 @@
UdpSocketLoopbackTest::DoRun ()
{
Ptr<Node> rxNode = CreateObject<Node> ();
- AddInternetStack (rxNode);
+ InternetStackHelper internet;
+ internet.Install (rxNode);
Ptr<SocketFactory> rxSocketFactory = rxNode->GetObject<UdpSocketFactory> ();
Ptr<Socket> rxSocket = rxSocketFactory->CreateSocket ();
@@ -175,7 +130,8 @@
Udp6SocketLoopbackTest::DoRun ()
{
Ptr<Node> rxNode = CreateObject<Node> ();
- AddInternetStack6 (rxNode);
+ InternetStackHelper internet;
+ internet.Install (rxNode);
Ptr<SocketFactory> rxSocketFactory = rxNode->GetObject<UdpSocketFactory> ();
Ptr<Socket> rxSocket = rxSocketFactory->CreateSocket ();
@@ -262,65 +218,49 @@
// Receiver Node
Ptr<Node> rxNode = CreateObject<Node> ();
- AddInternetStack (rxNode);
- Ptr<SimpleNetDevice> rxDev1, rxDev2;
- { // first interface
- rxDev1 = CreateObject<SimpleNetDevice> ();
- rxDev1->SetAddress (Mac48Address::ConvertFrom (Mac48Address::Allocate ()));
- rxNode->AddDevice (rxDev1);
- Ptr<Ipv4> ipv4 = rxNode->GetObject<Ipv4> ();
- uint32_t netdev_idx = ipv4->AddInterface (rxDev1);
- Ipv4InterfaceAddress ipv4Addr = Ipv4InterfaceAddress (Ipv4Address ("10.0.0.1"), Ipv4Mask (0xffff0000U));
- ipv4->AddAddress (netdev_idx, ipv4Addr);
- ipv4->SetUp (netdev_idx);
- }
-
- { // second interface
- rxDev2 = CreateObject<SimpleNetDevice> ();
- rxDev2->SetAddress (Mac48Address::ConvertFrom (Mac48Address::Allocate ()));
- rxNode->AddDevice (rxDev2);
- Ptr<Ipv4> ipv4 = rxNode->GetObject<Ipv4> ();
- uint32_t netdev_idx = ipv4->AddInterface (rxDev2);
- Ipv4InterfaceAddress ipv4Addr = Ipv4InterfaceAddress (Ipv4Address ("10.0.1.1"), Ipv4Mask (0xffff0000U));
- ipv4->AddAddress (netdev_idx, ipv4Addr);
- ipv4->SetUp (netdev_idx);
- }
-
// Sender Node
Ptr<Node> txNode = CreateObject<Node> ();
- AddInternetStack (txNode);
- Ptr<SimpleNetDevice> txDev1;
- {
- txDev1 = CreateObject<SimpleNetDevice> ();
- txDev1->SetAddress (Mac48Address::ConvertFrom (Mac48Address::Allocate ()));
- txNode->AddDevice (txDev1);
- Ptr<Ipv4> ipv4 = txNode->GetObject<Ipv4> ();
- uint32_t netdev_idx = ipv4->AddInterface (txDev1);
- Ipv4InterfaceAddress ipv4Addr = Ipv4InterfaceAddress (Ipv4Address ("10.0.0.2"), Ipv4Mask (0xffff0000U));
- ipv4->AddAddress (netdev_idx, ipv4Addr);
- ipv4->SetUp (netdev_idx);
- }
- Ptr<SimpleNetDevice> txDev2;
- {
- txDev2 = CreateObject<SimpleNetDevice> ();
- txDev2->SetAddress (Mac48Address::ConvertFrom (Mac48Address::Allocate ()));
- txNode->AddDevice (txDev2);
- Ptr<Ipv4> ipv4 = txNode->GetObject<Ipv4> ();
- uint32_t netdev_idx = ipv4->AddInterface (txDev2);
- Ipv4InterfaceAddress ipv4Addr = Ipv4InterfaceAddress (Ipv4Address ("10.0.1.2"), Ipv4Mask (0xffff0000U));
- ipv4->AddAddress (netdev_idx, ipv4Addr);
- ipv4->SetUp (netdev_idx);
- }
+
+ NodeContainer nodes (rxNode, txNode);
+
+ SimpleNetDeviceHelper helperChannel1;
+ helperChannel1.SetNetDevicePointToPointMode (true);
+ NetDeviceContainer net1 = helperChannel1.Install (nodes);
+
+ SimpleNetDeviceHelper helperChannel2;
+ helperChannel2.SetNetDevicePointToPointMode (true);
+ NetDeviceContainer net2 = helperChannel2.Install (nodes);
+
+ InternetStackHelper internet;
+ internet.Install (nodes);
+
+ Ptr<Ipv4> ipv4;
+ uint32_t netdev_idx;
+ Ipv4InterfaceAddress ipv4Addr;
- // link the two nodes
- Ptr<SimpleChannel> channel1 = CreateObject<SimpleChannel> ();
- rxDev1->SetChannel (channel1);
- txDev1->SetChannel (channel1);
+ // Receiver Node
+ ipv4 = rxNode->GetObject<Ipv4> ();
+ netdev_idx = ipv4->AddInterface (net1.Get (0));
+ ipv4Addr = Ipv4InterfaceAddress (Ipv4Address ("10.0.0.1"), Ipv4Mask (0xffff0000U));
+ ipv4->AddAddress (netdev_idx, ipv4Addr);
+ ipv4->SetUp (netdev_idx);
+
+ netdev_idx = ipv4->AddInterface (net2.Get (0));
+ ipv4Addr = Ipv4InterfaceAddress (Ipv4Address ("10.0.1.1"), Ipv4Mask (0xffff0000U));
+ ipv4->AddAddress (netdev_idx, ipv4Addr);
+ ipv4->SetUp (netdev_idx);
- Ptr<SimpleChannel> channel2 = CreateObject<SimpleChannel> ();
- rxDev2->SetChannel (channel2);
- txDev2->SetChannel (channel2);
+ // Sender Node
+ ipv4 = txNode->GetObject<Ipv4> ();
+ netdev_idx = ipv4->AddInterface (net1.Get (1));
+ ipv4Addr = Ipv4InterfaceAddress (Ipv4Address ("10.0.0.2"), Ipv4Mask (0xffff0000U));
+ ipv4->AddAddress (netdev_idx, ipv4Addr);
+ ipv4->SetUp (netdev_idx);
+ netdev_idx = ipv4->AddInterface (net2.Get (1));
+ ipv4Addr = Ipv4InterfaceAddress (Ipv4Address ("10.0.1.2"), Ipv4Mask (0xffff0000U));
+ ipv4->AddAddress (netdev_idx, ipv4Addr);
+ ipv4->SetUp (netdev_idx);
// Create the UDP sockets
Ptr<SocketFactory> rxSocketFactory = rxNode->GetObject<UdpSocketFactory> ();
@@ -374,7 +314,7 @@
// Simple Link-local multicast test
- txSocket->BindToNetDevice (txDev1);
+ txSocket->BindToNetDevice (net1.Get (1));
SendData (txSocket, "224.0.0.9");
NS_TEST_EXPECT_MSG_EQ (m_receivedPacket->GetSize (), 0, "first socket should not receive it (it is bound specifically to the second interface's address");
NS_TEST_EXPECT_MSG_EQ (m_receivedPacket2->GetSize (), 123, "recv2: 224.0.0.9");
@@ -465,64 +405,59 @@
// Receiver Node
Ptr<Node> rxNode = CreateObject<Node> ();
- AddInternetStack6 (rxNode);
- Ptr<SimpleNetDevice> rxDev1, rxDev2;
- { // first interface
- rxDev1 = CreateObject<SimpleNetDevice> ();
- rxDev1->SetAddress (Mac48Address::ConvertFrom (Mac48Address::Allocate ()));
- rxNode->AddDevice (rxDev1);
- Ptr<Ipv6> ipv6 = rxNode->GetObject<Ipv6> ();
- uint32_t netdev_idx = ipv6->AddInterface (rxDev1);
- Ipv6InterfaceAddress ipv6Addr = Ipv6InterfaceAddress (Ipv6Address ("2001:0100::1"), Ipv6Prefix (64));
- ipv6->AddAddress (netdev_idx, ipv6Addr);
- ipv6->SetUp (netdev_idx);
- }
- { // second interface
- rxDev2 = CreateObject<SimpleNetDevice> ();
- rxDev2->SetAddress (Mac48Address::ConvertFrom (Mac48Address::Allocate ()));
- rxNode->AddDevice (rxDev2);
- Ptr<Ipv6> ipv6 = rxNode->GetObject<Ipv6> ();
- uint32_t netdev_idx = ipv6->AddInterface (rxDev2);
- Ipv6InterfaceAddress ipv6Addr = Ipv6InterfaceAddress (Ipv6Address ("2001:0100:1::1"), Ipv6Prefix (64));
- ipv6->AddAddress (netdev_idx, ipv6Addr);
- ipv6->SetUp (netdev_idx);
- }
-
// Sender Node
Ptr<Node> txNode = CreateObject<Node> ();
- AddInternetStack6 (txNode);
- Ptr<SimpleNetDevice> txDev1;
- {
- txDev1 = CreateObject<SimpleNetDevice> ();
- txDev1->SetAddress (Mac48Address::ConvertFrom (Mac48Address::Allocate ()));
- txNode->AddDevice (txDev1);
- Ptr<Ipv6> ipv6 = txNode->GetObject<Ipv6> ();
- uint32_t netdev_idx = ipv6->AddInterface (txDev1);
- Ipv6InterfaceAddress ipv6Addr = Ipv6InterfaceAddress (Ipv6Address ("2001:0100::2"), Ipv6Prefix (64));
- ipv6->AddAddress (netdev_idx, ipv6Addr);
- ipv6->SetUp (netdev_idx);
- }
- Ptr<SimpleNetDevice> txDev2;
- {
- txDev2 = CreateObject<SimpleNetDevice> ();
- txDev2->SetAddress (Mac48Address::ConvertFrom (Mac48Address::Allocate ()));
- txNode->AddDevice (txDev2);
- Ptr<Ipv6> ipv6 = txNode->GetObject<Ipv6> ();
- uint32_t netdev_idx = ipv6->AddInterface (txDev2);
- Ipv6InterfaceAddress ipv6Addr = Ipv6InterfaceAddress (Ipv6Address ("2001:0100:1::2"), Ipv6Prefix (64));
- ipv6->AddAddress (netdev_idx, ipv6Addr);
- ipv6->SetUp (netdev_idx);
- }
+
+ NodeContainer nodes (rxNode, txNode);
+
+ SimpleNetDeviceHelper helperChannel1;
+ helperChannel1.SetNetDevicePointToPointMode (true);
+ NetDeviceContainer net1 = helperChannel1.Install (nodes);
+
+ SimpleNetDeviceHelper helperChannel2;
+ helperChannel2.SetNetDevicePointToPointMode (true);
+ NetDeviceContainer net2 = helperChannel2.Install (nodes);
+
+ InternetStackHelper internetv6;
+ internetv6.Install (nodes);
+
+ txNode->GetObject<Icmpv6L4Protocol> ()->SetAttribute ("DAD", BooleanValue (false));
+ rxNode->GetObject<Icmpv6L4Protocol> ()->SetAttribute ("DAD", BooleanValue (false));
+
+ Ipv6AddressHelper ipv6helper;
+ Ipv6InterfaceContainer iic1 = ipv6helper.AssignWithoutAddress (net1);
+ Ipv6InterfaceContainer iic2 = ipv6helper.AssignWithoutAddress (net2);
+
+ Ptr<NetDevice> device;
+ Ptr<Ipv6> ipv6;
+ int32_t ifIndex;
+ Ipv6InterfaceAddress ipv6Addr;
- // link the two nodes
- Ptr<SimpleChannel> channel1 = CreateObject<SimpleChannel> ();
- rxDev1->SetChannel (channel1);
- txDev1->SetChannel (channel1);
+ ipv6 = rxNode->GetObject<Ipv6> ();
+ device = net1.Get (0);
+ ifIndex = ipv6->GetInterfaceForDevice (device);
+ ipv6Addr = Ipv6InterfaceAddress (Ipv6Address ("2001:0100::1"), Ipv6Prefix (64));
+ ipv6->AddAddress (ifIndex, ipv6Addr);
+ ipv6->SetUp (ifIndex);
+
+ device = net2.Get (0);
+ ifIndex = ipv6->GetInterfaceForDevice (device);
+ ipv6Addr = Ipv6InterfaceAddress (Ipv6Address ("2001:0100:1::1"), Ipv6Prefix (64));
+ ipv6->AddAddress (ifIndex, ipv6Addr);
+ ipv6->SetUp (ifIndex);
- Ptr<SimpleChannel> channel2 = CreateObject<SimpleChannel> ();
- rxDev2->SetChannel (channel2);
- txDev2->SetChannel (channel2);
+ ipv6 = txNode->GetObject<Ipv6> ();
+ device = net1.Get (1);
+ ifIndex = ipv6->GetInterfaceForDevice (device);
+ ipv6Addr = Ipv6InterfaceAddress (Ipv6Address ("2001:0100::2"), Ipv6Prefix (64));
+ ipv6->AddAddress (ifIndex, ipv6Addr);
+ ipv6->SetUp (ifIndex);
+ device = net2.Get (1);
+ ifIndex = ipv6->GetInterfaceForDevice (device);
+ ipv6Addr = Ipv6InterfaceAddress (Ipv6Address ("2001:0100:1::2"), Ipv6Prefix (64));
+ ipv6->AddAddress (ifIndex, ipv6Addr);
+ ipv6->SetUp (ifIndex);
// Create the UDP sockets
Ptr<SocketFactory> rxSocketFactory = rxNode->GetObject<UdpSocketFactory> ();
@@ -557,7 +492,7 @@
rxSocket2->SetRecvCallback (MakeCallback (&Udp6SocketImplTest::ReceivePkt2, this));
NS_TEST_EXPECT_MSG_EQ (rxSocket2->Bind (Inet6SocketAddress (Ipv6Address ("::"), 1234)), 0, "trivial");
- txSocket->BindToNetDevice (txDev1);
+ txSocket->BindToNetDevice (net1.Get (1));
SendData (txSocket, "ff02::1");
NS_TEST_EXPECT_MSG_EQ (m_receivedPacket->GetSize (), 0, "first socket should not receive it (it is bound specifically to the second interface's address");
NS_TEST_EXPECT_MSG_EQ (m_receivedPacket2->GetSize (), 123, "recv2: ff02::1");
--- a/src/network/bindings/modulegen__gcc_ILP32.py Sat Sep 06 06:57:27 2014 +0200
+++ b/src/network/bindings/modulegen__gcc_ILP32.py Sat Sep 06 07:08:49 2014 +0200
@@ -152,6 +152,8 @@
module.add_class('SequenceNumber32')
## sequence-number.h (module 'network'): ns3::SequenceNumber<unsigned short, short> [class]
module.add_class('SequenceNumber16')
+ ## simple-net-device-helper.h (module 'network'): ns3::SimpleNetDeviceHelper [class]
+ module.add_class('SimpleNetDeviceHelper')
## simple-ref-count.h (module 'core'): ns3::SimpleRefCount<ns3::Object, ns3::ObjectBase, ns3::ObjectDeleter> [class]
module.add_class('SimpleRefCount', automatic_type_narrowing=True, import_from_module='ns.core', template_parameters=['ns3::Object', 'ns3::ObjectBase', 'ns3::ObjectDeleter'], parent=root_module['ns3::ObjectBase'], memory_policy=cppclass.ReferenceCountingMethodsPolicy(incref_method='Ref', decref_method='Unref', peekref_method='GetReferenceCount'))
## simulator.h (module 'core'): ns3::Simulator [class]
@@ -606,6 +608,7 @@
register_Ns3PcapHelperForDevice_methods(root_module, root_module['ns3::PcapHelperForDevice'])
register_Ns3SequenceNumber32_methods(root_module, root_module['ns3::SequenceNumber32'])
register_Ns3SequenceNumber16_methods(root_module, root_module['ns3::SequenceNumber16'])
+ register_Ns3SimpleNetDeviceHelper_methods(root_module, root_module['ns3::SimpleNetDeviceHelper'])
register_Ns3SimpleRefCount__Ns3Object_Ns3ObjectBase_Ns3ObjectDeleter_methods(root_module, root_module['ns3::SimpleRefCount< ns3::Object, ns3::ObjectBase, ns3::ObjectDeleter >'])
register_Ns3Simulator_methods(root_module, root_module['ns3::Simulator'])
register_Ns3StatisticalSummary_methods(root_module, root_module['ns3::StatisticalSummary'])
@@ -757,8 +760,8 @@
def register_Ns3Address_methods(root_module, cls):
cls.add_binary_comparison_operator('!=')
+ cls.add_binary_comparison_operator('<')
cls.add_output_stream_operator()
- cls.add_binary_comparison_operator('<')
cls.add_binary_comparison_operator('==')
## address.h (module 'network'): ns3::Address::Address() [constructor]
cls.add_constructor([])
@@ -1728,8 +1731,8 @@
def register_Ns3Ipv4Address_methods(root_module, cls):
cls.add_binary_comparison_operator('!=')
+ cls.add_binary_comparison_operator('<')
cls.add_output_stream_operator()
- cls.add_binary_comparison_operator('<')
cls.add_binary_comparison_operator('==')
## ipv4-address.h (module 'network'): ns3::Ipv4Address::Ipv4Address(ns3::Ipv4Address const & arg0) [copy constructor]
cls.add_constructor([param('ns3::Ipv4Address const &', 'arg0')])
@@ -1899,8 +1902,8 @@
def register_Ns3Ipv6Address_methods(root_module, cls):
cls.add_binary_comparison_operator('!=')
+ cls.add_binary_comparison_operator('<')
cls.add_output_stream_operator()
- cls.add_binary_comparison_operator('<')
cls.add_binary_comparison_operator('==')
## ipv6-address.h (module 'network'): ns3::Ipv6Address::Ipv6Address() [constructor]
cls.add_constructor([])
@@ -2156,8 +2159,8 @@
def register_Ns3Mac16Address_methods(root_module, cls):
cls.add_binary_comparison_operator('!=')
+ cls.add_binary_comparison_operator('<')
cls.add_output_stream_operator()
- cls.add_binary_comparison_operator('<')
cls.add_binary_comparison_operator('==')
## mac16-address.h (module 'network'): ns3::Mac16Address::Mac16Address(ns3::Mac16Address const & arg0) [copy constructor]
cls.add_constructor([param('ns3::Mac16Address const &', 'arg0')])
@@ -2193,8 +2196,8 @@
def register_Ns3Mac48Address_methods(root_module, cls):
cls.add_binary_comparison_operator('!=')
+ cls.add_binary_comparison_operator('<')
cls.add_output_stream_operator()
- cls.add_binary_comparison_operator('<')
cls.add_binary_comparison_operator('==')
## mac48-address.h (module 'network'): ns3::Mac48Address::Mac48Address(ns3::Mac48Address const & arg0) [copy constructor]
cls.add_constructor([param('ns3::Mac48Address const &', 'arg0')])
@@ -2265,8 +2268,8 @@
def register_Ns3Mac64Address_methods(root_module, cls):
cls.add_binary_comparison_operator('!=')
+ cls.add_binary_comparison_operator('<')
cls.add_output_stream_operator()
- cls.add_binary_comparison_operator('<')
cls.add_binary_comparison_operator('==')
## mac64-address.h (module 'network'): ns3::Mac64Address::Mac64Address(ns3::Mac64Address const & arg0) [copy constructor]
cls.add_constructor([param('ns3::Mac64Address const &', 'arg0')])
@@ -3215,6 +3218,53 @@
is_const=True)
return
+def register_Ns3SimpleNetDeviceHelper_methods(root_module, cls):
+ ## simple-net-device-helper.h (module 'network'): ns3::SimpleNetDeviceHelper::SimpleNetDeviceHelper(ns3::SimpleNetDeviceHelper const & arg0) [copy constructor]
+ cls.add_constructor([param('ns3::SimpleNetDeviceHelper const &', 'arg0')])
+ ## simple-net-device-helper.h (module 'network'): ns3::SimpleNetDeviceHelper::SimpleNetDeviceHelper() [constructor]
+ cls.add_constructor([])
+ ## simple-net-device-helper.h (module 'network'): ns3::NetDeviceContainer ns3::SimpleNetDeviceHelper::Install(ns3::Ptr<ns3::Node> node) const [member function]
+ cls.add_method('Install',
+ 'ns3::NetDeviceContainer',
+ [param('ns3::Ptr< ns3::Node >', 'node')],
+ is_const=True)
+ ## simple-net-device-helper.h (module 'network'): ns3::NetDeviceContainer ns3::SimpleNetDeviceHelper::Install(ns3::Ptr<ns3::Node> node, ns3::Ptr<ns3::SimpleChannel> channel) const [member function]
+ cls.add_method('Install',
+ 'ns3::NetDeviceContainer',
+ [param('ns3::Ptr< ns3::Node >', 'node'), param('ns3::Ptr< ns3::SimpleChannel >', 'channel')],
+ is_const=True)
+ ## simple-net-device-helper.h (module 'network'): ns3::NetDeviceContainer ns3::SimpleNetDeviceHelper::Install(ns3::NodeContainer const & c) const [member function]
+ cls.add_method('Install',
+ 'ns3::NetDeviceContainer',
+ [param('ns3::NodeContainer const &', 'c')],
+ is_const=True)
+ ## simple-net-device-helper.h (module 'network'): ns3::NetDeviceContainer ns3::SimpleNetDeviceHelper::Install(ns3::NodeContainer const & c, ns3::Ptr<ns3::SimpleChannel> channel) const [member function]
+ cls.add_method('Install',
+ 'ns3::NetDeviceContainer',
+ [param('ns3::NodeContainer const &', 'c'), param('ns3::Ptr< ns3::SimpleChannel >', 'channel')],
+ is_const=True)
+ ## simple-net-device-helper.h (module 'network'): void ns3::SimpleNetDeviceHelper::SetChannel(std::string type, std::string n1="", ns3::AttributeValue const & v1=ns3::EmptyAttributeValue(), std::string n2="", ns3::AttributeValue const & v2=ns3::EmptyAttributeValue(), std::string n3="", ns3::AttributeValue const & v3=ns3::EmptyAttributeValue(), std::string n4="", ns3::AttributeValue const & v4=ns3::EmptyAttributeValue()) [member function]
+ cls.add_method('SetChannel',
+ 'void',
+ [param('std::string', 'type'), param('std::string', 'n1', default_value='""'), param('ns3::AttributeValue const &', 'v1', default_value='ns3::EmptyAttributeValue()'), param('std::string', 'n2', default_value='""'), param('ns3::AttributeValue const &', 'v2', default_value='ns3::EmptyAttributeValue()'), param('std::string', 'n3', default_value='""'), param('ns3::AttributeValue const &', 'v3', default_value='ns3::EmptyAttributeValue()'), param('std::string', 'n4', default_value='""'), param('ns3::AttributeValue const &', 'v4', default_value='ns3::EmptyAttributeValue()')])
+ ## simple-net-device-helper.h (module 'network'): void ns3::SimpleNetDeviceHelper::SetChannelAttribute(std::string n1, ns3::AttributeValue const & v1) [member function]
+ cls.add_method('SetChannelAttribute',
+ 'void',
+ [param('std::string', 'n1'), param('ns3::AttributeValue const &', 'v1')])
+ ## simple-net-device-helper.h (module 'network'): void ns3::SimpleNetDeviceHelper::SetDeviceAttribute(std::string n1, ns3::AttributeValue const & v1) [member function]
+ cls.add_method('SetDeviceAttribute',
+ 'void',
+ [param('std::string', 'n1'), param('ns3::AttributeValue const &', 'v1')])
+ ## simple-net-device-helper.h (module 'network'): void ns3::SimpleNetDeviceHelper::SetNetDevicePointToPointMode(bool pointToPointMode) [member function]
+ cls.add_method('SetNetDevicePointToPointMode',
+ 'void',
+ [param('bool', 'pointToPointMode')])
+ ## simple-net-device-helper.h (module 'network'): void ns3::SimpleNetDeviceHelper::SetQueue(std::string type, std::string n1="", ns3::AttributeValue const & v1=ns3::EmptyAttributeValue(), std::string n2="", ns3::AttributeValue const & v2=ns3::EmptyAttributeValue(), std::string n3="", ns3::AttributeValue const & v3=ns3::EmptyAttributeValue(), std::string n4="", ns3::AttributeValue const & v4=ns3::EmptyAttributeValue()) [member function]
+ cls.add_method('SetQueue',
+ 'void',
+ [param('std::string', 'type'), param('std::string', 'n1', default_value='""'), param('ns3::AttributeValue const &', 'v1', default_value='ns3::EmptyAttributeValue()'), param('std::string', 'n2', default_value='""'), param('ns3::AttributeValue const &', 'v2', default_value='ns3::EmptyAttributeValue()'), param('std::string', 'n3', default_value='""'), param('ns3::AttributeValue const &', 'v3', default_value='ns3::EmptyAttributeValue()'), param('std::string', 'n4', default_value='""'), param('ns3::AttributeValue const &', 'v4', default_value='ns3::EmptyAttributeValue()')])
+ return
+
def register_Ns3SimpleRefCount__Ns3Object_Ns3ObjectBase_Ns3ObjectDeleter_methods(root_module, cls):
## simple-ref-count.h (module 'core'): ns3::SimpleRefCount<ns3::Object, ns3::ObjectBase, ns3::ObjectDeleter>::SimpleRefCount() [constructor]
cls.add_constructor([])
@@ -3489,8 +3539,8 @@
def register_Ns3TypeId_methods(root_module, cls):
cls.add_binary_comparison_operator('!=')
+ cls.add_binary_comparison_operator('<')
cls.add_output_stream_operator()
- cls.add_binary_comparison_operator('<')
cls.add_binary_comparison_operator('==')
## type-id.h (module 'core'): ns3::TypeId::TypeId(char const * name) [constructor]
cls.add_constructor([param('char const *', 'name')])
@@ -3684,10 +3734,8 @@
return
def register_Ns3Int64x64_t_methods(root_module, cls):
- cls.add_binary_comparison_operator('<=')
cls.add_binary_comparison_operator('!=')
cls.add_inplace_numeric_operator('+=', param('ns3::int64x64_t const &', u'right'))
- cls.add_output_stream_operator()
cls.add_binary_numeric_operator('*', root_module['ns3::int64x64_t'], root_module['ns3::int64x64_t'], param('ns3::int64x64_t const &', u'right'))
cls.add_binary_numeric_operator('+', root_module['ns3::int64x64_t'], root_module['ns3::int64x64_t'], param('ns3::int64x64_t const &', u'right'))
cls.add_binary_numeric_operator('-', root_module['ns3::int64x64_t'], root_module['ns3::int64x64_t'], param('ns3::int64x64_t const &', u'right'))
@@ -3698,6 +3746,8 @@
cls.add_inplace_numeric_operator('*=', param('ns3::int64x64_t const &', u'right'))
cls.add_inplace_numeric_operator('-=', param('ns3::int64x64_t const &', u'right'))
cls.add_inplace_numeric_operator('/=', param('ns3::int64x64_t const &', u'right'))
+ cls.add_output_stream_operator()
+ cls.add_binary_comparison_operator('<=')
cls.add_binary_comparison_operator('==')
cls.add_binary_comparison_operator('>=')
## int64x64-double.h (module 'core'): ns3::int64x64_t::int64x64_t() [constructor]
@@ -5329,10 +5379,8 @@
return
def register_Ns3Time_methods(root_module, cls):
- cls.add_binary_comparison_operator('<=')
cls.add_binary_comparison_operator('!=')
cls.add_inplace_numeric_operator('+=', param('ns3::Time const &', u'right'))
- cls.add_output_stream_operator()
cls.add_binary_numeric_operator('*', root_module['ns3::Time'], root_module['ns3::Time'], param('int64_t const &', u'right'))
cls.add_binary_numeric_operator('+', root_module['ns3::Time'], root_module['ns3::Time'], param('ns3::Time const &', u'right'))
cls.add_binary_numeric_operator('-', root_module['ns3::Time'], root_module['ns3::Time'], param('ns3::Time const &', u'right'))
@@ -5340,6 +5388,8 @@
cls.add_binary_comparison_operator('<')
cls.add_binary_comparison_operator('>')
cls.add_inplace_numeric_operator('-=', param('ns3::Time const &', u'right'))
+ cls.add_output_stream_operator()
+ cls.add_binary_comparison_operator('<=')
cls.add_binary_comparison_operator('==')
cls.add_binary_comparison_operator('>=')
## nstime.h (module 'core'): ns3::Time::Time() [constructor]
@@ -5360,10 +5410,10 @@
cls.add_constructor([param('long unsigned int', 'v')])
## nstime.h (module 'core'): ns3::Time::Time(long long unsigned int v) [constructor]
cls.add_constructor([param('long long unsigned int', 'v')])
+ ## nstime.h (module 'core'): ns3::Time::Time(ns3::int64x64_t const & v) [constructor]
+ cls.add_constructor([param('ns3::int64x64_t const &', 'v')])
## nstime.h (module 'core'): ns3::Time::Time(std::string const & s) [constructor]
cls.add_constructor([param('std::string const &', 's')])
- ## nstime.h (module 'core'): ns3::Time::Time(ns3::int64x64_t const & value) [constructor]
- cls.add_constructor([param('ns3::int64x64_t const &', 'value')])
## nstime.h (module 'core'): ns3::TimeWithUnit ns3::Time::As(ns3::Time::Unit const unit) const [member function]
cls.add_method('As',
'ns3::TimeWithUnit',
@@ -5374,25 +5424,25 @@
'int',
[param('ns3::Time const &', 'o')],
is_const=True)
- ## nstime.h (module 'core'): static ns3::Time ns3::Time::From(ns3::int64x64_t const & from, ns3::Time::Unit timeUnit) [member function]
- cls.add_method('From',
- 'ns3::Time',
- [param('ns3::int64x64_t const &', 'from'), param('ns3::Time::Unit', 'timeUnit')],
- is_static=True)
## nstime.h (module 'core'): static ns3::Time ns3::Time::From(ns3::int64x64_t const & value) [member function]
cls.add_method('From',
'ns3::Time',
[param('ns3::int64x64_t const &', 'value')],
is_static=True)
- ## nstime.h (module 'core'): static ns3::Time ns3::Time::FromDouble(double value, ns3::Time::Unit timeUnit) [member function]
+ ## nstime.h (module 'core'): static ns3::Time ns3::Time::From(ns3::int64x64_t const & value, ns3::Time::Unit unit) [member function]
+ cls.add_method('From',
+ 'ns3::Time',
+ [param('ns3::int64x64_t const &', 'value'), param('ns3::Time::Unit', 'unit')],
+ is_static=True)
+ ## nstime.h (module 'core'): static ns3::Time ns3::Time::FromDouble(double value, ns3::Time::Unit unit) [member function]
cls.add_method('FromDouble',
'ns3::Time',
- [param('double', 'value'), param('ns3::Time::Unit', 'timeUnit')],
- is_static=True)
- ## nstime.h (module 'core'): static ns3::Time ns3::Time::FromInteger(uint64_t value, ns3::Time::Unit timeUnit) [member function]
+ [param('double', 'value'), param('ns3::Time::Unit', 'unit')],
+ is_static=True)
+ ## nstime.h (module 'core'): static ns3::Time ns3::Time::FromInteger(uint64_t value, ns3::Time::Unit unit) [member function]
cls.add_method('FromInteger',
'ns3::Time',
- [param('uint64_t', 'value'), param('ns3::Time::Unit', 'timeUnit')],
+ [param('uint64_t', 'value'), param('ns3::Time::Unit', 'unit')],
is_static=True)
## nstime.h (module 'core'): double ns3::Time::GetDays() const [member function]
cls.add_method('GetDays',
@@ -5509,20 +5559,20 @@
'bool',
[],
is_static=True)
- ## nstime.h (module 'core'): ns3::int64x64_t ns3::Time::To(ns3::Time::Unit timeUnit) const [member function]
+ ## nstime.h (module 'core'): ns3::int64x64_t ns3::Time::To(ns3::Time::Unit unit) const [member function]
cls.add_method('To',
'ns3::int64x64_t',
- [param('ns3::Time::Unit', 'timeUnit')],
- is_const=True)
- ## nstime.h (module 'core'): double ns3::Time::ToDouble(ns3::Time::Unit timeUnit) const [member function]
+ [param('ns3::Time::Unit', 'unit')],
+ is_const=True)
+ ## nstime.h (module 'core'): double ns3::Time::ToDouble(ns3::Time::Unit unit) const [member function]
cls.add_method('ToDouble',
'double',
- [param('ns3::Time::Unit', 'timeUnit')],
- is_const=True)
- ## nstime.h (module 'core'): int64_t ns3::Time::ToInteger(ns3::Time::Unit timeUnit) const [member function]
+ [param('ns3::Time::Unit', 'unit')],
+ is_const=True)
+ ## nstime.h (module 'core'): int64_t ns3::Time::ToInteger(ns3::Time::Unit unit) const [member function]
cls.add_method('ToInteger',
'int64_t',
- [param('ns3::Time::Unit', 'timeUnit')],
+ [param('ns3::Time::Unit', 'unit')],
is_const=True)
return
@@ -9160,6 +9210,11 @@
'ns3::Ptr< ns3::Node >',
[],
is_const=True, is_virtual=True)
+ ## simple-net-device.h (module 'network'): ns3::Ptr<ns3::Queue> ns3::SimpleNetDevice::GetQueue() const [member function]
+ cls.add_method('GetQueue',
+ 'ns3::Ptr< ns3::Queue >',
+ [],
+ is_const=True)
## simple-net-device.h (module 'network'): static ns3::TypeId ns3::SimpleNetDevice::GetTypeId() [member function]
cls.add_method('GetTypeId',
'ns3::TypeId',
@@ -9238,6 +9293,10 @@
'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)
+ ## simple-net-device.h (module 'network'): void ns3::SimpleNetDevice::SetQueue(ns3::Ptr<ns3::Queue> queue) [member function]
+ cls.add_method('SetQueue',
+ 'void',
+ [param('ns3::Ptr< ns3::Queue >', 'queue')])
## simple-net-device.h (module 'network'): void ns3::SimpleNetDevice::SetReceiveCallback(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) [member function]
cls.add_method('SetReceiveCallback',
'void',
--- a/src/network/bindings/modulegen__gcc_LP64.py Sat Sep 06 06:57:27 2014 +0200
+++ b/src/network/bindings/modulegen__gcc_LP64.py Sat Sep 06 07:08:49 2014 +0200
@@ -152,6 +152,8 @@
module.add_class('SequenceNumber32')
## sequence-number.h (module 'network'): ns3::SequenceNumber<unsigned short, short> [class]
module.add_class('SequenceNumber16')
+ ## simple-net-device-helper.h (module 'network'): ns3::SimpleNetDeviceHelper [class]
+ module.add_class('SimpleNetDeviceHelper')
## simple-ref-count.h (module 'core'): ns3::SimpleRefCount<ns3::Object, ns3::ObjectBase, ns3::ObjectDeleter> [class]
module.add_class('SimpleRefCount', automatic_type_narrowing=True, import_from_module='ns.core', template_parameters=['ns3::Object', 'ns3::ObjectBase', 'ns3::ObjectDeleter'], parent=root_module['ns3::ObjectBase'], memory_policy=cppclass.ReferenceCountingMethodsPolicy(incref_method='Ref', decref_method='Unref', peekref_method='GetReferenceCount'))
## simulator.h (module 'core'): ns3::Simulator [class]
@@ -606,6 +608,7 @@
register_Ns3PcapHelperForDevice_methods(root_module, root_module['ns3::PcapHelperForDevice'])
register_Ns3SequenceNumber32_methods(root_module, root_module['ns3::SequenceNumber32'])
register_Ns3SequenceNumber16_methods(root_module, root_module['ns3::SequenceNumber16'])
+ register_Ns3SimpleNetDeviceHelper_methods(root_module, root_module['ns3::SimpleNetDeviceHelper'])
register_Ns3SimpleRefCount__Ns3Object_Ns3ObjectBase_Ns3ObjectDeleter_methods(root_module, root_module['ns3::SimpleRefCount< ns3::Object, ns3::ObjectBase, ns3::ObjectDeleter >'])
register_Ns3Simulator_methods(root_module, root_module['ns3::Simulator'])
register_Ns3StatisticalSummary_methods(root_module, root_module['ns3::StatisticalSummary'])
@@ -757,8 +760,8 @@
def register_Ns3Address_methods(root_module, cls):
cls.add_binary_comparison_operator('!=')
+ cls.add_binary_comparison_operator('<')
cls.add_output_stream_operator()
- cls.add_binary_comparison_operator('<')
cls.add_binary_comparison_operator('==')
## address.h (module 'network'): ns3::Address::Address() [constructor]
cls.add_constructor([])
@@ -1728,8 +1731,8 @@
def register_Ns3Ipv4Address_methods(root_module, cls):
cls.add_binary_comparison_operator('!=')
+ cls.add_binary_comparison_operator('<')
cls.add_output_stream_operator()
- cls.add_binary_comparison_operator('<')
cls.add_binary_comparison_operator('==')
## ipv4-address.h (module 'network'): ns3::Ipv4Address::Ipv4Address(ns3::Ipv4Address const & arg0) [copy constructor]
cls.add_constructor([param('ns3::Ipv4Address const &', 'arg0')])
@@ -1899,8 +1902,8 @@
def register_Ns3Ipv6Address_methods(root_module, cls):
cls.add_binary_comparison_operator('!=')
+ cls.add_binary_comparison_operator('<')
cls.add_output_stream_operator()
- cls.add_binary_comparison_operator('<')
cls.add_binary_comparison_operator('==')
## ipv6-address.h (module 'network'): ns3::Ipv6Address::Ipv6Address() [constructor]
cls.add_constructor([])
@@ -2156,8 +2159,8 @@
def register_Ns3Mac16Address_methods(root_module, cls):
cls.add_binary_comparison_operator('!=')
+ cls.add_binary_comparison_operator('<')
cls.add_output_stream_operator()
- cls.add_binary_comparison_operator('<')
cls.add_binary_comparison_operator('==')
## mac16-address.h (module 'network'): ns3::Mac16Address::Mac16Address(ns3::Mac16Address const & arg0) [copy constructor]
cls.add_constructor([param('ns3::Mac16Address const &', 'arg0')])
@@ -2193,8 +2196,8 @@
def register_Ns3Mac48Address_methods(root_module, cls):
cls.add_binary_comparison_operator('!=')
+ cls.add_binary_comparison_operator('<')
cls.add_output_stream_operator()
- cls.add_binary_comparison_operator('<')
cls.add_binary_comparison_operator('==')
## mac48-address.h (module 'network'): ns3::Mac48Address::Mac48Address(ns3::Mac48Address const & arg0) [copy constructor]
cls.add_constructor([param('ns3::Mac48Address const &', 'arg0')])
@@ -2265,8 +2268,8 @@
def register_Ns3Mac64Address_methods(root_module, cls):
cls.add_binary_comparison_operator('!=')
+ cls.add_binary_comparison_operator('<')
cls.add_output_stream_operator()
- cls.add_binary_comparison_operator('<')
cls.add_binary_comparison_operator('==')
## mac64-address.h (module 'network'): ns3::Mac64Address::Mac64Address(ns3::Mac64Address const & arg0) [copy constructor]
cls.add_constructor([param('ns3::Mac64Address const &', 'arg0')])
@@ -3215,6 +3218,53 @@
is_const=True)
return
+def register_Ns3SimpleNetDeviceHelper_methods(root_module, cls):
+ ## simple-net-device-helper.h (module 'network'): ns3::SimpleNetDeviceHelper::SimpleNetDeviceHelper(ns3::SimpleNetDeviceHelper const & arg0) [copy constructor]
+ cls.add_constructor([param('ns3::SimpleNetDeviceHelper const &', 'arg0')])
+ ## simple-net-device-helper.h (module 'network'): ns3::SimpleNetDeviceHelper::SimpleNetDeviceHelper() [constructor]
+ cls.add_constructor([])
+ ## simple-net-device-helper.h (module 'network'): ns3::NetDeviceContainer ns3::SimpleNetDeviceHelper::Install(ns3::Ptr<ns3::Node> node) const [member function]
+ cls.add_method('Install',
+ 'ns3::NetDeviceContainer',
+ [param('ns3::Ptr< ns3::Node >', 'node')],
+ is_const=True)
+ ## simple-net-device-helper.h (module 'network'): ns3::NetDeviceContainer ns3::SimpleNetDeviceHelper::Install(ns3::Ptr<ns3::Node> node, ns3::Ptr<ns3::SimpleChannel> channel) const [member function]
+ cls.add_method('Install',
+ 'ns3::NetDeviceContainer',
+ [param('ns3::Ptr< ns3::Node >', 'node'), param('ns3::Ptr< ns3::SimpleChannel >', 'channel')],
+ is_const=True)
+ ## simple-net-device-helper.h (module 'network'): ns3::NetDeviceContainer ns3::SimpleNetDeviceHelper::Install(ns3::NodeContainer const & c) const [member function]
+ cls.add_method('Install',
+ 'ns3::NetDeviceContainer',
+ [param('ns3::NodeContainer const &', 'c')],
+ is_const=True)
+ ## simple-net-device-helper.h (module 'network'): ns3::NetDeviceContainer ns3::SimpleNetDeviceHelper::Install(ns3::NodeContainer const & c, ns3::Ptr<ns3::SimpleChannel> channel) const [member function]
+ cls.add_method('Install',
+ 'ns3::NetDeviceContainer',
+ [param('ns3::NodeContainer const &', 'c'), param('ns3::Ptr< ns3::SimpleChannel >', 'channel')],
+ is_const=True)
+ ## simple-net-device-helper.h (module 'network'): void ns3::SimpleNetDeviceHelper::SetChannel(std::string type, std::string n1="", ns3::AttributeValue const & v1=ns3::EmptyAttributeValue(), std::string n2="", ns3::AttributeValue const & v2=ns3::EmptyAttributeValue(), std::string n3="", ns3::AttributeValue const & v3=ns3::EmptyAttributeValue(), std::string n4="", ns3::AttributeValue const & v4=ns3::EmptyAttributeValue()) [member function]
+ cls.add_method('SetChannel',
+ 'void',
+ [param('std::string', 'type'), param('std::string', 'n1', default_value='""'), param('ns3::AttributeValue const &', 'v1', default_value='ns3::EmptyAttributeValue()'), param('std::string', 'n2', default_value='""'), param('ns3::AttributeValue const &', 'v2', default_value='ns3::EmptyAttributeValue()'), param('std::string', 'n3', default_value='""'), param('ns3::AttributeValue const &', 'v3', default_value='ns3::EmptyAttributeValue()'), param('std::string', 'n4', default_value='""'), param('ns3::AttributeValue const &', 'v4', default_value='ns3::EmptyAttributeValue()')])
+ ## simple-net-device-helper.h (module 'network'): void ns3::SimpleNetDeviceHelper::SetChannelAttribute(std::string n1, ns3::AttributeValue const & v1) [member function]
+ cls.add_method('SetChannelAttribute',
+ 'void',
+ [param('std::string', 'n1'), param('ns3::AttributeValue const &', 'v1')])
+ ## simple-net-device-helper.h (module 'network'): void ns3::SimpleNetDeviceHelper::SetDeviceAttribute(std::string n1, ns3::AttributeValue const & v1) [member function]
+ cls.add_method('SetDeviceAttribute',
+ 'void',
+ [param('std::string', 'n1'), param('ns3::AttributeValue const &', 'v1')])
+ ## simple-net-device-helper.h (module 'network'): void ns3::SimpleNetDeviceHelper::SetNetDevicePointToPointMode(bool pointToPointMode) [member function]
+ cls.add_method('SetNetDevicePointToPointMode',
+ 'void',
+ [param('bool', 'pointToPointMode')])
+ ## simple-net-device-helper.h (module 'network'): void ns3::SimpleNetDeviceHelper::SetQueue(std::string type, std::string n1="", ns3::AttributeValue const & v1=ns3::EmptyAttributeValue(), std::string n2="", ns3::AttributeValue const & v2=ns3::EmptyAttributeValue(), std::string n3="", ns3::AttributeValue const & v3=ns3::EmptyAttributeValue(), std::string n4="", ns3::AttributeValue const & v4=ns3::EmptyAttributeValue()) [member function]
+ cls.add_method('SetQueue',
+ 'void',
+ [param('std::string', 'type'), param('std::string', 'n1', default_value='""'), param('ns3::AttributeValue const &', 'v1', default_value='ns3::EmptyAttributeValue()'), param('std::string', 'n2', default_value='""'), param('ns3::AttributeValue const &', 'v2', default_value='ns3::EmptyAttributeValue()'), param('std::string', 'n3', default_value='""'), param('ns3::AttributeValue const &', 'v3', default_value='ns3::EmptyAttributeValue()'), param('std::string', 'n4', default_value='""'), param('ns3::AttributeValue const &', 'v4', default_value='ns3::EmptyAttributeValue()')])
+ return
+
def register_Ns3SimpleRefCount__Ns3Object_Ns3ObjectBase_Ns3ObjectDeleter_methods(root_module, cls):
## simple-ref-count.h (module 'core'): ns3::SimpleRefCount<ns3::Object, ns3::ObjectBase, ns3::ObjectDeleter>::SimpleRefCount() [constructor]
cls.add_constructor([])
@@ -3489,8 +3539,8 @@
def register_Ns3TypeId_methods(root_module, cls):
cls.add_binary_comparison_operator('!=')
+ cls.add_binary_comparison_operator('<')
cls.add_output_stream_operator()
- cls.add_binary_comparison_operator('<')
cls.add_binary_comparison_operator('==')
## type-id.h (module 'core'): ns3::TypeId::TypeId(char const * name) [constructor]
cls.add_constructor([param('char const *', 'name')])
@@ -3684,10 +3734,8 @@
return
def register_Ns3Int64x64_t_methods(root_module, cls):
- cls.add_binary_comparison_operator('<=')
cls.add_binary_comparison_operator('!=')
cls.add_inplace_numeric_operator('+=', param('ns3::int64x64_t const &', u'right'))
- cls.add_output_stream_operator()
cls.add_binary_numeric_operator('*', root_module['ns3::int64x64_t'], root_module['ns3::int64x64_t'], param('ns3::int64x64_t const &', u'right'))
cls.add_binary_numeric_operator('+', root_module['ns3::int64x64_t'], root_module['ns3::int64x64_t'], param('ns3::int64x64_t const &', u'right'))
cls.add_binary_numeric_operator('-', root_module['ns3::int64x64_t'], root_module['ns3::int64x64_t'], param('ns3::int64x64_t const &', u'right'))
@@ -3698,6 +3746,8 @@
cls.add_inplace_numeric_operator('*=', param('ns3::int64x64_t const &', u'right'))
cls.add_inplace_numeric_operator('-=', param('ns3::int64x64_t const &', u'right'))
cls.add_inplace_numeric_operator('/=', param('ns3::int64x64_t const &', u'right'))
+ cls.add_output_stream_operator()
+ cls.add_binary_comparison_operator('<=')
cls.add_binary_comparison_operator('==')
cls.add_binary_comparison_operator('>=')
## int64x64-double.h (module 'core'): ns3::int64x64_t::int64x64_t() [constructor]
@@ -5329,10 +5379,8 @@
return
def register_Ns3Time_methods(root_module, cls):
- cls.add_binary_comparison_operator('<=')
cls.add_binary_comparison_operator('!=')
cls.add_inplace_numeric_operator('+=', param('ns3::Time const &', u'right'))
- cls.add_output_stream_operator()
cls.add_binary_numeric_operator('*', root_module['ns3::Time'], root_module['ns3::Time'], param('int64_t const &', u'right'))
cls.add_binary_numeric_operator('+', root_module['ns3::Time'], root_module['ns3::Time'], param('ns3::Time const &', u'right'))
cls.add_binary_numeric_operator('-', root_module['ns3::Time'], root_module['ns3::Time'], param('ns3::Time const &', u'right'))
@@ -5340,6 +5388,8 @@
cls.add_binary_comparison_operator('<')
cls.add_binary_comparison_operator('>')
cls.add_inplace_numeric_operator('-=', param('ns3::Time const &', u'right'))
+ cls.add_output_stream_operator()
+ cls.add_binary_comparison_operator('<=')
cls.add_binary_comparison_operator('==')
cls.add_binary_comparison_operator('>=')
## nstime.h (module 'core'): ns3::Time::Time() [constructor]
@@ -5360,10 +5410,10 @@
cls.add_constructor([param('long unsigned int', 'v')])
## nstime.h (module 'core'): ns3::Time::Time(long long unsigned int v) [constructor]
cls.add_constructor([param('long long unsigned int', 'v')])
+ ## nstime.h (module 'core'): ns3::Time::Time(ns3::int64x64_t const & v) [constructor]
+ cls.add_constructor([param('ns3::int64x64_t const &', 'v')])
## nstime.h (module 'core'): ns3::Time::Time(std::string const & s) [constructor]
cls.add_constructor([param('std::string const &', 's')])
- ## nstime.h (module 'core'): ns3::Time::Time(ns3::int64x64_t const & value) [constructor]
- cls.add_constructor([param('ns3::int64x64_t const &', 'value')])
## nstime.h (module 'core'): ns3::TimeWithUnit ns3::Time::As(ns3::Time::Unit const unit) const [member function]
cls.add_method('As',
'ns3::TimeWithUnit',
@@ -5374,25 +5424,25 @@
'int',
[param('ns3::Time const &', 'o')],
is_const=True)
- ## nstime.h (module 'core'): static ns3::Time ns3::Time::From(ns3::int64x64_t const & from, ns3::Time::Unit timeUnit) [member function]
- cls.add_method('From',
- 'ns3::Time',
- [param('ns3::int64x64_t const &', 'from'), param('ns3::Time::Unit', 'timeUnit')],
- is_static=True)
## nstime.h (module 'core'): static ns3::Time ns3::Time::From(ns3::int64x64_t const & value) [member function]
cls.add_method('From',
'ns3::Time',
[param('ns3::int64x64_t const &', 'value')],
is_static=True)
- ## nstime.h (module 'core'): static ns3::Time ns3::Time::FromDouble(double value, ns3::Time::Unit timeUnit) [member function]
+ ## nstime.h (module 'core'): static ns3::Time ns3::Time::From(ns3::int64x64_t const & value, ns3::Time::Unit unit) [member function]
+ cls.add_method('From',
+ 'ns3::Time',
+ [param('ns3::int64x64_t const &', 'value'), param('ns3::Time::Unit', 'unit')],
+ is_static=True)
+ ## nstime.h (module 'core'): static ns3::Time ns3::Time::FromDouble(double value, ns3::Time::Unit unit) [member function]
cls.add_method('FromDouble',
'ns3::Time',
- [param('double', 'value'), param('ns3::Time::Unit', 'timeUnit')],
- is_static=True)
- ## nstime.h (module 'core'): static ns3::Time ns3::Time::FromInteger(uint64_t value, ns3::Time::Unit timeUnit) [member function]
+ [param('double', 'value'), param('ns3::Time::Unit', 'unit')],
+ is_static=True)
+ ## nstime.h (module 'core'): static ns3::Time ns3::Time::FromInteger(uint64_t value, ns3::Time::Unit unit) [member function]
cls.add_method('FromInteger',
'ns3::Time',
- [param('uint64_t', 'value'), param('ns3::Time::Unit', 'timeUnit')],
+ [param('uint64_t', 'value'), param('ns3::Time::Unit', 'unit')],
is_static=True)
## nstime.h (module 'core'): double ns3::Time::GetDays() const [member function]
cls.add_method('GetDays',
@@ -5509,20 +5559,20 @@
'bool',
[],
is_static=True)
- ## nstime.h (module 'core'): ns3::int64x64_t ns3::Time::To(ns3::Time::Unit timeUnit) const [member function]
+ ## nstime.h (module 'core'): ns3::int64x64_t ns3::Time::To(ns3::Time::Unit unit) const [member function]
cls.add_method('To',
'ns3::int64x64_t',
- [param('ns3::Time::Unit', 'timeUnit')],
- is_const=True)
- ## nstime.h (module 'core'): double ns3::Time::ToDouble(ns3::Time::Unit timeUnit) const [member function]
+ [param('ns3::Time::Unit', 'unit')],
+ is_const=True)
+ ## nstime.h (module 'core'): double ns3::Time::ToDouble(ns3::Time::Unit unit) const [member function]
cls.add_method('ToDouble',
'double',
- [param('ns3::Time::Unit', 'timeUnit')],
- is_const=True)
- ## nstime.h (module 'core'): int64_t ns3::Time::ToInteger(ns3::Time::Unit timeUnit) const [member function]
+ [param('ns3::Time::Unit', 'unit')],
+ is_const=True)
+ ## nstime.h (module 'core'): int64_t ns3::Time::ToInteger(ns3::Time::Unit unit) const [member function]
cls.add_method('ToInteger',
'int64_t',
- [param('ns3::Time::Unit', 'timeUnit')],
+ [param('ns3::Time::Unit', 'unit')],
is_const=True)
return
@@ -9160,6 +9210,11 @@
'ns3::Ptr< ns3::Node >',
[],
is_const=True, is_virtual=True)
+ ## simple-net-device.h (module 'network'): ns3::Ptr<ns3::Queue> ns3::SimpleNetDevice::GetQueue() const [member function]
+ cls.add_method('GetQueue',
+ 'ns3::Ptr< ns3::Queue >',
+ [],
+ is_const=True)
## simple-net-device.h (module 'network'): static ns3::TypeId ns3::SimpleNetDevice::GetTypeId() [member function]
cls.add_method('GetTypeId',
'ns3::TypeId',
@@ -9238,6 +9293,10 @@
'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)
+ ## simple-net-device.h (module 'network'): void ns3::SimpleNetDevice::SetQueue(ns3::Ptr<ns3::Queue> queue) [member function]
+ cls.add_method('SetQueue',
+ 'void',
+ [param('ns3::Ptr< ns3::Queue >', 'queue')])
## simple-net-device.h (module 'network'): void ns3::SimpleNetDevice::SetReceiveCallback(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) [member function]
cls.add_method('SetReceiveCallback',
'void',
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/network/helper/simple-net-device-helper.cc Sat Sep 06 07:08:49 2014 +0200
@@ -0,0 +1,143 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2014 Universita' di Firenze
+ *
+ * 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: Tommaso Pecorella <tommaso.pecorella@unifi.it>
+ */
+
+#include "ns3/abort.h"
+#include "ns3/log.h"
+#include "ns3/simulator.h"
+#include "ns3/object-factory.h"
+#include "ns3/simple-net-device.h"
+#include "ns3/simple-channel.h"
+#include "ns3/config.h"
+#include "ns3/packet.h"
+#include "ns3/names.h"
+#include "ns3/boolean.h"
+
+#include "ns3/trace-helper.h"
+#include "simple-net-device-helper.h"
+
+#include <string>
+
+NS_LOG_COMPONENT_DEFINE ("SimpleNetDeviceHelper");
+
+namespace ns3 {
+
+SimpleNetDeviceHelper::SimpleNetDeviceHelper ()
+{
+ m_queueFactory.SetTypeId ("ns3::DropTailQueue");
+ m_deviceFactory.SetTypeId ("ns3::SimpleNetDevice");
+ m_channelFactory.SetTypeId ("ns3::SimpleChannel");
+ m_pointToPointMode = false;
+}
+
+void
+SimpleNetDeviceHelper::SetQueue (std::string type,
+ std::string n1, const AttributeValue &v1,
+ std::string n2, const AttributeValue &v2,
+ std::string n3, const AttributeValue &v3,
+ std::string n4, const AttributeValue &v4)
+{
+ m_queueFactory.SetTypeId (type);
+ m_queueFactory.Set (n1, v1);
+ m_queueFactory.Set (n2, v2);
+ m_queueFactory.Set (n3, v3);
+ m_queueFactory.Set (n4, v4);
+}
+
+void
+SimpleNetDeviceHelper::SetChannel (std::string type,
+ std::string n1, const AttributeValue &v1,
+ std::string n2, const AttributeValue &v2,
+ std::string n3, const AttributeValue &v3,
+ std::string n4, const AttributeValue &v4)
+{
+ m_channelFactory.SetTypeId (type);
+ m_channelFactory.Set (n1, v1);
+ m_channelFactory.Set (n2, v2);
+ m_channelFactory.Set (n3, v3);
+ m_channelFactory.Set (n4, v4);
+}
+
+void
+SimpleNetDeviceHelper::SetDeviceAttribute (std::string n1, const AttributeValue &v1)
+{
+ m_deviceFactory.Set (n1, v1);
+}
+
+void
+SimpleNetDeviceHelper::SetChannelAttribute (std::string n1, const AttributeValue &v1)
+{
+ m_channelFactory.Set (n1, v1);
+}
+
+void
+SimpleNetDeviceHelper::SetNetDevicePointToPointMode (bool pointToPointMode)
+{
+ m_pointToPointMode = pointToPointMode;
+}
+
+NetDeviceContainer
+SimpleNetDeviceHelper::Install (Ptr<Node> node) const
+{
+ Ptr<SimpleChannel> channel = m_channelFactory.Create<SimpleChannel> ();
+ return Install (node, channel);
+}
+
+NetDeviceContainer
+SimpleNetDeviceHelper::Install (Ptr<Node> node, Ptr<SimpleChannel> channel) const
+{
+ return NetDeviceContainer (InstallPriv (node, channel));
+}
+
+NetDeviceContainer
+SimpleNetDeviceHelper::Install (const NodeContainer &c) const
+{
+ Ptr<SimpleChannel> channel = m_channelFactory.Create<SimpleChannel> ();
+
+ return Install (c, channel);
+}
+
+NetDeviceContainer
+SimpleNetDeviceHelper::Install (const NodeContainer &c, Ptr<SimpleChannel> channel) const
+{
+ NetDeviceContainer devs;
+
+ for (NodeContainer::Iterator i = c.Begin (); i != c.End (); i++)
+ {
+ devs.Add (InstallPriv (*i, channel));
+ }
+
+ return devs;
+}
+
+Ptr<NetDevice>
+SimpleNetDeviceHelper::InstallPriv (Ptr<Node> node, Ptr<SimpleChannel> channel) const
+{
+ Ptr<SimpleNetDevice> device = m_deviceFactory.Create<SimpleNetDevice> ();
+ device->SetAttribute ("PointToPointMode", BooleanValue (m_pointToPointMode));
+ device->SetAddress (Mac48Address::Allocate ());
+ node->AddDevice (device);
+ device->SetChannel (channel);
+ Ptr<Queue> queue = m_queueFactory.Create<Queue> ();
+ device->SetQueue (queue);
+ NS_ASSERT_MSG (!m_pointToPointMode || (channel->GetNDevices () <= 2), "Device set to PointToPoint and more than 2 devices on the channel.");
+ return device;
+}
+
+} // namespace ns3
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/network/helper/simple-net-device-helper.h Sat Sep 06 07:08:49 2014 +0200
@@ -0,0 +1,191 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2014 Universita' di Firenze
+ *
+ * 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: Tommaso Pecorella <tommaso.pecorella@unifi.it>
+ */
+#ifndef SIMPLE_NETDEVICE_HELPER_H
+#define SIMPLE_NETDEVICE_HELPER_H
+
+#include <string>
+
+#include "ns3/attribute.h"
+#include "ns3/object-factory.h"
+#include "ns3/net-device-container.h"
+#include "ns3/node-container.h"
+#include "ns3/simple-channel.h"
+#include "ns3/deprecated.h"
+
+namespace ns3 {
+
+/**
+ * \brief build a set of SimpleNetDevice objects
+ */
+class SimpleNetDeviceHelper
+{
+public:
+ /**
+ * Construct a SimpleNetDeviceHelper.
+ */
+ SimpleNetDeviceHelper ();
+ virtual ~SimpleNetDeviceHelper () {}
+
+ /**
+ * Each net device must have a queue to pass packets through.
+ * This method allows one to set the type of the queue that is automatically
+ * created when the device is created and attached to a node.
+ *
+ * \param type the type of queue
+ * \param n1 the name of the attribute to set on the queue
+ * \param v1 the value of the attribute to set on the queue
+ * \param n2 the name of the attribute to set on the queue
+ * \param v2 the value of the attribute to set on the queue
+ * \param n3 the name of the attribute to set on the queue
+ * \param v3 the value of the attribute to set on the queue
+ * \param n4 the name of the attribute to set on the queue
+ * \param v4 the value of the attribute to set on the queue
+ *
+ * Set the type of queue to create and associated to each
+ * SimpleNetDevice created through SimpleNetDeviceHelper::Install.
+ */
+ void SetQueue (std::string type,
+ 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 ());
+
+ /**
+ * Each net device must have a channel to pass packets through.
+ * This method allows one to set the type of the channel that is automatically
+ * created when the device is created and attached to a node.
+ *
+ * \param type the type of queue
+ * \param n1 the name of the attribute to set on the queue
+ * \param v1 the value of the attribute to set on the queue
+ * \param n2 the name of the attribute to set on the queue
+ * \param v2 the value of the attribute to set on the queue
+ * \param n3 the name of the attribute to set on the queue
+ * \param v3 the value of the attribute to set on the queue
+ * \param n4 the name of the attribute to set on the queue
+ * \param v4 the value of the attribute to set on the queue
+ *
+ * Set the type of channel to create and associated to each
+ * SimpleNetDevice created through SimpleNetDeviceHelper::Install.
+ */
+ void SetChannel (std::string type,
+ 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 ());
+
+
+ /**
+ * \param n1 the name of the attribute to set
+ * \param v1 the value of the attribute to set
+ *
+ * Set these attributes on each ns3::SimpleNetDevice created
+ * by SimpleNetDeviceHelper::Install
+ */
+ void SetDeviceAttribute (std::string n1, const AttributeValue &v1);
+
+ /**
+ * \param n1 the name of the attribute to set
+ * \param v1 the value of the attribute to set
+ *
+ * Set these attributes on each ns3::CsmaChannel created
+ * by SimpleNetDeviceHelper::Install
+ */
+ void SetChannelAttribute (std::string n1, const AttributeValue &v1);
+
+ /**
+ * SimpleNetDevice is Broadcast capable and ARP needing. This function
+ * limits the number of SimpleNetDevices on one channel to two, disables
+ * Broadcast and ARP and enables PointToPoint mode.
+ *
+ * \warning It must be used before installing a NetDevice on a node.
+ *
+ * \param pointToPointMode True for PointToPoint SimpleNetDevice
+ */
+ void SetNetDevicePointToPointMode (bool pointToPointMode);
+
+ /**
+ * This method creates an ns3::SimpleChannel with the attributes configured by
+ * SimpleNetDeviceHelper::SetChannelAttribute, an ns3::SimpleNetDevice with the attributes
+ * configured by SimpleNetDeviceHelper::SetDeviceAttribute and then adds the device
+ * to the node and attaches the channel to the device.
+ *
+ * \param node The node to install the device in
+ * \returns A container holding the added net device.
+ */
+ NetDeviceContainer Install (Ptr<Node> node) const;
+
+ /**
+ * This method creates an ns3::SimpleNetDevice with the attributes configured by
+ * SimpleNetDeviceHelper::SetDeviceAttribute and then adds the device to the node and
+ * attaches the provided channel to the device.
+ *
+ * \param node The node to install the device in
+ * \param channel The channel to attach to the device.
+ * \returns A container holding the added net device.
+ */
+ NetDeviceContainer Install (Ptr<Node> node, Ptr<SimpleChannel> channel) const;
+
+ /**
+ * This method creates an ns3::SimpleChannel with the attributes configured by
+ * SimpleNetDeviceHelper::SetChannelAttribute. For each Ptr<node> in the provided
+ * container: it creates an ns3::SimpleNetDevice (with the attributes
+ * configured by SimpleNetDeviceHelper::SetDeviceAttribute); adds the device to the
+ * node; and attaches the channel to the device.
+ *
+ * \param c The NodeContainer holding the nodes to be changed.
+ * \returns A container holding the added net devices.
+ */
+ NetDeviceContainer Install (const NodeContainer &c) const;
+
+ /**
+ * For each Ptr<node> in the provided container, this method creates an
+ * ns3::SimpleNetDevice (with the attributes configured by
+ * SimpleNetDeviceHelper::SetDeviceAttribute); adds the device to the node; and attaches
+ * the provided channel to the device.
+ *
+ * \param c The NodeContainer holding the nodes to be changed.
+ * \param channel The channel to attach to the devices.
+ * \returns A container holding the added net devices.
+ */
+ NetDeviceContainer Install (const NodeContainer &c, Ptr<SimpleChannel> channel) const;
+
+private:
+ /**
+ * This method creates an ns3::SimpleNetDevice with the attributes configured by
+ * SimpleNetDeviceHelper::SetDeviceAttribute and then adds the device to the node and
+ * attaches the provided channel to the device.
+ *
+ * \param node The node to install the device in
+ * \param channelName The name of the channel to attach to the device.
+ * \returns The new net device.
+ */
+ Ptr<NetDevice> InstallPriv (Ptr<Node> node, Ptr<SimpleChannel> channel) const;
+
+ ObjectFactory m_queueFactory; //!< Queue factory
+ ObjectFactory m_deviceFactory; //!< NetDevice factory
+ ObjectFactory m_channelFactory; //!< Channel factory
+ bool m_pointToPointMode; //!< Install PointToPoint SimpleNetDevice or Broadcast ones
+
+};
+
+} // namespace ns3
+
+#endif /* SIMPLE_NETDEVICE_HELPER_H */
--- a/src/network/utils/simple-channel.cc Sat Sep 06 06:57:27 2014 +0200
+++ b/src/network/utils/simple-channel.cc Sat Sep 06 07:08:49 2014 +0200
@@ -36,6 +36,10 @@
static TypeId tid = TypeId ("ns3::SimpleChannel")
.SetParent<Channel> ()
.AddConstructor<SimpleChannel> ()
+ .AddAttribute ("Delay", "Transmission delay through the channel",
+ TimeValue (Seconds (0)),
+ MakeTimeAccessor (&SimpleChannel::m_delay),
+ MakeTimeChecker ())
;
return tid;
}
@@ -58,7 +62,7 @@
{
continue;
}
- Simulator::ScheduleWithContext (tmp->GetNode ()->GetId (), Seconds (0),
+ Simulator::ScheduleWithContext (tmp->GetNode ()->GetId (), m_delay,
&SimpleNetDevice::Receive, tmp, p->Copy (), protocol, to, from);
}
}
--- a/src/network/utils/simple-channel.h Sat Sep 06 06:57:27 2014 +0200
+++ b/src/network/utils/simple-channel.h Sat Sep 06 07:08:49 2014 +0200
@@ -21,6 +21,7 @@
#define SIMPLE_CHANNEL_H
#include "ns3/channel.h"
+#include "ns3/nstime.h"
#include "mac48-address.h"
#include <vector>
@@ -31,7 +32,15 @@
/**
* \ingroup channel
- * \brief A simple channel, for simple things and testing
+ * \brief A simple channel, for simple things and testing.
+ *
+ * This channel doesn't check for packet collisions and it
+ * does not introduce any error.
+ * By default, it does not add any delay to the packets.
+ * Furthermore, it assumes that the associated NetDevices
+ * are using 48-bit MAC addresses.
+ *
+ * This channel is meant to be used by ns3::SimpleNetDevices.
*/
class SimpleChannel : public Channel
{
@@ -70,6 +79,7 @@
virtual Ptr<NetDevice> GetDevice (uint32_t i) const;
private:
+ Time m_delay; //!< The assigned speed-of-light delay of the channel
std::vector<Ptr<SimpleNetDevice> > m_devices; //!< devices connected by the channel
};
--- a/src/network/utils/simple-net-device.cc Sat Sep 06 06:57:27 2014 +0200
+++ b/src/network/utils/simple-net-device.cc Sat Sep 06 07:08:49 2014 +0200
@@ -25,11 +25,132 @@
#include "ns3/pointer.h"
#include "ns3/error-model.h"
#include "ns3/trace-source-accessor.h"
+#include "ns3/boolean.h"
+#include "ns3/tag.h"
+#include "ns3/simulator.h"
+#include "ns3/drop-tail-queue.h"
NS_LOG_COMPONENT_DEFINE ("SimpleNetDevice");
namespace ns3 {
+/**
+ * \brief Internal tag to store source, destination and protocol of each packet.
+ */
+class SimpleTag : public Tag {
+public:
+ static TypeId GetTypeId (void);
+ virtual TypeId GetInstanceTypeId (void) const;
+
+ virtual uint32_t GetSerializedSize (void) const;
+ virtual void Serialize (TagBuffer i) const;
+ virtual void Deserialize (TagBuffer i);
+
+ void SetSrc (Mac48Address src);
+ Mac48Address GetSrc (void) const;
+
+ void SetDst (Mac48Address dst);
+ Mac48Address GetDst (void) const;
+
+ void SetProto (uint16_t proto);
+ uint16_t GetProto (void) const;
+
+ void Print (std::ostream &os) const;
+
+private:
+ Mac48Address m_src;
+ Mac48Address m_dst;
+ uint16_t m_protocolNumber;
+};
+
+
+NS_OBJECT_ENSURE_REGISTERED (SimpleTag);
+
+TypeId
+SimpleTag::GetTypeId (void)
+{
+ static TypeId tid = TypeId ("SimpleTag")
+ .SetParent<Tag> ()
+ .AddConstructor<SimpleTag> ()
+ ;
+ return tid;
+}
+TypeId
+SimpleTag::GetInstanceTypeId (void) const
+{
+ return GetTypeId ();
+}
+
+uint32_t
+SimpleTag::GetSerializedSize (void) const
+{
+ return 8+8+2;
+}
+void
+SimpleTag::Serialize (TagBuffer i) const
+{
+ uint8_t mac[6];
+ m_src.CopyTo (mac);
+ i.Write (mac, 6);
+ m_dst.CopyTo (mac);
+ i.Write (mac, 6);
+ i.WriteU16 (m_protocolNumber);
+}
+void
+SimpleTag::Deserialize (TagBuffer i)
+{
+ uint8_t mac[6];
+ i.Read (mac, 6);
+ m_src.CopyFrom (mac);
+ i.Read (mac, 6);
+ m_dst.CopyFrom (mac);
+ m_protocolNumber = i.ReadU16 ();
+}
+
+void
+SimpleTag::SetSrc (Mac48Address src)
+{
+ m_src = src;
+}
+
+Mac48Address
+SimpleTag::GetSrc (void) const
+{
+ return m_src;
+}
+
+void
+SimpleTag::SetDst (Mac48Address dst)
+{
+ m_dst = dst;
+}
+
+Mac48Address
+SimpleTag::GetDst (void) const
+{
+ return m_dst;
+}
+
+void
+SimpleTag::SetProto (uint16_t proto)
+{
+ m_protocolNumber = proto;
+}
+
+uint16_t
+SimpleTag::GetProto (void) const
+{
+ return m_protocolNumber;
+}
+
+void
+SimpleTag::Print (std::ostream &os) const
+{
+ os << "src=" << m_src << " dst=" << m_dst << " proto=" << m_protocolNumber;
+}
+
+
+
NS_OBJECT_ENSURE_REGISTERED (SimpleNetDevice);
TypeId
@@ -43,6 +164,21 @@
PointerValue (),
MakePointerAccessor (&SimpleNetDevice::m_receiveErrorModel),
MakePointerChecker<ErrorModel> ())
+ .AddAttribute ("PointToPointMode",
+ "The device is configured in Point to Point mode",
+ BooleanValue (false),
+ MakeBooleanAccessor (&SimpleNetDevice::m_pointToPointMode),
+ MakeBooleanChecker ())
+ .AddAttribute ("TxQueue",
+ "A queue to use as the transmit queue in the device.",
+ PointerValue (CreateObject<DropTailQueue> ()),
+ MakePointerAccessor (&SimpleNetDevice::m_queue),
+ MakePointerChecker<Queue> ())
+ .AddAttribute ("DataRate",
+ "The default data rate for point to point links. Zero means infinite",
+ DataRateValue (DataRate ("0b/s")),
+ MakeDataRateAccessor (&SimpleNetDevice::m_bps),
+ MakeDataRateChecker ())
.AddTraceSource ("PhyRxDrop",
"Trace source indicating a packet has been dropped by the device during reception",
MakeTraceSourceAccessor (&SimpleNetDevice::m_phyRxDropTrace))
@@ -54,7 +190,8 @@
: m_channel (0),
m_node (0),
m_mtu (0xffff),
- m_ifIndex (0)
+ m_ifIndex (0),
+ m_linkUp (false)
{
NS_LOG_FUNCTION (this);
}
@@ -78,7 +215,7 @@
}
else if (to.IsBroadcast ())
{
- packetType = NetDevice::PACKET_HOST;
+ packetType = NetDevice::PACKET_BROADCAST;
}
else if (to.IsGroup ())
{
@@ -88,7 +225,12 @@
{
packetType = NetDevice::PACKET_OTHERHOST;
}
- m_rxCallback (this, packet, protocol, from);
+
+ if (packetType != NetDevice::PACKET_OTHERHOST)
+ {
+ m_rxCallback (this, packet, protocol, from);
+ }
+
if (!m_promiscCallback.IsNull ())
{
m_promiscCallback (this, packet, protocol, from, to, packetType);
@@ -101,6 +243,22 @@
NS_LOG_FUNCTION (this << channel);
m_channel = channel;
m_channel->Add (this);
+ m_linkUp = true;
+ m_linkChangeCallbacks ();
+}
+
+Ptr<Queue>
+SimpleNetDevice::GetQueue () const
+{
+ NS_LOG_FUNCTION (this);
+ return m_queue;
+}
+
+void
+SimpleNetDevice::SetQueue (Ptr<Queue> q)
+{
+ NS_LOG_FUNCTION (this << q);
+ m_queue = q;
}
void
@@ -160,17 +318,22 @@
SimpleNetDevice::IsLinkUp (void) const
{
NS_LOG_FUNCTION (this);
- return true;
+ return m_linkUp;
}
void
SimpleNetDevice::AddLinkChangeCallback (Callback<void> callback)
{
NS_LOG_FUNCTION (this << &callback);
+ m_linkChangeCallbacks.ConnectWithoutContext (callback);
}
bool
SimpleNetDevice::IsBroadcast (void) const
{
NS_LOG_FUNCTION (this);
+ if (m_pointToPointMode)
+ {
+ return false;
+ }
return true;
}
Address
@@ -183,7 +346,11 @@
SimpleNetDevice::IsMulticast (void) const
{
NS_LOG_FUNCTION (this);
- return false;
+ if (m_pointToPointMode)
+ {
+ return false;
+ }
+ return true;
}
Address
SimpleNetDevice::GetMulticast (Ipv4Address multicastGroup) const
@@ -202,6 +369,10 @@
SimpleNetDevice::IsPointToPoint (void) const
{
NS_LOG_FUNCTION (this);
+ if (m_pointToPointMode)
+ {
+ return true;
+ }
return false;
}
@@ -216,18 +387,85 @@
SimpleNetDevice::Send (Ptr<Packet> packet, const Address& dest, uint16_t protocolNumber)
{
NS_LOG_FUNCTION (this << packet << dest << protocolNumber);
+
+ return SendFrom (packet, m_address, dest, protocolNumber);
+}
+
+bool
+SimpleNetDevice::SendFrom (Ptr<Packet> p, const Address& source, const Address& dest, uint16_t protocolNumber)
+{
+ NS_LOG_FUNCTION (this << p << source << dest << protocolNumber);
+ if (p->GetSize () > GetMtu ())
+ {
+ return false;
+ }
+ Ptr<Packet> packet = p->Copy ();
+
Mac48Address to = Mac48Address::ConvertFrom (dest);
- m_channel->Send (packet, protocolNumber, to, m_address, this);
+ Mac48Address from = Mac48Address::ConvertFrom (source);
+
+ SimpleTag tag;
+ tag.SetSrc (from);
+ tag.SetDst (to);
+ tag.SetProto (protocolNumber);
+
+ p->AddPacketTag (tag);
+
+ if (m_queue->Enqueue (p))
+ {
+ if (m_queue->GetNPackets () == 1)
+ {
+ p = m_queue->Dequeue ();
+ p->RemovePacketTag (tag);
+ Time txTime = Time (0);
+ if (m_bps > DataRate (0))
+ {
+ txTime = Seconds (m_bps.CalculateTxTime (packet->GetSize ()));
+ }
+ m_channel->Send (p, protocolNumber, to, from, this);
+ TransmitCompleteEvent = Simulator::Schedule (txTime, &SimpleNetDevice::TransmitComplete, this);
+ }
+ return true;
+ }
+
+
+ m_channel->Send (packet, protocolNumber, to, from, this);
return true;
}
-bool
-SimpleNetDevice::SendFrom (Ptr<Packet> packet, const Address& source, const Address& dest, uint16_t protocolNumber)
+
+
+void
+SimpleNetDevice::TransmitComplete ()
{
- NS_LOG_FUNCTION (this << packet << source << dest << protocolNumber);
- Mac48Address to = Mac48Address::ConvertFrom (dest);
- Mac48Address from = Mac48Address::ConvertFrom (source);
- m_channel->Send (packet, protocolNumber, to, from, this);
- return true;
+ NS_LOG_FUNCTION (this);
+
+ if (m_queue->GetNPackets () == 0)
+ {
+ return;
+ }
+
+ Ptr<Packet> packet = m_queue->Dequeue ();
+
+ SimpleTag tag;
+ packet->RemovePacketTag (tag);
+
+ Mac48Address src = tag.GetSrc ();
+ Mac48Address dst = tag.GetDst ();
+ uint16_t proto = tag.GetProto ();
+
+ m_channel->Send (packet, proto, dst, src, this);
+
+ if (m_queue->GetNPackets ())
+ {
+ Time txTime = Time (0);
+ if (m_bps > DataRate (0))
+ {
+ txTime = Seconds (m_bps.CalculateTxTime (packet->GetSize ()));
+ }
+ TransmitCompleteEvent = Simulator::Schedule (txTime, &SimpleNetDevice::TransmitComplete, this);
+ }
+
+ return;
}
Ptr<Node>
@@ -246,7 +484,11 @@
SimpleNetDevice::NeedsArp (void) const
{
NS_LOG_FUNCTION (this);
- return false;
+ if (m_pointToPointMode)
+ {
+ return false;
+ }
+ return true;
}
void
SimpleNetDevice::SetReceiveCallback (NetDevice::ReceiveCallback cb)
@@ -262,6 +504,11 @@
m_channel = 0;
m_node = 0;
m_receiveErrorModel = 0;
+ m_queue->DequeueAll ();
+ if (TransmitCompleteEvent.IsRunning ())
+ {
+ TransmitCompleteEvent.Cancel ();
+ }
NetDevice::DoDispose ();
}
--- a/src/network/utils/simple-net-device.h Sat Sep 06 06:57:27 2014 +0200
+++ b/src/network/utils/simple-net-device.h Sat Sep 06 07:08:49 2014 +0200
@@ -20,11 +20,17 @@
#ifndef SIMPLE_NET_DEVICE_H
#define SIMPLE_NET_DEVICE_H
-#include "ns3/net-device.h"
-#include "mac48-address.h"
#include <stdint.h>
#include <string>
+
#include "ns3/traced-callback.h"
+#include "ns3/net-device.h"
+#include "ns3/queue.h"
+#include "ns3/data-rate.h"
+#include "ns3/data-rate.h"
+#include "ns3/event-id.h"
+
+#include "mac48-address.h"
namespace ns3 {
@@ -35,11 +41,15 @@
/**
* \ingroup netdevice
*
- * This device does not have a helper and assumes 48-bit mac addressing;
- * the default address assigned to each device is zero, so you must
- * assign a real address to use it. There is also the possibility to
+ * This device assumes 48-bit mac addressing; there is also the possibility to
* add an ErrorModel if you want to force losses on the device.
*
+ * The device can be installed on a node through the SimpleNetDeviceHelper.
+ * In case of manual creation, the user is responsible for assigning an unique
+ * address to the device.
+ *
+ * By default the device is in Broadcast mode, with infinite bandwidth.
+ *
* \brief simple net device for simple things and testing
*/
class SimpleNetDevice : public NetDevice
@@ -65,7 +75,6 @@
void Receive (Ptr<Packet> packet, uint16_t protocol, Mac48Address to, Mac48Address from);
/**
- *
* Attach a channel to this net device. This will be the
* channel the net device sends on
*
@@ -75,6 +84,20 @@
void SetChannel (Ptr<SimpleChannel> channel);
/**
+ * Attach a queue to the SimpleNetDevice.
+ *
+ * \param queue Ptr to the new queue.
+ */
+ void SetQueue (Ptr<Queue> queue);
+
+ /**
+ * Get a copy of the attached Queue.
+ *
+ * \returns Ptr to the queue.
+ */
+ Ptr<Queue> GetQueue (void) const;
+
+ /**
* Attach a receive ErrorModel to the SimpleNetDevice.
*
* The SimpleNetDevice may optionally include an ErrorModel in
@@ -124,6 +147,7 @@
uint32_t m_ifIndex; //!< Interface index
Mac48Address m_address; //!< MAC address
Ptr<ErrorModel> m_receiveErrorModel; //!< Receive error model.
+
/**
* The trace source fired when the phy layer drops a packet it has received
* due to the error model being active. Although SimpleNetDevice doesn't
@@ -133,6 +157,29 @@
* \see class CallBackTraceSource
*/
TracedCallback<Ptr<const Packet> > m_phyRxDropTrace;
+
+ /**
+ * The TransmitComplete method is used internally to finish the process
+ * of sending a packet out on the channel.
+ */
+ void TransmitComplete (void);
+
+ bool m_linkUp; //!< Flag indicating whether or not the link is up
+
+ /**
+ * Flag indicating whether or not the NetDevice is a Point to Point model.
+ * Enabling this will disable Broadcast and Arp.
+ */
+ bool m_pointToPointMode;
+
+ Ptr<Queue> m_queue; //!< The Queue for outgoing packets.
+ DataRate m_bps; //!< The device nominal Data rate. Zero means infinite
+ EventId TransmitCompleteEvent; //!< the Tx Complete event
+
+ /**
+ * List of callbacks to fire if the link changes state (up or down).
+ */
+ TracedCallback<> m_linkChangeCallbacks;
};
} // namespace ns3
--- a/src/network/wscript Sat Sep 06 06:57:27 2014 +0200
+++ b/src/network/wscript Sat Sep 06 07:08:49 2014 +0200
@@ -61,6 +61,7 @@
'helper/packet-socket-helper.cc',
'helper/trace-helper.cc',
'helper/delay-jitter-estimation.cc',
+ 'helper/simple-net-device-helper.cc',
]
network_test = bld.create_ns3_module_test_library('network')
@@ -143,6 +144,7 @@
'helper/packet-socket-helper.h',
'helper/trace-helper.h',
'helper/delay-jitter-estimation.h',
+ 'helper/simple-net-device-helper.h',
]
if (bld.env['ENABLE_EXAMPLES']):