-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
combined.cc implementing customNetDevice #13
Merged
Merged
Changes from 3 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
b10600b
Copied combined.cc to customNetDevice
charliebarber cf3fe73
Combined with customNetDevice. Attempt to dereference zero pointer
charliebarber 4b08179
Regular PointToPointHelper for all but congested link. Still crashing
charliebarber f6ccf53
:bug: issues with frr
YousefEZ 1e7fa94
:art: format files
YousefEZ 48c424f
Fixed typo in sink_app start/stop
charliebarber 33ec107
No more UDP ICMP messages, packet sink setup for UDP port
charliebarber ffeefc4
Properly combined TCP and UDP with custom net device. ACKs coming thr…
charliebarber 4ae87fa
Merge branch 'main' into combined-customNetDevice
YousefEZ File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,253 @@ | ||
#include <iostream> | ||
|
||
#include "ns3/core-module.h" | ||
#include "ns3/network-module.h" | ||
#include "ns3/internet-module.h" | ||
#include "ns3/point-to-point-module.h" | ||
#include "ns3/applications-module.h" | ||
#include "ns3/log.h" | ||
|
||
#include "../libs/frr_queue.h" | ||
#include "../libs/dummy_congestion_policy.h" | ||
#include "../libs/modulo_congestion_policy.h" | ||
#include "../libs/lfa_policy.h" | ||
#include "../libs/random_congestion_policy.h" | ||
#include "../libs/point_to_point_frr_helper.h" | ||
|
||
using namespace ns3; | ||
|
||
// using CongestionPolicy = BasicCongestionPolicy<0>; | ||
using CongestionPolicy = RandomCongestionPolicy<100>; | ||
using FRRPolicy = LFAPolicy; | ||
|
||
using SimulationQueue = FRRQueue<CongestionPolicy>; | ||
using FRRNetDevice = PointToPointFRRNetDevice<FRRPolicy>; | ||
using FRRChannel = PointToPointFRRChannel<FRRPolicy>; | ||
|
||
void toggleCongestion(Ptr<SimulationQueue> queue) | ||
{ | ||
queue->m_congestionPolicy.turnOff(); | ||
} | ||
|
||
// void enableRerouting(Ptr<SimulationQueue> queue) | ||
// { | ||
// // queue->m_congestionPolicy.enable(); | ||
// } | ||
|
||
NS_OBJECT_ENSURE_REGISTERED(SimulationQueue); | ||
NS_OBJECT_ENSURE_REGISTERED(FRRChannel); | ||
NS_OBJECT_ENSURE_REGISTERED(FRRNetDevice); | ||
|
||
template <int INDEX> | ||
Ptr<FRRNetDevice> getDevice(const NetDeviceContainer& devices) | ||
{ | ||
return devices.Get(INDEX)->GetObject<FRRNetDevice>(); | ||
} | ||
|
||
template <int INDEX> | ||
Ptr<SimulationQueue> getQueue(const NetDeviceContainer& devices) | ||
{ | ||
return DynamicCast<SimulationQueue>(getDevice<INDEX>(devices)->GetQueue()); | ||
} | ||
|
||
template <int INDEX> | ||
void setAlternateTarget(const NetDeviceContainer& devices, | ||
Ptr<FRRNetDevice> target) | ||
{ | ||
getDevice<INDEX>(devices)->addAlternateTarget(target); | ||
} | ||
|
||
void SetupTCPConfig() | ||
{ | ||
// TCP recovery algorithm | ||
Config::SetDefault( | ||
"ns3::TcpL4Protocol::RecoveryType", | ||
TypeIdValue(TypeId::LookupByName("ns3::TcpClassicRecovery"))); | ||
// Congestion control algorithm | ||
Config::SetDefault("ns3::TcpL4Protocol::SocketType", | ||
StringValue("ns3::TcpLinuxReno")); | ||
Config::SetDefault("ns3::TcpSocket::SndBufSize", UintegerValue(1073741824)); | ||
Config::SetDefault("ns3::TcpSocket::RcvBufSize", UintegerValue(1073741824)); | ||
// Initial congestion window | ||
Config::SetDefault("ns3::TcpSocket::InitialCwnd", UintegerValue(1)); | ||
// Set delayed ack count | ||
Config::SetDefault("ns3::TcpSocket::DelAckTimeout", TimeValue(Time("1ms"))); | ||
Config::SetDefault("ns3::TcpSocket::DelAckCount", UintegerValue(1)); | ||
// Set segment size of packet | ||
Config::SetDefault("ns3::TcpSocket::SegmentSize", UintegerValue(1024)); | ||
// Enable/disable SACKs (disabled) | ||
Config::SetDefault("ns3::TcpSocketBase::Sack", BooleanValue(false)); | ||
Config::SetDefault("ns3::TcpSocketBase::MinRto", TimeValue(Seconds(1.0))); | ||
} | ||
|
||
// NS_LOG_COMPONENT_DEFINE("CongestionFastReRoute"); | ||
int main(int argc, char* argv[]) | ||
{ | ||
LogComponentEnable("FRRQueue", LOG_LEVEL_LOGIC); | ||
/* | ||
* +----------+ +-----------+ | ||
* |Congestion| | Traffic | | ||
* | Sender | | Sender | | ||
* 0+----+-----+ 1+-----+-----+ | ||
* | | | ||
* | +----------+ | | ||
* +---+ Router +---+ | ||
* | 01 | | ||
* 2+----+-----+--------+ | ||
* | | | ||
* | +-----+----+ | ||
* | | Router | | ||
* | | 03 | | ||
* +----+-----+ 4+----+-----+ | ||
* | Router | | | ||
* | 02 +-------+ | ||
* 3+----+-----+ | ||
* | | ||
* | | ||
* +----+-----+ | ||
* | Receiver | | ||
* | | | ||
* 5+----------+ | ||
*/ | ||
// Topology setup | ||
NS_LOG_INFO("Creating Topology"); | ||
NodeContainer nodes; | ||
nodes.Create(6); | ||
Names::Add("CongestionSender", nodes.Get(0)); | ||
Names::Add("TrafficSender", nodes.Get(1)); | ||
Names::Add("Router01", nodes.Get(2)); | ||
Names::Add("Router02", nodes.Get(3)); | ||
Names::Add("Router03", nodes.Get(4)); | ||
Names::Add("Receiver", nodes.Get(5)); | ||
|
||
InternetStackHelper stack; | ||
stack.Install(nodes); | ||
|
||
// Configure PointToPoint link for normal traffic | ||
PointToPointHelper p2p_traffic; | ||
p2p_traffic.SetDeviceAttribute("DataRate", StringValue("1Mbps")); | ||
p2p_traffic.SetChannelAttribute("Delay", StringValue("1ms")); | ||
// Set the custom queue for the device | ||
p2p_traffic.SetQueue("ns3::DropTailQueue<Packet>"); | ||
// Install devices and channels between nodes | ||
|
||
PointToPointFRRHelper<FRRPolicy> p2p_congested_link; | ||
p2p_congested_link.SetDeviceAttribute("DataRate", StringValue("1Mbps")); | ||
p2p_congested_link.SetChannelAttribute("Delay", StringValue("1ms")); | ||
p2p_congested_link.SetQueue(SimulationQueue::getQueueString()); | ||
|
||
NetDeviceContainer devices_0_2 = | ||
p2p_traffic.Install(nodes.Get(0), nodes.Get(2)); | ||
NetDeviceContainer devices_2_3 = | ||
p2p_congested_link.Install(nodes.Get(2), nodes.Get(3)); | ||
NetDeviceContainer devices_2_4 = | ||
p2p_traffic.Install(nodes.Get(2), nodes.Get(4)); | ||
NetDeviceContainer devices_4_3 = | ||
p2p_traffic.Install(nodes.Get(4), nodes.Get(3)); | ||
NetDeviceContainer devices_3_5 = | ||
p2p_traffic.Install(nodes.Get(3), nodes.Get(5)); | ||
|
||
// Configure PointToPoint link for congestion link | ||
PointToPointHelper p2p_congestion; | ||
p2p_congestion.SetDeviceAttribute("DataRate", StringValue("1Mbps")); | ||
p2p_congestion.SetChannelAttribute("Delay", StringValue("1ms")); | ||
// Set the custom queue for the device | ||
p2p_congestion.SetQueue("ns3::DropTailQueue<Packet>"); | ||
// Install devices and channels between nodes | ||
NetDeviceContainer devices_1_2 = | ||
p2p_congestion.Install(nodes.Get(1), nodes.Get(2)); | ||
|
||
// Assign IP addresses to subnets | ||
Ipv4AddressHelper address; | ||
address.SetBase("10.1.1.0", "255.255.255.0"); | ||
Ipv4InterfaceContainer interfaces_0_2 = address.Assign(devices_0_2); | ||
Ipv4InterfaceContainer interfaces_1_2 = address.Assign(devices_1_2); | ||
address.NewNetwork(); | ||
address.SetBase("10.1.2.0", "255.255.255.0"); | ||
Ipv4InterfaceContainer interfaces_2_3 = address.Assign(devices_2_3); | ||
address.NewNetwork(); | ||
address.SetBase("10.1.3.0", "255.255.255.0"); | ||
Ipv4InterfaceContainer interfaces_2_4 = address.Assign(devices_2_4); | ||
address.NewNetwork(); | ||
address.SetBase("10.1.4.0", "255.255.255.0"); | ||
Ipv4InterfaceContainer interfaces_4_3 = address.Assign(devices_4_3); | ||
address.NewNetwork(); | ||
address.SetBase("10.1.5.0", "255.255.255.0"); | ||
Ipv4InterfaceContainer interfaces_3_5 = address.Assign(devices_3_5); | ||
address.NewNetwork(); | ||
Ipv4GlobalRoutingHelper::PopulateRoutingTables(); | ||
|
||
// Receiver address | ||
Ipv4Address receiver_addr = interfaces_3_5.GetAddress(1); | ||
|
||
// UDP Congestion traffic setup | ||
uint16_t udp_port = 5001; | ||
OnOffHelper udp_source("ns3::UdpSocketFactory", | ||
InetSocketAddress(receiver_addr, udp_port)); | ||
udp_source.SetAttribute( | ||
"OnTime", StringValue("ns3::ConstantRandomVariable[Constant=1]")); | ||
udp_source.SetAttribute( | ||
"OffTime", StringValue("ns3::ConstantRandomVariable[Constant=0]")); | ||
udp_source.SetAttribute("DataRate", DataRateValue(DataRate("1Mbps"))); | ||
udp_source.SetAttribute("PacketSize", UintegerValue(1024)); | ||
|
||
ApplicationContainer udp_app = udp_source.Install(nodes.Get(0)); | ||
udp_app.Start(Seconds(3.0)); | ||
udp_app.Stop(Seconds(6.0)); | ||
|
||
// TCP Setup | ||
SetupTCPConfig(); | ||
uint16_t tcp_port = 5002; | ||
BulkSendHelper tcp_source("ns3::TcpSocketFactory", | ||
InetSocketAddress(receiver_addr, tcp_port)); | ||
tcp_source.SetAttribute("MaxBytes", UintegerValue(10000)); // Tweak this | ||
ApplicationContainer tcp_app = tcp_source.Install(nodes.Get(1)); | ||
tcp_app.Start(Seconds(0.0)); | ||
tcp_app.Stop(Seconds(10.0)); | ||
|
||
// Packet sink setup (Receiver node) | ||
PacketSinkHelper sink("ns3::TcpSocketFactory", | ||
InetSocketAddress(Ipv4Address::GetAny(), tcp_port)); | ||
ApplicationContainer sink_app = sink.Install(nodes.Get(5)); | ||
tcp_app.Start(Seconds(0.0)); | ||
tcp_app.Start(Seconds(10.0)); | ||
|
||
// SimulationQueue::sinkAddress = | ||
// Mac48Address::ConvertFrom(getDevice<1>(devices_3_5)->GetAddress()); | ||
// NOTE: Is TrafficControlHelper needed here? | ||
|
||
// LFA Alternate Path setup | ||
// Set up an alternate forwarding target, assuming you have an alternate | ||
// 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>(devices01, getDevice<0>(devices02)); | ||
// setAlternateTarget<0>(devices02, getDevice<0>(devices01)); | ||
|
||
// setAlternateTarget<0>(devices12, getDevice<1>(devices01)); | ||
// setAlternateTarget<1>(devices01, getDevice<0>(devices12)); | ||
|
||
// setAlternateTarget<1>(devices02, getDevice<1>(devices12)); | ||
// 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/"); | ||
|
||
Simulator::Run(); | ||
Simulator::Destroy(); | ||
return 0; | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
some of these devices are not using a simulation queue, and could trigger a segfault.
e.g.
devices_0_2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
only
devices_2_3
is has a simulation queue