21 #include "ns3/log.h" |
21 #include "ns3/log.h" |
22 #include "ns3/node.h" |
22 #include "ns3/node.h" |
23 #include "ns3/inet-socket-address.h" |
23 #include "ns3/inet-socket-address.h" |
24 #include "ns3/ipv4-route.h" |
24 #include "ns3/ipv4-route.h" |
25 #include "ns3/ipv4.h" |
25 #include "ns3/ipv4.h" |
26 #include "ns3/ipv4.h" |
26 #include "ns3/udp-socket-factory.h" |
27 #include "ns3/udp.h" |
|
28 #include "ns3/trace-source-accessor.h" |
27 #include "ns3/trace-source-accessor.h" |
29 #include "ns3/uinteger.h" |
28 #include "ns3/uinteger.h" |
30 #include "ns3/boolean.h" |
29 #include "ns3/boolean.h" |
31 #include "udp-socket.h" |
30 #include "udp-socket.h" |
32 #include "udp-l4-protocol.h" |
31 #include "udp-l4-protocol.h" |
462 |
461 |
463 #ifdef RUN_SELF_TESTS |
462 #ifdef RUN_SELF_TESTS |
464 |
463 |
465 #include "ns3/test.h" |
464 #include "ns3/test.h" |
466 #include "ns3/socket-factory.h" |
465 #include "ns3/socket-factory.h" |
467 #include "ns3/udp.h" |
466 #include "ns3/udp-socket-factory.h" |
468 #include "ns3/simulator.h" |
467 #include "ns3/simulator.h" |
469 #include "ns3/simple-channel.h" |
468 #include "ns3/simple-channel.h" |
470 #include "ns3/simple-net-device.h" |
469 #include "ns3/simple-net-device.h" |
471 #include "ns3/drop-tail-queue.h" |
470 #include "ns3/drop-tail-queue.h" |
472 #include "internet-stack.h" |
471 #include "internet-stack.h" |
586 rxDev2->SetChannel (channel2); |
585 rxDev2->SetChannel (channel2); |
587 txDev2->SetChannel (channel2); |
586 txDev2->SetChannel (channel2); |
588 |
587 |
589 |
588 |
590 // Create the UDP sockets |
589 // Create the UDP sockets |
591 Ptr<SocketFactory> rxSocketFactory = rxNode->GetObject<Udp> (); |
590 Ptr<SocketFactory> rxSocketFactory = rxNode->GetObject<UdpSocketFactory> (); |
592 Ptr<Socket> rxSocket = rxSocketFactory->CreateSocket (); |
591 Ptr<Socket> rxSocket = rxSocketFactory->CreateSocket (); |
593 NS_TEST_ASSERT_EQUAL (rxSocket->Bind (InetSocketAddress (Ipv4Address ("10.0.0.1"), 1234)), 0); |
592 NS_TEST_ASSERT_EQUAL (rxSocket->Bind (InetSocketAddress (Ipv4Address ("10.0.0.1"), 1234)), 0); |
594 rxSocket->SetRecvCallback (MakeCallback (&UdpSocketTest::ReceivePkt, this)); |
593 rxSocket->SetRecvCallback (MakeCallback (&UdpSocketTest::ReceivePkt, this)); |
595 |
594 |
596 Ptr<Socket> rxSocket2 = rxSocketFactory->CreateSocket (); |
595 Ptr<Socket> rxSocket2 = rxSocketFactory->CreateSocket (); |
597 rxSocket2->SetRecvCallback (MakeCallback (&UdpSocketTest::ReceivePkt2, this)); |
596 rxSocket2->SetRecvCallback (MakeCallback (&UdpSocketTest::ReceivePkt2, this)); |
598 NS_TEST_ASSERT_EQUAL (rxSocket2->Bind (InetSocketAddress (Ipv4Address ("10.0.1.1"), 1234)), 0); |
597 NS_TEST_ASSERT_EQUAL (rxSocket2->Bind (InetSocketAddress (Ipv4Address ("10.0.1.1"), 1234)), 0); |
599 |
598 |
600 Ptr<SocketFactory> txSocketFactory = txNode->GetObject<Udp> (); |
599 Ptr<SocketFactory> txSocketFactory = txNode->GetObject<UdpSocketFactory> (); |
601 Ptr<Socket> txSocket = txSocketFactory->CreateSocket (); |
600 Ptr<Socket> txSocket = txSocketFactory->CreateSocket (); |
602 |
601 |
603 // ------ Now the tests ------------ |
602 // ------ Now the tests ------------ |
604 |
603 |
605 // Unicast test |
604 // Unicast test |