diffserv_baclassifier_1.test 4.4 KB

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