ospf_1_area_Dynamic.test 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298
  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. num-rngs = 2
  128. **.ospf.ospfConfig = xmldoc("ASConfig.xml")
  129. **.numUdpApps = 2
  130. **.udpApp[0].typename = "UDPBasicApp"
  131. **.udpApp[0].destPort = 1234
  132. **.udpApp[0].messageLength = 32 bytes
  133. **.udpApp[0].sendInterval = 1s
  134. **.udpApp[0].startTime = 100s + uniform(-0.5s, 0.5s, 1)
  135. **.udpApp[0].stopTime = this.startTime + 999.9s
  136. **.H2.udpApp[0].destAddresses = "H1"
  137. **.H1.udpApp[0].destAddresses = "H2"
  138. **.udpApp[1].typename = "UDPEchoApp"
  139. **.udpApp[1].localPort = 1234
  140. **.arp.cacheTimeout = 1s
  141. **.numIRouters = ${0,1,2,3,5,10,25}
  142. %#--------------------------------------------------------------------------------------------------------------
  143. %file: ASConfig.xml
  144. <?xml version="1.0"?>
  145. <OSPFASConfig xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="OSPF.xsd">
  146. <!-- Areas -->
  147. <Area id="0.0.0.0">
  148. <AddressRange address="192.168.1.0" mask="255.255.255.0" status="Advertise" />
  149. <AddressRange address="192.168.2.0" mask="255.255.255.0" status="Advertise" />
  150. <AddressRange address="192.168.60.0" mask="255.255.255.0" status="Advertise" />
  151. </Area>
  152. <!-- Routers -->
  153. <Router name="R1A" RFC1583Compatible="true">
  154. <BroadcastInterface ifName="eth0" areaID="0.0.0.0" interfaceOutputCost="1" routerPriority="1" />
  155. <PointToPointInterface toward="RA" areaID="0.0.0.0" interfaceOutputCost="1" />
  156. <PointToPointInterface toward="RB" areaID="0.0.0.0" interfaceOutputCost="2" />
  157. </Router>
  158. <Router name="RA" RFC1583Compatible="true">
  159. <PointToPointInterface toward="R1A" areaID="0.0.0.0" interfaceOutputCost="1" />
  160. <PointToPointInterface toward="R1B" areaID="0.0.0.0" interfaceOutputCost="1" />
  161. </Router>
  162. <Router name="RB" RFC1583Compatible="true">
  163. <PointToPointInterface toward="R1A" areaID="0.0.0.0" interfaceOutputCost="2" />
  164. <PointToPointInterface toward="R1B" areaID="0.0.0.0" interfaceOutputCost="2" />
  165. </Router>
  166. <Router name="R1B" RFC1583Compatible="true">
  167. <PointToPointInterface ifName="eth0" areaID="0.0.0.0" interfaceOutputCost="2" />
  168. <PointToPointInterface toward="RA" areaID="0.0.0.0" interfaceOutputCost="1" />
  169. <PointToPointInterface toward="RB" areaID="0.0.0.0" interfaceOutputCost="2" />
  170. </Router>
  171. <Router name="RI[*]" RFC1583Compatible="true">
  172. <PointToPointInterface ifName="eth0" areaID="0.0.0.0" interfaceOutputCost="2" />
  173. <PointToPointInterface ifName="eth1" areaID="0.0.0.0" interfaceOutputCost="2" />
  174. </Router>
  175. <Router name="R2" RFC1583Compatible="true">
  176. <PointToPointInterface ifName="eth0" areaID="0.0.0.0" interfaceOutputCost="2" />
  177. <BroadcastInterface ifName="eth1" areaID="0.0.0.0" interfaceOutputCost="1" routerPriority="2" />
  178. </Router>
  179. </OSPFASConfig>
  180. %#--------------------------------------------------------------------------------------------------------------
  181. %file: scenario.xml
  182. <scenario>
  183. <at t="350">
  184. <disconnect src-module="RA" src-gate="ethg$o[0]" />
  185. <disconnect src-module="R1A" src-gate="ethg$o[1]" />
  186. </at>
  187. <at t="850">
  188. <connect src-module="RA" src-gate="ethg[0]"
  189. dest-module="R1A" dest-gate="ethg[1]"
  190. channel-type="inet.common.misc.ThruputMeteringChannel">
  191. <param name="delay" value="0.1us" />
  192. <param name="datarate" value="100Mbps" />
  193. <param name="thruputDisplayFormat" value='"#N"' />
  194. </connect>
  195. </at>
  196. </scenario>
  197. %#--------------------------------------------------------------------------------------------------------------
  198. %postrun-command: Rscript check.r
  199. %#--------------------------------------------------------------------------------------------------------------
  200. %file: check.r
  201. #!/usr/bin/env Rscript
  202. options(echo=FALSE)
  203. options(width=160)
  204. library("omnetpp", warn.conflicts=FALSE)
  205. #TEST parameters
  206. runCount <- 7
  207. hostCount <- 2
  208. sentPk <- 1000
  209. echoedPk <- 960
  210. rcvdPk <- 960
  211. # begin TEST:
  212. cat("\nOMNETPP TEST RESULT:\n")
  213. x <- loadDataset('results/General-*.sca')
  214. ds <- x$scalars[grep("\\.H\\d\\.udpApp\\[\\d\\]$",x$scalars$module),]
  215. #merge runnumber column to ds:
  216. y <- subset(x$runattrs, attrname=='runnumber')
  217. names(y) <- c("runid","runnumber")
  218. ds <- merge(ds,y)
  219. sent <- ds[ds$name == "sentPk:count",]
  220. rcvd <- ds[ds$name == "rcvdPk:count",]
  221. echoed <- ds[ds$name == "echoedPk:count",]
  222. cat("\nOSPF TEST RESULT:\n")
  223. sent$success = (sent$value == sentPk)
  224. if(length(sent$value) == runCount*hostCount & min(sent$success) == TRUE)
  225. {
  226. cat("SENT OK\n")
  227. } else {
  228. cat("SENT BAD:\n")
  229. sent$rate = sent$value*100/sentPk
  230. print(sent)
  231. }
  232. echoed$success = (echoed$value >= echoedPk & echoed$value <= sentPk)
  233. if(length(echoed$value) == runCount*hostCount & min(echoed$success) == TRUE)
  234. {
  235. cat("ECHOED OK\n")
  236. } else {
  237. cat("ECHOED BAD:\n")
  238. echoed$rate = echoed$value*100/sentPk
  239. print(echoed)
  240. }
  241. rcvd$success = ((rcvd$value >= rcvdPk) & (rcvd$value <= sentPk))
  242. if(length(rcvd$value) == runCount*hostCount & min(rcvd$success) == TRUE)
  243. {
  244. cat("RCVD OK\n")
  245. } else {
  246. cat("RCVD BAD:\n")
  247. rcvd$rate = rcvd$value*100/sentPk
  248. print(rcvd)
  249. }
  250. cat("\n")
  251. %#--------------------------------------------------------------------------------------------------------------
  252. %contains: postrun-command(1).out
  253. OMNETPP TEST RESULT:
  254. OSPF TEST RESULT:
  255. SENT OK
  256. ECHOED OK
  257. RCVD OK
  258. %#--------------------------------------------------------------------------------------------------------------