22 #include "rocketfuel-weights-reader.h" 
   24 #include "ns3/nstime.h" 
   26 #include "ns3/assert.h" 
   27 #include "ns3/names.h" 
   28 #include "ns3/net-device-container.h" 
   29 #include "ns3/point-to-point-helper.h" 
   30 #include "ns3/point-to-point-net-device.h" 
   31 #include "ns3/internet-stack-helper.h" 
   32 #include "ns3/ipv4-address-helper.h" 
   33 #include "ns3/ipv4-global-routing-helper.h" 
   34 #include "ns3/drop-tail-queue.h" 
   35 #include "ns3/ipv4-interface.h" 
   37 #include "ns3/string.h" 
   38 #include "ns3/pointer.h" 
   39 #include "ns3/uinteger.h" 
   40 #include "ns3/ipv4-address.h" 
   42 #include "ns3/mobility-model.h" 
   46 #include <boost/foreach.hpp> 
   47 #include <boost/lexical_cast.hpp> 
   54 NS_LOG_COMPONENT_DEFINE (
"RocketfuelWeightsReader");
 
   58 RocketfuelWeightsReader::RocketfuelWeightsReader (
const std::string &path, 
double scale)
 
   59   : AnnotatedTopologyReader (path, scale)
 
   60   , m_defaultBandwidth (
"100Mbps")
 
   62   NS_LOG_FUNCTION (
this);
 
   72 RocketfuelWeightsReader::~RocketfuelWeightsReader ()
 
   74   NS_LOG_FUNCTION (
this);
 
   78 RocketfuelWeightsReader::SetFileType (uint8_t inputType)
 
   80   m_inputType = inputType;
 
   86   if (m_inputType == POSITIONS)
 
   90   topgen.open (GetFileName ().c_str ());
 
   92   if ( !topgen.is_open () )
 
   94       NS_LOG_ERROR (
"Cannot open file " << GetFileName () << 
" for reading");
 
   98   map<string, set<string> > processedLinks; 
 
   99   bool repeatedRun = LinksSize () > 0;
 
  100   std::list<Link>::iterator linkIterator = m_linksList.begin ();
 
  102   while (!topgen.eof ())
 
  105       getline (topgen,line);
 
  106       if (line == 
"") 
continue;
 
  107       if (line[0] == 
'#') 
continue; 
 
  111       istringstream lineBuffer (line);
 
  112       string from, to, attribute;
 
  114       lineBuffer >> from >> to >> attribute;
 
  116       if (processedLinks[to].size () != 0 &&
 
  117           processedLinks[to].find (from) != processedLinks[to].end ())
 
  121       processedLinks[from].insert (to);
 
  123       Ptr<Node> fromNode = Names::Find<Node> (m_path, from);
 
  126           fromNode = CreateNode (from, 0);
 
  129       Ptr<Node> toNode   = Names::Find<Node> (m_path, to);
 
  132           toNode = CreateNode (to, 0);
 
  137         link = 
new Link (fromNode, from, toNode, to);
 
  140           NS_ASSERT (linkIterator != m_linksList.end ());
 
  141           link = &(*linkIterator);
 
  158             uint16_t metric = boost::lexical_cast<uint16_t> (attribute);
 
  159             link->SetAttribute (
"OSPF", boost::lexical_cast<string> (metric));
 
  166           link->SetAttribute (
"DataRate", m_defaultBandwidth);
 
  167           link->SetAttribute (
"Delay", attribute+
"ms");
 
  168           if (!m_queue.empty ())
 
  170               link->SetAttribute (
"MaxPackets", m_queue);
 
  177       NS_LOG_DEBUG (
"Link " << from << 
" <==> " << to << 
" / " << attribute);
 
  189       NS_LOG_INFO (
"Rocketfuel topology created with " << m_nodes.GetN () << 
" nodes and " << LinksSize () << 
" links");
 
  195 RocketfuelWeightsReader::Commit ()
 
void ApplySettings()
This method applies setting to corresponding nodes and links NetDeviceContainer must be allocated Nod...
 
virtual NodeContainer Read()
Main annotated topology reading function. 
 
virtual NodeContainer Read(void)
Main topology reading function.