topology-reader: Adding support for adding and configuring ErrorModel on each link

Thanks to Saran Tarnoi for the initial implemenation
diff --git a/examples/ndn-grid-topo-plugin-loss.cc b/examples/ndn-grid-topo-plugin-loss.cc
new file mode 100644
index 0000000..355372d
--- /dev/null
+++ b/examples/ndn-grid-topo-plugin-loss.cc
@@ -0,0 +1,100 @@
+/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2011-2012 University of California, Los Angeles
+ *
+ * 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: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
+ */
+// ndn-grid-topo-plugin.cc
+#include "ns3/core-module.h"
+#include "ns3/network-module.h"
+#include "ns3/ndnSIM-module.h"
+
+using namespace ns3;
+
+/**
+ * This scenario simulates a grid topology (using topology reader module)
+ *
+ * (consumer) -- ( ) ----- ( )
+ *     |          |         |
+ *    ( ) ------ ( ) ----- ( )
+ *     |          |         |
+ *    ( ) ------ ( ) -- (producer)
+ *
+ * All links are 1Mbps with propagation 10ms delay. 
+ *
+ * FIB is populated using NdnGlobalRoutingHelper.
+ *
+ * Consumer requests data from producer with frequency 10 interests per second
+ * (interests contain constantly increasing sequence number).
+ *
+ * For every received interest, producer replies with a data packet, containing
+ * 1024 bytes of virtual payload.
+ *
+ * To run scenario and see what is happening, use the following command:
+ *
+ *     NS_LOG=ndn.Consumer:ndn.Producer ./waf --run=ndn-grid-topo-plugin
+ */
+
+int
+main (int argc, char *argv[])
+{
+  CommandLine cmd;
+  cmd.Parse (argc, argv);
+
+  AnnotatedTopologyReader topologyReader ("", 25);
+  topologyReader.SetFileName ("src/ndnSIM/examples/topologies/topo-grid-3x3-loss.txt");
+  topologyReader.Read ();
+
+  // Install NDN stack on all nodes
+  ndn::StackHelper ndnHelper;
+  ndnHelper.SetForwardingStrategy ("ns3::ndn::fw::BestRoute");
+  ndnHelper.InstallAll ();
+
+  // Installing global routing interface on all nodes
+  ndn::GlobalRoutingHelper ndnGlobalRoutingHelper;
+  ndnGlobalRoutingHelper.InstallAll ();
+
+  // Getting containers for the consumer/producer
+  Ptr<Node> producer = Names::Find<Node> ("Node8");
+  NodeContainer consumerNodes;
+  consumerNodes.Add (Names::Find<Node> ("Node0"));
+
+  // Install NDN applications
+  std::string prefix = "/prefix";
+
+  ndn::AppHelper consumerHelper ("ns3::ndn::ConsumerCbr");
+  consumerHelper.SetPrefix (prefix);
+  consumerHelper.SetAttribute ("Frequency", StringValue ("100")); // 100 interests a second
+  consumerHelper.Install (consumerNodes);
+
+  ndn::AppHelper producerHelper ("ns3::ndn::Producer");
+  producerHelper.SetPrefix (prefix);
+  producerHelper.SetAttribute ("PayloadSize", StringValue("1024"));
+  producerHelper.Install (producer);
+
+  // Add /prefix origins to ndn::GlobalRouter
+  ndnGlobalRoutingHelper.AddOrigins (prefix, producer);
+
+  // Calculate and install FIBs
+  ndn::GlobalRoutingHelper::CalculateRoutes ();
+
+  Simulator::Stop (Seconds (20.0));
+
+  Simulator::Run ();
+  Simulator::Destroy ();
+
+  return 0;
+}
diff --git a/examples/topologies/topo-grid-3x3-loss.txt b/examples/topologies/topo-grid-3x3-loss.txt
new file mode 100644
index 0000000..922bcef
--- /dev/null
+++ b/examples/topologies/topo-grid-3x3-loss.txt
@@ -0,0 +1,61 @@
+# topo-grid-3x3.txt
+
+#   /--------\	    /-\	        /-\
+#   |Consumer|<---->| |<------->| |
+#   \--------/	    \-/	        \-/
+#       ^   	     ^ 	         ^
+#       |            |           |   1Mbps/10ms delay
+#       v            v           v
+#      /-\          /-\         /-\
+#      | |<-------->| |<------->| |
+#      \-/          \-/         \-/
+#       ^   	     ^ 	         ^
+#       |            |           |
+#       v            v           v
+#      /-\	    /-\	     /--------\
+#      | |<-------->| |<---->|Producer|
+#      \-/          \-/      \--------/
+
+# any empty lines and lines starting with '#' symbol is ignored
+#
+# The file should contain exactly two sections: router and link, each starting with the corresponding keyword
+#
+# router section defines topology nodes and their relative positions (e.g., to use in visualizer)
+router
+
+# each line in this section represents one router and should have the following data
+# node  comment     yPos    xPos
+Node0   NA          3       1
+Node1   NA          3       2
+Node2   NA          3       3
+Node3   NA          2       1
+Node4   NA          2       2
+Node5   NA          2       3
+Node6   NA          1       1
+Node7   NA          1       2
+Node8   NA          1       3
+# Note that `node` can be any string. It is possible to access to the node by name using Names::Find, see examples.
+
+# link section defines point-to-point links between nodes and characteristics of these links
+link
+
+# Each line should be in the following format (only first two are required, the rest can be omitted)
+# srcNode   dstNode     bandwidth   metric  delay   queue
+# bandwidth: link bandwidth
+# metric: routing metric
+# delay:  link delay
+# queue:  MaxPackets for transmission queue on the link (both directions)
+# error:  comma-separated list, specifying class for ErrorModel and necessary attributes
+Node0       Node1       1Mbps       1       10ms    10      ns3::RateErrorModel,ErrorUnit=ERROR_UNIT_PACKET,ErrorRate=0.9
+Node0       Node3       1Mbps       1       10ms    10
+Node1       Node2       1Mbps       1       10ms    10
+Node1       Node4       1Mbps       1       10ms    10
+Node2       Node5       1Mbps       1       10ms    10
+Node3       Node4       1Mbps       1       10ms    10
+Node3       Node6       1Mbps       1       10ms    10
+Node4       Node5       1Mbps       1       10ms    10
+Node4       Node7       1Mbps       1       10ms    10
+Node5       Node8       1Mbps       1       10ms    10
+Node6       Node7       1Mbps       1       10ms    10
+Node7       Node8       1Mbps       1       10ms    10
+
diff --git a/examples/wscript b/examples/wscript
index c7868f5..695e17c 100644
--- a/examples/wscript
+++ b/examples/wscript
@@ -24,6 +24,9 @@
         obj = bld.create_ns3_program('ndn-grid-topo-plugin', ['ndnSIM'])
         obj.source = 'ndn-grid-topo-plugin.cc'
 
+        obj = bld.create_ns3_program('ndn-grid-topo-plugin-loss', ['ndnSIM'])
+        obj.source = 'ndn-grid-topo-plugin-loss.cc'
+
         obj = bld.create_ns3_program('ndn-congestion-topo-plugin', ['ndnSIM'])
         obj.source = 'ndn-congestion-topo-plugin.cc'