From e05dc827cc6cabc9d5fc4cd5ed088bd5ff363b19 Mon Sep 17 00:00:00 2001
From: Tim Schubert <tim.schubert@tu-bs.de>
Date: Fri, 3 Jul 2020 18:41:15 +0200
Subject: [PATCH] Remove broadcast hack

---
 model/isl-mock-channel.cc |  6 +---
 model/leo-mock-channel.cc | 68 +++++++++------------------------------
 2 files changed, 17 insertions(+), 57 deletions(-)

diff --git a/model/isl-mock-channel.cc b/model/isl-mock-channel.cc
index caeb78c..4fc1765 100644
--- a/model/isl-mock-channel.cc
+++ b/model/isl-mock-channel.cc
@@ -68,11 +68,7 @@ IslMockChannel::TransmitStart (
   if (dst == nullptr)
   {
     NS_LOG_LOGIC ("destination address " << destAddr << " unknown on channel");
-    for (uint32_t i = 0; i < GetNDevices (); i++)
-    {
-      Deliver (p, src, DynamicCast<MockNetDevice> (GetDevice (i)), txTime);
-    }
-    return true;
+    return false;
   }
   else
   {
diff --git a/model/leo-mock-channel.cc b/model/leo-mock-channel.cc
index a91ef3d..7953ad5 100644
--- a/model/leo-mock-channel.cc
+++ b/model/leo-mock-channel.cc
@@ -49,67 +49,31 @@ LeoMockChannel::TransmitStart (Ptr<const Packet> p,
       return false;
     }
 
-  // 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)
+  if (fromGround)
     {
-      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
-      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 ())
         {
-          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);
-            }
+          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
     {
-      if (fromGround)
+      for (DeviceIndex::iterator it = m_groundDevices.begin ();
+           it != m_groundDevices.end ();
+           it++)
         {
-          // 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);
-            }
+          // TODO deliver only to devices in the same beam
+          Deliver (p, srcDev, it->second, txTime);
         }
     }