Processing the original format of Abilene topology file
diff --git a/examples/abilene-topology.cc b/examples/abilene-topology.cc
index 747b588..394b0e2 100644
--- a/examples/abilene-topology.cc
+++ b/examples/abilene-topology.cc
@@ -81,7 +81,7 @@
     
   AnnotatedTopologyReader reader ("/abilene");
   reader.SetFileName (input);
-  reader.SetBoundingBox (100.0, 100.0, 5000.0, 5000.0;
+  reader.SetBoundingBox (100.0, 100.0, 5000.0, 5000.0);
     
   NodeContainer nodes = reader.Read ();
     
@@ -104,10 +104,10 @@
     
   NS_LOG_INFO ("Installing Applications");
   CcnxConsumerHelper consumerHelper ("tralala");
-  ApplicationContainer consumers = consumerHelper.Install (Names::Find<Node> ("/abilene", "1"));
+  ApplicationContainer consumers = consumerHelper.Install (Names::Find<Node> ("/abilene", "ATLAng"));
     
   CcnxProducerHelper producerHelper ("tralala",1024);
-  ApplicationContainer producers = producerHelper.Install (Names::Find<Node> ("/abilene", "6"));
+  ApplicationContainer producers = producerHelper.Install (Names::Find<Node> ("/abilene", "IPLSng"));
 
   // Simulator::Schedule (Seconds (1.0), PrintFIBs);
   PrintFIBs ();
diff --git a/examples/abilene-topology.txt b/examples/abilene-topology.txt
index 6ce358c..5eb607d 100644
--- a/examples/abilene-topology.txt
+++ b/examples/abilene-topology.txt
@@ -1,16 +1,48 @@
-12  15
-1   2   9920000 1   1   100 100 84  34  84  34
-2   5   9920000 1176    1   100 100 84  34  96  30
-2   6   2480000 587 1   100 100 84  34  86  40
-2   12  9920000 846 1   100 100 84  34  77  39
-3   6   9920000 260 1   100 100 88  42  86  40
-3   9   9920000 700 1   100 100 88  42  74  41
-4   7   9920000 639 1   100 100 105 41  97  39
-4   10  9920000 1295 1   100 100    105 41  122 37
-4   11  9920000 2095    1   100 100 105 41  122 48
-5   7   9920000 902 1   100 100 96  30  97  39
-5   8   9920000 1893 1   100 100    96  30  118 34
-6   7   9920000 548 1   100 100 86  40  97  39
-8   10  9920000 366 1   100 100 118 34  122 37
-9   12  9920000 233 1   100 100 74  41  77  39
-10  11  9920000 861 1   100 100 122 37  122 48
\ No newline at end of file
+router
+#name	city	latitude	longitude
+ATLA-M5	Atlanta_GA	33.750000	-84.383300
+ATLAng	Atlanta_GA	33.750000	-84.383300
+CHINng	Chicago_IL	41.833300	-87.616700
+DNVRng	Denver_CO	40.750000	-105.000000
+HSTNng	Houston_TX	29.770031	-95.517364
+IPLSng	Indianapolis_IN	39.780622	-86.159535
+KSCYng	Kansas_City_MO	38.961694	-96.596704
+LOSAng	Los_Angeles_CA	34.050000	-118.250000
+NYCMng	New_York_NY	40.783300	-73.966700
+SNVAng	Sunnyvale_CA	37.38575	-122.02553
+STTLng	Seattle_WA	47.600000	-122.300000
+WASHng	Washington_DC	38.897303	-77.026842
+link
+#capacity on 4/10/2003 (see page 20 of http://www.internet2.edu/presentations/spring03/20030410-Abilene-Corbato.pdf)
+#OSPF weight on 04/10/2003 (see http://www.abilene.iu.edu/images/Ab-IGP-topo.jpg)
+#x	y	capacity(kbps)	OSPF
+ATLA-M5	ATLAng	9920000 1
+ATLAng	ATLA-M5	9920000 1
+ATLAng	HSTNng	9920000 1176
+ATLAng	IPLSng	2480000 587
+ATLAng	WASHng	9920000 846
+CHINng	IPLSng	9920000 260
+CHINng	NYCMng	9920000 700
+DNVRng	KSCYng	9920000 639
+DNVRng	SNVAng	9920000 1295
+DNVRng	STTLng	9920000 2095
+HSTNng	ATLAng	9920000 1176
+HSTNng	KSCYng	9920000 902
+HSTNng	LOSAng	9920000 1893
+IPLSng	ATLAng	2480000 587
+IPLSng	CHINng	9920000 260
+IPLSng	KSCYng	9920000 548
+KSCYng	DNVRng	9920000 639
+KSCYng	HSTNng	9920000 902
+KSCYng	IPLSng	9920000 548
+LOSAng	HSTNng	9920000 1893
+LOSAng	SNVAng	9920000 366
+NYCMng	CHINng	9920000 700
+NYCMng	WASHng	9920000 233
+SNVAng	DNVRng	9920000 1295
+SNVAng	LOSAng	9920000 366
+SNVAng	STTLng	9920000 861
+STTLng	DNVRng	9920000 2095
+STTLng	SNVAng	9920000 861
+WASHng	ATLAng	9920000 846
+WASHng	NYCMng	9920000 233
diff --git a/model/annotated-topology-reader.cc b/model/annotated-topology-reader.cc
index 4b17ba4..239b6a3 100644
--- a/model/annotated-topology-reader.cc
+++ b/model/annotated-topology-reader.cc
@@ -44,6 +44,8 @@
 #include <boost/foreach.hpp>
 #include <boost/lexical_cast.hpp>
 
+#include <set>
+
 using namespace std;
 
 namespace ns3 
@@ -55,10 +57,10 @@
     
 TypeId AnnotatedTopologyReader::GetTypeId (void)
 {
-    static TypeId tid = TypeId ("ns3::AnnotatedTopologyReader")
+  static TypeId tid = TypeId ("ns3::AnnotatedTopologyReader")
     .SetParent<Object> ()
     ;
-    return tid;
+  return tid;
 }
     
 AnnotatedTopologyReader::AnnotatedTopologyReader (const std::string &path)
@@ -68,7 +70,7 @@
   , m_lrx (100.0)
   , m_lry (100.0)
 {
-    NS_LOG_FUNCTION (this);
+  NS_LOG_FUNCTION (this);
 }
     
 void
@@ -84,117 +86,105 @@
 
 AnnotatedTopologyReader::~AnnotatedTopologyReader ()
 {
-    NS_LOG_FUNCTION (this);
+  NS_LOG_FUNCTION (this);
 }
-    
+
 NodeContainer
 AnnotatedTopologyReader::Read (void)
 {
-    ifstream topgen;
-    topgen.open (GetFileName ().c_str ());
-    NodeContainer nodes;
+  ifstream topgen;
+  topgen.open (GetFileName ().c_str ());
+  NodeContainer nodes;
         
-    if ( !topgen.is_open () )
+  if ( !topgen.is_open () )
     {
       NS_LOG_ERROR ("Cannot open file " << GetFileName () << " for reading");
-        return nodes;
+      return nodes;
     }
-        
-    int linksNumber = 0;
-    int nodesNumber = 0;
-        
-    string line;
-    getline (topgen,line);
-  istringstream headerLineBuffer (line);
-        
-  int totnode;
-  int totlink;
-  headerLineBuffer >> totnode;
-  headerLineBuffer >> totlink;
-  
-    NS_LOG_INFO ("Annotated topology should have " << totnode << " nodes and " << totlink << " links");
-        
-    for (int i = 0; i < totlink && !topgen.eof (); i++)
-    {
-        getline (topgen,line);
-      istringstream lineBuffer (line);
-            
-      string from;
-      string to;
-        lineBuffer >> from;
-        lineBuffer >> to;
-            
-        if ( (!from.empty ()) && (!to.empty ()) )
-        {
-            NS_LOG_INFO ( linksNumber << " From: " << from << " to: " << to );
-                
-          Ptr<Node> fromNode = Names::Find<Node> (m_path, from);
-          Ptr<Node> toNode   = Names::Find<Node> (m_path, to);
-          
-          if (fromNode == 0)
-            {
-              fromNode = CreateObject<Node> ();
-              Names::Add (m_path, from, fromNode);
-              nodes.Add (fromNode);
-                nodesNumber++;
-            }
-                
-          if (toNode == 0)
-            {
-              toNode = CreateObject<Node> ();
-              Names::Add (m_path, to, toNode);
-              nodes.Add (toNode);
-                nodesNumber++;
-            }
-                
-          Link link (fromNode, from, toNode, to);
-                
-          string dataRate;
-          lineBuffer >> dataRate;
-            
-          string ospf;
-          lineBuffer >> ospf;
-                
-          string delay;
-          lineBuffer >> delay;
-                
-          string queueSizeNode1;
-          lineBuffer >> queueSizeNode1;
-                
-          string queueSizeNode2;
-          lineBuffer >> queueSizeNode2;
 
-          if (dataRate.empty () ||
-              ospf.empty () ||
-              delay.empty () ||
-              queueSizeNode1.empty () ||
-              queueSizeNode2.empty ())
-            {
-              NS_LOG_ERROR ("File [" << GetFileName () << ":" << i+2 << " wrong format, skipping");
-              continue;
-            }
-            
-          link.SetAttribute ("DataRate", dataRate);
-          link.SetAttribute ("OSPF", ospf);
-          link.SetAttribute ("Delay", delay);
-          link.SetAttribute ("QueueSizeNode1", queueSizeNode1);
-          link.SetAttribute ("QueueSizeNode2", queueSizeNode2);
-                
-            AddLink (link);
-                
-            linksNumber++;
+  uint32_t linksNumber = 0;
+  uint32_t nodesNumber = 0;
+
+  while (!topgen.eof ())
+    {
+      string line;
+      getline (topgen, line);
+
+      if (line == "router") break;
+    }
+
+  while (!topgen.eof ())
+    {
+      string line;
+      getline (topgen,line);
+      if (line[0] == '#') continue; // comments
+      if (line=="link") break; // stop reading nodes
+      
+      istringstream lineBuffer (line);
+      string name, city;
+      double latitude, longitude;
+
+      lineBuffer >> name >> city >> latitude >> longitude;
+      Ptr<Node> node = CreateObject<Node> ();
+      Ptr<ConstantPositionMobilityModel> loc = CreateObject<ConstantPositionMobilityModel> ();
+      node->AggregateObject (loc);
+
+      loc->SetPosition (Vector (latitude, longitude, 0));
+
+      Names::Add (m_path, name, node);
+      nodes.Add (node);
+      nodesNumber++;
+    }
+
+  map<string, set<string> > processedLinks; // to eliminate duplications
+  
+  // SeekToSection ("link"); 
+  while (!topgen.eof ())
+    {
+      string line;
+      getline (topgen,line);
+      if (line == "") continue;
+      if (line[0] == '#') continue; // comments
+
+      // NS_LOG_DEBUG ("Input: [" << line << "]");
+      
+      istringstream lineBuffer (line);
+      string from, to, capacity, metric;
+
+      lineBuffer >> from >> to >> capacity >> metric;
+
+      if (processedLinks[to].size () != 0 &&
+          processedLinks[to].find (from) != processedLinks[to].end ())
+        {
+          continue; // duplicated link
         }
+      processedLinks[from].insert (to);
+      
+      Ptr<Node> fromNode = Names::Find<Node> (m_path, from);
+      NS_ASSERT (fromNode != 0);
+      Ptr<Node> toNode   = Names::Find<Node> (m_path, to);
+      NS_ASSERT (fromNode != 0);
+
+      Link link (fromNode, from, toNode, to);
+      
+      link.SetAttribute ("DataRate", capacity);
+      link.SetAttribute ("OSPF", metric);
+      // link.SetAttribute ("Delay", delay);
+      // link.SetAttribute ("QueueSizeNode1", queueSizeNode1);
+      // link.SetAttribute ("QueueSizeNode2", queueSizeNode2);
+
+      AddLink (link);
+      NS_LOG_DEBUG ("New link " << from << " <==> " << to << " / " << capacity << "Kbps with " << metric << " metric");
+                
+      linksNumber++;
     }
         
-  NS_ASSERT (nodesNumber == totnode && linksNumber == totlink);
-        
-    NS_LOG_INFO ("Annotated topology created with " << nodesNumber << " nodes and " << linksNumber << " links");
-    topgen.close ();
+  NS_LOG_INFO ("Annotated topology created with " << nodesNumber << " nodes and " << linksNumber << " links");
+  topgen.close ();
         
   ApplySettings ();
-  AssignCoordinates ();
   
-    return nodes;
+  return nodes;
 }
     
 void
@@ -209,19 +199,19 @@
         
       base = Ipv4Address (base.Get () + 256);
       address.SetBase (base, Ipv4Mask ("/24"));
-        }
+    }
         
   ApplyOspfMetric ();
-        }
+}
         
 void
 AnnotatedTopologyReader::ApplyOspfMetric ()
-    {
+{
   BOOST_FOREACH (const Link &link, m_linksList)
-        {
+    {
       uint16_t metric = boost::lexical_cast<uint16_t> (link.GetAttribute ("OSPF"));
         
-        {
+      {
         Ptr<Ipv4> ipv4 = link.GetFromNode ()->GetObject<Ipv4> ();
         NS_ASSERT (ipv4 != 0);
         
@@ -229,9 +219,9 @@
         NS_ASSERT (interfaceId >= 0);
         
         ipv4->SetMetric (interfaceId,metric);
-        }
+      }
         
-        {
+      {
         Ptr<Ipv4> ipv4 = link.GetToNode ()->GetObject<Ipv4> ();
         NS_ASSERT (ipv4 != 0);
         
@@ -239,9 +229,9 @@
         NS_ASSERT (interfaceId >= 0);
 
         ipv4->SetMetric (interfaceId,metric);
+      }
     }
 }
-}
 
 void
 AnnotatedTopologyReader::ApplySettings ()
@@ -254,53 +244,45 @@
 
   BOOST_FOREACH (Link &link, m_linksList)
     {
+      string tmp;
+
       NS_LOG_INFO ("DataRate = " + link.GetAttribute("DataRate")+"Kbps");
       p2p.SetDeviceAttribute ("DataRate", StringValue(link.GetAttribute("DataRate")+"Kbps"));
-        
-      NS_LOG_INFO ("Delay = " + link.GetAttribute("Delay")+"ms");
-      p2p.SetChannelAttribute ("Delay", StringValue(link.GetAttribute("Delay")+"ms"));
+
+      if (link.GetAttributeFailSafe("Delay", tmp))
+        {
+          NS_LOG_INFO ("Delay = " + link.GetAttribute("Delay")+"ms");
+          p2p.SetChannelAttribute ("Delay", StringValue(link.GetAttribute("Delay")+"ms"));
+        }
+      else
+        {
+          NS_LOG_INFO ("Default delay 1ms");
+          p2p.SetChannelAttribute ("Delay", StringValue("1ms"));
+        }
         
       NetDeviceContainer nd = p2p.Install(link.GetFromNode (), link.GetToNode ());
       link.SetNetDevices (nd.Get (0), nd.Get (1));
 
-      NS_LOG_INFO ("Queue: " << link.GetAttribute("QueueSizeNode1") << " <==> " << link.GetAttribute("QueueSizeNode2"));
-        
-      PointerValue txQueueFrom;
-      link.GetFromNetDevice ()->GetAttribute ("TxQueue", txQueueFrom);
-      NS_ASSERT (txQueueFrom.Get<DropTailQueue> () != 0);
-        
-      PointerValue txQueueTo;
-      link.GetToNetDevice ()->GetAttribute ("TxQueue", txQueueTo);
-      NS_ASSERT (txQueueTo.Get<DropTailQueue> () != 0);
-        
-      txQueueFrom.Get<DropTailQueue> ()->SetAttribute ("MaxPackets", StringValue (link.GetAttribute("QueueSizeNode1")));
-      txQueueTo.  Get<DropTailQueue> ()->SetAttribute ("MaxPackets", StringValue (link.GetAttribute("QueueSizeNode2")));
-        }
-        }
+      // NS_LOG_INFO ("Queue: " << link.GetAttribute("QueueSizeNode1") << " <==> " << link.GetAttribute("QueueSizeNode2"));
 
-void
-AnnotatedTopologyReader::AssignCoordinates ()
-{
-  UniformVariable randX (m_ulx, m_lrx);
-    double x = 0.0;
-  UniformVariable randY (m_uly, m_lry);
-    double y = 0.0;
+      if (link.GetAttributeFailSafe("QueueSizeNode1", tmp))
+        {
+          PointerValue txQueueFrom;
+          link.GetFromNetDevice ()->GetAttribute ("TxQueue", txQueueFrom);
+          NS_ASSERT (txQueueFrom.Get<DropTailQueue> () != 0);
 
-  BOOST_FOREACH (Link &link, m_linksList)
-    {
-      Ptr<ConstantPositionMobilityModel> loc = link.GetFromNode ()->GetObject<ConstantPositionMobilityModel> ();
-      if (loc != 0)
-        continue; // no need to assign twice
+          txQueueFrom.Get<DropTailQueue> ()->SetAttribute ("MaxPackets", StringValue (link.GetAttribute("QueueSizeNode1")));
+        }
+      
+      if (link.GetAttributeFailSafe("QueueSizeNode2", tmp))
+        {
+          PointerValue txQueueTo;
+          link.GetToNetDevice ()->GetAttribute ("TxQueue", txQueueTo);
+          NS_ASSERT (txQueueTo.Get<DropTailQueue> () != 0);
         
-            loc = CreateObject<ConstantPositionMobilityModel> ();
-      link.GetFromNode ()->AggregateObject (loc);
-        
-      x = randX.GetValue();
-      y = randY.GetValue();
-        NS_LOG_INFO("X = "<<x <<"Y = "<<y);
-        
-      loc->SetPosition (Vector (x, y, 0));
+          txQueueTo.  Get<DropTailQueue> ()->SetAttribute ("MaxPackets", StringValue (link.GetAttribute("QueueSizeNode2")));
         }
     }
+}
 
 }
diff --git a/model/annotated-topology-reader.h b/model/annotated-topology-reader.h
index 6346b6a..cfe5233 100644
--- a/model/annotated-topology-reader.h
+++ b/model/annotated-topology-reader.h
@@ -84,7 +84,6 @@
      * NodeContainer from Read method
      */
   void ApplySettings ();
-  void AssignCoordinates ();
   void ApplyOspfMetric ();
     
 private: