Skip to content

Commit

Permalink
🐛 issues with frr
Browse files Browse the repository at this point in the history
  • Loading branch information
YousefEZ committed Mar 15, 2024
1 parent 4b08179 commit f6ccf53
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 30 deletions.
11 changes: 2 additions & 9 deletions libs/lfa_policy.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ class LFAPolicy;
class LFAPolicy
{
private:
std::list<ns3::Ptr<ns3::PointToPointFRRNetDevice<LFAPolicy>>>
m_alternateTargets;
std::list<ns3::Ptr<ns3::NetDevice>> m_alternateTargets;

public:
LFAPolicy() = default;
Expand All @@ -38,13 +37,7 @@ void LFAPolicy::addAlternateTargets(DEVICES&&... devices)
bool LFAPolicy::reroute(Ptr<Packet> 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
Expand Down
4 changes: 2 additions & 2 deletions libs/point_to_point_frr_net_device.h
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ class PointToPointFRRNetDevice : public NetDevice

bool isCongested();

void addAlternateTarget(Ptr<PointToPointFRRNetDevice<FRR_POLICY>> device);
void addAlternateTarget(Ptr<ns3::NetDevice> device);

static std::string makeNetDeviceString();
static const std::string& getNetDeviceString();
Expand Down Expand Up @@ -934,7 +934,7 @@ bool PointToPointFRRNetDevice<FRR_POLICY>::IsBridge() const

template <typename FRR_POLICY>
void PointToPointFRRNetDevice<FRR_POLICY>::addAlternateTarget(
Ptr<PointToPointFRRNetDevice<FRR_POLICY>> device)
Ptr<ns3::NetDevice> device)
{
m_frr_policy.addAlternateTargets(device);
}
Expand Down
28 changes: 9 additions & 19 deletions src/combined.cc
Original file line number Diff line number Diff line change
Expand Up @@ -38,23 +38,24 @@ NS_OBJECT_ENSURE_REGISTERED(SimulationQueue);
NS_OBJECT_ENSURE_REGISTERED(FRRChannel);
NS_OBJECT_ENSURE_REGISTERED(FRRNetDevice);

template <int INDEX>
Ptr<FRRNetDevice> getDevice(const NetDeviceContainer& devices)
template <int INDEX, typename DEVICE_TYPE>
Ptr<DEVICE_TYPE> getDevice(const NetDeviceContainer& devices)
{
return devices.Get(INDEX)->GetObject<FRRNetDevice>();
return devices.Get(INDEX)->GetObject<DEVICE_TYPE>();
}


template <int INDEX>
Ptr<SimulationQueue> getQueue(const NetDeviceContainer& devices)
{
return DynamicCast<SimulationQueue>(getDevice<INDEX>(devices)->GetQueue());
return DynamicCast<SimulationQueue>(getDevice<INDEX, FRRNetDevice>(devices)->GetQueue());
}

template <int INDEX>
void setAlternateTarget(const NetDeviceContainer& devices,
Ptr<FRRNetDevice> target)
Ptr<ns3::NetDevice> target)
{
getDevice<INDEX>(devices)->addAlternateTarget(target);
getDevice<INDEX, FRRNetDevice>(devices)->addAlternateTarget(target);
}

void SetupTCPConfig()
Expand Down Expand Up @@ -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));

Expand All @@ -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/");

Expand Down

0 comments on commit f6ccf53

Please sign in to comment.