ApplicationContainer ac_sinkTcp[m_numSources]; // m_numSources is the number of sources
ApplicationContainer sourceApp[m_numSources];
int source_nodes[m_numSources] = {0, 1, 2};
int dest_interfaces[m_numSources] = {3, 7, 11};
Ptr<Socket> ns3TcpSocket[m_numSources];
Ptr<TestApp> app[m_numSources];
Address sinkAddress[m_numSources];
for (int i = 0; i < m_numSources; i++)
{
if (i == 0)
ac_sinkTcp[i] = sinkTcp0.Install (nc_wireless.Get(12));
if (i == 1)
ac_sinkTcp[i] = sinkTcp1.Install (nc_wireless.Get(12));
if (i == 2)
ac_sinkTcp[i] = sinkTcp2.Install (nc_wireless.Get(12));
ac_sinkTcp[i].Start (Seconds (0.1 + i * 0.1));
ac_sinkTcp[i].Stop (Seconds (m_totalTime));
ns3TcpSocket[i] = Socket::CreateSocket(nc_wireless.Get(source_nodes[i]), TcpSocketFactory::GetTypeId());
sinkAddress[i] = InetSocketAddress (if_wireless.GetAddress (dest_interfaces[i]), i+9);
app[i] = CreateObject<TestApp> ();
app[i]->Setup(ns3TcpSocket[i], sinkAddress[i], 1448, 5000, DataRate (m_txAppRate));
nc_wireless.Get(source_nodes[i])->AddApplication(app[i]);
app[i]->SetStartTime(Seconds(0.5 + i * 0.1));
app[i]->SetStopTime(Seconds(m_totalTime));
if(CwndTracerEnable)
{
AsciiTraceHelper ascii;
std::string filename = "cwnd-" + std::to_string(i) + ".data";
cWndStream = ascii.CreateFileStream (filename);
ns3TcpSocket[i]->TraceConnectWithoutContext ("CongestionWindow", MakeCallback (&CwndTracer));
}
}
static void
CwndTracer (uint32_t oldval, uint32_t newval)
{
if (firstCwnd)
{
*cWndStream->GetStream () << "0.0 " << oldval << std::endl;
firstCwnd = false;
}
*cWndStream->GetStream () << Simulator::Now ().GetSeconds () << " " << newval << std::endl;
cWndValue = newval;
if (!firstSshThr)
{
*ssThreshStream->GetStream () << Simulator::Now ().GetSeconds () << " " << ssThreshValue << std::endl;
}
}
if(CwndTracerEnable)
{
AsciiTraceHelper ascii;
std::string filename = "/home/mahesh/ns3/ns-allinone-3.26/ns-3.26/test-output/cwnd-" + std::to_string(i) + ".data";
//cWndStream = ascii.CreateFileStream ("/home/mahesh/ns3/ns-allinone-3.26/ns-3.26/test-output/cwnd.data");
cWndStream = ascii.CreateFileStream (filename);
ns3TcpSocket[i]->TraceConnectWithoutContext ("CongestionWindow", MakeCallback (&CwndTracer));
}
Program received signal SIGSEGV, Segmentation fault.
0x00007fffeca6d5d9 in std::ostream::sentry::sentry(std::ostream&) () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
app[i]->Setup(ns3TcpSocket[i], sinkAddress[i], 1448, 10000, DataRate (m_txAppRate));
Hello Peter,
I'm tracing TCP stats like CWND, RTT etc. In my scenario, I am varying the number of sources from nodes 1 to 24 except for node 12 which is the sink. Static routing is being used.
There are 3 flows in the code:
Flow 1: Node 0 to Node 12
Flow 2: Node 1 to Node 12
Flow 3: Node 2 to Node 12
I have to capture the TCP traces for each of these 3 flows. Only one flow's traces are being written to files. I know I have to make use of vectors but I don't know how to proceed.
Please help me out. Expecting your kind reply at the earliest.
Thanks,
Mahesh
<test.cc>