Dear NS-3 users,
Hope you all had a great holidays!
I am simulating a scenario with Wi-Fi nodes using OLSR, where the source node sends a certain traffic to the sink node. My scenario is very similar to the one on wifi-simple-adhoc-grid.cc, but I want to use TCP instead.
I modified the code to use TcpSocketFactory instead of UdpSocketFactory. I am also using the FlowMonitor to get the statistics of the transmission. Please see code snippet below.
NodeContainer c;
c.Create (numNodes);
...
Ipv4AddressHelper ipv4;
NS_LOG_INFO ("Assign IP Addresses.");
ipv4.SetBase ("10.1.1.0", "255.255.255.0");
Ipv4InterfaceContainer i = ipv4.Assign (devices);
TypeId tid = TypeId::LookupByName ("ns3::TcpSocketFactory");
Ptr<Socket> recvSink = Socket::CreateSocket (c.Get (sinkNode), tid);
InetSocketAddress local = InetSocketAddress (Ipv4Address::GetAny (), 80);
recvSink->Bind (local);
recvSink->SetRecvCallback (MakeCallback (&ReceivePacket));
Ptr<Socket> source = Socket::CreateSocket (c.Get (sourceNode), tid);
InetSocketAddress remote = InetSocketAddress (i.GetAddress (sinkNode, 0), 80);
source->Connect (remote);
...
// Give OLSR time to converge-- 30 seconds perhaps
Simulator::Schedule (Seconds (30.0), &GenerateTraffic,
source, packetSize, numPackets, interPacketInterval);
Problem 1:
FlowMonitor shows only one packer transmitted and one received;
Problem 2:
ReceivePacket method is never called.
I was reading the TCP reference page (
https://www.nsnam.org/docs/release/3.24/models/html/tcp.html) and looked at the examples in ns-3/examples/tcp, but I could not figure out what is missing.
What is the best way to implement TCP in NS-3? I want an application to send 1000 packets of 1040 bytes each, every 100 ms.
Thanks in advance for your help.
Thiago