ospf_1_area_Dynamic2.test.off 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  1. %description:
  2. Testing OSPF routing
  3. Backbone only with n routers
  4. UDP communications through entire backbone
  5. %#--------------------------------------------------------------------------------------------------------------
  6. %testprog: opp_run
  7. %#--------------------------------------------------------------------------------------------------------------
  8. %file: test.ned
  9. import inet.linklayer.ethernet.EtherHub;
  10. import inet.networklayer.configurator.ipv4.IPv4NetworkConfigurator;
  11. import inet.node.inet.StandardHost;
  12. import inet.node.ospfv2.OSPFRouter;
  13. import inet.common.misc.ThruputMeteringChannel;
  14. import inet.common.scenario.ScenarioManager;
  15. network Test1
  16. {
  17. parameters:
  18. int numIRouters = default(0);
  19. @display("p=10,10;b=712,152");
  20. types:
  21. channel C extends ThruputMeteringChannel
  22. {
  23. delay = 0.1us;
  24. datarate = 100Mbps;
  25. thruputDisplayFormat = "#N";
  26. }
  27. submodules:
  28. H1: StandardHost {
  29. parameters:
  30. @display("p=56,92;i=device/laptop");
  31. gates:
  32. ethg[1];
  33. }
  34. N1: EtherHub {
  35. parameters:
  36. @display("p=184,182");
  37. gates:
  38. ethg[2];
  39. }
  40. R1A: OSPFRouter {
  41. parameters:
  42. @display("p=226,132");
  43. gates:
  44. ethg[3];
  45. }
  46. RA: OSPFRouter {
  47. parameters:
  48. @display("p=266,92");
  49. gates:
  50. ethg[2];
  51. }
  52. RB: OSPFRouter {
  53. parameters:
  54. @display("p=266,182");
  55. gates:
  56. ethg[2];
  57. }
  58. R1B: OSPFRouter {
  59. parameters:
  60. @display("p=306,132");
  61. gates:
  62. ethg[3];
  63. }
  64. RI[numIRouters]: OSPFRouter {
  65. gates:
  66. ethg[2];
  67. }
  68. R2: OSPFRouter {
  69. parameters:
  70. @display("p=416,92");
  71. gates:
  72. ethg[2];
  73. }
  74. N2: EtherHub {
  75. parameters:
  76. @display("p=532,182");
  77. gates:
  78. ethg[2];
  79. }
  80. H2: StandardHost {
  81. parameters:
  82. @display("p=660,92;i=device/laptop");
  83. gates:
  84. ethg[1];
  85. }
  86. scenarioManager: ScenarioManager {
  87. parameters:
  88. @display("p=594,50");
  89. script = xmldoc("scenario.xml");
  90. // script = xml("<empty/>");
  91. }
  92. configurator: IPv4NetworkConfigurator {
  93. parameters:
  94. config = xml("<config>"+
  95. "<interface among='H1 R1A' address='192.168.1.x' netmask='255.255.255.0' />"+
  96. "<interface among='H2 R2' address='192.168.2.x' netmask='255.255.255.0' />"+
  97. "<interface among='R1A R1B RA RB RI[*] R2' address='192.168.60.x' netmask='255.255.255.x' />"+
  98. "<route hosts='H1 H2' destination='*' netmask='0.0.0.0' interface='eth0' />"+
  99. "</config>");
  100. addStaticRoutes = false;
  101. addDefaultRoutes = false;
  102. @display("p=75,43");
  103. }
  104. connections:
  105. H1.ethg[0] <--> C <--> N1.ethg[0];
  106. N1.ethg[1] <--> C <--> R1A.ethg[0];
  107. R1A.ethg[1] <--> C <--> RA.ethg[0];
  108. R1A.ethg[2] <--> C <--> RB.ethg[0];
  109. RA.ethg[1] <--> C <--> R1B.ethg[1];
  110. RB.ethg[1] <--> C <--> R1B.ethg[2];
  111. R1B.ethg[0] <--> C <--> R2.ethg[0] if numIRouters == 0;
  112. R1B.ethg[0] <--> C <--> RI[0].ethg[0] if numIRouters > 0;
  113. for i = 1..numIRouters-1 {
  114. RI[i-1].ethg[1] <--> C <--> RI[i].ethg[0];
  115. }
  116. RI[numIRouters-1].ethg[1] <--> C <--> R2.ethg[0] if numIRouters > 0;
  117. R2.ethg[1] <--> C <--> N2.ethg[0];
  118. N2.ethg[1] <--> C <--> H2.ethg[0];
  119. }
  120. %#--------------------------------------------------------------------------------------------------------------
  121. %inifile: omnetpp.ini
  122. [General]
  123. description = "Simple test"
  124. network = Test1
  125. tkenv-plugin-path = ../../../etc/plugins
  126. sim-time-limit = 1200s
  127. **.ospf.ospfConfig = xmldoc("ASConfig.xml")
  128. **.numUdpApps = 2
  129. **.udpApp[0].typename = "UDPBasicApp"
  130. **.udpApp[0].destPort = 1234
  131. **.udpApp[0].messageLength = 32 bytes
  132. **.udpApp[0].sendInterval = 1s
  133. **.udpApp[0].startTime = 100s + uniform(-0.2s, 0.2s)
  134. **.udpApp[0].stopTime = this.startTime + 1000s
  135. **.H2.udpApp[0].destAddresses = "H1"
  136. **.H1.udpApp[0].destAddresses = "H2"
  137. **.udpApp[1].typename = "UDPEchoApp"
  138. **.udpApp[1].localPort = 1234
  139. **.arp.cacheTimeout = 1s
  140. **.numIRouters = ${3,3,3,3,3,3}
  141. %#--------------------------------------------------------------------------------------------------------------
  142. %file: ASConfig.xml
  143. <?xml version="1.0"?>
  144. <OSPFASConfig xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="OSPF.xsd">
  145. <!-- Areas -->
  146. <Area id="0.0.0.0">
  147. <AddressRange address="192.168.1.0" mask="255.255.255.0" status="Advertise" />
  148. <AddressRange address="192.168.2.0" mask="255.255.255.0" status="Advertise" />
  149. <AddressRange address="192.168.60.0" mask="255.255.255.0" status="Advertise" />
  150. </Area>
  151. <!-- Routers -->
  152. <Router name="R1A" RFC1583Compatible="true">
  153. <BroadcastInterface ifName="eth0" areaID="0.0.0.0" interfaceOutputCost="1" routerPriority="1" />
  154. <PointToPointInterface toward="RA" areaID="0.0.0.0" interfaceOutputCost="1" />
  155. <PointToPointInterface toward="RB" areaID="0.0.0.0" interfaceOutputCost="2" />
  156. </Router>
  157. <Router name="RA" RFC1583Compatible="true">
  158. <PointToPointInterface toward="R1A" areaID="0.0.0.0" interfaceOutputCost="1" />
  159. <PointToPointInterface toward="R1B" areaID="0.0.0.0" interfaceOutputCost="1" />
  160. </Router>
  161. <Router name="RB" RFC1583Compatible="true">
  162. <PointToPointInterface toward="R1A" areaID="0.0.0.0" interfaceOutputCost="2" />
  163. <PointToPointInterface toward="R1B" areaID="0.0.0.0" interfaceOutputCost="2" />
  164. </Router>
  165. <Router name="R1B" RFC1583Compatible="true">
  166. <PointToPointInterface ifName="eth0" areaID="0.0.0.0" interfaceOutputCost="2" />
  167. <PointToPointInterface toward="RA" areaID="0.0.0.0" interfaceOutputCost="1" />
  168. <PointToPointInterface toward="RB" areaID="0.0.0.0" interfaceOutputCost="2" />
  169. </Router>
  170. <Router name="RI[*]" RFC1583Compatible="true">
  171. <PointToPointInterface ifName="eth0" areaID="0.0.0.0" interfaceOutputCost="2" />
  172. <PointToPointInterface ifName="eth1" areaID="0.0.0.0" interfaceOutputCost="2" />
  173. </Router>
  174. <Router name="R2" RFC1583Compatible="true">
  175. <PointToPointInterface ifName="eth0" areaID="0.0.0.0" interfaceOutputCost="2" />
  176. <BroadcastInterface ifName="eth1" areaID="0.0.0.0" interfaceOutputCost="1" routerPriority="2" />
  177. </Router>
  178. </OSPFASConfig>
  179. %#--------------------------------------------------------------------------------------------------------------
  180. %file: scenario.xml
  181. <scenario>
  182. <at t="350">
  183. <disconnect src-module="RA" src-gate="ethg$o[0]" />
  184. <disconnect src-module="R1A" src-gate="ethg$o[1]" />
  185. </at>
  186. <at t="850">
  187. <connect src-module="RA" src-gate="ethg[0]"
  188. dest-module="R1A" dest-gate="ethg[1]"
  189. channel-type="inet.common.misc.ThruputMeteringChannel">
  190. <param name="delay" value="0.1us" />
  191. <param name="datarate" value="100Mbps" />
  192. <param name="thruputDisplayFormat" value='"#N"' />
  193. </connect>
  194. </at>
  195. </scenario>
  196. %#--------------------------------------------------------------------------------------------------------------
  197. %postrun-command: Rscript check.r
  198. %#--------------------------------------------------------------------------------------------------------------
  199. %file: check.r
  200. #!/usr/bin/env Rscript
  201. options(echo=FALSE)
  202. options(width=160)
  203. library("omnetpp", warn.conflicts=FALSE)
  204. #TEST parameters
  205. runCount <- 6
  206. hostCount <- 2
  207. sentPk <- 1000
  208. echoedPk <- 920
  209. rcvdPk <- 920
  210. # begin TEST:
  211. cat("\nOMNETPP TEST RESULT:\n")
  212. x <- loadDataset('results/General-*.sca')
  213. ds <- x$scalars[grep("\\.H\\d\\.udpApp\\[\\d\\]$",x$scalars$module),]
  214. #merge runnumber column to ds:
  215. y <- subset(x$runattrs, attrname=='runnumber')
  216. names(y) <- c("runid","runnumber")
  217. ds <- merge(ds,y)
  218. sent <- ds[ds$name == "sentPk:count",]
  219. rcvd <- ds[ds$name == "rcvdPk:count",]
  220. echoed <- ds[ds$name == "echoedPk:count",]
  221. cat("\nOSPF TEST RESULT:\n")
  222. sent$success = (sent$value == sentPk)
  223. if(length(sent$value) == runCount*hostCount & min(sent$success) == TRUE)
  224. {
  225. cat("SENT OK\n")
  226. } else {
  227. cat("SENT BAD:\n")
  228. sent$rate = sent$value*100/sentPk
  229. print(sent)
  230. }
  231. echoed$success = (echoed$value >= echoedPk & echoed$value <= sentPk)
  232. if(length(echoed$value) == runCount*hostCount & min(echoed$success) == TRUE)
  233. {
  234. cat("ECHOED OK\n")
  235. } else {
  236. cat("ECHOED BAD:\n")
  237. echoed$rate = echoed$value*100/sentPk
  238. print(echoed)
  239. }
  240. rcvd$success = ((rcvd$value >= rcvdPk) & (rcvd$value <= sentPk))
  241. if(length(rcvd$value) == runCount*hostCount & min(rcvd$success) == TRUE)
  242. {
  243. cat("RCVD OK\n")
  244. } else {
  245. cat("RCVD BAD:\n")
  246. rcvd$rate = rcvd$value*100/sentPk
  247. print(rcvd)
  248. }
  249. cat("\n")
  250. %#--------------------------------------------------------------------------------------------------------------
  251. %contains: postrun-command(1).out
  252. OMNETPP TEST RESULT:
  253. OSPF TEST RESULT:
  254. SENT OK
  255. ECHOED OK
  256. RCVD OK
  257. %#--------------------------------------------------------------------------------------------------------------