BGPRouterEx.ned 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. //
  2. // Copyright (C) 2010 Helene Lageber
  3. //
  4. // This program is free software; you can redistribute it and/or
  5. // modify it under the terms of the GNU Lesser 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 Lesser General Public License for more details.
  13. //
  14. // You should have received a copy of the GNU Lesser General Public License
  15. // along with this program; if not, see <http://www.gnu.org/licenses/>.
  16. //
  17. package inet.examples.bgpv4.BGPUpdate;
  18. import inet.common.misc.MessageChecker;
  19. import inet.linklayer.contract.IWiredNic;
  20. import inet.networklayer.common.InterfaceTable;
  21. import inet.networklayer.ipv4.IPv4NetworkLayer;
  22. import inet.networklayer.ipv4.IPv4RoutingTable;
  23. import inet.routing.bgpv4.BGPRouting;
  24. import inet.routing.ospfv2.OSPFRouting;
  25. import inet.transportlayer.contract.ITCP;
  26. //
  27. // Example IP router with BGPv4 and OSPFv4 support.
  28. //
  29. module BGPRouterEx
  30. {
  31. parameters:
  32. @networkNode();
  33. @labels(node,ethernet-node);
  34. @display("i=abstract/router");
  35. string tcpType = default(firstAvailable("TCP","TCP_lwIP","TCP_NSC")); // tcp implementation (e.g. ~TCP, ~TCP_lwIP, ~TCP_NSC) or ~TCPSpoof
  36. *.interfaceTableModule = default(absPath(".interfaceTable"));
  37. *.routingTableModule = default(absPath(".routingTable"));
  38. gates:
  39. inout pppg[] @labels(PPPFrame-conn);
  40. inout ethg[] @labels(EtherFrame-conn);
  41. submodules:
  42. interfaceTable: InterfaceTable {
  43. parameters:
  44. @display("p=52,108;i=block/table_s");
  45. }
  46. routingTable: IPv4RoutingTable {
  47. parameters:
  48. forwarding = true;
  49. routerId = "auto";
  50. @display("p=52,172;i=block/table2_s");
  51. }
  52. ospf: OSPFRouting {
  53. parameters:
  54. @display("p=235,284,row;i=block/network2");
  55. }
  56. bgp: BGPRouting {
  57. parameters:
  58. ospfRoutingModule = "^.ospf";
  59. @display("p=160,50;i=block/network");
  60. }
  61. snifferIn: MessageChecker {
  62. parameters:
  63. @display("i=block/uparrow_s;p=132,124");
  64. }
  65. snifferOut: MessageChecker {
  66. parameters:
  67. @display("i=block/downarrow_s;p=196,124");
  68. }
  69. tcp: <tcpType> like ITCP {
  70. parameters:
  71. @display("p=160,202;i=block/transport");
  72. }
  73. networkLayer: IPv4NetworkLayer {
  74. parameters:
  75. proxyARP = true;
  76. @display("p=120,284;i=block/layer;q=queue");
  77. gates:
  78. ifIn[sizeof(pppg)+sizeof(ethg)];
  79. ifOut[sizeof(pppg)+sizeof(ethg)];
  80. }
  81. ppp[sizeof(pppg)]: <default("PPPInterface")> like IWiredNic {
  82. parameters:
  83. @display("p=74,369,row,110;q=l2queue;i=block/ifcard");
  84. }
  85. eth[sizeof(ethg)]: <default("EthernetInterface")> like IWiredNic {
  86. parameters:
  87. @display("p=196,369,row,110;q=l2queue;i=block/ifcard");
  88. }
  89. connections allowunconnected:
  90. bgp.tcpOut --> { @display("m=s"); } --> snifferOut.in;
  91. bgp.tcpIn <-- { @display("m=s"); } <-- snifferIn.out;
  92. snifferOut.out --> { @display("m=s"); } --> tcp.appIn++;
  93. snifferIn.in <-- { @display("m=s"); } <-- tcp.appOut++;
  94. tcp.ipOut --> { @display("m=s"); } --> networkLayer.transportIn++;
  95. tcp.ipIn <-- { @display("m=s"); } <-- networkLayer.transportOut++;
  96. ospf.ipOut --> { @display("m=s"); } --> networkLayer.transportIn++;
  97. ospf.ipIn <-- { @display("m=s"); } <-- networkLayer.transportOut++;
  98. // connections to network outside
  99. for i=0..sizeof(pppg)-1 {
  100. pppg[i] <--> ppp[i].phys;
  101. ppp[i].upperLayerOut --> networkLayer.ifIn[i];
  102. ppp[i].upperLayerIn <-- networkLayer.ifOut[i];
  103. }
  104. for i=0..sizeof(ethg)-1 {
  105. ethg[i] <--> eth[i].phys;
  106. eth[i].upperLayerOut --> networkLayer.ifIn[sizeof(pppg)+i];
  107. eth[i].upperLayerIn <-- networkLayer.ifOut[sizeof(pppg)+i];
  108. }
  109. }