LargeNet.ned 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296
  1. //
  2. // Copyright (C) 2003 CTIE, Monash University
  3. //
  4. // This program is free software; you can redistribute it and/or
  5. // modify it under the terms of the GNU General Public License
  6. // as published by the Free Software Foundation; either version 2
  7. // of the License, or (at your option) any later version.
  8. //
  9. // This program is distributed in the hope that it will be useful,
  10. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. // GNU General Public License for more details.
  13. //
  14. // You should have received a copy of the GNU General Public License
  15. // along with this program; if not, write to the Free Software
  16. // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  17. //
  18. package inet.examples.ethernet.lans;
  19. import inet.linklayer.ethernet.EtherBus;
  20. import inet.linklayer.ethernet.EtherHub;
  21. import inet.node.ethernet.EtherHost;
  22. import inet.node.ethernet.EtherSwitch;
  23. import ned.DatarateChannel;
  24. //
  25. // A 100Mb/s Ethernet cable. Part of ~LargeNet.
  26. //
  27. channel cable extends DatarateChannel
  28. {
  29. parameters:
  30. delay = 0.1us;
  31. datarate = 100Mbps;
  32. }
  33. //
  34. // Several hosts on an Ethernet hub; part of ~LargeNet.
  35. //
  36. module SmallLAN
  37. {
  38. parameters:
  39. int h; // number of hosts on the hub
  40. @display("i=old/cloud_s");
  41. gates:
  42. inout ethg;
  43. submodules:
  44. hub: EtherHub {
  45. @display("is=s");
  46. }
  47. host[h]: EtherHost {
  48. @display("is=s");
  49. }
  50. connections:
  51. for i=0..h-1 {
  52. hub.ethg++ <--> cable <--> host[i].ethg;
  53. }
  54. hub.ethg++ <--> ethg;
  55. }
  56. //
  57. // Several hosts and an Ethernet hub on a switch; part of ~LargeNet.
  58. //
  59. module MediumLAN
  60. {
  61. parameters:
  62. int n; // number of hosts on the switch
  63. int h; // number of hosts on the hub
  64. @display("i=old/cloud_s");
  65. gates:
  66. inout ethg;
  67. submodules:
  68. switch: EtherSwitch {
  69. @display("is=s");
  70. }
  71. host[n]: EtherHost {
  72. @display("is=s");
  73. }
  74. hub: EtherHub {
  75. @display("is=s");
  76. }
  77. hhost[h]: EtherHost {
  78. @display("is=s");
  79. }
  80. connections:
  81. for i=0..n-1 {
  82. switch.ethg++ <--> cable <--> host[i].ethg;
  83. }
  84. switch.ethg++ <--> ethg;
  85. for i=0..h-1 {
  86. hub.ethg++ <--> cable <--> hhost[i].ethg;
  87. }
  88. switch.ethg++ <--> cable <--> hub.ethg++;
  89. }
  90. //
  91. // Several hosts and an Ethernet hub on a switch. One port of the hub
  92. // connect to a 10Base2 segment. Part of ~LargeNet.
  93. //
  94. module LargeLAN
  95. {
  96. parameters:
  97. int n; // number of hosts on the switch
  98. int h; // number of hosts on the hub
  99. int b; // number of hosts on the bus
  100. @display("i=old/cloud");
  101. gates:
  102. inout ethg;
  103. types:
  104. channel cabletobus extends DatarateChannel
  105. {
  106. parameters:
  107. delay = 0;
  108. datarate = 10Mbps;
  109. }
  110. submodules:
  111. switch: EtherSwitch {
  112. @display("is=s");
  113. }
  114. host[n]: EtherHost {
  115. @display("is=s");
  116. }
  117. hub: EtherHub {
  118. @display("is=s");
  119. }
  120. hhost[h]: EtherHost {
  121. @display("is=s");
  122. }
  123. bus: EtherBus {
  124. parameters:
  125. positions = "5 10 15"; // every 5 meters
  126. propagationSpeed = 2e8 mps; // 1us = 200m
  127. @display("b=424,6;o=#408060");
  128. }
  129. bhost[b]: EtherHost {
  130. parameters:
  131. @display("is=s;p=,r");
  132. }
  133. connections:
  134. for i=0..n-1 {
  135. switch.ethg++ <--> cable <--> host[i].ethg;
  136. }
  137. switch.ethg++ <--> ethg;
  138. for i=0..h-1 {
  139. hub.ethg++ <--> cabletobus <--> hhost[i].ethg;
  140. }
  141. switch.ethg++ <--> cabletobus <--> hub.ethg++;
  142. for i=0..b-1 {
  143. bus.ethg++ <--> cabletobus <--> bhost[i].ethg;
  144. }
  145. bus.ethg++ <--> cabletobus <--> hub.ethg++;
  146. }
  147. //
  148. // A large Ethernet LAN -- see model description
  149. // <a href="largenet.html">here</a>.
  150. //
  151. network LargeNet
  152. {
  153. parameters:
  154. int n; // length of the "backbone" (n>5!)
  155. int bbs; // number of small LANs on "backbone" switches
  156. int bbm; // number of medium LANs on "backbone" switches
  157. int bbl; // number of large LANs on "backbone" switches
  158. int as; // number of small LANs on switch A
  159. int am; // number of medium LANs on switch A
  160. int al; // number of large LANs on switch A
  161. int bs; // number of small LANs on switch B
  162. int bm; // number of medium LANs on switch B
  163. int bl; // number of large LANs on switch B
  164. int cs; // number of small LANs on switch C
  165. int cm; // number of medium LANs on switch C
  166. int cl; // number of large LANs on switch C
  167. int ds; // number of small LANs on switch D
  168. int dm; // number of medium LANs on switch D
  169. int dl; // number of large LANs on switch D
  170. types:
  171. channel cabletoserver extends DatarateChannel
  172. {
  173. parameters:
  174. delay = 0;
  175. datarate = 1Gbps;
  176. }
  177. submodules:
  178. switchBB[n]: EtherSwitch {
  179. @display("is=s");
  180. }
  181. slanBB[n*bbs]: SmallLAN;
  182. mlanBB[n*bbm]: MediumLAN;
  183. llanBB[n*bbl]: LargeLAN;
  184. switchA: EtherSwitch;
  185. serverA: EtherHost;
  186. slanA[as]: SmallLAN;
  187. mlanA[am]: MediumLAN;
  188. llanA[al]: LargeLAN;
  189. switchB: EtherSwitch;
  190. serverB: EtherHost;
  191. slanB[bs]: SmallLAN;
  192. mlanB[bm]: MediumLAN;
  193. llanB[bl]: LargeLAN;
  194. switchC: EtherSwitch;
  195. serverC: EtherHost;
  196. slanC[cs]: SmallLAN;
  197. mlanC[cm]: MediumLAN;
  198. llanC[cl]: LargeLAN;
  199. switchD: EtherSwitch;
  200. serverD: EtherHost;
  201. slanD[ds]: SmallLAN;
  202. mlanD[dm]: MediumLAN;
  203. llanD[dl]: LargeLAN;
  204. connections:
  205. // "backbone" switches
  206. for k=0..n-1, for i=0..bbs-1 {
  207. switchBB[k].ethg++ <--> cable <--> slanBB[k*bbs+i].ethg;
  208. }
  209. for k=0..n-1, for i=0..bbm-1 {
  210. switchBB[k].ethg++ <--> cable <--> mlanBB[k*bbm+i].ethg;
  211. }
  212. for k=0..n-1, for i=0..bbl-1 {
  213. switchBB[k].ethg++ <--> cable <--> llanBB[k*bbl+i].ethg;
  214. }
  215. for k=0..n-2 {
  216. switchBB[k].ethg++ <--> cable <--> switchBB[k+1].ethg++;
  217. }
  218. // switch A
  219. for i=0..as-1 {
  220. switchA.ethg++ <--> cable <--> slanA[i].ethg;
  221. }
  222. for i=0..am-1 {
  223. switchA.ethg++ <--> cable <--> mlanA[i].ethg;
  224. }
  225. for i=0..al-1 {
  226. switchA.ethg++ <--> cable <--> llanA[i].ethg;
  227. }
  228. switchA.ethg++ <--> cabletoserver <--> serverA.ethg;
  229. // switch B
  230. for i=0..bs-1 {
  231. switchB.ethg++ <--> cable <--> slanB[i].ethg;
  232. }
  233. for i=0..bm-1 {
  234. switchB.ethg++ <--> cable <--> mlanB[i].ethg;
  235. }
  236. for i=0..bl-1 {
  237. switchB.ethg++ <--> cable <--> llanB[i].ethg;
  238. }
  239. switchB.ethg++ <--> cabletoserver <--> serverB.ethg;
  240. // switch C
  241. for i=0..cs-1 {
  242. switchC.ethg++ <--> cable <--> slanC[i].ethg;
  243. }
  244. for i=0..cm-1 {
  245. switchC.ethg++ <--> cable <--> mlanC[i].ethg;
  246. }
  247. for i=0..cl-1 {
  248. switchC.ethg++ <--> cable <--> llanC[i].ethg;
  249. }
  250. switchC.ethg++ <--> cabletoserver <--> serverC.ethg;
  251. // switch D
  252. for i=0..ds-1 {
  253. switchD.ethg++ <--> cable <--> slanD[i].ethg;
  254. }
  255. for i=0..dm-1 {
  256. switchD.ethg++ <--> cable <--> mlanD[i].ethg;
  257. }
  258. for i=0..dl-1 {
  259. switchD.ethg++ <--> cable <--> llanD[i].ethg;
  260. }
  261. switchD.ethg++ <--> cabletoserver <--> serverD.ethg;
  262. // connect switches
  263. switchA.ethg++ <--> cable <--> switchB.ethg++;
  264. switchB.ethg++ <--> cable <--> switchC.ethg++;
  265. switchC.ethg++ <--> cable <--> switchD.ethg++;
  266. switchB.ethg++ <--> cable <--> switchBB[4].ethg++;
  267. }