refactor stuff

This commit is contained in:
Tim Schubert 2020-07-20 15:48:24 +02:00
parent 57b04d6424
commit 97de8c9d24
15 changed files with 135 additions and 88 deletions

View file

@ -3,6 +3,7 @@
#include "ns3/core-module.h"
#include "ns3/network-module.h"
#include "ns3/internet-module.h"
#include "ns3/log.h"
#include "../model/leo-mock-net-device.h"
#include "arp-cache-helper.h"
@ -10,13 +11,18 @@
namespace ns3
{
NS_LOG_COMPONENT_DEFINE ("ArpCacheHelper");
void
ArpCacheHelper::Install (NetDeviceContainer &devices, Ipv4InterfaceContainer &interfaces) const
{
NS_LOG_FUNCTION (this);
for (size_t i = 0; i < devices.GetN (); i ++)
{
Ptr<NetDevice> dev = devices.Get (i);
Ptr<Node> node = dev->GetNode ();
NS_LOG_INFO ("Preparing ARP cache of " << node);
Ptr<Ipv4L3Protocol> ipv4 = node->GetObject<Ipv4L3Protocol> ();
int32_t ifIndex = ipv4->GetInterfaceForDevice (dev);
Ptr<Ipv4Interface> interface = ipv4->GetInterface (ifIndex);
@ -47,6 +53,8 @@ ArpCacheHelper::Install (NetDeviceContainer &devices, Ipv4InterfaceContainer &in
entry = cache->Add (ipaddr);
}
entry->SetMacAddress (address);
NS_LOG_DEBUG ("Added entry for " << address);
}
}
}

View file

@ -20,4 +20,4 @@ public:
}; /* namespace ns3 */
#endif /* ARP_CACHE_HELPER */
#endif /* ARP_CACHE_HELPER_H */

View file

@ -224,12 +224,15 @@ IslHelper::Install (NodeContainer c)
NetDeviceContainer
IslHelper::Install (std::vector<Ptr<Node> > &nodes)
{
NS_LOG_FUNCTION (this);
Ptr<MockChannel> channel = m_channelFactory.Create<MockChannel> ();
NetDeviceContainer container;
for (Ptr<Node> node: nodes)
{
NS_LOG_DEBUG ("Adding device for node " << node->GetId ());
Ptr<MockNetDevice> dev = m_deviceFactory.Create<MockNetDevice> ();
dev->SetAddress (Mac48Address::Allocate ());
node->AddDevice (dev);

View file

@ -230,6 +230,8 @@ LeoChannelHelper::EnableAsciiInternal (
NetDeviceContainer
LeoChannelHelper::Install (std::vector<Ptr<Node> > &satellites, std::vector<Ptr<Node> > &stations)
{
NS_LOG_FUNCTION (this);
Ptr<LeoMockChannel> channel = m_channelFactory.Create<LeoMockChannel> ();
NetDeviceContainer container;
@ -243,6 +245,8 @@ LeoChannelHelper::Install (std::vector<Ptr<Node> > &satellites, std::vector<Ptr<
dev->SetQueue (queue);
dev->Attach (channel);
container.Add (dev);
NS_LOG_DEBUG ("Added device for node " << node->GetId ());
}
for (Ptr<Node> node : stations)
@ -254,6 +258,8 @@ LeoChannelHelper::Install (std::vector<Ptr<Node> > &satellites, std::vector<Ptr<
dev->SetQueue (queue);
dev->Attach (channel);
container.Add (dev);
NS_LOG_DEBUG ("Added device for node " << node->GetId ());
}
return container;
@ -270,15 +276,19 @@ LeoChannelHelper::Install (NodeContainer &satellites, NodeContainer &stations)
NetDeviceContainer
LeoChannelHelper::Install (std::vector<std::string> &satellites, std::vector<std::string> &stations)
{
NS_LOG_FUNCTION (this);
std::vector<Ptr<Node> > sats;
std::vector<Ptr<Node> > stats;
for (std::string name : satellites)
{
NS_LOG_DEBUG ("Adding node " << name);
Ptr<Node> node = Names::Find<Node>(name);
sats.push_back (node);
}
for (std::string name : stations)
{
NS_LOG_DEBUG ("Adding node " << name);
Ptr<Node> node = Names::Find<Node>(name);
stats.push_back (node);
}

View file

@ -29,17 +29,17 @@ LeoHelper::Install (NodeContainer &satellites, NodeContainer &gateways, NodeCont
m_stackHelper.Install (gateways);
m_stackHelper.Install (terminals);
// Make all networks addressable
Ipv6AddressHelper address;
Ipv6InterfaceContainer islAddrs = address.Assign (islNet);
Ipv6InterfaceContainer gwAddrs = address.Assign (gwNet);
Ipv6InterfaceContainer utAddrs = address.Assign (utNet);
//// Make all networks addressable
//Ipv6AddressHelper address;
//Ipv6InterfaceContainer islAddrs = address.Assign (islNet);
//Ipv6InterfaceContainer gwAddrs = address.Assign (gwNet);
//Ipv6InterfaceContainer utAddrs = address.Assign (utNet);
// Pre-fill the ND caches of networks
NdCacheHelper ndCache;
ndCache.Install (islNet, islAddrs);
ndCache.Install (gwNet, gwAddrs);
ndCache.Install (utNet, utAddrs);
//// Pre-fill the ND caches of networks
//NdCacheHelper ndCache;
//ndCache.Install (islNet, islAddrs);
//ndCache.Install (gwNet, gwAddrs);
//ndCache.Install (utNet, utAddrs);
// Make all networks addressable for legacy protocol
Ipv4AddressHelper legacy;

View file

@ -3,6 +3,7 @@
#include "ns3/core-module.h"
#include "ns3/network-module.h"
#include "ns3/internet-module.h"
#include "ns3/log.h"
#include "../model/leo-mock-net-device.h"
#include "nd-cache-helper.h"
@ -10,9 +11,13 @@
namespace ns3
{
NS_LOG_COMPONENT_DEFINE ("NdCacheHelper");
void
NdCacheHelper::Install (NetDeviceContainer &devices, Ipv6InterfaceContainer &interfaces) const
{
NS_LOG_FUNCTION (this);
// prepare NDS cache
for (uint32_t i = 0; i < devices.GetN (); i++)
{
@ -47,6 +52,8 @@ NdCacheHelper::Install (NetDeviceContainer &devices, Ipv6InterfaceContainer &int
entry = cache->Add (ipaddr);
}
entry->SetMacAddress (address);
NS_LOG_DEBUG ("Added entry for " << address);
}
}
}

View file

@ -28,7 +28,7 @@ LeoSatNodeHelper::SetAttribute (string name, const AttributeValue &value)
NodeContainer
LeoSatNodeHelper::Install (vector<string> &wpFiles)
{
NS_LOG_FUNCTION (wpFiles);
NS_LOG_FUNCTION (this);
NodeContainer nodes;
for (size_t i = 0; i < wpFiles.size (); i ++)