BGPRouterSimple.ned 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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.BGPOpen;
  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.transportlayer.contract.ITCP;
  25. //
  26. // Example IPv4 router with BGPv4 support.
  27. //
  28. module BGPRouterSimple
  29. {
  30. parameters:
  31. @networkNode();
  32. @labels(node,ethernet-node);
  33. @display("i=abstract/router");
  34. string tcpType = default(firstAvailable("TCP","TCP_lwIP","TCP_NSC")); // tcp implementation (e.g. ~TCP, ~TCP_lwIP, ~TCP_NSC) or ~TCPSpoof
  35. *.interfaceTableModule = default(absPath(".interfaceTable"));
  36. *.routingTableModule = default(absPath(".routingTable"));
  37. gates:
  38. inout pppg[] @labels(PPPFrame-conn);
  39. submodules:
  40. interfaceTable: InterfaceTable {
  41. parameters:
  42. @display("p=52,108;i=block/table_s");
  43. }
  44. routingTable: IPv4RoutingTable {
  45. parameters:
  46. forwarding = true;
  47. routerId = "auto";
  48. @display("p=52,172;i=block/table2_s");
  49. }
  50. bgp: BGPRouting {
  51. parameters:
  52. ospfRoutingModule = "";
  53. @display("p=160,50;i=block/network");
  54. }
  55. snifferIn: MessageChecker {
  56. parameters:
  57. @display("i=block/uparrow_s;p=132,124");
  58. }
  59. snifferOut: MessageChecker {
  60. parameters:
  61. @display("i=block/downarrow_s;p=196,124");
  62. }
  63. tcp: <tcpType> like ITCP if tcpType != "" {
  64. parameters:
  65. @display("p=160,202;i=block/transport");
  66. }
  67. networkLayer: IPv4NetworkLayer {
  68. parameters:
  69. proxyARP = true;
  70. @display("p=120,284;i=block/layer;q=queue");
  71. gates:
  72. ifIn[sizeof(pppg)];
  73. ifOut[sizeof(pppg)];
  74. }
  75. ppp[sizeof(pppg)]: <default("PPPInterface")> like IWiredNic {
  76. parameters:
  77. @display("p=74,369,row,110;q=l2queue;i=block/ifcard");
  78. }
  79. connections allowunconnected:
  80. bgp.tcpOut --> { @display("m=s"); } --> snifferOut.in;
  81. bgp.tcpIn <-- { @display("m=s"); } <-- snifferIn.out;
  82. snifferOut.out --> { @display("m=s"); } --> tcp.appIn++;
  83. snifferIn.in <-- { @display("m=s"); } <-- tcp.appOut++;
  84. tcp.ipOut --> { @display("m=s"); } --> networkLayer.transportIn++;
  85. tcp.ipIn <-- { @display("m=s"); } <-- networkLayer.transportOut++;
  86. // connections to network outside
  87. for i=0..sizeof(pppg)-1 {
  88. pppg[i] <--> { @display("m=s"); } <--> ppp[i].phys;
  89. ppp[i].upperLayerOut --> networkLayer.ifIn[i];
  90. ppp[i].upperLayerIn <-- networkLayer.ifOut[i];
  91. }
  92. }