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; -*- */
|
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||||
|
|
||||||
#include "ns3/core-module.h"
|
#include "ns3/core-module.h"
|
||||||
#include "ns3/network-module.h"
|
#include "ns3/network-module.h"
|
||||||
#include "ns3/internet-module.h"
|
#include "ns3/internet-module.h"
|
||||||
|
@ -6,7 +7,7 @@
|
||||||
#include "ns3/node-container.h"
|
#include "ns3/node-container.h"
|
||||||
#include "ns3/core-module.h"
|
#include "ns3/core-module.h"
|
||||||
|
|
||||||
#include "../helper/leo-helper.h"
|
#include "ns3/leo-module.h"
|
||||||
|
|
||||||
using namespace ns3;
|
using namespace ns3;
|
||||||
|
|
||||||
|
@ -40,17 +41,7 @@ main (int argc, char *argv[])
|
||||||
leo.SetChannelAttribute ("PropagationLoss", StringValue ("ns3::IslPropagationLossModel"));
|
leo.SetChannelAttribute ("PropagationLoss", StringValue ("ns3::IslPropagationLossModel"));
|
||||||
leo.SetDeviceAttribute ("MobilityModel", StringValue ("ns3::LeoMobilityModel"));
|
leo.SetDeviceAttribute ("MobilityModel", StringValue ("ns3::LeoMobilityModel"));
|
||||||
|
|
||||||
NetDeviceContainer devices;
|
leo.Install (satellites, gateways, terminals);
|
||||||
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);
|
|
||||||
|
|
||||||
// we want to ping terminals
|
// we want to ping terminals
|
||||||
UdpEchoServerHelper echoServer (9);
|
UdpEchoServerHelper echoServer (9);
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||||
|
|
||||||
|
#include "nd-cache-helper.h"
|
||||||
|
|
||||||
#include "leo-helper.h"
|
#include "leo-helper.h"
|
||||||
|
|
||||||
namespace ns3 {
|
namespace ns3 {
|
||||||
|
@ -10,35 +12,38 @@ LeoHelper::LeoHelper()
|
||||||
|
|
||||||
// TODO use template?
|
// TODO use template?
|
||||||
NetDeviceContainer
|
NetDeviceContainer
|
||||||
LeoHelper::Install (NodeContainer satellites, NodeContainer gateways, NodeContainer terminals)
|
LeoHelper::Install (NodeContainer &satellites, NodeContainer &gateways, NodeContainer &terminals)
|
||||||
{
|
{
|
||||||
NetDeviceContainer container = m_islChannelHelper.Install (satellites);
|
NetDeviceContainer container;
|
||||||
container.Add (m_gwChannelHelper.Install (satellites, gateways));
|
|
||||||
container.Add (m_utChannelHelper.Install (satellites, terminals));
|
|
||||||
|
|
||||||
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
|
// Install internet stack on nodes
|
||||||
LeoHelper::Install (std::vector<Ptr<Node> > &satellites,
|
InternetStackHelper stack;
|
||||||
std::vector<Ptr<Node> > &gateways,
|
stack.Install (satellites);
|
||||||
std::vector<Ptr<Node> > &terminals)
|
stack.Install (gateways);
|
||||||
{
|
stack.Install (terminals);
|
||||||
NetDeviceContainer container = m_islChannelHelper.Install (satellites);
|
|
||||||
container.Add (m_gwChannelHelper.Install (satellites, gateways));
|
|
||||||
container.Add (m_utChannelHelper.Install (satellites, 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
|
// Pre-fill the ND caches of networks
|
||||||
LeoHelper::Install (std::vector<std::string> &satellites,
|
NdCacheHelper ndCache;
|
||||||
std::vector<std::string> &gateways,
|
ndCache.Install (islNet, islAddrs);
|
||||||
std::vector<std::string> &terminals)
|
ndCache.Install (gwNet, gwAddrs);
|
||||||
{
|
ndCache.Install (utNet, utAddrs);
|
||||||
NetDeviceContainer container = m_islChannelHelper.Install (satellites);
|
|
||||||
container.Add (m_gwChannelHelper.Install (satellites, gateways));
|
// Add to resulting container of net devices
|
||||||
container.Add (m_utChannelHelper.Install (satellites, terminals));
|
container.Add (islNet);
|
||||||
|
container.Add (gwNet);
|
||||||
|
container.Add (utNet);
|
||||||
|
|
||||||
return container;
|
return container;
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,27 +53,10 @@ public:
|
||||||
*
|
*
|
||||||
* Same is done with each satellite and terminal node.
|
* 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.
|
* 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
|
* 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