src/devices/point-to-point/point-to-point-topology.cc
changeset 2231 a5b898c1ee2c
parent 2230 9f13ac3291e0
child 2257 71a58e70c671
equal deleted inserted replaced
2230:9f13ac3291e0 2231:a5b898c1ee2c
   109       std::swap(nd1, nd2);
   109       std::swap(nd1, nd2);
   110     }
   110     }
   111   NS_ASSERT (nd1->GetNode ()->GetId () == n1->GetId ());
   111   NS_ASSERT (nd1->GetNode ()->GetId () == n1->GetId ());
   112   NS_ASSERT (nd2->GetNode ()->GetId () == n2->GetId ());
   112   NS_ASSERT (nd2->GetNode ()->GetId () == n2->GetId ());
   113   
   113   
   114   Ptr<Ipv4> ip1 = n1->QueryInterface<Ipv4> (Ipv4::iid);
   114   Ptr<Ipv4> ip1 = n1->QueryInterface<Ipv4> ();
   115   uint32_t index1 = ip1->AddInterface (nd1);
   115   uint32_t index1 = ip1->AddInterface (nd1);
   116 
   116 
   117   ip1->SetAddress (index1, addr1);
   117   ip1->SetAddress (index1, addr1);
   118   ip1->SetNetworkMask (index1, netmask);
   118   ip1->SetNetworkMask (index1, netmask);
   119   ip1->SetUp (index1);
   119   ip1->SetUp (index1);
   120 
   120 
   121   Ptr<Ipv4> ip2 = n2->QueryInterface<Ipv4> (Ipv4::iid);
   121   Ptr<Ipv4> ip2 = n2->QueryInterface<Ipv4> ();
   122   uint32_t index2 = ip2->AddInterface (nd2);
   122   uint32_t index2 = ip2->AddInterface (nd2);
   123 
   123 
   124   ip2->SetAddress (index2, addr2);
   124   ip2->SetAddress (index2, addr2);
   125   ip2->SetNetworkMask (index2, netmask);
   125   ip2->SetNetworkMask (index2, netmask);
   126   ip2->SetUp (index2);
   126   ip2->SetUp (index2);
   151   // through the NetDevices until we find the Ipv4 ifIndex
   151   // through the NetDevices until we find the Ipv4 ifIndex
   152   // that corresponds to NetDevice nd1
   152   // that corresponds to NetDevice nd1
   153   // Get interface indexes for both nodes corresponding to the right channel
   153   // Get interface indexes for both nodes corresponding to the right channel
   154   uint32_t index = 0;
   154   uint32_t index = 0;
   155   bool found = false;
   155   bool found = false;
   156   Ptr<Ipv4> ip1 = n1->QueryInterface<Ipv4> (Ipv4::iid);
   156   Ptr<Ipv4> ip1 = n1->QueryInterface<Ipv4> ();
   157   for (uint32_t i = 0; i < ip1->GetNInterfaces (); i++)
   157   for (uint32_t i = 0; i < ip1->GetNInterfaces (); i++)
   158     {
   158     {
   159       if (ip1 ->GetNetDevice (i) == nd1)
   159       if (ip1 ->GetNetDevice (i) == nd1)
   160         {
   160         {
   161           index = i;
   161           index = i;
   165   NS_ASSERT(found);
   165   NS_ASSERT(found);
   166   ip1->SetMetric (index, metric);
   166   ip1->SetMetric (index, metric);
   167 
   167 
   168   index = 0;
   168   index = 0;
   169   found = false;
   169   found = false;
   170   Ptr<Ipv4> ip2 = n2->QueryInterface<Ipv4> (Ipv4::iid);
   170   Ptr<Ipv4> ip2 = n2->QueryInterface<Ipv4> ();
   171   for (uint32_t i = 0; i < ip2->GetNInterfaces (); i++)
   171   for (uint32_t i = 0; i < ip2->GetNInterfaces (); i++)
   172     {
   172     {
   173       if (ip2 ->GetNetDevice (i) == nd2)
   173       if (ip2 ->GetNetDevice (i) == nd2)
   174         {
   174         {
   175           index = i;
   175           index = i;
   210     {
   210     {
   211       NS_FATAL_ERROR("P2PTopo: Node does not contain an interface on Channel");
   211       NS_FATAL_ERROR("P2PTopo: Node does not contain an interface on Channel");
   212     }
   212     }
   213 
   213 
   214   // Assert that both are Ipv4 nodes
   214   // Assert that both are Ipv4 nodes
   215   Ptr<Ipv4> ip1 = nd1->GetNode ()->QueryInterface<Ipv4> (Ipv4::iid);
   215   Ptr<Ipv4> ip1 = nd1->GetNode ()->QueryInterface<Ipv4> ();
   216   Ptr<Ipv4> ip2 = nd2->GetNode ()->QueryInterface<Ipv4> (Ipv4::iid);
   216   Ptr<Ipv4> ip2 = nd2->GetNode ()->QueryInterface<Ipv4> ();
   217   NS_ASSERT(ip1 != 0 && ip2 != 0);
   217   NS_ASSERT(ip1 != 0 && ip2 != 0);
   218 
   218 
   219   // Get interface indexes for both nodes corresponding to the right channel
   219   // Get interface indexes for both nodes corresponding to the right channel
   220   uint32_t index1 = 0;
   220   uint32_t index1 = 0;
   221   bool found = false;
   221   bool found = false;