Networks.ned 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316
  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.common.misc.ThruputMeteringChannel;
  20. import inet.linklayer.ethernet.EtherBus;
  21. import inet.linklayer.ethernet.EtherHub;
  22. import inet.node.ethernet.EtherHost;
  23. import inet.node.ethernet.EtherSwitch;
  24. import ned.DatarateChannel;
  25. //
  26. // Sample Ethernet LAN containing eight hosts, a switch and a bus.
  27. //
  28. network MixedLAN
  29. {
  30. types:
  31. channel C extends ThruputMeteringChannel
  32. {
  33. delay = 01us;
  34. datarate = 100Mbps;
  35. }
  36. submodules:
  37. bus: EtherBus {
  38. parameters:
  39. positions = "10 20 24 35 40 48";
  40. propagationSpeed = 2e8 mps; // 1us = 200m
  41. @display("p=277,182;b=424,6;o=#408060");
  42. gates:
  43. ethg[6];
  44. }
  45. busHostA: EtherHost {
  46. parameters:
  47. @display("p=122,118");
  48. }
  49. busHostB: EtherHost {
  50. parameters:
  51. @display("p=210,118");
  52. }
  53. busHostC: EtherHost {
  54. parameters:
  55. @display("p=338,238");
  56. }
  57. busHostD: EtherHost {
  58. parameters:
  59. @display("p=426,238");
  60. }
  61. switchHostA: EtherHost {
  62. parameters:
  63. @display("p=82,300");
  64. }
  65. switchHostB: EtherHost {
  66. parameters:
  67. @display("p=162,300");
  68. }
  69. switchHostC: EtherHost {
  70. parameters:
  71. @display("p=234,300");
  72. }
  73. switchHostD: EtherHost {
  74. parameters:
  75. @display("p=306,300");
  76. }
  77. switch: EtherSwitch {
  78. parameters:
  79. @display("p=194,236");
  80. gates:
  81. ethg[5];
  82. }
  83. hubHostA: EtherHost {
  84. parameters:
  85. @display("p=297,55");
  86. }
  87. hubHostB: EtherHost {
  88. parameters:
  89. @display("p=365,55");
  90. }
  91. hubHostC: EtherHost {
  92. parameters:
  93. @display("p=430,55");
  94. }
  95. hub: EtherHub {
  96. parameters:
  97. @display("p=362,132");
  98. gates:
  99. ethg[4];
  100. }
  101. connections:
  102. bus.ethg[0] <--> C <--> busHostA.ethg;
  103. bus.ethg[1] <--> C <--> busHostB.ethg;
  104. bus.ethg[2] <--> C <--> switch.ethg[4];
  105. bus.ethg[3] <--> C <--> busHostC.ethg;
  106. bus.ethg[4] <--> C <--> hub.ethg[3];
  107. bus.ethg[5] <--> C <--> busHostD.ethg;
  108. switch.ethg[0] <--> C <--> switchHostA.ethg;
  109. switch.ethg[1] <--> C <--> switchHostB.ethg;
  110. switch.ethg[2] <--> C <--> switchHostC.ethg;
  111. switch.ethg[3] <--> C <--> switchHostD.ethg;
  112. hub.ethg[0] <--> { delay = 0.1us; datarate = 100Mbps; } <--> hubHostA.ethg;
  113. hub.ethg[1] <--> { delay = 0.3us; datarate = 100Mbps; } <--> hubHostB.ethg;
  114. hub.ethg[2] <--> { delay = 0.2us; datarate = 100Mbps; } <--> hubHostC.ethg;
  115. }
  116. //
  117. // Sample Ethernet LAN: two hosts directly connected to each other
  118. // via twisted pair.
  119. //
  120. network TwoHosts
  121. {
  122. submodules:
  123. hostA: EtherHost {
  124. parameters:
  125. @display("p=60,160");
  126. }
  127. hostB: EtherHost {
  128. parameters:
  129. @display("p=200,140");
  130. }
  131. connections:
  132. hostA.ethg <--> { delay = 0.5us; datarate = 100Mbps; } <--> hostB.ethg;
  133. }
  134. //
  135. // Sample Ethernet LAN: four hosts connected to a switch.
  136. //
  137. network SwitchedLAN
  138. {
  139. types:
  140. channel C extends DatarateChannel
  141. {
  142. delay = 0.1us;
  143. datarate = 100Mbps;
  144. }
  145. submodules:
  146. hostA: EtherHost {
  147. parameters:
  148. @display("p=161,55");
  149. }
  150. hostB: EtherHost {
  151. parameters:
  152. @display("p=253,125");
  153. }
  154. hostC: EtherHost {
  155. parameters:
  156. @display("p=158,199");
  157. }
  158. hostD: EtherHost {
  159. parameters:
  160. @display("p=59,127");
  161. }
  162. switch: EtherSwitch {
  163. parameters:
  164. @display("p=162,124");
  165. gates:
  166. ethg[4];
  167. }
  168. connections:
  169. switch.ethg[0] <--> C <--> hostA.ethg;
  170. switch.ethg[1] <--> C <--> hostB.ethg;
  171. switch.ethg[2] <--> C <--> hostC.ethg;
  172. switch.ethg[3] <--> C <--> hostD.ethg;
  173. }
  174. //
  175. // Sample Ethernet LAN: four hosts connected by a hub.
  176. //
  177. network HubLAN
  178. {
  179. submodules:
  180. hostA: EtherHost {
  181. parameters:
  182. @display("p=161,55");
  183. }
  184. hostB: EtherHost {
  185. parameters:
  186. @display("p=253,125");
  187. }
  188. hostC: EtherHost {
  189. parameters:
  190. @display("p=158,199");
  191. }
  192. hostD: EtherHost {
  193. parameters:
  194. @display("p=59,127");
  195. }
  196. hub: EtherHub {
  197. parameters:
  198. @display("p=162,124");
  199. gates:
  200. ethg[4];
  201. }
  202. connections:
  203. hub.ethg[0] <--> { delay = 0.1us; datarate = 100Mbps; } <--> hostA.ethg;
  204. hub.ethg[1] <--> { delay = 0.3us; datarate = 100Mbps; } <--> hostB.ethg;
  205. hub.ethg[2] <--> { delay = 0.4us; datarate = 100Mbps; } <--> hostC.ethg;
  206. hub.ethg[3] <--> { delay = 0.2us; datarate = 100Mbps; } <--> hostD.ethg;
  207. }
  208. //
  209. // Sample Ethernet LAN: four hosts on a bus.
  210. //
  211. network BusLAN
  212. {
  213. types:
  214. channel C extends DatarateChannel
  215. {
  216. delay = 0;
  217. datarate = 10Mbps;
  218. }
  219. submodules:
  220. hostA: EtherHost {
  221. parameters:
  222. @display("p=100,150");
  223. }
  224. hostB: EtherHost {
  225. parameters:
  226. @display("p=200,150");
  227. }
  228. hostC: EtherHost {
  229. parameters:
  230. @display("p=300,150");
  231. }
  232. hostD: EtherHost {
  233. parameters:
  234. @display("p=400,150");
  235. }
  236. bus: EtherBus {
  237. parameters:
  238. positions = "0 10 20 30";
  239. propagationSpeed = 2e8 mps;
  240. @display("p=250,100;b=400,6;o=#408060");
  241. gates:
  242. ethg[4];
  243. }
  244. connections:
  245. bus.ethg[0] <--> C <--> hostA.ethg;
  246. bus.ethg[1] <--> C <--> hostB.ethg;
  247. bus.ethg[2] <--> C <--> hostC.ethg;
  248. bus.ethg[3] <--> C <--> hostD.ethg;
  249. }
  250. network SwitchedDuplexLAN
  251. {
  252. types:
  253. channel ethernetline extends DatarateChannel
  254. {
  255. parameters:
  256. delay = 0.1us;
  257. datarate = 10Mbps;
  258. }
  259. module EtherHostFullDuplex extends EtherHost
  260. {
  261. parameters:
  262. csmacdSupport = false;
  263. }
  264. module EtherSwitchFullDuplex extends EtherSwitch
  265. {
  266. parameters:
  267. csmacdSupport = false;
  268. }
  269. submodules:
  270. hostA: EtherHostFullDuplex {
  271. parameters:
  272. @display("p=161,55");
  273. }
  274. hostB: EtherHostFullDuplex {
  275. parameters:
  276. @display("p=253,125");
  277. }
  278. hostC: EtherHostFullDuplex {
  279. parameters:
  280. @display("p=158,199");
  281. }
  282. hostD: EtherHostFullDuplex {
  283. parameters:
  284. @display("p=59,127");
  285. }
  286. switch: EtherSwitchFullDuplex {
  287. parameters:
  288. @display("p=162,124");
  289. gates:
  290. ethg[4];
  291. }
  292. connections:
  293. switch.ethg[0] <--> ethernetline <--> hostA.ethg;
  294. switch.ethg[1] <--> ethernetline <--> hostB.ethg;
  295. switch.ethg[2] <--> ethernetline <--> hostC.ethg;
  296. switch.ethg[3] <--> ethernetline <--> hostD.ethg;
  297. }