diffserv_dscpmarker_1.test 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  1. %description: Tests for DSCPMarker
  2. %file: TestApp.ned
  3. simple TestApp
  4. {
  5. gates:
  6. input in;
  7. output out[];
  8. }
  9. %file: TestApp.cc
  10. #include <fstream>
  11. #include "inet/common/INETDefs.h"
  12. #include "inet/networklayer/ipv4/IPv4Datagram.h"
  13. #include "inet/networklayer/ipv6/IPv6Datagram.h"
  14. namespace diffserv_dscpmarker_1
  15. {
  16. using namespace inet;
  17. class INET_API TestApp : public cSimpleModule
  18. {
  19. std::ofstream out;
  20. protected:
  21. void initialize();
  22. void finalize();
  23. void handleMessage(cMessage *msg);
  24. };
  25. Define_Module(TestApp);
  26. void TestApp::initialize()
  27. {
  28. out.open("result.txt");
  29. if (out.fail())
  30. throw cRuntimeError("Can not open output file.");
  31. char buf[30];
  32. // send 64 IPv4 datagram
  33. for (int i = 0; i < 64; i++)
  34. {
  35. sprintf(buf, "ipv4-%d", i);
  36. IPv4Datagram *datagram = new IPv4Datagram(buf);
  37. send(datagram, "out", i);
  38. }
  39. // send 64 IPv6 datagram
  40. for (int i = 0; i < 64; i++)
  41. {
  42. sprintf(buf, "ipv6-%d", i);
  43. IPv6Datagram *datagram = new IPv6Datagram(buf);
  44. send(datagram, "out", i);
  45. }
  46. }
  47. void TestApp::finalize()
  48. {
  49. out.close();
  50. }
  51. void TestApp::handleMessage(cMessage *msg)
  52. {
  53. if (dynamic_cast<IPv4Datagram*>(msg))
  54. {
  55. IPv4Datagram *datagram = (IPv4Datagram*)msg;
  56. out << datagram->getName() << ": " << datagram->getDiffServCodePoint() << "\n";
  57. }
  58. else if (dynamic_cast<IPv6Datagram*>(msg))
  59. {
  60. IPv6Datagram *datagram = (IPv6Datagram*)msg;
  61. out << datagram->getName() << ": " << datagram->getDiffServCodePoint() << "\n";
  62. }
  63. delete msg;
  64. }
  65. }
  66. %file: TestNetwork.ned
  67. import inet.networklayer.diffserv.DSCPMarker;
  68. network TestNetwork
  69. {
  70. submodules:
  71. app: TestApp;
  72. marker: DSCPMarker { dscps = "*"; }
  73. connections:
  74. for i=0..63 {
  75. app.out++ --> marker.in++;
  76. }
  77. marker.out --> app.in;
  78. }
  79. %inifile: omnetpp.ini
  80. ned-path = .;../../../../src;../../lib
  81. sim-time-limit=100s
  82. cmdenv-express-mode = true
  83. network = TestNetwork
  84. #omnetpp 5.0 - 5.1 compatibility:
  85. eventlog-file = "${resultdir}/${configname}-${runnumber}.elog"
  86. output-scalar-file = "${resultdir}/${configname}-${runnumber}.sca"
  87. output-vector-file = "${resultdir}/${configname}-${runnumber}.vec"
  88. snapshot-file = "${resultdir}/${configname}-${runnumber}.sna"
  89. %contains: result.txt
  90. ipv4-1: 1
  91. ipv4-2: 2
  92. ipv4-3: 3
  93. ipv4-4: 4
  94. ipv4-5: 5
  95. ipv4-6: 6
  96. ipv4-7: 7
  97. ipv4-8: 8
  98. ipv4-9: 9
  99. ipv4-10: 10
  100. ipv4-11: 11
  101. ipv4-12: 12
  102. ipv4-13: 13
  103. ipv4-14: 14
  104. ipv4-15: 15
  105. ipv4-16: 16
  106. ipv4-17: 17
  107. ipv4-18: 18
  108. ipv4-19: 19
  109. ipv4-20: 20
  110. ipv4-21: 21
  111. ipv4-22: 22
  112. ipv4-23: 23
  113. ipv4-24: 24
  114. ipv4-25: 25
  115. ipv4-26: 26
  116. ipv4-27: 27
  117. ipv4-28: 28
  118. ipv4-29: 29
  119. ipv4-30: 30
  120. ipv4-31: 31
  121. ipv4-32: 32
  122. ipv4-33: 33
  123. ipv4-34: 34
  124. ipv4-35: 35
  125. ipv4-36: 36
  126. ipv4-37: 37
  127. ipv4-38: 38
  128. ipv4-39: 39
  129. ipv4-40: 40
  130. ipv4-41: 41
  131. ipv4-42: 42
  132. ipv4-43: 43
  133. ipv4-44: 44
  134. ipv4-45: 45
  135. ipv4-46: 46
  136. ipv4-47: 47
  137. ipv4-48: 48
  138. ipv4-49: 49
  139. ipv4-50: 50
  140. ipv4-51: 51
  141. ipv4-52: 52
  142. ipv4-53: 53
  143. ipv4-54: 54
  144. ipv4-55: 55
  145. ipv4-56: 56
  146. ipv4-57: 57
  147. ipv4-58: 58
  148. ipv4-59: 59
  149. ipv4-60: 60
  150. ipv4-61: 61
  151. ipv4-62: 62
  152. ipv4-63: 63
  153. ipv6-0: 0
  154. ipv6-1: 1
  155. ipv6-2: 2
  156. ipv6-3: 3
  157. ipv6-4: 4
  158. ipv6-5: 5
  159. ipv6-6: 6
  160. ipv6-7: 7
  161. ipv6-8: 8
  162. ipv6-9: 9
  163. ipv6-10: 10
  164. ipv6-11: 11
  165. ipv6-12: 12
  166. ipv6-13: 13
  167. ipv6-14: 14
  168. ipv6-15: 15
  169. ipv6-16: 16
  170. ipv6-17: 17
  171. ipv6-18: 18
  172. ipv6-19: 19
  173. ipv6-20: 20
  174. ipv6-21: 21
  175. ipv6-22: 22
  176. ipv6-23: 23
  177. ipv6-24: 24
  178. ipv6-25: 25
  179. ipv6-26: 26
  180. ipv6-27: 27
  181. ipv6-28: 28
  182. ipv6-29: 29
  183. ipv6-30: 30
  184. ipv6-31: 31
  185. ipv6-32: 32
  186. ipv6-33: 33
  187. ipv6-34: 34
  188. ipv6-35: 35
  189. ipv6-36: 36
  190. ipv6-37: 37
  191. ipv6-38: 38
  192. ipv6-39: 39
  193. ipv6-40: 40
  194. ipv6-41: 41
  195. ipv6-42: 42
  196. ipv6-43: 43
  197. ipv6-44: 44
  198. ipv6-45: 45
  199. ipv6-46: 46
  200. ipv6-47: 47
  201. ipv6-48: 48
  202. ipv6-49: 49
  203. ipv6-50: 50
  204. ipv6-51: 51
  205. ipv6-52: 52
  206. ipv6-53: 53
  207. ipv6-54: 54
  208. ipv6-55: 55
  209. ipv6-56: 56
  210. ipv6-57: 57
  211. ipv6-58: 58
  212. ipv6-59: 59
  213. ipv6-60: 60
  214. ipv6-61: 61
  215. ipv6-62: 62
  216. ipv6-63: 63
  217. %#--------------------------------------------------------------------------------------------------------------
  218. %not-contains: stdout
  219. undisposed object:
  220. %not-contains: stdout
  221. -- check module destructor
  222. %#--------------------------------------------------------------------------------------------------------------