ndn-link-control-helper: Fixing bug during link failure

Change-Id: I6dbc5cf4d68679bd6f943322f572313884c8aed2
Refs: #2783
diff --git a/helper/ndn-link-control-helper.cpp b/helper/ndn-link-control-helper.cpp
index 3951daf..09137bf 100644
--- a/helper/ndn-link-control-helper.cpp
+++ b/helper/ndn-link-control-helper.cpp
@@ -74,16 +74,20 @@
     if (nd2->GetNode() == node1)
       nd2 = ppChannel->GetDevice(1);
 
-    ObjectFactory errorFactory("ns3::RateErrorModel");
-    errorFactory.Set("ErrorUnit", StringValue("ERROR_UNIT_PACKET"));
-    errorFactory.Set("ErrorRate", DoubleValue(errorRate));
-    if (errorRate <= 0) {
-      errorFactory.Set("IsEnabled", BooleanValue(false));
-    }
+    if (nd2->GetNode() == node2) {
+      ObjectFactory errorFactory("ns3::RateErrorModel");
+      errorFactory.Set("ErrorUnit", StringValue("ERROR_UNIT_PACKET"));
+      errorFactory.Set("ErrorRate", DoubleValue(errorRate));
+      if (errorRate <= 0) {
+        errorFactory.Set("IsEnabled", BooleanValue(false));
+      }
 
-    nd1->SetAttribute("ReceiveErrorModel", PointerValue(errorFactory.Create<ErrorModel>()));
-    nd2->SetAttribute("ReceiveErrorModel", PointerValue(errorFactory.Create<ErrorModel>()));
+      nd1->SetAttribute("ReceiveErrorModel", PointerValue(errorFactory.Create<ErrorModel>()));
+      nd2->SetAttribute("ReceiveErrorModel", PointerValue(errorFactory.Create<ErrorModel>()));
+      return;
+    }
   }
+  NS_FATAL_ERROR("There is no link to fail between the requested nodes");
 }
 
 void