mirror of
https://gitlab.ibr.cs.tu-bs.de/tschuber/ns-3-leo.git
synced 2025-06-08 18:13:57 +02:00
Prepare ND cache for ground space networks
This commit is contained in:
parent
ed80214449
commit
227ae70a1d
5 changed files with 110 additions and 56 deletions
|
@ -1,4 +1,5 @@
|
|||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
|
||||
#include "ns3/core-module.h"
|
||||
#include "ns3/network-module.h"
|
||||
#include "ns3/internet-module.h"
|
||||
|
@ -6,7 +7,7 @@
|
|||
#include "ns3/node-container.h"
|
||||
#include "ns3/core-module.h"
|
||||
|
||||
#include "../helper/leo-helper.h"
|
||||
#include "ns3/leo-module.h"
|
||||
|
||||
using namespace ns3;
|
||||
|
||||
|
@ -40,17 +41,7 @@ main (int argc, char *argv[])
|
|||
leo.SetChannelAttribute ("PropagationLoss", StringValue ("ns3::IslPropagationLossModel"));
|
||||
leo.SetDeviceAttribute ("MobilityModel", StringValue ("ns3::LeoMobilityModel"));
|
||||
|
||||
NetDeviceContainer devices;
|
||||
devices = leo.Install (satellites, gateways, terminals);
|
||||
|
||||
InternetStackHelper stack;
|
||||
stack.Install (satellites);
|
||||
stack.Install (gateways);
|
||||
stack.Install (terminals);
|
||||
|
||||
// make all devices addressable
|
||||
Ipv6AddressHelper address;
|
||||
Ipv6InterfaceContainer interfaces = address.Assign (devices);
|
||||
leo.Install (satellites, gateways, terminals);
|
||||
|
||||
// we want to ping terminals
|
||||
UdpEchoServerHelper echoServer (9);
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
|
||||
#include "nd-cache-helper.h"
|
||||
|
||||
#include "leo-helper.h"
|
||||
|
||||
namespace ns3 {
|
||||
|
@ -10,35 +12,38 @@ LeoHelper::LeoHelper()
|
|||
|
||||
// TODO use template?
|
||||
NetDeviceContainer
|
||||
LeoHelper::Install (NodeContainer satellites, NodeContainer gateways, NodeContainer terminals)
|
||||
LeoHelper::Install (NodeContainer &satellites, NodeContainer &gateways, NodeContainer &terminals)
|
||||
{
|
||||
NetDeviceContainer container = m_islChannelHelper.Install (satellites);
|
||||
container.Add (m_gwChannelHelper.Install (satellites, gateways));
|
||||
container.Add (m_utChannelHelper.Install (satellites, terminals));
|
||||
NetDeviceContainer container;
|
||||
|
||||
return container;
|
||||
}
|
||||
// Create sets of net devices for individual networks
|
||||
NetDeviceContainer islNet, gwNet, utNet;
|
||||
islNet = m_islChannelHelper.Install (satellites);
|
||||
gwNet = m_gwChannelHelper.Install (satellites, gateways);
|
||||
utNet = m_utChannelHelper.Install (satellites, terminals);
|
||||
|
||||
NetDeviceContainer
|
||||
LeoHelper::Install (std::vector<Ptr<Node> > &satellites,
|
||||
std::vector<Ptr<Node> > &gateways,
|
||||
std::vector<Ptr<Node> > &terminals)
|
||||
{
|
||||
NetDeviceContainer container = m_islChannelHelper.Install (satellites);
|
||||
container.Add (m_gwChannelHelper.Install (satellites, gateways));
|
||||
container.Add (m_utChannelHelper.Install (satellites, terminals));
|
||||
// Install internet stack on nodes
|
||||
InternetStackHelper stack;
|
||||
stack.Install (satellites);
|
||||
stack.Install (gateways);
|
||||
stack.Install (terminals);
|
||||
|
||||
return container;
|
||||
}
|
||||
// Make all networks addressable
|
||||
Ipv6AddressHelper address;
|
||||
Ipv6InterfaceContainer islAddrs = address.Assign (islNet);
|
||||
Ipv6InterfaceContainer gwAddrs = address.Assign (gwNet);
|
||||
Ipv6InterfaceContainer utAddrs = address.Assign (utNet);
|
||||
|
||||
NetDeviceContainer
|
||||
LeoHelper::Install (std::vector<std::string> &satellites,
|
||||
std::vector<std::string> &gateways,
|
||||
std::vector<std::string> &terminals)
|
||||
{
|
||||
NetDeviceContainer container = m_islChannelHelper.Install (satellites);
|
||||
container.Add (m_gwChannelHelper.Install (satellites, gateways));
|
||||
container.Add (m_utChannelHelper.Install (satellites, terminals));
|
||||
// Pre-fill the ND caches of networks
|
||||
NdCacheHelper ndCache;
|
||||
ndCache.Install (islNet, islAddrs);
|
||||
ndCache.Install (gwNet, gwAddrs);
|
||||
ndCache.Install (utNet, utAddrs);
|
||||
|
||||
// Add to resulting container of net devices
|
||||
container.Add (islNet);
|
||||
container.Add (gwNet);
|
||||
container.Add (utNet);
|
||||
|
||||
return container;
|
||||
}
|
||||
|
|
|
@ -53,27 +53,10 @@ public:
|
|||
*
|
||||
* Same is done with each satellite and terminal node.
|
||||
*/
|
||||
NetDeviceContainer Install (NodeContainer satellites, NodeContainer gateways, NodeContainer terminals);
|
||||
NetDeviceContainer Install (NodeContainer &satellites,
|
||||
NodeContainer &gateways,
|
||||
NodeContainer &terminals);
|
||||
|
||||
/**
|
||||
* \param nodes Nodes
|
||||
* \return a NetDeviceContainer for nodes
|
||||
*
|
||||
* Saves you from having to construct a temporary NodeContainer.
|
||||
*/
|
||||
NetDeviceContainer Install (std::vector<Ptr<Node> > &satellites,
|
||||
std::vector<Ptr<Node> > &gateways,
|
||||
std::vector<Ptr<Node> > &terminals);
|
||||
|
||||
/**
|
||||
* \param nodes Names of the nodes
|
||||
* \return a NetDeviceContainer for nodes
|
||||
*
|
||||
* Saves you from having to construct a temporary NodeContainer.
|
||||
*/
|
||||
NetDeviceContainer Install (std::vector<std::string> &satellites,
|
||||
std::vector<std::string> &gateways,
|
||||
std::vector<std::string> &terminals);
|
||||
/**
|
||||
* Each point to point net device must have a queue to pass packets through.
|
||||
* This method allows one to set the type of the queue that is automatically
|
||||
|
|
52
helper/nd-cache-helper.cc
Normal file
52
helper/nd-cache-helper.cc
Normal file
|
@ -0,0 +1,52 @@
|
|||
#include "ns3/core-module.h"
|
||||
#include "ns3/network-module.h"
|
||||
#include "ns3/internet-module.h"
|
||||
#include "../model/leo-mock-net-device.h"
|
||||
|
||||
#include "nd-cache-helper.h"
|
||||
|
||||
namespace ns3
|
||||
{
|
||||
|
||||
void
|
||||
NdCacheHelper::Install (NetDeviceContainer &devices, Ipv6InterfaceContainer &interfaces) const
|
||||
{
|
||||
// prepare NDS cache
|
||||
for (uint32_t i = 0; i < devices.GetN (); i++)
|
||||
{
|
||||
Ptr<NetDevice> dev = devices.Get (i);
|
||||
Ptr<Node> node = dev->GetNode ();
|
||||
uint32_t ifIndex = dev->GetIfIndex ();
|
||||
Ptr<Ipv6L3Protocol> ipv6 = node->GetObject<Ipv6L3Protocol> ();
|
||||
Ptr<Ipv6Interface> interface = ipv6->GetInterface (ifIndex);
|
||||
Ptr<NdiscCache> cache = interface->GetNdiscCache ();
|
||||
for (uint32_t j = 0; j < devices.GetN (); j++)
|
||||
{
|
||||
// every other device, that is not of same "type"
|
||||
Ptr<NetDevice> otherDevice = devices.Get (j);
|
||||
Ptr<LeoMockNetDevice> leoDev = DynamicCast<LeoMockNetDevice> (dev);
|
||||
Ptr<LeoMockNetDevice> otherLeoDev = DynamicCast<LeoMockNetDevice> (otherDevice);
|
||||
if (i == j || (leoDev != 0
|
||||
&& otherLeoDev != 0
|
||||
&& leoDev->GetDeviceType () == otherLeoDev->GetDeviceType ()))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
Address address = otherDevice->GetAddress (); // MAC
|
||||
|
||||
// and associated address
|
||||
uint32_t otherIfIndex = otherDevice->GetIfIndex ();
|
||||
Ipv6Address ipaddr = interfaces.GetAddress (otherIfIndex, 1); // IP
|
||||
|
||||
// update cache
|
||||
NdiscCache::Entry* entry = cache->Lookup (ipaddr);
|
||||
if (entry == 0)
|
||||
{
|
||||
entry = cache->Add (ipaddr);
|
||||
}
|
||||
entry->SetMacAddress (address);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}; /* namespace ns3 */
|
23
helper/nd-cache-helper.h
Normal file
23
helper/nd-cache-helper.h
Normal file
|
@ -0,0 +1,23 @@
|
|||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
|
||||
#include "ns3/core-module.h"
|
||||
#include "ns3/network-module.h"
|
||||
#include "ns3/internet-module.h"
|
||||
#include "ns3/applications-module.h"
|
||||
#include "ns3/node-container.h"
|
||||
|
||||
#ifndef NDS_CACHE_HELPER_
|
||||
#define NDS_CACHE_HELPER_
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
class NdCacheHelper
|
||||
{
|
||||
public:
|
||||
void Install (NetDeviceContainer &devices, Ipv6InterfaceContainer &interfaces) const;
|
||||
void Install (NetDeviceContainer &devicesSrc, NetDeviceContainer &devicesDst, Ipv6InterfaceContainer &interfaces) const;
|
||||
};
|
||||
|
||||
}; /* namespace ns3 */
|
||||
|
||||
#endif /* NDS_CACHE_HELPER */
|
Loading…
Add table
Add a link
Reference in a new issue