我正在尝试在 ns-3 中设置多跳 AdHoc 802.11g 网络。
首先,我使用了示例“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 永远不会被调用,这意味着套接字 Sink 没有接收到数据包。
整个代码:https ://gist.github.com/3023757
路由输出:
Ptr<OutputStreamWrapper> routingStream = Create<OutputStreamWrapper>
("wifi-multihop.routes", std::ios::out)