21 #include "ns3/object-factory.h"
23 #include "ns3/dce-application-helper.h"
24 #include "ns3/names.h"
25 #include "ns3/linux-socket-fd-factory.h"
59 static TypeId tid = TypeId (
"ns3::Mip6dConfig")
61 .AddConstructor<Mip6dConfig> ()
98 os <<
"# IPsec configuration - NO IPSEC AT THE MOMENT" << std::endl
99 <<
"UseMnHaIPsec disabled;" << std::endl
100 <<
"KeyMngMobCapability disabled;" << std::endl
101 <<
"# EOF" << std::endl;
124 for (uint32_t i = 0; i < nodes.GetN (); i++)
126 Ptr<Mip6dConfig> mip6d_conf = nodes.Get (i)->GetObject<
Mip6dConfig> ();
129 mip6d_conf = CreateObject<Mip6dConfig> ();
130 nodes.Get (i)->AggregateObject (mip6d_conf);
135 Simulator::ScheduleWithContext (nodes.Get (i)->GetId (), Seconds (0.1),
137 ".net.ipv6.conf.all.forwarding",
"1"));
138 Simulator::ScheduleWithContext (nodes.Get (i)->GetId (), Seconds (0.1),
140 ".net.ipv6.conf.all.proxy_ndp",
"1"));
148 Ipv6Address prefix, Ipv6Prefix plen)
150 Ptr<Mip6dConfig> mip6d_conf = node->GetObject<
Mip6dConfig> ();
153 mip6d_conf = CreateObject<Mip6dConfig> ();
154 node->AggregateObject (mip6d_conf);
157 std::ostringstream oss;
159 oss <<
"/" << (uint32_t)plen.GetPrefixLength ();
161 mip6d_conf->m_ha_served_pfx = oss.str ();
171 for (uint32_t i = 0; i < nodes.GetN (); i++)
173 Ptr<Mip6dConfig> mip6d_conf = nodes.Get (i)->GetObject<
Mip6dConfig> ();
176 mip6d_conf = CreateObject<Mip6dConfig> ();
177 nodes.Get (i)->AggregateObject (mip6d_conf);
182 Simulator::ScheduleWithContext (nodes.Get (i)->GetId (), Seconds (0.1),
184 ".net.ipv6.conf.all.forwarding",
"1"));
192 Ipv6Address prefix, Ipv6Prefix plen)
194 Ptr<Mip6dConfig> mip6d_conf = node->GetObject<
Mip6dConfig> ();
197 mip6d_conf = CreateObject<Mip6dConfig> ();
198 node->AggregateObject (mip6d_conf);
201 std::ostringstream oss;
203 oss <<
"/" << (uint32_t)plen.GetPrefixLength ();
205 mip6d_conf->m_mr_mobile_pfx->push_back (oss.str ());
213 Ptr<Mip6dConfig> mip6d_conf = node->GetObject<
Mip6dConfig> ();
216 mip6d_conf = CreateObject<Mip6dConfig> ();
217 node->AggregateObject (mip6d_conf);
228 Ptr<Mip6dConfig> mip6d_conf = node->GetObject<
Mip6dConfig> ();
231 mip6d_conf = CreateObject<Mip6dConfig> ();
232 node->AggregateObject (mip6d_conf);
235 std::ostringstream oss;
237 mip6d_conf->m_mn_ha_addr = oss.str ();
244 Ipv6Address addr, Ipv6Prefix plen)
246 Ptr<Mip6dConfig> mip6d_conf = node->GetObject<
Mip6dConfig> ();
249 mip6d_conf = CreateObject<Mip6dConfig> ();
250 node->AggregateObject (mip6d_conf);
253 std::ostringstream oss;
255 oss <<
"/" << (uint32_t)plen.GetPrefixLength ();
256 mip6d_conf->m_mr_home_addr = oss.str ();
265 Ptr<Mip6dConfig> mip6d_conf = node->GetObject<
Mip6dConfig>();
268 mip6d_conf = CreateObject<Mip6dConfig> ();
269 node->AggregateObject (mip6d_conf);
273 mip6d_conf->m_lma_mag_ifname = ifname;
279 const char *ifname, Ipv6Address addr)
281 Ptr<Mip6dConfig> mip6d_conf = node->GetObject<
Mip6dConfig>();
284 mip6d_conf = CreateObject<Mip6dConfig> ();
285 node->AggregateObject (mip6d_conf);
289 std::ostringstream oss;
291 mip6d_conf->m_mag_egress_gaddr = oss.str ();
292 mip6d_conf->m_mag_egress_ifname = ifname;
297 Ipv6Address lma_addr,
298 Ipv6Address home_pfx, Ipv6Prefix home_plen)
300 Ptr<Mip6dConfig> mip6d_conf = node->GetObject<
Mip6dConfig>();
303 mip6d_conf = CreateObject<Mip6dConfig> ();
304 node->AggregateObject (mip6d_conf);
307 std::ostringstream oss;
314 lma_addr.Print (oss);
318 home_pfx.Print (oss);
319 oss <<
"/" << (uint32_t)home_plen.GetPrefixLength ();
322 mip6d_conf->m_mag_mn_profiles->push_back (profile);
331 for (uint32_t i = 0; i < nodes.GetN (); i++)
333 Ptr<Mip6dConfig> mip6d_conf = nodes.Get (i)->GetObject<
Mip6dConfig> ();
336 mip6d_conf = CreateObject<Mip6dConfig> ();
337 nodes.Get (i)->AggregateObject (mip6d_conf);
348 for (uint32_t i = 0; i < nodes.GetN (); i++)
350 Ptr<Mip6dConfig> mip6d_conf = nodes.Get (i)->GetObject<
Mip6dConfig> ();
353 mip6d_conf = CreateObject<Mip6dConfig> ();
354 nodes.Get (i)->AggregateObject (mip6d_conf);
364 for (uint32_t i = 0; i < nodes.GetN (); i++)
366 Ptr<Mip6dConfig> mip6d_conf = nodes.Get (i)->GetObject<
Mip6dConfig> ();
370 nodes.Get (i)->AggregateObject (mip6d_conf);
372 mip6d_conf->m_usemanualconf =
true;
380 for (uint32_t i = 0; i < nodes.GetN (); i++)
382 Ptr<Mip6dConfig> mip6d_conf = nodes.Get (i)->GetObject<
Mip6dConfig> ();
386 nodes.Get (i)->AggregateObject (mip6d_conf);
388 mip6d_conf->m_binary = binary;
396 Ptr<Mip6dConfig> mip6d_conf = node->GetObject<
Mip6dConfig> ();
398 if (mip6d_conf->m_usemanualconf)
404 std::stringstream conf_dir, conf_file;
406 conf_dir <<
"files-" << node->GetId () <<
"";
407 ::mkdir (conf_dir.str ().c_str (), S_IRWXU | S_IRWXG);
409 ::mkdir (conf_dir.str ().c_str (), S_IRWXU | S_IRWXG);
411 conf_file << conf_dir.str () <<
"/mip6d.conf";
413 conf.open (conf_file.str ().c_str ());
415 if (mip6d_conf->m_haenable)
417 conf <<
"NodeConfig HA;" << std::endl
418 <<
"Interface \"sim0\";" << std::endl
419 <<
"HaAcceptMobRtr enabled;" << std::endl
420 <<
"#BindingAclPolicy 2001:1:2:3::1000 (2001:1:2:5::/64) allow;" << std::endl
421 <<
"DefaultBindingAclPolicy allow;" << std::endl;
423 if (!mip6d_conf->m_lma_mag_ifname.empty ())
424 conf <<
"LMAInterfaceMAG \"" << mip6d_conf->
m_lma_mag_ifname <<
"\";" << std::endl;
426 if (!mip6d_conf->m_ha_served_pfx.empty ())
427 conf <<
"HaServedPrefix " << mip6d_conf->m_ha_served_pfx <<
";" << std::endl;
429 if (mip6d_conf->m_dsmip6enable)
431 conf <<
"HaAcceptDsmip6 enabled;" << std::endl;
433 if (mip6d_conf->m_dsmip6enable)
435 conf <<
"# The IPv4 address of the HA or the HA name can be given." << std::endl;
436 conf <<
"HomeAgentV4Address 192.168.10.1;" << std::endl;
440 else if (mip6d_conf->m_magenable)
442 conf <<
"NodeConfig MN;" << std::endl
443 <<
"DoRouteOptimizationCN disabled;" << std::endl
444 <<
"DoRouteOptimizationMN disabled;" << std::endl
445 <<
"UseCnBuAck disabled;" << std::endl
446 <<
"OptimisticHandoff enabled;" << std::endl
447 <<
"MnMaxHaBindingLife 60;" << std::endl;
449 conf <<
"MAGInterfaceLMA \"" << mip6d_conf->m_mag_egress_ifname <<
"\";" << std::endl;
450 conf <<
"MAGEgressGlobalAddress " << mip6d_conf->m_mag_egress_gaddr <<
";" << std::endl;
453 for (std::vector<Mip6dConfig::pmipMNprofile_t>::iterator i = mip6d_conf->m_mag_mn_profiles->begin ();
454 i != mip6d_conf->m_mag_mn_profiles->end (); ++i)
456 conf <<
"MNIdentifier \"" << (*i).m_mn_id <<
"\" {" << std::endl;
457 conf <<
" PMIPEnabled 1;" << std::endl;
458 conf <<
" LMAAddress " << (*i).m_lma_addr <<
";" << std::endl;
459 conf <<
" HomeNetworkPrefix1 " << (*i).m_home_prefix <<
";" << std::endl;
460 conf <<
" PMIPInterface1 \"sim0(XXX)\";" << std::endl;
461 conf <<
" HomePrefixLifetime 460.0;" << std::endl;
462 conf <<
"}" << std::endl;
468 if (mip6d_conf->m_dsmip6enable)
470 conf <<
"MnUseDsmip6 enabled;" << std::endl;
473 conf <<
"NodeConfig MN;" << std::endl
474 <<
"DoRouteOptimizationCN enabled;" << std::endl
475 <<
"DoRouteOptimizationMN disabled;" << std::endl
476 <<
"UseCnBuAck disabled;" << std::endl
477 <<
"MnDiscardHaParamProb enabled;" << std::endl
478 <<
"MobRtrUseExplicitMode enabled;" << std::endl;
480 for (std::vector<std::string>::iterator i = mip6d_conf->m_mr_egress_if->begin ();
481 i != mip6d_conf->m_mr_egress_if->end (); ++i)
483 if (mip6d_conf->m_dsmip6enable)
485 conf <<
"Interface \"" << (*i) <<
"\"{" << std::endl;
486 conf <<
" # Specify if this interface should use DHCP to get an IPv4 CoA" << std::endl;
487 conf <<
" UseDhcp enabled;" << std::endl;
488 conf <<
"}" << std::endl;
492 conf <<
"Interface \"" << (*i) <<
"\";" << std::endl;
497 conf <<
"MnRouterProbes 1;" << std::endl
498 <<
"MnHomeLink \"sim0\" {" << std::endl;
499 if (mip6d_conf->m_dsmip6enable)
501 conf <<
"# The IPv4 address of the HA or the HA name can be given." << std::endl
502 <<
"# If both are given, the HomeAgentName field is ignored." << std::endl
503 <<
"HomeAgentV4Address 192.168.10.1;" << std::endl
504 <<
"# HomeAgentName <FQDN of the Home Agent>;" << std::endl;
507 if (mip6d_conf->m_mrenable)
509 conf <<
" IsMobRtr enabled;" << std::endl;
511 conf <<
" HomeAgentAddress " << mip6d_conf->m_mn_ha_addr <<
";" << std::endl;
513 conf <<
" HomeAddress " << mip6d_conf->m_mr_home_addr;
515 if (mip6d_conf->m_mrenable)
518 for (std::vector<std::string>::iterator i = mip6d_conf->m_mr_mobile_pfx->begin ();
519 i != mip6d_conf->m_mr_mobile_pfx->end (); ++i)
521 if (i != mip6d_conf->m_mr_mobile_pfx->begin ())
527 conf <<
")" << std::endl;
529 conf <<
";" << std::endl;
530 conf <<
"}" << std::endl;
533 if (mip6d_conf->m_debug)
535 conf <<
"DebugLevel 10;" << std::endl;
553 Ptr<Node> node = Names::Find<Node> (nodeName);
560 ApplicationContainer apps;
561 for (NodeContainer::Iterator i = c.Begin (); i != c.End (); ++i)
573 ApplicationContainer apps;
575 Ptr<Mip6dConfig> mip6d_conf = node->GetObject<
Mip6dConfig> ();
579 node->AggregateObject (mip6d_conf);
584 process.
SetBinary (mip6d_conf->m_binary);
587 apps.Add (process.
Install (node));
588 apps.Get (0)->SetStartTime (Seconds (1.0 + 0.01 * node->GetId ()));
589 node->AddApplication (apps.Get (0));