You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Ntk_IGS 5.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. == NTK_RFC 0003 ==
  2. Subject: Internet Gateway Search
  3. ----
  4. This text describes a change to the Npv7.
  5. It will be included in the final documentation, so feel free to correct it.
  6. But if you want to change the system here described, please contact us first.
  7. ----
  8. If the nodes are in restricted mode (compatibility with the Internet), they
  9. should share their Internet connection. This can be easily done, in fact, if
  10. a node X, connected to the Internet, activates the masquerading, it is
  11. possible for the other nodes to connect by setting as the default gateway
  12. their rnode which lead to the node X.
  13. This can be automated by Netsukuku itself and it requires small changes in the
  14. code: it is just necessary that the nodes connected to the Internet set a flag
  15. in the qspn_pkt, in this way the other nodes will know the routes to reach the
  16. Internet.
  17. === Multi-gateways ===
  18. The situation becomes a little complex when there is more than one node which
  19. shares its internet connection. Let's consider this scenario:
  20. {{{
  21. A(gw) B(gw)
  22. \ /
  23. \___ ___/
  24. \/
  25. Ntk nodes (10.x.x.x)
  26. }}}
  27. A and B are nodes which shares their internet connection, we call them
  28. gateways. Let's call X the node which wants to connect to an Internet host.
  29. In this case, the nodes near A, might find useful to use A itself to
  30. reach the Internet, the same happens for the nodes near B.
  31. Instead, the nodes in the middle don't know what is the best choice and they
  32. might continuosly change their gw. This means that a tcp connection
  33. (to an inet host), which was established trough A, when is then routed trough
  34. B dies because A and B have different public IPs on the Internet.
  35. The node X has to create an IPIP tunnel to the gateway it wants to use, and
  36. set as default gw the tunnel. In this way, the node X is sure to always use
  37. the same gateway while the routing of the packets between it and the gw is
  38. made transparently by the other Netsukuku nodes.
  39. ==== Anti loop multi-inet_gw shield ====
  40. An inet-gw is a normal node like all the other, therefore it can use the
  41. Internet connections of the other inet-gws in conjunction with its own one.
  42. Consider the previous scenario, A and B are two inet-gw.
  43. A sets in his internet default route the adsl modem and B.
  44. B does the same, but sets A as the second default route.
  45. What would happen if the default route, written in the routing cache of A, is
  46. B and, at the same time, the default route set in the routing cache of B is A?
  47. The packets would jump endlessy in a infinite loop loosing themself forever.
  48. That's why we need the "anti loop multi-inet_gw shield".
  49. It's working way is simple: each inet-gw has a netfilter rule which marks
  50. all the packets coming from the outside and directed to the Internet. These
  51. packets are then routed directly to the Internet without being sent, again, to
  52. an inet-gw. In the example:
  53. A wants to send a packet to the Internet and its looks in its routing cache.
  54. It decide to forward the packet to B. B receives the packet, recognizes it is
  55. an extern packet directed to the Internet and shoots it on its modem.
  56. === Load sharing ===
  57. Let's consider the previous scenario.
  58. The node X can also decide to use both A and B to reach the Internet, using
  59. at the same time their connections! Even the gw A can use at the same time
  60. its own line and the connection of the gw B.
  61. The procedure to implement this is what follows:
  62. * X creates a tunnel to A and another one to B
  63. * X adds in the routing table the default route using A and B as multipath
  64. gateways. The gateway for the connections is chosen randomly.
  65. * X adds a rule in the routing table to route all the packets of established
  66. connections trough the same gateway used to create the same connection.
  67. The rule is linked to some netfilter rules which track and mark each
  68. connection. The method is described in details here:
  69. https://lists.netfilter.org/pipermail/netfilter/2006-March/065005.html
  70. === The bad ===
  71. The implementation of the Load sharing is very Linux specific, so it will be
  72. very difficult to port it to other kernels, therefore this feature will be
  73. available only to nodes which run Linux (ehi, one more reason to use Linux ;).
  74. === MASQUERADING ===
  75. Each node sharing the Internet connection (inet-gw) has to masquerade its
  76. interfaces, so iptables must be used.
  77. In order to keep the daemon portable, NetsukukuD will launch the script found
  78. at /etc/netsukuku/masquerade.sh, which in Linux will be a simple script that
  79. executes "iptables -A POSTROUTING -t nat -j MASQUERADE".
  80. When NetsukukuD is closed the added firewall rules are flushed with
  81. "/etc/netsukuku/masquerade.sh close"
  82. === Traffic shaping ===
  83. The inet-gw can also shape its internet connection in order to prioritize its
  84. local outgoing traffic (the traffic coming from its 192.168.x.x LAN).
  85. In this way, even if it shares its Internet connection, it won't notice any
  86. difference 'cause it will have the first priority. Moreover with the traffic
  87. shaper, the inet-gw can also prioritize some protocol, i.e. SSH.
  88. The traffic shaper will activated at the start of NetsukukuD. The daemon will
  89. run the /etc/netsukuku/tc_shaper.sh script, which in Linux utilizes the
  90. iproute2 userspace utility.
  91. When the daemon is closed the traffic shaping will be disabled with
  92. "/etc/netsukuku/tc_shaper.sh close".
  93. === See also ===
  94. For more information on the necessity of using ipip tunnels in an adhoc
  95. network used to share internet connections, you can read this paper:
  96. http://www.olsr.org/docs/XA-OLSR-paper-for-ICC04.pdf
  97. ----
  98. related: ["Netsukuku RFC"]