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);
|
||||
LogComponentEnable ("UdpEchoClientApplication", LOG_LEVEL_INFO);
|
||||
LogComponentEnable ("UdpEchoServerApplication", LOG_LEVEL_INFO);
|
||||
LogComponentEnable ("UdpClient", LOG_LEVEL_INFO);
|
||||
LogComponentEnable ("UdpEchoClient", LOG_LEVEL_INFO);
|
||||
|
||||
NodeContainer nodes;
|
||||
nodes.Create (3);
|
||||
|
|
|
@ -10,6 +10,8 @@
|
|||
|
||||
using namespace ns3;
|
||||
|
||||
NS_LOG_COMPONENT_DEFINE ("LeoExample");
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
|
@ -23,14 +25,14 @@ main (int argc, char *argv[])
|
|||
Time::SetResolution (Time::NS);
|
||||
LogComponentEnable ("UdpEchoClientApplication", LOG_LEVEL_INFO);
|
||||
LogComponentEnable ("UdpEchoServerApplication", LOG_LEVEL_INFO);
|
||||
LogComponentEnable ("UdpClient", LOG_LEVEL_INFO);
|
||||
LogComponentEnable ("MockNetDevice", LOG_LEVEL_DEBUG);
|
||||
|
||||
NodeContainer satellites;
|
||||
satellites.Create (100);
|
||||
NodeContainer gateways;
|
||||
gateways.Create (10);
|
||||
NodeContainer terminals;
|
||||
terminals.Create (2000);
|
||||
terminals.Create (20);
|
||||
|
||||
LeoHelper leo;
|
||||
leo.SetDeviceAttribute ("DataRate", StringValue ("10Mbps"));
|
||||
|
@ -60,9 +62,10 @@ main (int argc, char *argv[])
|
|||
ApplicationContainer clientApps;
|
||||
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);
|
||||
echoClient.SetAttribute ("MaxPackets", UintegerValue (10));
|
||||
echoClient.SetAttribute ("MaxPackets", UintegerValue (1));
|
||||
echoClient.SetAttribute ("Interval", TimeValue (Seconds (1.0)));
|
||||
echoClient.SetAttribute ("PacketSize", UintegerValue (1024));
|
||||
|
||||
|
|
|
@ -22,8 +22,9 @@ LeoChannelHelper::LeoChannelHelper ()
|
|||
|
||||
m_gndDeviceFactory.SetTypeId ("ns3::LeoMockNetDevice");
|
||||
m_gndDeviceFactory.Set ("DeviceType", EnumValue (LeoMockNetDevice::GND));
|
||||
|
||||
m_satDeviceFactory.SetTypeId ("ns3::LeoMockNetDevice");
|
||||
m_gndDeviceFactory.Set ("DeviceType", EnumValue (LeoMockNetDevice::SAT));
|
||||
m_satDeviceFactory.Set ("DeviceType", EnumValue (LeoMockNetDevice::SAT));
|
||||
|
||||
m_channelFactory.SetTypeId ("ns3::LeoMockChannel");
|
||||
}
|
||||
|
|
|
@ -43,23 +43,50 @@ LeoMockChannel::TransmitStart (Ptr<const Packet> p,
|
|||
{
|
||||
// Find devices joined to channel
|
||||
Ptr<MockNetDevice> srcDev = DynamicCast<MockNetDevice> (GetDevice (devId));
|
||||
if (srcDev == 0)
|
||||
{
|
||||
NS_LOG_ERROR ("Source device unknown");
|
||||
return false;
|
||||
}
|
||||
|
||||
bool isBroadcast = (srcDev->GetBroadcast () == dst);
|
||||
bool toSatellite = m_groundDevices.find (srcDev->GetAddress ()) != m_groundDevices.end ();
|
||||
// Hack for NDP and ARP caches
|
||||
// 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)
|
||||
{
|
||||
NS_LOG_DEBUG (">>>broadcast for " << srcDev->GetAddress () << " -> " << dst);
|
||||
// Broadcast hack for ARP and neighbor cache
|
||||
// TODO remove if found a way to fill neighbor cache / ARP by hand
|
||||
for (uint32_t i = 0; i < GetNDevices (); i++)
|
||||
if (fromGround)
|
||||
{
|
||||
for (DeviceIndex::iterator it = m_satelliteDevices.begin ();
|
||||
it != m_satelliteDevices.end ();
|
||||
it++)
|
||||
{
|
||||
// TODO deliver only to devices in the same beam
|
||||
Deliver (p, srcDev, DynamicCast<MockNetDevice> (GetDevice (i)), txTime);
|
||||
NS_LOG_DEBUG ("from ground " << srcDev->GetAddress () << " -> " << it->second->GetAddress ());
|
||||
Deliver (p, srcDev, it->second, txTime);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (toSatellite)
|
||||
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
|
||||
{
|
||||
if (fromGround)
|
||||
{
|
||||
// Satellites can always directly be addresses
|
||||
// Assume beams are narrow enough to not also receive the signal at other
|
||||
|
@ -67,10 +94,11 @@ LeoMockChannel::TransmitStart (Ptr<const Packet> p,
|
|||
DeviceIndex::iterator it = m_satelliteDevices.find (dst);
|
||||
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;
|
||||
}
|
||||
Deliver (p, srcDev, it->second, txTime);
|
||||
NS_LOG_DEBUG ("BOOOOM " << srcDev->GetAddress () << " -> " << dst);
|
||||
return Deliver (p, srcDev, it->second, txTime);
|
||||
}
|
||||
else
|
||||
// space to ground delivers to everything within the beam
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue