kill dead code.

This commit is contained in:
Mathieu Lacage
2008-03-31 14:36:21 -07:00
parent 40349f92d8
commit b41554c18f
11 changed files with 0 additions and 994 deletions

View File

@@ -1,165 +0,0 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
//
// Copyright (c) 2007 Emmanuelle Laprise
//
// 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: Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
//
#include <algorithm>
#include "ns3/assert.h"
#include "ns3/fatal-error.h"
#include "ns3/nstime.h"
#include "ns3/internet-node.h"
#include "ns3/ipv4-address.h"
#include "ns3/ipv4.h"
#include "ns3/queue.h"
#include "ns3/drop-tail-queue.h"
#include "ns3/string.h"
#include "csma-channel.h"
#include "csma-net-device.h"
#include "csma-ipv4-topology.h"
namespace ns3 {
uint32_t
CsmaIpv4Topology::AddIpv4CsmaNetDevice(
Ptr<Node> node,
Ptr<CsmaChannel> channel,
Mac48Address addr)
{
Ptr<Queue> q = CreateObject<DropTailQueue> ();
// assume full-duplex
Ptr<CsmaNetDevice> nd = CreateObject<CsmaNetDevice> ("Address", addr,
"EncapsulationMode", String ("IpArp"));
node->AddDevice (nd);
nd->AddQueue(q);
nd->Attach (channel);
return nd->GetIfIndex ();
}
void
CsmaIpv4Topology::AddIpv4LlcCsmaNode(Ptr<Node> n1,
Ptr<CsmaChannel> ch,
Mac48Address addr)
{
Ptr<Queue> q = CreateObject<DropTailQueue> ();
Ptr<CsmaNetDevice> nd0 = CreateObject<CsmaNetDevice> ("Address", addr,
"EncapsulationMode", String ("Llc"));
n1->AddDevice (nd0);
nd0->SetSendEnable (true);
nd0->SetReceiveEnable (false);
nd0->AddQueue(q);
nd0->Attach (ch);
Ptr<CsmaNetDevice> nd1 = CreateObject<CsmaNetDevice> ("Address", addr,
"EncapsulationMode", String ("Llc"));
n1->AddDevice (nd1);
nd1->SetSendEnable (false);
nd1->SetReceiveEnable (true);
nd1->AddQueue(q);
nd1->Attach (ch);
}
void
CsmaIpv4Topology::AddIpv4RawCsmaNode(Ptr<Node> n1,
Ptr<CsmaChannel> ch,
Mac48Address addr)
{
Ptr<Queue> q = CreateObject<DropTailQueue> ();
Ptr<CsmaNetDevice> nd0 = CreateObject<CsmaNetDevice> ("Address", addr,
"EncapsulationMode", String ("Raw"));
n1->AddDevice (nd0);
nd0->SetSendEnable (true);
nd0->SetReceiveEnable (false);
nd0->AddQueue(q);
nd0->Attach (ch);
Ptr<CsmaNetDevice> nd1 = CreateObject<CsmaNetDevice> ("Address", addr,
"EncapsulationMode", String ("Raw"));
n1->AddDevice (nd1);
nd1->SetSendEnable (false);
nd1->SetReceiveEnable (true);
nd1->AddQueue(q);
nd1->Attach (ch);
}
uint32_t
CsmaIpv4Topology::AddIpv4Address(
Ptr<Node> node,
uint32_t netDeviceNumber,
const Ipv4Address address,
const Ipv4Mask mask,
uint16_t metric)
{
Ptr<NetDevice> nd = node->GetDevice(netDeviceNumber);
Ptr<Ipv4> ipv4 = node->GetObject<Ipv4> ();
uint32_t ifIndex = ipv4->AddInterface (nd);
ipv4->SetAddress (ifIndex, address);
ipv4->SetNetworkMask (ifIndex, mask);
ipv4->SetMetric (ifIndex, metric);
ipv4->SetUp (ifIndex);
return ifIndex;
}
void
CsmaIpv4Topology::AddIpv4Routes (
Ptr<NetDevice> nd1, Ptr<NetDevice> nd2)
{
// Assert that both are Ipv4 nodes
Ptr<Ipv4> ip1 = nd1->GetNode ()->GetObject<Ipv4> ();
Ptr<Ipv4> ip2 = nd2->GetNode ()->GetObject<Ipv4> ();
NS_ASSERT(ip1 != 0 && ip2 != 0);
// Get interface indexes for both nodes corresponding to the right channel
uint32_t index1 = 0;
bool found = false;
for (uint32_t i = 0; i < ip1->GetNInterfaces (); i++)
{
if (ip1 ->GetNetDevice (i) == nd1)
{
index1 = i;
found = true;
}
}
NS_ASSERT (found);
uint32_t index2 = 0;
found = false;
for (uint32_t i = 0; i < ip2->GetNInterfaces (); i++)
{
if (ip2 ->GetNetDevice (i) == nd2)
{
index2 = i;
found = true;
}
}
NS_ASSERT (found);
ip1->AddHostRouteTo (ip2-> GetAddress (index2), index1);
ip2->AddHostRouteTo (ip1-> GetAddress (index1), index2);
}
} // namespace ns3

View File

@@ -1,129 +0,0 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
//
// Copyright (c) 2007 Emmanuelle Laprise
//
// 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: Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
//
#ifndef __CSMA_IPV4_TOPOLOGY_H__
#define __CSMA_IPV4_TOPOLOGY_H__
#include "ns3/ptr.h"
#include "ns3/ipv4-address.h"
#include "ns3/ipv4.h"
#include "ns3/ipv4-route.h"
#include "ns3/internet-node.h"
#include "ns3/csma-net-device.h"
// The topology class consists of only static methods thar are used to
// create the topology and data flows for an ns3 simulation
namespace ns3 {
class CsmaIpv4Channel;
class Node;
class IPAddr;
class DataRate;
class Queue;
/**
* \brief A helper class to create Topologies based on the
* InternetNodes and CsmaChannels. Either the
* SimpleCsmaNetDevice or the LLCCsmaNetDevice can be used
* when constructing these topologies.
*/
class CsmaIpv4Topology {
public:
/**
* \param node Node to be attached to the Csma channel
* \param channel CsmaChannel to which node n1 should be attached
* \param addr Mac address of the node
*
* Add a Csma node to a Csma channel. This function adds
* a EthernetCsmaNetDevice to the nodes so that they can
* connect to a CsmaChannel. This means that Ethernet headers
* and trailers will be added to the packet before sending out on
* the net device.
*
* \return ifIndex of the device
*/
static uint32_t AddIpv4CsmaNetDevice(Ptr<Node> node,
Ptr<CsmaChannel> channel,
Mac48Address addr);
/**
* \param n1 Node to be attached to the Csma channel
* \param ch CsmaChannel to which node n1 should be attached
* \param addr Mac address of the node
*
* Add a Csma node to a Csma channel. This function adds
* a RawCsmaNetDevice to the nodes so that they can connect
* to a CsmaChannel.
*/
static void AddIpv4RawCsmaNode( Ptr<Node> n1,
Ptr<CsmaChannel> ch,
Mac48Address addr);
/**
* \param n1 Node to be attached to the Csma channel
* \param ch CsmaChannel to which node n1 should be attached
* \param addr Mac address of the node
*
* Add a Csma node to a Csma channel. This function adds
* a LlcCsmaNetDevice to the nodes so that they can connect
* to a CsmaChannel.
*/
static void AddIpv4LlcCsmaNode( Ptr<Node> n1,
Ptr<CsmaChannel> ch,
Mac48Address addr);
/**
* \brief Create an Ipv4 interface for a net device and assign an
* Ipv4Address to that interface.
*
* \param node The node to which to add the new address and corresponding
* interface.
* \param netDeviceNumber The NetDevice index number with which to associate
* the address.
* \param address The Ipv4 Address for the interface.
* \param mask The network mask for the interface
* \param metric (optional) metric (cost) to assign for routing calculations
*
* Add an Ipv4Address to the Ipv4 interface associated with the
* ndNum CsmaIpv4NetDevices on the provided CsmaIpv4Channel
*/
static uint32_t AddIpv4Address(Ptr<Node> node,
uint32_t netDeviceNumber,
const Ipv4Address address,
const Ipv4Mask mask,
uint16_t metric = 1);
/**
* \param nd1 Node
* \param nd2 Node
*
* Add an IPV4 host route between the two specified net devices
*/
static void AddIpv4Routes (Ptr<NetDevice> nd1, Ptr<NetDevice> nd2);
};
} // namespace ns3
#endif

View File

@@ -1,102 +0,0 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
//
// Copyright (c) 2007 Emmanuelle Laprise
//
// 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: Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
//
//
// Topology helper for Csma channels in ns3.
#include "ns3/assert.h"
#include "ns3/queue.h"
#include "csma-channel.h"
#include "csma-net-device.h"
#include "csma-topology.h"
#include "ns3/socket-factory.h"
namespace ns3 {
Ptr<CsmaChannel>
CsmaTopology::CreateCsmaChannel(
const DataRate& bps,
const Time& delay)
{
Ptr<CsmaChannel> channel = CreateObject<CsmaChannel> ("BitRate", bps, "Delay", delay);
return channel;
}
#if 0
Ptr<CsmaNetDevice>
CsmaTopology::AddCsmaEthernetNode(
Ptr<Node> n1,
Ptr<CsmaChannel> ch,
Mac48Address addr)
{
Ptr<CsmaNetDevice> nd1 = CreateObject<CsmaNetDevice> ("Address", addr,
"EncapsulationMode", "EthernetV1");
Ptr<Queue> q = Queue::CreateDefault ();
nd1->AddQueue(q);
nd1->Attach (ch);
return nd1;
}
Ptr<PacketSocket>
CsmaTopology::ConnectPacketSocket(Ptr<PacketSocketApp> app,
Ptr<CsmaNetDevice> ndSrc,
Ptr<CsmaNetDevice> ndDest)
{
Ptr<PacketSocket> socket = CreateObject<PacketSocket> ();
socket->Bind(ndSrc);
socket->Connect(ndDest->GetAddress());
app->Connect(socket);
return socket;
}
Ptr<PacketSocket>
CsmaTopology::ConnectPacketSocket(Ptr<PacketSocketApp> app,
Ptr<CsmaNetDevice> ndSrc,
MacAddress macAddr)
{
Ptr<PacketSocket> socket = CreateObject<PacketSocket> ();
socket->Bind(ndSrc);
socket->Connect(macAddr);
app->Connect(socket);
return socket;
}
Ptr<Socket>
CsmaTopology::CreatePacketSocket(Ptr<Node> n1, std::string tid_name)
{
TypeId tid = TypeId::LookupByName (tid_name);
Ptr<SocketFactory> socketFactory =
n1->GetObject<SocketFactory> (tid);
Ptr<Socket> socket = socketFactory->CreateSocket ();
return socket;
}
#endif
} // namespace ns3

View File

@@ -1,123 +0,0 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
//
// Copyright (c) 2007 Emmanuelle Laprise
//
// 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: Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
//
// Topology helper for multipoint channels in ns3.
//
#ifndef CSMA_TOPOLOGY_H
#define CSMA_TOPOLOGY_H
#include "ns3/ptr.h"
#include "ns3/csma-net-device.h"
#include "ns3/node.h"
// The topology class consists of only static methods thar are used to
// create the topology and data flows for an ns3 simulation
namespace ns3 {
class CsmaChannel;
class Node;
class DataRate;
class Queue;
/**
* \brief A helper class to create Csma Topologies
*
* Csma topologies are created based on the
* ns3::CsmaNetDevice subclasses and ns3::CsmaChannel
* objects. This class uses the EthernetNetDevice and
* PacketSocket classes in order to create logical connections between
* net devices. The PacketSocket class generates the data and the
* EthernetNetDevice class creates ethernet packets from the
* data, filling in source and destination addresses. The
* EthernetNetDevice class filters received data packets
* according to its destination Mac addresses.
*/
class CsmaTopology {
public:
/**
* \param dataRate Maximum transmission link rate
* \param delay propagation delay between any two nodes
* \return Pointer to the created CsmaChannel
*
* Create a CsmaChannel. All nodes connected to a multipoint
* channels will receive all packets written to that channel
*/
static Ptr<CsmaChannel> CreateCsmaChannel(
const DataRate& dataRate, const Time& delay);
#if 0
/**
* \param n1 Node to be attached to the multipoint channel
* \param ch CsmaChannel to which node n1 should be attached
* \param addr MacAddress that should be assigned to the
* EthernetNetDevice that will be added to the node.
*
* Add a multipoint node to a multipoint channel
*/
static Ptr<CsmaNetDevice> AddCsmaEthernetNode(Ptr<Node> n1,
Ptr<CsmaChannel> ch,
MacAddress addr);
/**
* \param app Application that will be sending data to the agent
* \param ndSrc Net Device that will be sending the packets onto the
* network
* \param ndDest Net Device to which ndSrc will be sending the packets
* \return A pointer to the PacketSocket
*
* Creates an PacketSocket and configure it to send packets between
* two net devices
*/
static Ptr<PacketSocket> ConnectPacketSocket(Ptr<PacketSocketApp> app,
Ptr<CsmaNetDevice> ndSrc,
Ptr<CsmaNetDevice> ndDest);
/**
* \param app Application that will be sending data to the agent
* \param ndSrc Net Device that will be sending the packets onto the
* network
* \param macAddr Mac destination address for the packets send by
* the ndSrc net device \return a Pointer to the created
* PacketSocket
*
* Creates an PacketSocket and configure it to send packets from a
* net device to a destination MacAddress
*/
static Ptr<PacketSocket> ConnectPacketSocket(Ptr<PacketSocketApp> app,
Ptr<CsmaNetDevice> ndSrc,
MacAddress macAddr);
/**
* \param n1 Node from which socketfactory should be tested.
* \param tid_name Interface identifier ("ns3::PacketSocketFactory", in this case)
*
* This is a test function to make sure that a socket can be created
* by using the socketfactory interface provided in the
* netdevicenode.
*/
static Ptr<Socket> CreatePacketSocket(Ptr<Node> n1,
std::string tid_name);
#endif
};
} // namespace ns3
#endif

View File

@@ -6,8 +6,6 @@ def build(bld):
'backoff.cc',
'csma-net-device.cc',
'csma-channel.cc',
'csma-topology.cc',
'csma-ipv4-topology.cc',
]
headers = bld.create_obj('ns3header')
headers.module = 'csma'
@@ -15,6 +13,4 @@ def build(bld):
'backoff.h',
'csma-net-device.h',
'csma-channel.h',
'csma-topology.h',
'csma-ipv4-topology.h',
]

View File

@@ -1,252 +0,0 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
//
// Copyright (c) 2006 Georgia Tech Research Corporation
//
// 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: George F. Riley<riley@ece.gatech.edu>
//
//
// Topology helper for ns3.
// George F. Riley, Georgia Tech, Spring 2007
#include <algorithm>
#include "ns3/assert.h"
#include "ns3/log.h"
#include "ns3/fatal-error.h"
#include "ns3/nstime.h"
#include "ns3/internet-node.h"
#include "ns3/ipv4-address.h"
#include "ns3/ipv4.h"
#include "ns3/queue.h"
#include "ns3/drop-tail-queue.h"
#include "point-to-point-channel.h"
#include "point-to-point-net-device.h"
#include "point-to-point-topology.h"
namespace ns3 {
Ptr<PointToPointChannel>
PointToPointTopology::AddPointToPointLink(
Ptr<Node> n1,
Ptr<Node> n2,
const DataRate& bps,
const Time& delay)
{
Ptr<PointToPointChannel> channel = CreateObject<PointToPointChannel> ("BitRate", bps, "Delay", delay);
Ptr<PointToPointNetDevice> net1 = CreateObject<PointToPointNetDevice> ("Address", Mac48Address::Allocate ());
n1->AddDevice (net1);
Ptr<Queue> q = CreateObject<DropTailQueue> ();
net1->AddQueue(q);
net1->Attach (channel);
Ptr<PointToPointNetDevice> net2 = CreateObject<PointToPointNetDevice> ("Address", Mac48Address::Allocate ());
n2->AddDevice (net2);
q = CreateObject<DropTailQueue> ();
net2->AddQueue(q);
net2->Attach (channel);
return channel;
}
Ptr<PointToPointNetDevice>
PointToPointTopology::GetNetDevice (Ptr<Node> n, Ptr<PointToPointChannel> chan)
{
Ptr<PointToPointNetDevice> found = 0;
// The PointToPoint channel is used to find the relevant NetDevice
NS_ASSERT (chan->GetNDevices () == 2);
Ptr<PointToPointNetDevice> nd1 = chan->GetPointToPointDevice (0);
Ptr<PointToPointNetDevice> nd2 = chan->GetPointToPointDevice (1);
if ( nd1->GetNode ()->GetId () == n->GetId () )
{
found = nd1;
}
else if ( nd2->GetNode ()->GetId () == n->GetId () )
{
found = nd2;
}
else
{
NS_ASSERT (found);
}
return found;
}
void
PointToPointTopology::AddIpv4Addresses(
Ptr<const PointToPointChannel> chan,
Ptr<Node> n1, const Ipv4Address& addr1,
Ptr<Node> n2, const Ipv4Address& addr2)
{
// Duplex link is assumed to be subnetted as a /30
// May run this unnumbered in the future?
Ipv4Mask netmask("255.255.255.252");
NS_ASSERT (netmask.IsMatch(addr1,addr2));
// The PointToPoint channel is used to find the relevant NetDevices
NS_ASSERT (chan->GetNDevices () == 2);
Ptr<NetDevice> nd1 = chan->GetDevice (0);
Ptr<NetDevice> nd2 = chan->GetDevice (1);
// Make sure that nd1 belongs to n1 and nd2 to n2
if ( (nd1->GetNode ()->GetId () == n2->GetId () ) &&
(nd2->GetNode ()->GetId () == n1->GetId () ) )
{
std::swap(nd1, nd2);
}
NS_ASSERT (nd1->GetNode ()->GetId () == n1->GetId ());
NS_ASSERT (nd2->GetNode ()->GetId () == n2->GetId ());
Ptr<Ipv4> ip1 = n1->GetObject<Ipv4> ();
uint32_t index1 = ip1->AddInterface (nd1);
ip1->SetAddress (index1, addr1);
ip1->SetNetworkMask (index1, netmask);
ip1->SetUp (index1);
Ptr<Ipv4> ip2 = n2->GetObject<Ipv4> ();
uint32_t index2 = ip2->AddInterface (nd2);
ip2->SetAddress (index2, addr2);
ip2->SetNetworkMask (index2, netmask);
ip2->SetUp (index2);
}
void
PointToPointTopology::SetIpv4Metric(
Ptr<const PointToPointChannel> chan,
Ptr<Node> n1, Ptr<Node> n2, uint16_t metric)
{
// The PointToPoint channel is used to find the relevant NetDevices
NS_ASSERT (chan->GetNDevices () == 2);
Ptr<NetDevice> nd1 = chan->GetDevice (0);
Ptr<NetDevice> nd2 = chan->GetDevice (1);
// Make sure that nd1 belongs to n1 and nd2 to n2
if ( (nd1->GetNode ()->GetId () == n2->GetId () ) &&
(nd2->GetNode ()->GetId () == n1->GetId () ) )
{
std::swap(nd1, nd2);
}
NS_ASSERT (nd1->GetNode ()->GetId () == n1->GetId ());
NS_ASSERT (nd2->GetNode ()->GetId () == n2->GetId ());
// The NetDevice ifIndex does not correspond to the
// ifIndex used by Ipv4. Therefore, we have to iterate
// through the NetDevices until we find the Ipv4 ifIndex
// that corresponds to NetDevice nd1
// Get interface indexes for both nodes corresponding to the right channel
uint32_t index = 0;
bool found = false;
Ptr<Ipv4> ip1 = n1->GetObject<Ipv4> ();
for (uint32_t i = 0; i < ip1->GetNInterfaces (); i++)
{
if (ip1 ->GetNetDevice (i) == nd1)
{
index = i;
found = true;
}
}
NS_ASSERT(found);
ip1->SetMetric (index, metric);
index = 0;
found = false;
Ptr<Ipv4> ip2 = n2->GetObject<Ipv4> ();
for (uint32_t i = 0; i < ip2->GetNInterfaces (); i++)
{
if (ip2 ->GetNetDevice (i) == nd2)
{
index = i;
found = true;
}
}
NS_ASSERT(found);
ip2->SetMetric (index, metric);
}
void
PointToPointTopology::AddIpv4Routes (
Ptr<Node> n1, Ptr<Node> n2, Ptr<const PointToPointChannel> chan)
{
// The PointToPoint channel is used to find the relevant NetDevices
NS_ASSERT (chan->GetNDevices () == 2);
Ptr<NetDevice> nd1 = chan->GetDevice (0);
Ptr<NetDevice> nd2 = chan->GetDevice (1);
// Assert that n1 is the Node owning one of the two NetDevices
// and make sure that nd1 corresponds to it
if (nd1->GetNode ()->GetId () == n1->GetId ())
{
; // Do nothing
}
else if (nd2->GetNode ()->GetId () == n1->GetId ())
{
std::swap(nd1, nd2);
}
else
{
NS_FATAL_ERROR("P2PTopo: Node does not contain an interface on Channel");
}
// Assert that n2 is the Node owning one of the two NetDevices
// and make sure that nd2 corresponds to it
if (nd2->GetNode ()->GetId () != n2->GetId ())
{
NS_FATAL_ERROR("P2PTopo: Node does not contain an interface on Channel");
}
// Assert that both are Ipv4 nodes
Ptr<Ipv4> ip1 = nd1->GetNode ()->GetObject<Ipv4> ();
Ptr<Ipv4> ip2 = nd2->GetNode ()->GetObject<Ipv4> ();
NS_ASSERT(ip1 != 0 && ip2 != 0);
// Get interface indexes for both nodes corresponding to the right channel
uint32_t index1 = 0;
bool found = false;
for (uint32_t i = 0; i < ip1->GetNInterfaces (); i++)
{
if (ip1 ->GetNetDevice (i) == nd1)
{
index1 = i;
found = true;
}
}
NS_ASSERT(found);
uint32_t index2 = 0;
found = false;
for (uint32_t i = 0; i < ip2->GetNInterfaces (); i++)
{
if (ip2 ->GetNetDevice (i) == nd2)
{
index2 = i;
found = true;
}
}
NS_ASSERT(found);
ip1->AddHostRouteTo (ip2-> GetAddress (index2), index1);
ip2->AddHostRouteTo (ip1-> GetAddress (index1), index2);
}
} // namespace ns3

View File

@@ -1,112 +0,0 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
//
// Copyright (c) 2006 Georgia Tech Research Corporation
//
// 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: George F. Riley<riley@ece.gatech.edu>
//
// Topology helper for ns3.
// George F. Riley, Georgia Tech, Spring 2007
#ifndef __POINT_TO_POINT_TOPOLOGY_H__
#define __POINT_TO_POINT_TOPOLOGY_H__
#include "ns3/ptr.h"
// The topology class consists of only static methods thar are used to
// create the topology and data flows for an ns3 simulation
namespace ns3 {
class PointToPointChannel;
class Node;
class IPAddr;
class DataRate;
class Queue;
/**
* \brief A helper class to create Topologies based on the
* ns3::PointToPointNetDevice and ns3::PointToPointChannel objects.
*/
class PointToPointTopology {
public:
/**
* \param n1 Node
* \param n2 Node
* \param dataRate Maximum transmission link rate
* \param delay one-way propagation delay
* \return Pointer to the underlying PointToPointChannel
*
* Add a full-duplex point-to-point link between two nodes
* and attach PointToPointNetDevices to the resulting
* PointToPointChannel.
*/
static Ptr<PointToPointChannel> AddPointToPointLink(
Ptr<Node> n1, Ptr<Node> n2, const DataRate& dataRate, const Time& delay);
/**
* \param n Node
* \param chan PointToPointChannel connected to node n
* \return Pointer to the corresponding PointToPointNetDevice
*
* Utility function to retrieve a PointToPointNetDevice pointer
* corresponding to the input parameters
*/
static Ptr<PointToPointNetDevice> GetNetDevice(
Ptr<Node> n, Ptr<PointToPointChannel> chan);
/**
* \param chan PointToPointChannel to use
* \param n1 Node
* \param addr1 Ipv4 Address for n1
* \param n2 Node
* \param addr2 Ipv4 Address for n2
*
* Add Ipv4Addresses to the Ipv4 interfaces associated with the
* two PointToPointNetDevices on the provided PointToPointChannel
*/
static void AddIpv4Addresses(
Ptr<const PointToPointChannel> chan,
Ptr<Node> n1, const Ipv4Address& addr1,
Ptr<Node> n2, const Ipv4Address& addr2);
/**
* \param chan PointToPointChannel to use
* \param n1 Node
* \param n2 Node
* \param metric link metric to assign on Ipv4Link on chan between n1 and n2
*
* Add a non-unit-cost link metric (bidirectionally) to the Ipv4
* interfaces associated with the two PointToPointNetDevices on the
* provided PointToPointChannel
*/
static void SetIpv4Metric(
Ptr<const PointToPointChannel> chan,
Ptr<Node> n1, Ptr<Node> n2, uint16_t metric);
/**
* \param channel PointToPointChannel to use
* \param n1 Node
* \param n2 Node
*
* For the given PointToPointChannel, for each Node, add an
* IPv4 host route to the IPv4 address of the peer node.
*/
static void AddIpv4Routes (Ptr<Node> n1, Ptr<Node> n2, Ptr<const PointToPointChannel> channel);
};
} // namespace ns3
#endif

View File

@@ -6,7 +6,6 @@ def build(bld):
module.source = [
'point-to-point-net-device.cc',
'point-to-point-channel.cc',
'point-to-point-topology.cc',
'point-to-point-test.cc',
]
headers = bld.create_obj('ns3header')
@@ -14,6 +13,5 @@ def build(bld):
headers.source = [
'point-to-point-net-device.h',
'point-to-point-channel.h',
'point-to-point-topology.h',
]

View File

@@ -1,38 +0,0 @@
// -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*-
//
// Copyright (c) 2006 Georgia Tech Research Corporation
// All rights reserved.
//
// 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: George F. Riley<riley@ece.gatech.edu>
//
// Implementation of the InternetNode class for ns3.
// George F. Riley, Georgia Tech, Fall 2006
#include "ns3/net-device.h"
#include "ns3/callback.h"
#include "internet-node.h"
#include "internet-stack.h"
namespace ns3 {
InternetNode::InternetNode()
{
AddInternetStack (this);
}
}//namespace ns3

View File

@@ -1,65 +0,0 @@
// -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*-
//
// Copyright (c) 2006 Georgia Tech Research Corporation
// All rights reserved.
//
// 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: George F. Riley<riley@ece.gatech.edu>
//
// Define a basic "Internet" node, with a protocol stack (l3 and l4),
// network device list, process list, and routing.
#ifndef INTERNET_NODE_H
#define INTERNET_NODE_H
#include <list>
#include <string>
#include "ns3/node.h"
namespace ns3 {
/**
* \ingroup internetNode
*
* \section InternetNode Overview
*
* The InternetNode module contains an implementation of TCP, UDP, and
* IPv4. ns-3 Applications sit above this module, and ns-3 NetDevices
* sit below it...
*
* InternetNode is implemented as a subclass of Node but this may be
* refactored in the future to
*/
/*
* \brief Container class for various TCP/IP objects and interfaces
* aggregated to a Node.
*
* This class exists primarily to assemble the layer-3/4 stack of a Node
* from constituent parts, including implementations of TCP, IPv4, UDP,
* and ARP. It provides only constructors and destructors as its public
* API. Internally, the various protocols are instantiated, aggregated
* to a Node, and plumbed together.
*/
class InternetNode : public Node
{
public:
InternetNode();
};
}//namespace ns3
#endif /* INTERNET_NODE_H */

View File

@@ -4,7 +4,6 @@
def build(bld):
obj = bld.create_ns3_module('internet-node', ['node'])
obj.source = [
'internet-node.cc',
'internet-stack.cc',
'ipv4-l4-demux.cc',
'ipv4-l4-protocol.cc',
@@ -39,7 +38,6 @@ def build(bld):
headers = bld.create_obj('ns3header')
headers.module = 'internet-node'
headers.source = [
'internet-node.h',
'internet-stack.h',
'ascii-trace.h',
'pcap-trace.h',