UDPSocket_1.test 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. %description:
  2. Tests UDPSocket method calls:
  3. 1. Socket options can be set before the bind() or connect() call.
  4. 2. connect() can be called more than once.
  5. 3. bind() can be called after connect().
  6. %file: TestApp.cc
  7. #include "inet/transportlayer/contract/udp/UDPSocket.h"
  8. #include "inet/transportlayer/contract/udp/UDPControlInfo_m.h"
  9. using namespace inet;
  10. namespace UDPSocket_1 {
  11. class TestApp : public cSimpleModule
  12. {
  13. public:
  14. TestApp() : cSimpleModule(65536) {}
  15. protected:
  16. virtual void activity();
  17. };
  18. Define_Module(TestApp);
  19. void TestApp::activity()
  20. {
  21. UDPSocket s;
  22. s.setOutputGate(gate("udpOut"));
  23. s.setMulticastLoop(false);
  24. s.connect(L3Address("10.0.0.1"), 1000);
  25. s.bind(100);
  26. s.connect(L3Address("10.0.0.2"), 2000);
  27. }
  28. }
  29. %file: TestApp.ned
  30. import inet.applications.contract.IUDPApp;
  31. simple TestApp like IUDPApp
  32. {
  33. gates:
  34. input udpIn;
  35. output udpOut;
  36. }
  37. %inifile: omnetpp.ini
  38. [General]
  39. ned-path = .;../../../../src;../../lib
  40. network = SimpleTestNetwork
  41. cmdenv-express-mode = false
  42. cmdenv-log-prefix = "C:%C: "
  43. #omnetpp 5.0 - 5.1 compatibility:
  44. eventlog-file = "${resultdir}/${configname}-${runnumber}.elog"
  45. output-scalar-file = "${resultdir}/${configname}-${runnumber}.sca"
  46. output-vector-file = "${resultdir}/${configname}-${runnumber}.vec"
  47. snapshot-file = "${resultdir}/${configname}-${runnumber}.sna"
  48. **.client.numUdpApps = 1
  49. **.client.udpApp[0].typename = "TestApp"
  50. **.client.udpApp[0].cmdenv-log-level=TRACE
  51. %contains: stdout
  52. C:(TestApp)SimpleTestNetwork.client.udpApp[0]: UDPSocket: Send (omnetpp::cMessage)SetMulticastLoop control info: (inet::UDPSetMulticastLoopCommand)
  53. C:(TestApp)SimpleTestNetwork.client.udpApp[0]: UDPSocket: Send (omnetpp::cMessage)CONNECT control info: (inet::UDPConnectCommand)
  54. C:(TestApp)SimpleTestNetwork.client.udpApp[0]: UDPSocket: Send (omnetpp::cMessage)BIND control info: (inet::UDPBindCommand)
  55. C:(TestApp)SimpleTestNetwork.client.udpApp[0]: UDPSocket: Send (omnetpp::cMessage)CONNECT control info: (inet::UDPConnectCommand)
  56. %contains-regex: stdout
  57. C:\(UDP\)SimpleTestNetwork\.client\.udp: Socket created: sockId=2 appGateIndex=0 localPort=1025
  58. .*
  59. C:\(UDP\)SimpleTestNetwork\.client\.udp: Socket connected: sockId=2 appGateIndex=0 localPort=1025 remotePort=1000 remoteAddr=10\.0\.0\.1 multicastLoop=0
  60. .*
  61. C:\(UDP\)SimpleTestNetwork\.client\.udp: Socket connected: sockId=2 appGateIndex=0 localPort=100 remotePort=2000 remoteAddr=10\.0\.0\.2 multicastLoop=0
  62. %#--------------------------------------------------------------------------------------------------------------
  63. %not-contains: stdout
  64. undisposed object:
  65. %not-contains: stdout
  66. -- check module destructor
  67. %#--------------------------------------------------------------------------------------------------------------