From f6ccf530f17a3de03ab489912925a032ecb06a0f Mon Sep 17 00:00:00 2001 From: YousefEZ <45167695+YousefEZ@users.noreply.github.com> Date: Fri, 15 Mar 2024 23:51:47 +0000 Subject: [PATCH] :bug: issues with frr --- libs/lfa_policy.h | 11 ++--------- libs/point_to_point_frr_net_device.h | 4 ++-- src/combined.cc | 28 +++++++++------------------- 3 files changed, 13 insertions(+), 30 deletions(-) diff --git a/libs/lfa_policy.h b/libs/lfa_policy.h index 296fe7f5..5a8010c9 100644 --- a/libs/lfa_policy.h +++ b/libs/lfa_policy.h @@ -16,8 +16,7 @@ class LFAPolicy; class LFAPolicy { private: - std::list>> - m_alternateTargets; + std::list> m_alternateTargets; public: LFAPolicy() = default; @@ -38,13 +37,7 @@ void LFAPolicy::addAlternateTargets(DEVICES&&... devices) bool LFAPolicy::reroute(Ptr packet, const Address& dest, uint16_t protocolNumber) { - for (auto& target : m_alternateTargets) { - if (!target->isCongested()) { - target->Send(packet, dest, protocolNumber); - return true; - } - } - return false; + return !m_alternateTargets.empty() && m_alternateTargets.front()->Send(packet, dest, protocolNumber); } } // namespace ns3 diff --git a/libs/point_to_point_frr_net_device.h b/libs/point_to_point_frr_net_device.h index df431089..47ba5e6c 100644 --- a/libs/point_to_point_frr_net_device.h +++ b/libs/point_to_point_frr_net_device.h @@ -145,7 +145,7 @@ class PointToPointFRRNetDevice : public NetDevice bool isCongested(); - void addAlternateTarget(Ptr> device); + void addAlternateTarget(Ptr device); static std::string makeNetDeviceString(); static const std::string& getNetDeviceString(); @@ -934,7 +934,7 @@ bool PointToPointFRRNetDevice::IsBridge() const template void PointToPointFRRNetDevice::addAlternateTarget( - Ptr> device) + Ptr device) { m_frr_policy.addAlternateTargets(device); } diff --git a/src/combined.cc b/src/combined.cc index 7f636e17..5d95e108 100644 --- a/src/combined.cc +++ b/src/combined.cc @@ -38,23 +38,24 @@ NS_OBJECT_ENSURE_REGISTERED(SimulationQueue); NS_OBJECT_ENSURE_REGISTERED(FRRChannel); NS_OBJECT_ENSURE_REGISTERED(FRRNetDevice); -template -Ptr getDevice(const NetDeviceContainer& devices) +template +Ptr getDevice(const NetDeviceContainer& devices) { - return devices.Get(INDEX)->GetObject(); + return devices.Get(INDEX)->GetObject(); } + template Ptr getQueue(const NetDeviceContainer& devices) { - return DynamicCast(getDevice(devices)->GetQueue()); + return DynamicCast(getDevice(devices)->GetQueue()); } template void setAlternateTarget(const NetDeviceContainer& devices, - Ptr target) + Ptr target) { - getDevice(devices)->addAlternateTarget(target); + getDevice(devices)->addAlternateTarget(target); } void SetupTCPConfig() @@ -221,8 +222,8 @@ int main(int argc, char* argv[]) // path configured // TODO: Need some help with setting alternate target - setAlternateTarget<0>(devices_2_3, getDevice<0>(devices_2_4)); - setAlternateTarget<1>(devices_2_3, getDevice<1>(devices_4_3)); + setAlternateTarget<0>(devices_2_3, getDevice<0, ns3::PointToPointNetDevice>(devices_2_4)); + setAlternateTarget<1>(devices_2_3, getDevice<1, ns3::PointToPointNetDevice>(devices_4_3)); // setAlternateTarget<0>(devices01, getDevice<0>(devices02)); // setAlternateTarget<0>(devices02, getDevice<0>(devices01)); @@ -233,17 +234,6 @@ int main(int argc, char* argv[]) // setAlternateTarget<1>(devices12, getDevice<1>(devices02)); // enableRerouting(getQueue<0>(devices_2_3)); - toggleCongestion(getQueue<0>(devices_0_2)); - toggleCongestion(getQueue<1>(devices_0_2)); - toggleCongestion(getQueue<0>(devices_2_4)); - toggleCongestion(getQueue<1>(devices_2_4)); - toggleCongestion(getQueue<0>(devices_4_3)); - toggleCongestion(getQueue<1>(devices_4_3)); - toggleCongestion(getQueue<0>(devices_3_5)); - toggleCongestion(getQueue<1>(devices_3_5)); - toggleCongestion(getQueue<0>(devices_1_2)); - toggleCongestion(getQueue<1>(devices_1_2)); - p2p_traffic.EnablePcapAll("traces/"); p2p_congestion.EnablePcapAll("traces/");