我想建立一个多跳的AdHoc 802.11g标准的网络在NS-3。
要开始我使用的示例“wifi-simple-adhoc-grid.cc”。
本例使用UDP,但我想用TCP。 因此,我切换
TypeId tid = ns3::UdpSocketFactory::GetTypeId();
Ptr<Socket> recvSink = Socket::CreateSocket (c.Get (sinkNode), tid);
InetSocketAddress local = InetSocketAddress (Ipv4Address::GetAny (), 80);
recvSink->Bind (local);
recvSink->SetRecvCallback (MakeCallback (&ReceivePacket));
至
TypeId tid = ns3::TcpSocketFactory::GetTypeId();
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);
发送数据包是没有问题的,但ReceivePacket不会被调用,这意味着,插座灌不接收数据包。
整个代码: https://gist.github.com/3023757
路线输出方式:
Ptr<OutputStreamWrapper> routingStream = Create<OutputStreamWrapper>
("wifi-multihop.routes", std::ios::out)