merge
This commit is contained in:
20
examples/topology-read/Inet_small_toposample.txt
Normal file
20
examples/topology-read/Inet_small_toposample.txt
Normal file
@@ -0,0 +1,20 @@
|
||||
10 9
|
||||
0 5625 2473
|
||||
1 4505 4098
|
||||
2 9866 2148
|
||||
3 8315 7088
|
||||
4 8564 5989
|
||||
5 2064 510
|
||||
6 2942 2145
|
||||
7 2646 9895
|
||||
8 5051 3220
|
||||
9 6715 6729
|
||||
0 1 1973
|
||||
0 2 4253
|
||||
0 3 5341
|
||||
0 5 4066
|
||||
0 6 2702
|
||||
0 9 4393
|
||||
1 8 1033
|
||||
2 7 10589
|
||||
3 4 1126
|
||||
7826
examples/topology-read/Inet_toposample.txt
Normal file
7826
examples/topology-read/Inet_toposample.txt
Normal file
File diff suppressed because it is too large
Load Diff
2769
examples/topology-read/Orbis_toposample.txt
Normal file
2769
examples/topology-read/Orbis_toposample.txt
Normal file
File diff suppressed because it is too large
Load Diff
208
examples/topology-read/topology-example-sim.cc
Normal file
208
examples/topology-read/topology-example-sim.cc
Normal file
@@ -0,0 +1,208 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation;
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* Author: Tommaso Pecorella <tommaso.pecorella@unifi.it>
|
||||
* Author: Valerio Sartini <valesar@gmail.com>
|
||||
*
|
||||
* This program conducts a simple experiment: It builds up a topology based on
|
||||
* either Inet or Orbis trace files. A random node is then chosen, and all the
|
||||
* other nodes will send a packet to it. The TTL is measured and reported as an histogram.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <ctime>
|
||||
|
||||
#include <sstream>
|
||||
|
||||
#include "ns3/core-module.h"
|
||||
#include "ns3/common-module.h"
|
||||
#include "ns3/node-module.h"
|
||||
#include "ns3/helper-module.h"
|
||||
#include "ns3/simulator-module.h"
|
||||
|
||||
#include "ns3/topology-read-module.h"
|
||||
#include <list>
|
||||
|
||||
using namespace ns3;
|
||||
using namespace std;
|
||||
|
||||
NS_LOG_COMPONENT_DEFINE ("TopologyCreationExperiment");
|
||||
|
||||
|
||||
static list<unsigned int> data;
|
||||
|
||||
static void SinkRx (Ptr<const Packet> p, const Address &ad)
|
||||
{
|
||||
Ipv4Header ipv4;
|
||||
p->PeekHeader (ipv4);
|
||||
std::cout << "TTL: " << (unsigned)ipv4.GetTtl () << std::endl;
|
||||
}
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// -- main
|
||||
// ----------------------------------------------
|
||||
int main (int argc, char *argv[])
|
||||
{
|
||||
|
||||
string format ("Inet");
|
||||
string input ("examples/topology-read/Inet_small_toposample.txt");
|
||||
|
||||
// Set up command line parameters used to control the experiment.
|
||||
CommandLine cmd;
|
||||
cmd.AddValue ("format", "Format to use for data input [Orbis|Inet].",
|
||||
format);
|
||||
cmd.AddValue ("input", "Name of the input file.",
|
||||
input);
|
||||
cmd.Parse (argc, argv);
|
||||
|
||||
|
||||
// ------------------------------------------------------------
|
||||
// -- Read topology data.
|
||||
// --------------------------------------------
|
||||
|
||||
// Pick a topology reader based in the requested format.
|
||||
|
||||
Ptr<TopologyReader> inFile = 0;
|
||||
TopologyReaderHelper topoHelp;
|
||||
|
||||
NodeContainer nodes;
|
||||
|
||||
topoHelp.SetFileName(input);
|
||||
topoHelp.SetFileType(format);
|
||||
inFile = topoHelp.GetTopologyReader();
|
||||
|
||||
if (inFile != 0)
|
||||
{
|
||||
nodes = inFile->Read ();
|
||||
}
|
||||
|
||||
if (inFile->LinksSize () == 0)
|
||||
{
|
||||
NS_LOG_ERROR ("Problems reading the topology file. Failing.");
|
||||
return -1;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------
|
||||
// -- Create nodes and network stacks
|
||||
// --------------------------------------------
|
||||
NS_LOG_INFO ("creating internet stack");
|
||||
InternetStackHelper stack;
|
||||
|
||||
// Setup NixVector Routing
|
||||
Ipv4NixVectorHelper nixRouting;
|
||||
Ipv4StaticRoutingHelper staticRouting;
|
||||
|
||||
Ipv4ListRoutingHelper listRH;
|
||||
listRH.Add (staticRouting, 0);
|
||||
listRH.Add (nixRouting, 10);
|
||||
|
||||
stack.SetRoutingHelper (listRH);
|
||||
stack.Install (nodes);
|
||||
|
||||
NS_LOG_INFO ("creating ip4 addresses");
|
||||
Ipv4AddressHelper address;
|
||||
address.SetBase ("10.0.0.0", "255.255.255.252");
|
||||
|
||||
int totlinks = inFile->LinksSize ();
|
||||
|
||||
NS_LOG_INFO ("creating node containers");
|
||||
NodeContainer nc[totlinks];
|
||||
TopologyReader::ConstLinksIterator iter;
|
||||
int i = 0;
|
||||
for ( iter = inFile->LinksBegin (); iter != inFile->LinksEnd (); iter++, i++ )
|
||||
{
|
||||
nc[i] = NodeContainer (iter->GetFromNode (), iter->GetToNode ());
|
||||
}
|
||||
|
||||
NS_LOG_INFO ("creating net device containers");
|
||||
NetDeviceContainer ndc[totlinks];
|
||||
PointToPointHelper p2p;
|
||||
for (int i = 0; i < totlinks; i++)
|
||||
{
|
||||
// p2p.SetChannelAttribute ("Delay", TimeValue(MilliSeconds(weight[i])));
|
||||
p2p.SetChannelAttribute ("Delay", StringValue ("2ms"));
|
||||
p2p.SetDeviceAttribute ("DataRate", StringValue ("5Mbps"));
|
||||
ndc[i] = p2p.Install (nc[i]);
|
||||
}
|
||||
|
||||
// it crates little subnets, one for each couple of nodes.
|
||||
NS_LOG_INFO ("creating ipv4 interfaces");
|
||||
Ipv4InterfaceContainer ipic[totlinks];
|
||||
for (int i = 0; i < totlinks; i++)
|
||||
{
|
||||
ipic[i] = address.Assign (ndc[i]);
|
||||
address.NewNetwork ();
|
||||
}
|
||||
|
||||
|
||||
uint32_t totalNodes = nodes.GetN ();
|
||||
UniformVariable unifRandom (0, totalNodes - 1);
|
||||
|
||||
unsigned int randomServerNumber = unifRandom.GetInteger (0, totalNodes - 1);
|
||||
|
||||
Ptr<Node> randomServerNode = nodes.Get (randomServerNumber);
|
||||
Ptr<Ipv4> ipv4Server = randomServerNode->GetObject<Ipv4> ();
|
||||
Ipv4InterfaceAddress iaddrServer = ipv4Server->GetAddress (1,0);
|
||||
Ipv4Address ipv4AddrServer = iaddrServer.GetLocal ();
|
||||
|
||||
// ------------------------------------------------------------
|
||||
// -- Send around packets to check the ttl
|
||||
// --------------------------------------------
|
||||
Config::SetDefault ("ns3::Ipv4RawSocketImpl::Protocol", StringValue ("2"));
|
||||
InetSocketAddress dst = InetSocketAddress ( ipv4AddrServer );
|
||||
|
||||
OnOffHelper onoff = OnOffHelper ("ns3::Ipv4RawSocketFactory", dst);
|
||||
onoff.SetAttribute ("OnTime", RandomVariableValue (ConstantVariable (1.0)));
|
||||
onoff.SetAttribute ("OffTime", RandomVariableValue (ConstantVariable (0.0)));
|
||||
onoff.SetAttribute ("DataRate", DataRateValue (DataRate (15000)));
|
||||
onoff.SetAttribute ("PacketSize", UintegerValue (1200));
|
||||
|
||||
NodeContainer clientNodes;
|
||||
for ( unsigned int i = 0; i < nodes.GetN (); i++ )
|
||||
{
|
||||
if (i != randomServerNumber )
|
||||
{
|
||||
Ptr<Node> clientNode = nodes.Get (i);
|
||||
clientNodes.Add (clientNode);
|
||||
}
|
||||
}
|
||||
|
||||
ApplicationContainer apps = onoff.Install (clientNodes);
|
||||
apps.Start (Seconds (1.0));
|
||||
apps.Stop (Seconds (2.0));
|
||||
|
||||
PacketSinkHelper sink = PacketSinkHelper ("ns3::Ipv4RawSocketFactory", dst);
|
||||
apps = sink.Install (randomServerNode);
|
||||
apps.Start (Seconds (0.0));
|
||||
apps.Stop (Seconds (3.0));
|
||||
|
||||
// we trap the packet sink receiver to extract the TTL.
|
||||
Config::ConnectWithoutContext ("/NodeList/*/ApplicationList/*/$ns3::PacketSink/Rx",
|
||||
MakeCallback (&SinkRx));
|
||||
|
||||
// ------------------------------------------------------------
|
||||
// -- Run the simulation
|
||||
// --------------------------------------------
|
||||
NS_LOG_INFO ("Run Simulation.");
|
||||
Simulator::Run ();
|
||||
Simulator::Destroy ();
|
||||
|
||||
NS_LOG_INFO ("Done.");
|
||||
|
||||
return 0;
|
||||
|
||||
// end main
|
||||
}
|
||||
1
examples/topology-read/waf
vendored
Normal file
1
examples/topology-read/waf
vendored
Normal file
@@ -0,0 +1 @@
|
||||
exec "`dirname "$0"`"/../../waf "$@"
|
||||
5
examples/topology-read/wscript
Normal file
5
examples/topology-read/wscript
Normal file
@@ -0,0 +1,5 @@
|
||||
## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
|
||||
|
||||
def build(bld):
|
||||
obj = bld.create_ns3_program('topology-read', ['topology-read', 'internet-stack'])
|
||||
obj.source = 'topology-example-sim.cc'
|
||||
@@ -74,11 +74,6 @@ public:
|
||||
void SetLambda (double frequency, double speed);
|
||||
double GetShadowing (void);
|
||||
void SetShadowing (double shadowing);
|
||||
/**
|
||||
* \param d the distnace between the sender and the receiver
|
||||
* \returns the bulk path loss
|
||||
*/
|
||||
double cost231_formula (double d); // the formula that calculates the bulk path loss
|
||||
private:
|
||||
virtual double DoCalcRxPower (double txPowerDbm, Ptr<MobilityModel> a, Ptr<MobilityModel> b) const;
|
||||
double m_BSAntennaHeight; // in meter
|
||||
|
||||
140
src/contrib/topology-read/inet-topology-reader.cc
Normal file
140
src/contrib/topology-read/inet-topology-reader.cc
Normal file
@@ -0,0 +1,140 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2010 Universita' di Firenze, Italy
|
||||
*
|
||||
* 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)
|
||||
* Author: Valerio Sartini (Valesar@gmail.com)
|
||||
*/
|
||||
|
||||
#include <fstream>
|
||||
#include <cstdlib>
|
||||
#include <sstream>
|
||||
|
||||
#include "ns3/log.h"
|
||||
#include "inet-topology-reader.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
NS_LOG_COMPONENT_DEFINE ("InetTopologyReader");
|
||||
|
||||
NS_OBJECT_ENSURE_REGISTERED (InetTopologyReader);
|
||||
|
||||
TypeId InetTopologyReader::GetTypeId (void)
|
||||
{
|
||||
static TypeId tid = TypeId ("ns3::InetTopologyReader")
|
||||
.SetParent<Object> ()
|
||||
;
|
||||
return tid;
|
||||
}
|
||||
|
||||
InetTopologyReader::InetTopologyReader ()
|
||||
{
|
||||
NS_LOG_FUNCTION (this);
|
||||
}
|
||||
|
||||
InetTopologyReader::~InetTopologyReader ()
|
||||
{
|
||||
NS_LOG_FUNCTION (this);
|
||||
}
|
||||
|
||||
NodeContainer
|
||||
InetTopologyReader::Read (void)
|
||||
{
|
||||
ifstream topgen;
|
||||
topgen.open (GetFileName ().c_str ());
|
||||
map<string, Ptr<Node> > nodeMap;
|
||||
NodeContainer nodes;
|
||||
|
||||
if ( !topgen.is_open () )
|
||||
{
|
||||
return nodes;
|
||||
}
|
||||
|
||||
string from;
|
||||
string to;
|
||||
string linkAttr;
|
||||
|
||||
int linksNumber = 0;
|
||||
int nodesNumber = 0;
|
||||
|
||||
int totnode = 0;
|
||||
int totlink = 0;
|
||||
|
||||
istringstream lineBuffer;
|
||||
string line;
|
||||
|
||||
getline (topgen,line);
|
||||
lineBuffer.str (line);
|
||||
|
||||
lineBuffer >> totnode;
|
||||
lineBuffer >> totlink;
|
||||
NS_LOG_INFO ("Inet topology should have " << totnode << " nodes and " << totlink << " links");
|
||||
|
||||
for (int i = 0; i <= totnode; i++)
|
||||
{
|
||||
getline (topgen,line);
|
||||
}
|
||||
|
||||
for (int i = 0; i < totlink && !topgen.eof (); i++)
|
||||
{
|
||||
getline (topgen,line);
|
||||
lineBuffer.clear ();
|
||||
lineBuffer.str (line);
|
||||
|
||||
lineBuffer >> from;
|
||||
lineBuffer >> to;
|
||||
lineBuffer >> linkAttr;
|
||||
|
||||
if ( (!from.empty ()) && (!to.empty ()) )
|
||||
{
|
||||
NS_LOG_INFO ( linksNumber << " From: " << from << " to: " << to );
|
||||
|
||||
if ( nodeMap[from] == 0 )
|
||||
{
|
||||
Ptr<Node> tmpNode = CreateObject<Node> ();
|
||||
nodeMap[from] = tmpNode;
|
||||
nodes.Add (tmpNode);
|
||||
nodesNumber++;
|
||||
}
|
||||
|
||||
if (nodeMap[to] == 0)
|
||||
{
|
||||
Ptr<Node> tmpNode = CreateObject<Node> ();
|
||||
nodeMap[to] = tmpNode;
|
||||
nodes.Add (tmpNode);
|
||||
nodesNumber++;
|
||||
}
|
||||
|
||||
Link link ( nodeMap[from], from, nodeMap[to], to );
|
||||
if ( !linkAttr.empty () )
|
||||
{
|
||||
link.SetAttribute ("Weight", linkAttr);
|
||||
}
|
||||
AddLink (link);
|
||||
|
||||
linksNumber++;
|
||||
}
|
||||
}
|
||||
|
||||
NS_LOG_INFO ("Inet topology created with " << nodesNumber << " nodes and " << linksNumber << " links");
|
||||
topgen.close ();
|
||||
|
||||
return nodes;
|
||||
}
|
||||
|
||||
} /* namespace ns3 */
|
||||
76
src/contrib/topology-read/inet-topology-reader.h
Normal file
76
src/contrib/topology-read/inet-topology-reader.h
Normal file
@@ -0,0 +1,76 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2010 Universita' di Firenze, Italy
|
||||
*
|
||||
* 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)
|
||||
* Author: Valerio Sartini (valesar@gmail.com)
|
||||
*/
|
||||
|
||||
#ifndef __INET_TOPOLOGY_READER_H__
|
||||
#define __INET_TOPOLOGY_READER_H__
|
||||
|
||||
#include "ns3/nstime.h"
|
||||
|
||||
#include "topology-reader.h"
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
|
||||
// ------------------------------------------------------------
|
||||
// --------------------------------------------
|
||||
/**
|
||||
* \ingroup topology
|
||||
* \brief Topology file reader (Inet-format type).
|
||||
*
|
||||
* This class takes an input file in Inet format and extracts all
|
||||
* the informations needed to build the topology
|
||||
* (i.e.number of nodes, links and links structure).
|
||||
* It have been tested with Inet 3.0
|
||||
* http://topology.eecs.umich.edu/inet/
|
||||
*
|
||||
* It might set a link attribute named "Weight", corresponding to
|
||||
* the euclidean distance between two nodes, the nodes being randomly positioned.
|
||||
*/
|
||||
class InetTopologyReader : public TopologyReader
|
||||
{
|
||||
public:
|
||||
static TypeId GetTypeId (void);
|
||||
|
||||
InetTopologyReader ();
|
||||
virtual ~InetTopologyReader ();
|
||||
|
||||
/**
|
||||
* \brief Main topology reading function.
|
||||
*
|
||||
* This method opens an input stream and reads the Inet-format file.
|
||||
* From the first line it takes the total number of nodes and links.
|
||||
* Then discards a number of rows equals to total nodes (containing
|
||||
* useless geographical informations).
|
||||
* Then reads until the end of the file (total links number rows) and saves
|
||||
* the structure of every single link in the topology.
|
||||
*
|
||||
* \return the container of the nodes created (or empty container if there was an error)
|
||||
*/
|
||||
virtual NodeContainer Read (void);
|
||||
|
||||
// end class InetTopologyReader
|
||||
};
|
||||
|
||||
// end namespace ns3
|
||||
};
|
||||
|
||||
|
||||
#endif // __INET_TOPOLOGY_READER_H__
|
||||
121
src/contrib/topology-read/orbis-topology-reader.cc
Normal file
121
src/contrib/topology-read/orbis-topology-reader.cc
Normal file
@@ -0,0 +1,121 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2010 Universita' di Firenze, Italy
|
||||
*
|
||||
* 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)
|
||||
* Author: Valerio Sartini (valesar@gmail.com)
|
||||
*/
|
||||
|
||||
#include <fstream>
|
||||
#include <cstdlib>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
|
||||
#include "ns3/log.h"
|
||||
#include "orbis-topology-reader.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
NS_LOG_COMPONENT_DEFINE ("OrbisTopologyReader");
|
||||
|
||||
NS_OBJECT_ENSURE_REGISTERED (OrbisTopologyReader);
|
||||
|
||||
TypeId OrbisTopologyReader::GetTypeId (void)
|
||||
{
|
||||
static TypeId tid = TypeId ("ns3::OrbisTopologyReader")
|
||||
.SetParent<Object> ()
|
||||
;
|
||||
return tid;
|
||||
}
|
||||
|
||||
OrbisTopologyReader::OrbisTopologyReader ()
|
||||
{
|
||||
NS_LOG_FUNCTION (this);
|
||||
}
|
||||
|
||||
OrbisTopologyReader::~OrbisTopologyReader ()
|
||||
{
|
||||
NS_LOG_FUNCTION (this);
|
||||
}
|
||||
|
||||
NodeContainer
|
||||
OrbisTopologyReader::Read (void)
|
||||
{
|
||||
ifstream topgen;
|
||||
topgen.open (GetFileName ().c_str ());
|
||||
map<string, Ptr<Node> > nodeMap;
|
||||
NodeContainer nodes;
|
||||
|
||||
if ( !topgen.is_open () )
|
||||
{
|
||||
return nodes;
|
||||
}
|
||||
|
||||
string from;
|
||||
string to;
|
||||
istringstream lineBuffer;
|
||||
string line;
|
||||
|
||||
int linksNumber = 0;
|
||||
int nodesNumber = 0;
|
||||
|
||||
while (!topgen.eof ())
|
||||
{
|
||||
line.clear ();
|
||||
lineBuffer.clear ();
|
||||
from.clear ();
|
||||
to.clear ();
|
||||
|
||||
getline (topgen,line);
|
||||
lineBuffer.str (line);
|
||||
lineBuffer >> from;
|
||||
lineBuffer >> to;
|
||||
|
||||
if ( (!from.empty ()) && (!to.empty ()) )
|
||||
{
|
||||
NS_LOG_INFO ( linksNumber << " From: " << from << " to: " << to );
|
||||
if ( nodeMap[from] == 0 )
|
||||
{
|
||||
Ptr<Node> tmpNode = CreateObject<Node> ();
|
||||
nodeMap[from] = tmpNode;
|
||||
nodes.Add (tmpNode);
|
||||
nodesNumber++;
|
||||
}
|
||||
|
||||
if (nodeMap[to] == 0)
|
||||
{
|
||||
Ptr<Node> tmpNode = CreateObject<Node> ();
|
||||
nodeMap[to] = tmpNode;
|
||||
nodes.Add (tmpNode);
|
||||
nodesNumber++;
|
||||
}
|
||||
|
||||
Link link ( nodeMap[from], from, nodeMap[to], to );
|
||||
AddLink (link);
|
||||
|
||||
linksNumber++;
|
||||
}
|
||||
}
|
||||
NS_LOG_INFO ("Orbis topology created with " << nodesNumber << " nodes and " << linksNumber << " links");
|
||||
topgen.close ();
|
||||
|
||||
return nodes;
|
||||
}
|
||||
|
||||
} /* namespace ns3 */
|
||||
|
||||
73
src/contrib/topology-read/orbis-topology-reader.h
Normal file
73
src/contrib/topology-read/orbis-topology-reader.h
Normal file
@@ -0,0 +1,73 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2010 Universita' di Firenze, Italy
|
||||
*
|
||||
* 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)
|
||||
* Author: Valerio Sartini (valesar@gmail.com)
|
||||
*/
|
||||
|
||||
#ifndef __ORBIS_TOPOLOGY_READER_H__
|
||||
#define __ORBIS_TOPOLOGY_READER_H__
|
||||
|
||||
#include "ns3/nstime.h"
|
||||
|
||||
#include "topology-reader.h"
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
|
||||
// ------------------------------------------------------------
|
||||
// --------------------------------------------
|
||||
/**
|
||||
* \ingroup topology
|
||||
* \brief Topology file reader (Orbis-format type).
|
||||
*
|
||||
* This class takes an input file in Orbis format and extracts all
|
||||
* the informations needed to build the topology
|
||||
* (i.e.number of nodes, links and links structure).
|
||||
* It have been tested with Orbis 0.70
|
||||
* http://www.sysnet.ucsd.edu/~pmahadevan/topo_research/topo.html
|
||||
*/
|
||||
class OrbisTopologyReader : public TopologyReader
|
||||
{
|
||||
public:
|
||||
static TypeId GetTypeId (void);
|
||||
|
||||
OrbisTopologyReader ();
|
||||
virtual ~OrbisTopologyReader ();
|
||||
|
||||
/**
|
||||
* \brief Main topology reading function.
|
||||
*
|
||||
* This method opens an input stream and reads the Orbis-format file.
|
||||
* Every row represents a topology link (the ids of a couple of nodes),
|
||||
* so the input file is read line by line to figure out how many links
|
||||
* and nodes are in the topology.
|
||||
*
|
||||
* \return the container of the nodes created (or empty container if there was an error)
|
||||
*/
|
||||
virtual NodeContainer Read (void);
|
||||
|
||||
// end class OrbisTopologyReader
|
||||
};
|
||||
|
||||
// end namespace ns3
|
||||
};
|
||||
|
||||
|
||||
#endif // __ORBIS_TOPOLOGY_READER_H__
|
||||
|
||||
|
||||
169
src/contrib/topology-read/topology-reader.cc
Normal file
169
src/contrib/topology-read/topology-reader.cc
Normal file
@@ -0,0 +1,169 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2010 Universita' di Firenze, Italy
|
||||
*
|
||||
* 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)
|
||||
* Author: Valerio Sartini (valesar@gmail.com)
|
||||
*/
|
||||
|
||||
#include "ns3/log.h"
|
||||
|
||||
#include "topology-reader.h"
|
||||
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
NS_LOG_COMPONENT_DEFINE ("TopologyReader");
|
||||
|
||||
NS_OBJECT_ENSURE_REGISTERED (TopologyReader);
|
||||
|
||||
TypeId TopologyReader::GetTypeId (void)
|
||||
{
|
||||
static TypeId tid = TypeId ("ns3::TopologyReader")
|
||||
.SetParent<Object> ()
|
||||
;
|
||||
return tid;
|
||||
}
|
||||
|
||||
TopologyReader::TopologyReader ()
|
||||
{
|
||||
NS_LOG_FUNCTION (this);
|
||||
}
|
||||
|
||||
TopologyReader::~TopologyReader ()
|
||||
{
|
||||
NS_LOG_FUNCTION (this);
|
||||
}
|
||||
|
||||
void
|
||||
TopologyReader::SetFileName (const std::string fileName)
|
||||
{
|
||||
m_fileName = fileName;
|
||||
}
|
||||
|
||||
std::string
|
||||
TopologyReader::GetFileName () const
|
||||
{
|
||||
return m_fileName;
|
||||
}
|
||||
|
||||
/* Manipulating the address block */
|
||||
|
||||
TopologyReader::ConstLinksIterator
|
||||
TopologyReader::LinksBegin (void) const
|
||||
{
|
||||
return m_linksList.begin ();
|
||||
}
|
||||
|
||||
TopologyReader::ConstLinksIterator
|
||||
TopologyReader::LinksEnd (void) const
|
||||
{
|
||||
return m_linksList.end ();
|
||||
}
|
||||
|
||||
int
|
||||
TopologyReader::LinksSize (void) const
|
||||
{
|
||||
return m_linksList.size ();
|
||||
}
|
||||
|
||||
bool
|
||||
TopologyReader::LinksEmpty (void) const
|
||||
{
|
||||
return m_linksList.empty ();
|
||||
}
|
||||
|
||||
void
|
||||
TopologyReader::AddLink (Link link)
|
||||
{
|
||||
m_linksList.push_back (link);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
TopologyReader::Link::Link ( Ptr<Node> fromPtr, std::string fromName, Ptr<Node> toPtr, std::string toName )
|
||||
{
|
||||
m_fromPtr = fromPtr;
|
||||
m_fromName = fromName;
|
||||
m_toPtr = toPtr;
|
||||
m_toName = toName;
|
||||
}
|
||||
|
||||
TopologyReader::Link::Link ()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
Ptr<Node> TopologyReader::Link::GetFromNode (void) const
|
||||
{
|
||||
return m_fromPtr;
|
||||
}
|
||||
|
||||
std::string
|
||||
TopologyReader::Link::GetFromNodeName (void) const
|
||||
{
|
||||
return m_fromName;
|
||||
}
|
||||
|
||||
Ptr<Node>
|
||||
TopologyReader::Link::GetToNode (void) const
|
||||
{
|
||||
return m_toPtr;
|
||||
}
|
||||
|
||||
std::string
|
||||
TopologyReader::Link::GetToNodeName (void) const
|
||||
{
|
||||
return m_toName;
|
||||
}
|
||||
|
||||
std::string
|
||||
TopologyReader::Link::GetAttribute (std::string name)
|
||||
{
|
||||
NS_ASSERT_MSG (m_linkAttr.find ("name") == m_linkAttr.end (), "Requested topology link attribute not found");
|
||||
return m_linkAttr[name];
|
||||
}
|
||||
|
||||
bool
|
||||
TopologyReader::Link::GetAttributeFailSafe (std::string name, std::string &value)
|
||||
{
|
||||
if ( m_linkAttr.find ("name") == m_linkAttr.end () )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
value = m_linkAttr[name];
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
TopologyReader::Link::SetAttribute (std::string name, std::string &value)
|
||||
{
|
||||
m_linkAttr[name] = value;
|
||||
}
|
||||
|
||||
TopologyReader::Link::ConstAttributesIterator
|
||||
TopologyReader::Link::AttributesBegin (void)
|
||||
{
|
||||
return m_linkAttr.begin ();
|
||||
}
|
||||
TopologyReader::Link::ConstAttributesIterator
|
||||
TopologyReader::Link::AttributesEnd (void)
|
||||
{
|
||||
return m_linkAttr.end ();
|
||||
}
|
||||
|
||||
|
||||
} /* namespace ns3 */
|
||||
203
src/contrib/topology-read/topology-reader.h
Normal file
203
src/contrib/topology-read/topology-reader.h
Normal file
@@ -0,0 +1,203 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2010 Universita' di Firenze, Italy
|
||||
*
|
||||
* 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)
|
||||
* Author: Valerio Sartini (valesar@gmail.com)
|
||||
*/
|
||||
|
||||
#ifndef __TOPOLOGY_READER_H__
|
||||
#define __TOPOLOGY_READER_H__
|
||||
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include <list>
|
||||
|
||||
#include "ns3/object.h"
|
||||
#include "ns3/node-container.h"
|
||||
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
/**
|
||||
* \defgroup topology Topology Input Readers
|
||||
*/
|
||||
|
||||
/**
|
||||
* \ingroup topology
|
||||
* \brief Interface for input file readers management.
|
||||
*
|
||||
* This interface perform the shared tasks among all possible input file readers.
|
||||
* Each different file format is handled by its own topology reader.
|
||||
*/
|
||||
class TopologyReader : public Object
|
||||
{
|
||||
|
||||
public:
|
||||
/**
|
||||
* \ingroup topology
|
||||
* \brief Inner class holding the details about a link between two nodes.
|
||||
*
|
||||
* The link is not described in terms of technology. Rather it is only stating
|
||||
* an association between two nodes. The nodes are characterized also with names
|
||||
* reflecting how the nodes are called in the original topology file.
|
||||
*/
|
||||
class Link
|
||||
{
|
||||
public:
|
||||
typedef std::map<std::string, std::string >::const_iterator ConstAttributesIterator;
|
||||
|
||||
Link ( Ptr<Node> fromPtr, std::string fromName, Ptr<Node> toPtr, std::string toName );
|
||||
|
||||
/**
|
||||
* \brief Returns a Ptr<Node> to the "from" node of the link
|
||||
* \return a Ptr<Node> to the "from" node of the link
|
||||
*/
|
||||
Ptr<Node> GetFromNode (void) const;
|
||||
/**
|
||||
* \brief Returns the name of the "from" node of the link
|
||||
* \return the name of the "from" node of the link
|
||||
*/
|
||||
std::string GetFromNodeName (void) const;
|
||||
/**
|
||||
* \brief Returns a Ptr<Node> to the "to" node of the link
|
||||
* \return a Ptr<Node> to the "to" node of the link
|
||||
*/
|
||||
Ptr<Node> GetToNode (void) const;
|
||||
/**
|
||||
* \brief Returns the name of the "to" node of the link
|
||||
* \return the name of the "to" node of the link
|
||||
*/
|
||||
std::string GetToNodeName (void) const;
|
||||
/**
|
||||
* \brief Returns the value of a link attribute. The attribute must exist.
|
||||
*
|
||||
* \param name the name of the attribute
|
||||
*
|
||||
* \return the value of the attribute
|
||||
*/
|
||||
std::string GetAttribute (std::string name);
|
||||
/**
|
||||
* \brief Returns the value of a link attribute.
|
||||
* \param name the name of the attribute
|
||||
* \param value the value of the attribute
|
||||
*
|
||||
* \return true if the attribute was defined, false otherwise.
|
||||
*/
|
||||
bool GetAttributeFailSafe (std::string name, std::string &value);
|
||||
/**
|
||||
* \brief Sets an arbitrary link attribute.
|
||||
* \param name the name of the attribute
|
||||
* \param value the value of the attribute
|
||||
*/
|
||||
void SetAttribute (std::string name, std::string &value);
|
||||
/**
|
||||
* \brief Returns an iterator to the begin of the attributes.
|
||||
* \return a const iterator to the first attribute of a link.
|
||||
*/
|
||||
ConstAttributesIterator AttributesBegin (void);
|
||||
/**
|
||||
* \brief Returns an iterator to the end of the attributes.
|
||||
* \return a const iterator to the last attribute of a link.
|
||||
*/
|
||||
ConstAttributesIterator AttributesEnd (void);
|
||||
|
||||
private:
|
||||
Link ();
|
||||
std::string m_fromName;
|
||||
Ptr< Node > m_fromPtr;
|
||||
std::string m_toName;
|
||||
Ptr< Node > m_toPtr;
|
||||
std::map<std::string, std::string > m_linkAttr;
|
||||
};
|
||||
|
||||
/**
|
||||
* \brief Contant iterator to the list of the links.
|
||||
*/
|
||||
typedef std::list< Link >::const_iterator ConstLinksIterator;
|
||||
|
||||
static TypeId GetTypeId (void);
|
||||
|
||||
TopologyReader ();
|
||||
virtual ~TopologyReader ();
|
||||
|
||||
/**
|
||||
* \brief Main topology reading function.
|
||||
*
|
||||
* The data is parsed and the results are returned in the passed lists.
|
||||
* The rationale behind this choice is to allow non-progressive node IDs
|
||||
* in the topology files, as well as to separate the topology
|
||||
* reader from the choices about actual IP number assignment and
|
||||
* kind of links between nodes.
|
||||
*
|
||||
* \return the container of the nodes created (or null if there was an error)
|
||||
*/
|
||||
virtual NodeContainer Read (void) = 0;
|
||||
|
||||
/**
|
||||
* \brief Sets the input file name.
|
||||
* \param fileName the input file name.
|
||||
*/
|
||||
void SetFileName (const std::string fileName);
|
||||
|
||||
/**
|
||||
* \brief Returns the input file name.
|
||||
* \return the input file name.
|
||||
*/
|
||||
std::string GetFileName (void) const;
|
||||
|
||||
/**
|
||||
* \brief Returns an iterator to the the first link in this block.
|
||||
* \return a const iterator to the first link in this block.
|
||||
*/
|
||||
ConstLinksIterator LinksBegin (void) const;
|
||||
|
||||
/**
|
||||
* \brief Returns an iterator to the the last link in this block.
|
||||
* \return a const iterator to the last link in this block.
|
||||
*/
|
||||
ConstLinksIterator LinksEnd (void) const;
|
||||
|
||||
/**
|
||||
* \brief Returns the number of links in this block.
|
||||
* \return the number of links in this block.
|
||||
*/
|
||||
int LinksSize (void) const;
|
||||
|
||||
/**
|
||||
* \brief Checks if the block contains any links.
|
||||
* \return true if there are no links in this block, false otherwise.
|
||||
*/
|
||||
bool LinksEmpty (void) const;
|
||||
|
||||
/**
|
||||
* \brief Adds a link to the topology.
|
||||
* \param link the link to be added.
|
||||
*/
|
||||
void AddLink (Link link);
|
||||
|
||||
private:
|
||||
std::string m_fileName;
|
||||
std::list<Link> m_linksList;
|
||||
|
||||
// end class TopologyReader
|
||||
};
|
||||
|
||||
// end namespace ns3
|
||||
};
|
||||
|
||||
|
||||
#endif // __TOPOLOGY_READER_H__
|
||||
32
src/contrib/topology-read/topology.h
Normal file
32
src/contrib/topology-read/topology.h
Normal file
@@ -0,0 +1,32 @@
|
||||
/**
|
||||
* \addtogroup topology Topology Input Readers
|
||||
*
|
||||
* The topology modules aim at reading a topology file generated by an automatic topology generator.
|
||||
*
|
||||
* The process is divided in two steps:
|
||||
* - running a topology generator to build a topology file
|
||||
* - reading the topology file and build a ns-3 simulation
|
||||
*
|
||||
* Hence, model is focused on being able to read correctly the various topology formats.
|
||||
*
|
||||
* Currently there are two models:
|
||||
* - Orbis 0.7
|
||||
* - Inet 3.0
|
||||
*
|
||||
* A good source for topology data is also Archipelago (http://www.caida.org/projects/ark/)
|
||||
*
|
||||
* The current Archipelago Measurements, monthly updated, are stored here:
|
||||
* http://data.caida.org/datasets/topology/ipv4.allpref24-aslinks/
|
||||
* (complete notation and triple data source, one for each working group)
|
||||
*
|
||||
* A different and more compact notation that signs only the AS-relationships is here:
|
||||
* http://www.caida.org/data/active/as-relationships/index.xml
|
||||
* (a sort of more Orbis-like format)
|
||||
*
|
||||
* The compact notation can be easily stripped down to a pure Orbis format, just removing
|
||||
* the double relationships (the compact format use one-way links, while Orbis use two-way
|
||||
* links) and pruning the 3rd parameter. Note that with the compact data Orbis can then be
|
||||
* used create a rescaled version of the topology, thus being the most effective way
|
||||
* (to my best knowledge) to make an internet-like topology.
|
||||
*
|
||||
*/
|
||||
17
src/contrib/topology-read/wscript
Normal file
17
src/contrib/topology-read/wscript
Normal file
@@ -0,0 +1,17 @@
|
||||
## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
|
||||
|
||||
def build(bld):
|
||||
obj = bld.create_ns3_module('topology-read')
|
||||
obj.source = [
|
||||
'topology-reader.cc',
|
||||
'inet-topology-reader.cc',
|
||||
'orbis-topology-reader.cc',
|
||||
]
|
||||
headers = bld.new_task_gen('ns3header')
|
||||
headers.module = 'topology-read'
|
||||
headers.source = [
|
||||
'topology-reader.h',
|
||||
'inet-topology-reader.h',
|
||||
'orbis-topology-reader.h',
|
||||
]
|
||||
|
||||
@@ -64,6 +64,9 @@ public:
|
||||
void SetSubframeRatio (void);
|
||||
uint32_t GetSymbolsPerFrameAllocated (void);
|
||||
private:
|
||||
BandwidthManager (const BandwidthManager &);
|
||||
BandwidthManager& operator= (const BandwidthManager &);
|
||||
|
||||
Ptr<WimaxNetDevice> m_device;
|
||||
uint16_t m_nrBwReqsSent;
|
||||
};
|
||||
|
||||
@@ -57,6 +57,9 @@ public:
|
||||
*/
|
||||
void VerifyInvitedRanging (Cid cid, uint8_t uiuc);
|
||||
private:
|
||||
BSLinkManager (const BSLinkManager &);
|
||||
BSLinkManager & operator= (const BSLinkManager &);
|
||||
|
||||
void PerformRanging (Cid cid, RngReq rngreq);
|
||||
void PerformInitialRanging (Cid cid, RngReq *rngreq, RngRsp *rngrsp);
|
||||
void PerformInvitedRanging (Cid cid, RngRsp *rngrsp);
|
||||
|
||||
@@ -117,14 +117,6 @@ public:
|
||||
* \returns the number of retries on contention Ranging
|
||||
*/
|
||||
uint8_t GetMaxInvitedRangRetries (void) const;
|
||||
/**
|
||||
* \param maxDsaResponseRetries the number of retries on DSA request message
|
||||
*/
|
||||
void SetMaxDsaReqRetries (uint8_t maxDsaResponseRetries);
|
||||
/**
|
||||
* \returns the number of retries on DSA request message
|
||||
*/
|
||||
uint8_t GetMaxDsaReqRetries (void) const;
|
||||
/**
|
||||
* \param rangReqOppSize The ranging opportunity size in symbols
|
||||
*/
|
||||
|
||||
@@ -66,6 +66,9 @@ public:
|
||||
const RngReq *rngreq);
|
||||
uint8_t GetBurstProfileToRequest (void);
|
||||
private:
|
||||
BurstProfileManager (const BurstProfileManager &);
|
||||
BurstProfileManager& operator= (const BurstProfileManager &);
|
||||
|
||||
Ptr<WimaxNetDevice> m_device;
|
||||
};
|
||||
|
||||
|
||||
@@ -44,12 +44,6 @@ namespace ns3 {
|
||||
class CidFactory
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* \param m the value of the 'm' parameter to use for this factory
|
||||
*
|
||||
* The semantics of this parameter are defined in Table 345 ieee-802.16-2004
|
||||
*/
|
||||
CidFactory (uint16_t m);
|
||||
/**
|
||||
* Create a cid factory with a default value for m of 0x5500.
|
||||
*/
|
||||
|
||||
@@ -95,7 +95,6 @@ public:
|
||||
void SetTtg (uint8_t ttg);
|
||||
void SetRtg (uint8_t rtg);
|
||||
|
||||
void SetChnlSwitchFrameNr (uint32_t chnlSwitchFrameNr);
|
||||
void SetBaseStationId (Mac48Address baseStationId);
|
||||
void SetFrameDurationCode (uint8_t frameDurationCode);
|
||||
void SetFrameNumber (uint32_t frameNumber);
|
||||
@@ -104,7 +103,6 @@ public:
|
||||
uint8_t GetTtg (void) const;
|
||||
uint8_t GetRtg (void) const;
|
||||
|
||||
uint32_t GetChnlSwitchFrameNr (void) const;
|
||||
Mac48Address GetBaseStationId (void) const;
|
||||
uint8_t GetFrameDurationCode (void) const;
|
||||
uint32_t GetFrameNumber (void) const;
|
||||
|
||||
@@ -341,7 +341,6 @@ class DsaRsp : public Header
|
||||
public:
|
||||
DsaRsp (void);
|
||||
~DsaRsp (void);
|
||||
DsaRsp (ServiceFlow sf);
|
||||
|
||||
void SetTransactionId (uint16_t transactionId);
|
||||
uint16_t GetTransactionId (void) const;
|
||||
|
||||
@@ -64,7 +64,6 @@ public:
|
||||
std::list<Ptr<Packet> >::const_iterator End (void) const;
|
||||
private:
|
||||
void DoDispose (void);
|
||||
friend bool operator == (const PacketBurst &a, const PacketBurst &b);
|
||||
std::list<Ptr<Packet> > m_packets;
|
||||
};
|
||||
} // namespace ns3
|
||||
|
||||
@@ -51,7 +51,6 @@ public:
|
||||
~ServiceFlowManager (void);
|
||||
void DoDispose (void);
|
||||
|
||||
void defineServiceFlow (void);
|
||||
void AddServiceFlow (ServiceFlow * serviceFlow);
|
||||
ServiceFlow* GetServiceFlow (uint32_t sfid) const;
|
||||
ServiceFlow* GetServiceFlow (Cid cid) const;
|
||||
|
||||
@@ -64,6 +64,9 @@ public:
|
||||
SubscriberStationNetDevice::EventType eventType,
|
||||
bool deleteUlParameters, EventId &eventId);
|
||||
private:
|
||||
SSLinkManager (const SSLinkManager &);
|
||||
SSLinkManager & operator= (const SSLinkManager &);
|
||||
|
||||
void EndScanning (bool status, uint64_t frequency);
|
||||
void StartSynchronizing (void);
|
||||
bool SearchForDlChannel (uint8_t channel);
|
||||
|
||||
@@ -62,9 +62,6 @@ public:
|
||||
uint8_t GetInvitedRangRetries (void) const;
|
||||
void ResetInvitedRangingRetries (void);
|
||||
void IncrementInvitedRangingRetries (void);
|
||||
uint8_t GetDsaReqRetries (void) const;
|
||||
void ResetDsaReqRetries (void);
|
||||
void IncrementDsaReqRetries (void);
|
||||
void SetModulationType (WimaxPhy::ModulationType modulationType);
|
||||
WimaxPhy::ModulationType GetModulationType (void) const;
|
||||
|
||||
|
||||
@@ -58,6 +58,9 @@ public:
|
||||
void DoDispose (void);
|
||||
protected:
|
||||
private:
|
||||
SSScheduler (const SSScheduler &);
|
||||
SSScheduler & operator= (const SSScheduler &);
|
||||
|
||||
Ptr<WimaxConnection> SelectConnection (void);
|
||||
Ptr<SubscriberStationNetDevice> m_ss;
|
||||
bool m_pollMe;
|
||||
|
||||
@@ -70,16 +70,10 @@ public:
|
||||
* \return the maximum retries on DSA request message
|
||||
*/
|
||||
uint8_t GetMaxDsaReqRetries (void) const;
|
||||
/**
|
||||
* \return the maximum retries on DSA response message
|
||||
*/
|
||||
uint8_t GetMaxDsaRspRetries (void) const;
|
||||
|
||||
EventId GetDsaRspTimeoutEvent (void) const;
|
||||
EventId GetDsaAckTimeoutEvent (void) const;
|
||||
|
||||
void AllocateServiceFlows (const DsaReq &dsaReq, Cid cid);
|
||||
|
||||
void InitiateServiceFlows (void);
|
||||
|
||||
DsaReq CreateDsaReq (const ServiceFlow *serviceFlow);
|
||||
|
||||
@@ -214,13 +214,13 @@ public:
|
||||
virtual Address GetMulticast (Ipv4Address multicastGroup) const;
|
||||
virtual bool IsBridge (void) const;
|
||||
|
||||
Ptr<Object> GetMobility (void);
|
||||
void SetMobility (Ptr<Object> mobility);
|
||||
|
||||
bool IsPromisc (void);
|
||||
void NotifyPromiscTrace (Ptr<Packet> p);
|
||||
|
||||
private:
|
||||
WimaxNetDevice (const WimaxNetDevice &);
|
||||
WimaxNetDevice & operator= (const WimaxNetDevice &);
|
||||
|
||||
virtual bool DoSend (Ptr<Packet> packet,
|
||||
const Mac48Address& source,
|
||||
const Mac48Address& dest,
|
||||
|
||||
80
src/helper/topology-reader-helper.cc
Normal file
80
src/helper/topology-reader-helper.cc
Normal file
@@ -0,0 +1,80 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2010 Universita' di Firenze, Italy
|
||||
*
|
||||
* 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)
|
||||
* Author: Valerio Sartini (valesar@gmail.com)
|
||||
*/
|
||||
|
||||
#include "ns3/object.h"
|
||||
#include "ns3/topology-reader-helper.h"
|
||||
#include "ns3/inet-topology-reader.h"
|
||||
#include "ns3/orbis-topology-reader.h"
|
||||
#include "ns3/log.h"
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
NS_LOG_COMPONENT_DEFINE ("TopologyReaderHelper");
|
||||
|
||||
TopologyReaderHelper::TopologyReaderHelper ()
|
||||
{
|
||||
m_inFile = 0;
|
||||
}
|
||||
|
||||
void
|
||||
TopologyReaderHelper::SetFileName (const std::string fileName)
|
||||
{
|
||||
m_fileName = fileName;
|
||||
}
|
||||
|
||||
void
|
||||
TopologyReaderHelper::SetFileType (const std::string fileType)
|
||||
{
|
||||
m_fileType = fileType;
|
||||
}
|
||||
|
||||
|
||||
Ptr<TopologyReader>
|
||||
TopologyReaderHelper::GetTopologyReader ()
|
||||
{
|
||||
if (!m_inFile)
|
||||
{
|
||||
NS_ASSERT_MSG (!m_fileType.empty (), "Missing File Type");
|
||||
NS_ASSERT_MSG (!m_fileName.empty (), "Missing File Name");
|
||||
|
||||
if (m_fileType == "Orbis")
|
||||
{
|
||||
NS_LOG_INFO ("Creating Orbis formatted data input.");
|
||||
m_inFile = CreateObject<OrbisTopologyReader> ();
|
||||
}
|
||||
else if (m_fileType == "Inet")
|
||||
{
|
||||
NS_LOG_INFO ("Creating Inet formatted data input.");
|
||||
m_inFile = CreateObject<InetTopologyReader> ();
|
||||
}
|
||||
else
|
||||
{
|
||||
NS_ASSERT_MSG (false, "Wrong (unknown) File Type");
|
||||
}
|
||||
|
||||
m_inFile->SetFileName (m_fileName);
|
||||
}
|
||||
return m_inFile;
|
||||
}
|
||||
|
||||
|
||||
|
||||
} // namespace ns3
|
||||
66
src/helper/topology-reader-helper.h
Normal file
66
src/helper/topology-reader-helper.h
Normal file
@@ -0,0 +1,66 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2010 Universita' di Firenze, Italy
|
||||
*
|
||||
* 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)
|
||||
* Author: Valerio Sartini (valesar@gmail.com)
|
||||
*/
|
||||
|
||||
#ifndef TOPOLOGY_READER_HELPER_H
|
||||
#define TOPOLOGY_READER_HELPER_H
|
||||
|
||||
#include "ns3/topology-reader.h"
|
||||
#include <string>
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
/**
|
||||
* \ingroup topology
|
||||
* \brief Helper class which makes it easier to configure and use a generic TopologyReader.
|
||||
*/
|
||||
class TopologyReaderHelper
|
||||
{
|
||||
public:
|
||||
TopologyReaderHelper ();
|
||||
|
||||
/**
|
||||
* \brief Sets the input file name.
|
||||
* \param fileName the input file name.
|
||||
*/
|
||||
void SetFileName (const std::string fileName);
|
||||
|
||||
/**
|
||||
* \brief Sets the input file type. Supported file types are "Orbis" and "Inet".
|
||||
* \param fileType the input file type.
|
||||
*/
|
||||
void SetFileType (const std::string fileType);
|
||||
|
||||
/**
|
||||
* \brief Gets a Ptr<TopologyReader> to the actual TopologyReader.
|
||||
* \return the created Topoloy Reader (or null if there was an error).
|
||||
*/
|
||||
Ptr<TopologyReader> GetTopologyReader ();
|
||||
|
||||
private:
|
||||
Ptr<TopologyReader> m_inFile;
|
||||
std::string m_fileName;
|
||||
std::string m_fileType;
|
||||
};
|
||||
|
||||
} // namespace ns3
|
||||
|
||||
|
||||
#endif /* TOPOLOGY_READER_HELPER_H */
|
||||
@@ -50,6 +50,7 @@ def build(bld):
|
||||
'udp-client-server-helper.cc',
|
||||
'trace-helper.cc',
|
||||
'wimax-helper.cc',
|
||||
'topology-reader-helper.cc',
|
||||
]
|
||||
|
||||
headers = bld.new_task_gen('ns3header')
|
||||
@@ -103,6 +104,7 @@ def build(bld):
|
||||
'udp-client-server-helper.h',
|
||||
'trace-helper.h',
|
||||
'wimax-helper.h',
|
||||
'topology-reader-helper.h',
|
||||
]
|
||||
|
||||
env = bld.env_of_name('default')
|
||||
|
||||
@@ -51,6 +51,7 @@ all_modules = (
|
||||
'applications/udp-client-server',
|
||||
'devices/wimax',
|
||||
'mpi',
|
||||
'contrib/topology-read',
|
||||
)
|
||||
|
||||
def set_options(opt):
|
||||
|
||||
2
test.py
2
test.py
@@ -127,6 +127,8 @@ example_tests = [
|
||||
("tcp/tcp-nsc-zoo", "ENABLE_NSC == True", "True"),
|
||||
("tcp/tcp-star-server", "True", "True"),
|
||||
|
||||
("topology-read/topology-read --input=../../examples/topology-read/Inet_small_toposample.txt", "True", "True"),
|
||||
|
||||
("tunneling/virtual-net-device", "True", "True"),
|
||||
|
||||
("tutorial/first", "True", "True"),
|
||||
|
||||
Reference in New Issue
Block a user