#include <string>
#include <fstream>
#include "ns3/core-module.h"
#include "ns3/point-to-point-module.h"
#include "ns3/internet-module.h"
#include "ns3/applications-module.h"
#include "ns3/network-module.h"
#include "ns3/packet-sink.h"
int sf = 2;
using namespace ns3;
int main(int argc, char *argv[])
{
Config::SetDefault("ns3::Ipv4GlobalRouting::FlowEcmpRouting", BooleanValue(true));
Config::SetDefault("ns3::TcpSocket::SegmentSize", UintegerValue(1400));
Config::SetDefault("ns3::TcpSocket::DelAckCount", UintegerValue(3));
Config::SetDefault("ns3::DropTailQueue::Mode", StringValue("QUEUE_MODE_PACKETS"));
Config::SetDefault("ns3::DropTailQueue::MaxPackets", UintegerValue(100));
Config::SetDefault("ns3::TcpL4Protocol::SocketType", TypeIdValue(MpTcpSocketBase::GetTypeId()));
Config::SetDefault("ns3::MpTcpSocketBase::MaxSubflows", UintegerValue(8)); // Sink
Config::SetDefault("ns3::MpTcpSocketBase::CongestionControl", StringValue("Linked_Increases")); // Fully_Coupled Linked_Increases
Config::SetDefault("ns3::MpTcpSocketBase::SchedulingAlgorithm", StringValue("Round_Robin"));
Config::SetDefault("ns3::MpTcpSocketBase::PathManagement", StringValue("FullMesh"));
NodeContainer nodes;
nodes.Create(6);
InternetStackHelper internet;
internet.Install(nodes);
PointToPointHelper p2plink;
p2plink.SetDeviceAttribute ("DataRate", StringValue("5Mbps"));
p2plink.SetChannelAttribute("Delay", StringValue("10ms"));
PointToPointHelper p2plinkb;
p2plinkb.SetDeviceAttribute ("DataRate", StringValue("0.5Mbps"));
p2plinkb.SetChannelAttribute("Delay", StringValue("100ms"));
p2plinkb.SetQueue ("ns3::DropTailQueue","MaxPackets", StringValue ("100"));
NodeContainer n0n2 = NodeContainer(nodes.Get(0),nodes.Get(2));
NodeContainer n1n2 = NodeContainer(nodes.Get(1),nodes.Get(2));
NodeContainer n2n3 = NodeContainer(nodes.Get(2),nodes.Get(3));
NodeContainer n3n4 = NodeContainer(nodes.Get(3),nodes.Get(4));
NodeContainer n3n5 = NodeContainer(nodes.Get(3),nodes.Get(5));
NodeContainer n0n4 = NodeContainer(nodes.Get(0),nodes.Get(4));
Ipv4AddressHelper ipv4addr;
NetDeviceContainer dn0n2;
dn0n2 = p2plink.Install(n0n2);
NetDeviceContainer dn1n2;
dn1n2 = p2plink.Install(n1n2);
NetDeviceContainer dn2n3;
dn2n3 = p2plinkb.Install(n2n3);
NetDeviceContainer dn3n4;
dn3n4 = p2plink.Install(n3n4);
NetDeviceContainer dn3n5;
dn3n5 = p2plink.Install(n3n5);
NetDeviceContainer dn0n4;
dn0n4 = p2plink.Install(n0n4);
ipv4addr.SetBase("10.1.1.0", "255.255.255.0");
Ipv4InterfaceContainer in0n2 = ipv4addr.Assign(dn0n2);
ipv4addr.SetBase("10.1.2.0", "255.255.255.0");
Ipv4InterfaceContainer in1n2 = ipv4addr.Assign(dn1n2);
ipv4addr.SetBase("10.1.3.0", "255.255.255.0");
Ipv4InterfaceContainer in2n3 = ipv4addr.Assign(dn2n3);
ipv4addr.SetBase("10.1.4.0", "255.255.255.0");
Ipv4InterfaceContainer in3n4 = ipv4addr.Assign(dn3n4);
ipv4addr.SetBase("10.1.5.0", "255.255.255.0");
Ipv4InterfaceContainer in3n5 = ipv4addr.Assign(dn3n5);
ipv4addr.SetBase("10.1.6.0", "255.255.255.0");
Ipv4InterfaceContainer in0n4 = ipv4addr.Assign(dn0n4);
Ipv4GlobalRoutingHelper::PopulateRoutingTables();
uint16_t port = 9;
MpTcpPacketSinkHelper sink("ns3::TcpSocketFactory", InetSocketAddress(Ipv4Address::GetAny(), port));
ApplicationContainer sinkApps = sink.Install(nodes.Get(4));
sinkApps.Start(Seconds(0.0));
sinkApps.Stop(Seconds(1000.0));
MpTcpBulkSendHelper source("ns3::TcpSocketFactory", InetSocketAddress("10.1.4.1", port));
source.SetAttribute("MaxBytes", UintegerValue(1000000));
ApplicationContainer sourceApps = source.Install(nodes.Get(0));
sourceApps.Start(Seconds(0.0));
sourceApps.Stop(Seconds(100.0));
Simulator::Stop(Seconds(2000.0));
Simulator::Run();
Simulator::Destroy();
}
Handle peer error means the connection isn't even established, no SYN sent, no addresses advertised.
Please help in this.