186 NS_LOG_FUNCTION(
this << userCount);
190 NS_FATAL_ERROR(
"User count is zero!!!");
193 InternetStackHelper internet;
196 users.Create(userCount);
197 NodeContainer utUsers = NodeContainer(ut, users);
199 internet.Install(users);
202 Ipv4InterfaceContainer addresses =
m_ipv4Ut.Assign(nd);
203 Ipv4StaticRoutingHelper ipv4RoutingHelper;
205 for (NodeContainer::Iterator i = users.Begin(); i != users.End(); i++)
208 std::pair<std::map<Ptr<Node>, Ptr<Node>>::iterator,
bool> ret =
209 m_utMap.insert(std::make_pair(*i, ut));
210 NS_ASSERT(ret.second);
213 NS_ASSERT_MSG((*i)->GetNDevices() == 2,
214 "Failed to get the device to subscriber network in UT user node "
217 Ptr<NetDevice> dev = (*i)->GetDevice(1);
218 Singleton<SatIdMapper>::Get()->AttachMacToUtUserId(dev->GetAddress());
221 Ptr<Ipv4> ipv4 = (*i)->GetObject<Ipv4>();
224 Ptr<Ipv4StaticRouting> routing = ipv4RoutingHelper.GetStaticRouting(ipv4);
225 routing->SetDefaultRoute(addresses.GetAddress(0), 1);
226 NS_LOG_INFO(
"User default route: " << addresses.GetAddress(0));
231 for (NodeContainer::Iterator it = users.Begin(); it != users.End(); it++)
233 Singleton<SatTopology>::Get()->AddUtUserNode(*it, ut);
242 NS_LOG_FUNCTION(
this << userCount);
244 InternetStackHelper internet;
255 users.Create(userCount);
256 NodeContainer routerUsers = NodeContainer(
m_router, users);
258 internet.Install(users);
261 Ipv4InterfaceContainer addresses =
m_ipv4Gw.Assign(nd);
262 Ipv4StaticRoutingHelper ipv4RoutingHelper;
264 Ptr<Ipv4> ipv4Router =
m_router->GetObject<Ipv4>();
265 uint32_t lastRouterIf = ipv4Router->GetNInterfaces() - 1;
266 Ptr<Ipv4StaticRouting> routingRouter = ipv4RoutingHelper.GetStaticRouting(ipv4Router);
267 routingRouter->SetDefaultRoute(addresses.GetAddress(1), lastRouterIf);
268 NS_LOG_INFO(
"Router default route: " << addresses.GetAddress(1));
270 for (NodeContainer::Iterator i = users.Begin(); i != users.End(); i++)
273 NS_ASSERT_MSG((*i)->GetNDevices() == 2,
274 "Failed to get the device to backbone network in GW user node "
277 Ptr<NetDevice> dev = (*i)->GetDevice(1);
278 Singleton<SatIdMapper>::Get()->AttachMacToGwUserId(dev->GetAddress());
281 Ptr<Ipv4> ipv4 = (*i)->GetObject<Ipv4>();
284 Ptr<Ipv4StaticRouting> routing = ipv4RoutingHelper.GetStaticRouting(ipv4);
285 routing->SetDefaultRoute(addresses.GetAddress(0), 1);
286 NS_LOG_INFO(
"User default route: " << addresses.GetAddress(0));
288 Singleton<SatTopology>::Get()->AddGwUserNode(*i);
325 NS_LOG_FUNCTION(
this);
327 NodeContainer gwNodes = Singleton<SatTopology>::Get()->GetGwNodes();
329 for (NodeContainer::Iterator i = gwNodes.Begin(); i != gwNodes.End(); i++)
331 NodeContainer gwRouter = NodeContainer((*i), router);
334 Ipv4InterfaceContainer addresses =
m_ipv4Gw.Assign(nd);
335 Ipv4StaticRoutingHelper ipv4RoutingHelper;
338 Ptr<Ipv4> ipv4Gw = (*i)->GetObject<Ipv4>();
339 uint32_t lastGwIf = ipv4Gw->GetNInterfaces() - 1;
340 Ptr<Ipv4StaticRouting> routingGw = ipv4RoutingHelper.GetStaticRouting(ipv4Gw);
341 routingGw->SetDefaultRoute(addresses.GetAddress(1), lastGwIf);
342 NS_LOG_INFO(
"GW default route: " << addresses.GetAddress(1));
344 for (uint32_t routeIndex = 0; routeIndex < routingGw->GetNRoutes(); routeIndex++)
347 Ptr<Ipv4> ipv4Router = router->GetObject<Ipv4>();
348 uint32_t lastRouterIf = ipv4Router->GetNInterfaces() - 1;
349 Ptr<Ipv4StaticRouting> routingRouter = ipv4RoutingHelper.GetStaticRouting(ipv4Router);
351 Ipv4RoutingTableEntry route = routingGw->GetRoute(routeIndex);
352 uint32_t
interface = route.GetInterface();
355 if ((interface != 0) && (interface != lastGwIf))
357 routingRouter->AddNetworkRouteTo(route.GetDest(),
358 route.GetDestNetworkMask(),
359 addresses.GetAddress(0),
361 NS_LOG_INFO(
"Router network route:" << route.GetDest() <<
", "
362 << route.GetDestNetworkMask() <<
", "
363 << addresses.GetAddress(0));
479 NetDeviceContainer utNd,
483 Ipv4InterfaceContainer gwAddress =
m_ipv4Beam.Assign(gwNd);
484 Ipv4Address gwAddr = gwAddress.GetAddress(0);
485 NS_LOG_FUNCTION(
this << gw << gwNd << gwAddr);
487 Ipv4InterfaceContainer utIfs =
m_ipv4Beam.Assign(utNd);
489 Ipv4StaticRoutingHelper ipv4RoutingHelper;
490 Ptr<Ipv4L3Protocol> ipv4Gw = gw->GetObject<Ipv4L3Protocol>();
491 Ptr<Ipv4StaticRouting> srGw = ipv4RoutingHelper.GetStaticRouting(ipv4Gw);
494 m_gwDevices.insert(std::make_pair(gwNd->GetAddress(), gwNd));
497 Address macAddressGw = gwNd->GetAddress();
498 Ptr<SatArpCache> utArpCache = CreateObject<SatArpCache>();
499 utArpCache->Add(gwAddr, macAddressGw);
500 NS_LOG_INFO(
"UT ARP entry: " << gwAddr <<
" - " << macAddressGw);
506 Ptr<SatArpCache> gwArpCache = CreateObject<SatArpCache>();
507 for (uint32_t i = 0; i < utIfs.GetN(); ++i)
509 NS_ASSERT(utIfs.GetN() == utNd.GetN());
510 Ptr<NetDevice> nd = utNd.Get(i);
511 Ipv4Address ipv4Addr = utIfs.GetAddress(i);
512 gwArpCache->Add(ipv4Addr, nd->GetAddress());
513 NS_LOG_INFO(
"GW ARP entry: " << ipv4Addr <<
" - " << nd->GetAddress());
515 m_utDevices.insert(std::make_pair(nd->GetAddress(), nd));
520 ipv4Gw->GetInterface(gwNd->GetIfIndex())->SetArpCache(gwArpCache);
521 NS_LOG_INFO(
"Add ARP cache to GW " << gw->GetId());
523 uint32_t utAddressIndex = 0;
525 for (NodeContainer::Iterator i = ut.Begin(); i != ut.End(); i++)
527 Ptr<Ipv4L3Protocol> ipv4Ut = (*i)->GetObject<Ipv4L3Protocol>();
529 uint32_t count = ipv4Ut->GetNInterfaces();
531 for (uint32_t j = 1; j < count; j++)
533 std::string devName = ipv4Ut->GetNetDevice(j)->GetInstanceTypeId().GetName();
536 if (devName ==
"ns3::SatNetDevice" || devName ==
"ns3::SatLorawanNetDevice")
538 Ptr<Ipv4StaticRouting> srUt = ipv4RoutingHelper.GetStaticRouting(ipv4Ut);
539 srUt->SetDefaultRoute(gwAddr, j);
540 NS_LOG_INFO(
"UT default route: " << gwAddr);
543 ipv4Ut->GetInterface(j)->SetArpCache(utArpCache);
544 NS_LOG_INFO(
"Add the ARP cache to UT " << (*i)->GetId());
548 Ipv4Address address = ipv4Ut->GetAddress(j, 0).GetLocal();
549 Ipv4Mask mask = ipv4Ut->GetAddress(j, 0).GetMask();
551 srGw->AddNetworkRouteTo(address.CombineMask(mask),
553 utIfs.GetAddress(utAddressIndex),
555 NS_LOG_INFO(
"GW Network route: " << address.CombineMask(mask) <<
", " << mask
556 <<
", " << utIfs.GetAddress(utAddressIndex));
569 NS_LOG_FUNCTION(
this << utAddress << gwAddress);
571 std::map<Address, Ptr<NetDevice>>::iterator gwNdIterator =
m_gwDevices.find(gwAddress);
572 NS_ASSERT_MSG(gwNdIterator !=
m_gwDevices.end(),
"Unknown GW with MAC address " << gwAddress);
574 Ptr<SatNetDevice> gwNd = DynamicCast<SatNetDevice>(gwNdIterator->second);
575 NS_ASSERT(gwNd !=
nullptr);
577 gwNd->GetNode()->GetObject<Ipv4L3Protocol>()->GetAddress(gwNd->GetIfIndex(), 0).GetLocal();
579 std::map<Address, Ptr<NetDevice>>::iterator utNdIterator =
m_utDevices.find(utAddress);
580 NS_ASSERT_MSG(utNdIterator !=
m_utDevices.end(),
"Unknown UT with MAC address " << utAddress);
582 std::map<Address, Ptr<SatArpCache>>::iterator arpCacheIterator =
585 "ARP cache not found to gateway " << gwAddress);
587 Ptr<SatNetDevice> utNd = DynamicCast<SatNetDevice>(utNdIterator->second);
588 NS_ASSERT(utNd !=
nullptr);
589 Ptr<Ipv4L3Protocol> protocol = utNd->GetNode()->GetObject<Ipv4L3Protocol>();
590 uint32_t utIfIndex = utNdIterator->second->GetIfIndex();
592 NS_LOG_INFO(
"Changing ARP cache for UT " << utAddress <<
" pointing to " << ip <<
" through "
594 protocol->GetInterface(utIfIndex)->SetArpCache(arpCacheIterator->second);
596 Ipv4StaticRoutingHelper ipv4RoutingHelper;
597 Ptr<Ipv4StaticRouting> routing = ipv4RoutingHelper.GetStaticRouting(protocol);
598 routing->RemoveRoute(routing->GetNRoutes() - 1);
599 routing->SetDefaultRoute(ip, utIfIndex);
601 NS_LOG_INFO(
"Set default route on UT to " << ip);
603 uint32_t satId = gwNd->GetMac()->GetSatId();
604 uint32_t beamId = gwNd->GetMac()->GetBeamId();
605 Ptr<PropagationDelayModel> flDelayModel =
607 Ptr<PropagationDelayModel> ulDelayModel =
618 NS_LOG_FUNCTION(
this << ut << oldGateway << newGateway);
620 std::map<Address, Ptr<NetDevice>>::iterator utNdIterator =
m_utDevices.find(ut);
623 NS_FATAL_ERROR(
"Unknown UT with MAC address " << ut);
626 std::map<Address, Ptr<NetDevice>>::iterator oldGwNdIterator =
m_gwDevices.find(oldGateway);
629 NS_FATAL_ERROR(
"Unknown GW with MAC address " << oldGateway);
632 std::map<Address, Ptr<NetDevice>>::iterator newGwNdIterator =
m_gwDevices.find(newGateway);
635 NS_FATAL_ERROR(
"Unknown GW with MAC address " << newGateway);
638 uint32_t utIfIndex = utNdIterator->second->GetIfIndex();
639 Ptr<Ipv4L3Protocol> utProtocol = utNdIterator->second->GetNode()->GetObject<Ipv4L3Protocol>();
640 Ipv4Address utIpAddress = utProtocol->GetAddress(utIfIndex, 0).GetLocal();
642 Ptr<Node> oldGatewayNode = oldGwNdIterator->second->GetNode();
643 uint32_t oldIfIndex = oldGwNdIterator->second->GetIfIndex();
644 Ptr<Node> newGatewayNode = newGwNdIterator->second->GetNode();
645 uint32_t newIfIndex = newGwNdIterator->second->GetIfIndex();
647 Ptr<ArpCache> arpCache;
649 arpCache = oldGatewayNode->GetObject<Ipv4L3Protocol>()->GetInterface(oldIfIndex)->GetArpCache();
650 for (ArpCache::Entry* entry : arpCache->LookupInverse(ut))
652 arpCache->Remove(entry);
655 arpCache = newGatewayNode->GetObject<Ipv4L3Protocol>()->GetInterface(newIfIndex)->GetArpCache();
656 ArpCache::Entry* entry = arpCache->Add(utIpAddress);
657 entry->SetMacAddress(ut);
658 entry->MarkPermanent();
661 Ipv4StaticRoutingHelper ipv4RoutingHelper;
662 if (oldGatewayNode == newGatewayNode)
665 Ptr<Ipv4StaticRouting> routing =
666 ipv4RoutingHelper.GetStaticRouting(oldGatewayNode->GetObject<Ipv4L3Protocol>());
669 for (uint32_t routeIndex = routing->GetNRoutes(); routeIndex > 0; --routeIndex)
672 if (routing->GetRoute(routeIndex - 1).GetGateway() == utIpAddress)
674 routing->RemoveRoute(routeIndex - 1);
679 for (uint32_t ifIndex = 1; ifIndex < utProtocol->GetNInterfaces(); ++ifIndex)
681 Ipv4Address address = utProtocol->GetAddress(ifIndex, 0).GetLocal();
682 Ipv4Mask mask = utProtocol->GetAddress(ifIndex, 0).GetMask();
684 if (ifIndex == utIfIndex)
686 mask = Ipv4Mask(
"/32");
689 routing->AddNetworkRouteTo(address.CombineMask(mask), mask, utIpAddress, newIfIndex);
695 Ptr<Ipv4StaticRouting> routing =
696 ipv4RoutingHelper.GetStaticRouting(oldGatewayNode->GetObject<Ipv4L3Protocol>());
697 Ptr<Ipv4StaticRouting> routingRouter =
698 ipv4RoutingHelper.GetStaticRouting(
m_router->GetObject<Ipv4L3Protocol>());
701 for (uint32_t routeIndex = routing->GetNRoutes(); routeIndex > 0; --routeIndex)
704 Ipv4RoutingTableEntry gwRoute = routing->GetRoute(routeIndex - 1);
705 if (gwRoute.GetGateway() == utIpAddress)
707 routing->RemoveRoute(routeIndex - 1);
709 for (uint32_t routerIndex = 0; routerIndex < routingRouter->GetNRoutes();
712 Ipv4RoutingTableEntry route = routingRouter->GetRoute(routerIndex);
713 if (route.GetDestNetwork() == gwRoute.GetDestNetwork() &&
714 route.GetDestNetworkMask() == gwRoute.GetDestNetworkMask())
716 routingRouter->RemoveRoute(routerIndex);
724 Ptr<Ipv4L3Protocol> gwProtocol = newGatewayNode->GetObject<Ipv4L3Protocol>();
727 Ipv4Address gwAddress;
728 for (uint32_t ifIndex = 1; ifIndex < gwProtocol->GetNInterfaces(); ++ifIndex)
730 Ptr<NetDevice> gwNd = gwProtocol->GetNetDevice(ifIndex);
731 if (gwNd->GetInstanceTypeId().GetName() !=
"ns3::SatNetDevice" &&
732 gwNd->GetInstanceTypeId().GetName() !=
"ns3::SatLorawanNetDevice")
734 gwAddress = gwProtocol->GetAddress(ifIndex, 0).GetLocal();
740 uint32_t routingIfIndex = routingRouter->GetNRoutes();
741 for (uint32_t routeIndex = 0; routeIndex < routingRouter->GetNRoutes(); ++routeIndex)
743 Ipv4RoutingTableEntry route = routingRouter->GetRoute(routeIndex);
744 if (route.GetGateway() == gwAddress)
746 routingIfIndex = route.GetInterface();
751 NS_ASSERT_MSG(routingIfIndex != routingRouter->GetNRoutes(),
752 "Couldn't find interface on the terrestrial router to the new gateway.");
755 routing = ipv4RoutingHelper.GetStaticRouting(gwProtocol);
756 for (uint32_t ifIndex = 1; ifIndex < utProtocol->GetNInterfaces(); ++ifIndex)
758 Ipv4Address address = utProtocol->GetAddress(ifIndex, 0).GetLocal();
759 Ipv4Mask mask = utProtocol->GetAddress(ifIndex, 0).GetMask();
761 if (ifIndex == utIfIndex)
763 mask = Ipv4Mask(
"/32");
766 routing->AddNetworkRouteTo(address.CombineMask(mask), mask, utIpAddress, newIfIndex);
767 routingRouter->AddNetworkRouteTo(address.CombineMask(mask),
void SetCsmaQueue(std::string type, std::string name1="", const AttributeValue &value1=EmptyAttributeValue(), std::string name2="", const AttributeValue &value2=EmptyAttributeValue(), std::string name3="", const AttributeValue &value3=EmptyAttributeValue(), std::string name4="", const AttributeValue &value4=EmptyAttributeValue())
Set the type and the attribute values to be associated with each Queue object in each CsmaNetDevice c...