diff --git a/examples/isl-example.cc b/examples/isl-example.cc index bab298a..151cf45 100644 --- a/examples/isl-example.cc +++ b/examples/isl-example.cc @@ -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); diff --git a/examples/leo-example.cc b/examples/leo-example.cc index 7b2bb02..cc25d77 100644 --- a/examples/leo-example.cc +++ b/examples/leo-example.cc @@ -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 ()->GetAddress (0, 0).GetAddress (); + Address remote = terminals.Get (i)->GetObject ()->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)); diff --git a/helper/leo-channel-helper.cc b/helper/leo-channel-helper.cc index 49f6cd4..19a419b 100644 --- a/helper/leo-channel-helper.cc +++ b/helper/leo-channel-helper.cc @@ -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"); } diff --git a/model/leo-mock-channel.cc b/model/leo-mock-channel.cc index 91ba0e7..a91ef3d 100644 --- a/model/leo-mock-channel.cc +++ b/model/leo-mock-channel.cc @@ -37,52 +37,80 @@ LeoMockChannel::~LeoMockChannel() bool LeoMockChannel::TransmitStart (Ptr p, - uint32_t devId, - Address dst, - Time txTime) + uint32_t devId, + Address dst, + Time txTime) { // Find devices joined to channel Ptr srcDev = DynamicCast (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++) - { - // TODO deliver only to devices in the same beam - Deliver (p, srcDev, DynamicCast (GetDevice (i)), txTime); - } + if (fromGround) + { + for (DeviceIndex::iterator it = m_satelliteDevices.begin (); + 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 { - if (toSatellite) - { - // Satellites can always directly be addresses - // Assume beams are narrow enough to not also receive the signal at other - // satellites for performance reasons. - DeviceIndex::iterator it = m_satelliteDevices.find (dst); - if (it == m_satelliteDevices.end ()) - { - NS_LOG_LOGIC (this << "unable to find satellite with address " << dst); - return false; - } - Deliver (p, srcDev, it->second, txTime); - } + if (fromGround) + { + // Satellites can always directly be addresses + // Assume beams are narrow enough to not also receive the signal at other + // satellites for performance reasons. + DeviceIndex::iterator it = m_satelliteDevices.find (dst); + if (it == m_satelliteDevices.end ()) + { + NS_LOG_ERROR ("unable to find satellite with address " << dst); + return false; + } + NS_LOG_DEBUG ("BOOOOM " << srcDev->GetAddress () << " -> " << dst); + return Deliver (p, srcDev, it->second, txTime); + } else - // space to ground delivers to everything within the beam - { - for (DeviceIndex::iterator it = m_groundDevices.begin (); - it != m_groundDevices.end (); - it++) - { - // TODO deliver only to devices in the same beam - Deliver (p, srcDev, it->second, txTime); - } - } + // space to ground delivers to everything within the beam + { + for (DeviceIndex::iterator it = m_groundDevices.begin (); + it != m_groundDevices.end (); + it++) + { + // TODO deliver only to devices in the same beam + Deliver (p, srcDev, it->second, txTime); + } + } } return true;