mirror of
https://gitlab.ibr.cs.tu-bs.de/tschuber/ns-3-leo.git
synced 2025-06-08 10:03:58 +02:00
fixup: broadcast hack
This commit is contained in:
parent
51b110bf68
commit
603d8ccf70
4 changed files with 71 additions and 39 deletions
|
@ -21,7 +21,7 @@ main (int argc, char *argv[])
|
||||||
Time::SetResolution (Time::NS);
|
Time::SetResolution (Time::NS);
|
||||||
LogComponentEnable ("UdpEchoClientApplication", LOG_LEVEL_INFO);
|
LogComponentEnable ("UdpEchoClientApplication", LOG_LEVEL_INFO);
|
||||||
LogComponentEnable ("UdpEchoServerApplication", LOG_LEVEL_INFO);
|
LogComponentEnable ("UdpEchoServerApplication", LOG_LEVEL_INFO);
|
||||||
LogComponentEnable ("UdpClient", LOG_LEVEL_INFO);
|
LogComponentEnable ("UdpEchoClient", LOG_LEVEL_INFO);
|
||||||
|
|
||||||
NodeContainer nodes;
|
NodeContainer nodes;
|
||||||
nodes.Create (3);
|
nodes.Create (3);
|
||||||
|
|
|
@ -10,6 +10,8 @@
|
||||||
|
|
||||||
using namespace ns3;
|
using namespace ns3;
|
||||||
|
|
||||||
|
NS_LOG_COMPONENT_DEFINE ("LeoExample");
|
||||||
|
|
||||||
int
|
int
|
||||||
main (int argc, char *argv[])
|
main (int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
@ -23,14 +25,14 @@ main (int argc, char *argv[])
|
||||||
Time::SetResolution (Time::NS);
|
Time::SetResolution (Time::NS);
|
||||||
LogComponentEnable ("UdpEchoClientApplication", LOG_LEVEL_INFO);
|
LogComponentEnable ("UdpEchoClientApplication", LOG_LEVEL_INFO);
|
||||||
LogComponentEnable ("UdpEchoServerApplication", LOG_LEVEL_INFO);
|
LogComponentEnable ("UdpEchoServerApplication", LOG_LEVEL_INFO);
|
||||||
LogComponentEnable ("UdpClient", LOG_LEVEL_INFO);
|
LogComponentEnable ("MockNetDevice", LOG_LEVEL_DEBUG);
|
||||||
|
|
||||||
NodeContainer satellites;
|
NodeContainer satellites;
|
||||||
satellites.Create (100);
|
satellites.Create (100);
|
||||||
NodeContainer gateways;
|
NodeContainer gateways;
|
||||||
gateways.Create (10);
|
gateways.Create (10);
|
||||||
NodeContainer terminals;
|
NodeContainer terminals;
|
||||||
terminals.Create (2000);
|
terminals.Create (20);
|
||||||
|
|
||||||
LeoHelper leo;
|
LeoHelper leo;
|
||||||
leo.SetDeviceAttribute ("DataRate", StringValue ("10Mbps"));
|
leo.SetDeviceAttribute ("DataRate", StringValue ("10Mbps"));
|
||||||
|
@ -60,9 +62,10 @@ main (int argc, char *argv[])
|
||||||
ApplicationContainer clientApps;
|
ApplicationContainer clientApps;
|
||||||
for (uint32_t i = 1; i < terminals.GetN (); i++)
|
for (uint32_t i = 1; i < terminals.GetN (); i++)
|
||||||
{
|
{
|
||||||
Address remote = terminals.Get (i)->GetObject<Ipv6> ()->GetAddress (0, 0).GetAddress ();
|
Address remote = terminals.Get (i)->GetObject<Ipv6> ()->GetAddress (1, 0).GetAddress ();
|
||||||
|
NS_LOG_DEBUG ("REMOTE " << i << " " << remote);
|
||||||
UdpEchoClientHelper echoClient (remote, 9);
|
UdpEchoClientHelper echoClient (remote, 9);
|
||||||
echoClient.SetAttribute ("MaxPackets", UintegerValue (10));
|
echoClient.SetAttribute ("MaxPackets", UintegerValue (1));
|
||||||
echoClient.SetAttribute ("Interval", TimeValue (Seconds (1.0)));
|
echoClient.SetAttribute ("Interval", TimeValue (Seconds (1.0)));
|
||||||
echoClient.SetAttribute ("PacketSize", UintegerValue (1024));
|
echoClient.SetAttribute ("PacketSize", UintegerValue (1024));
|
||||||
|
|
||||||
|
|
|
@ -22,8 +22,9 @@ LeoChannelHelper::LeoChannelHelper ()
|
||||||
|
|
||||||
m_gndDeviceFactory.SetTypeId ("ns3::LeoMockNetDevice");
|
m_gndDeviceFactory.SetTypeId ("ns3::LeoMockNetDevice");
|
||||||
m_gndDeviceFactory.Set ("DeviceType", EnumValue (LeoMockNetDevice::GND));
|
m_gndDeviceFactory.Set ("DeviceType", EnumValue (LeoMockNetDevice::GND));
|
||||||
|
|
||||||
m_satDeviceFactory.SetTypeId ("ns3::LeoMockNetDevice");
|
m_satDeviceFactory.SetTypeId ("ns3::LeoMockNetDevice");
|
||||||
m_gndDeviceFactory.Set ("DeviceType", EnumValue (LeoMockNetDevice::SAT));
|
m_satDeviceFactory.Set ("DeviceType", EnumValue (LeoMockNetDevice::SAT));
|
||||||
|
|
||||||
m_channelFactory.SetTypeId ("ns3::LeoMockChannel");
|
m_channelFactory.SetTypeId ("ns3::LeoMockChannel");
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,52 +37,80 @@ LeoMockChannel::~LeoMockChannel()
|
||||||
|
|
||||||
bool
|
bool
|
||||||
LeoMockChannel::TransmitStart (Ptr<const Packet> p,
|
LeoMockChannel::TransmitStart (Ptr<const Packet> p,
|
||||||
uint32_t devId,
|
uint32_t devId,
|
||||||
Address dst,
|
Address dst,
|
||||||
Time txTime)
|
Time txTime)
|
||||||
{
|
{
|
||||||
// Find devices joined to channel
|
// Find devices joined to channel
|
||||||
Ptr<MockNetDevice> srcDev = DynamicCast<MockNetDevice> (GetDevice (devId));
|
Ptr<MockNetDevice> srcDev = DynamicCast<MockNetDevice> (GetDevice (devId));
|
||||||
|
if (srcDev == 0)
|
||||||
|
{
|
||||||
|
NS_LOG_ERROR ("Source device unknown");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
bool isBroadcast = (srcDev->GetBroadcast () == dst);
|
// Hack for NDP and ARP caches
|
||||||
bool toSatellite = m_groundDevices.find (srcDev->GetAddress ()) != m_groundDevices.end ();
|
// TODO check if NDP or ARP address
|
||||||
|
bool isBroadcast = (m_groundDevices.find (dst) == m_groundDevices.end ()
|
||||||
|
&& m_satelliteDevices.find (dst) == m_satelliteDevices.end ());
|
||||||
|
|
||||||
|
bool fromGround = m_groundDevices.find (srcDev->GetAddress ()) != m_groundDevices.end ();
|
||||||
|
|
||||||
if (isBroadcast)
|
if (isBroadcast)
|
||||||
{
|
{
|
||||||
|
NS_LOG_DEBUG (">>>broadcast for " << srcDev->GetAddress () << " -> " << dst);
|
||||||
// Broadcast hack for ARP and neighbor cache
|
// Broadcast hack for ARP and neighbor cache
|
||||||
// TODO remove if found a way to fill neighbor cache / ARP by hand
|
// TODO remove if found a way to fill neighbor cache / ARP by hand
|
||||||
for (uint32_t i = 0; i < GetNDevices (); i++)
|
if (fromGround)
|
||||||
{
|
{
|
||||||
// TODO deliver only to devices in the same beam
|
for (DeviceIndex::iterator it = m_satelliteDevices.begin ();
|
||||||
Deliver (p, srcDev, DynamicCast<MockNetDevice> (GetDevice (i)), txTime);
|
it != m_satelliteDevices.end ();
|
||||||
}
|
it++)
|
||||||
|
{
|
||||||
|
// TODO deliver only to devices in the same beam
|
||||||
|
NS_LOG_DEBUG ("from ground " << srcDev->GetAddress () << " -> " << it->second->GetAddress ());
|
||||||
|
Deliver (p, srcDev, it->second, txTime);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (DeviceIndex::iterator it = m_groundDevices.begin ();
|
||||||
|
it != m_groundDevices.end ();
|
||||||
|
it++)
|
||||||
|
{
|
||||||
|
// TODO deliver only to devices in the same beam
|
||||||
|
NS_LOG_DEBUG ("from space " << srcDev->GetAddress () << " -> " << it->second->GetAddress ());
|
||||||
|
Deliver (p, srcDev, it->second, txTime);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (toSatellite)
|
if (fromGround)
|
||||||
{
|
{
|
||||||
// Satellites can always directly be addresses
|
// Satellites can always directly be addresses
|
||||||
// Assume beams are narrow enough to not also receive the signal at other
|
// Assume beams are narrow enough to not also receive the signal at other
|
||||||
// satellites for performance reasons.
|
// satellites for performance reasons.
|
||||||
DeviceIndex::iterator it = m_satelliteDevices.find (dst);
|
DeviceIndex::iterator it = m_satelliteDevices.find (dst);
|
||||||
if (it == m_satelliteDevices.end ())
|
if (it == m_satelliteDevices.end ())
|
||||||
{
|
{
|
||||||
NS_LOG_LOGIC (this << "unable to find satellite with address " << dst);
|
NS_LOG_ERROR ("unable to find satellite with address " << dst);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Deliver (p, srcDev, it->second, txTime);
|
NS_LOG_DEBUG ("BOOOOM " << srcDev->GetAddress () << " -> " << dst);
|
||||||
}
|
return Deliver (p, srcDev, it->second, txTime);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
// space to ground delivers to everything within the beam
|
// space to ground delivers to everything within the beam
|
||||||
{
|
{
|
||||||
for (DeviceIndex::iterator it = m_groundDevices.begin ();
|
for (DeviceIndex::iterator it = m_groundDevices.begin ();
|
||||||
it != m_groundDevices.end ();
|
it != m_groundDevices.end ();
|
||||||
it++)
|
it++)
|
||||||
{
|
{
|
||||||
// TODO deliver only to devices in the same beam
|
// TODO deliver only to devices in the same beam
|
||||||
Deliver (p, srcDev, it->second, txTime);
|
Deliver (p, srcDev, it->second, txTime);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue