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_gnodes_contiguity 8.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. = NTK_RFC 0001 =
  2. Subject: Gnode contiguity
  3. ----
  4. This text describes a change to the Npv7 about the collision of IPs.
  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. = The real problems =
  9. A collision of IPs happens when two gnodes with the same ID are born separately,
  10. so when they meet each trough a direct link or trough other nodes many
  11. problems arise since there are some ambiguities:
  12. * In the first case there can be nodes which have the same IP.
  13. * In the second:
  14. A <-> B <-> D <-> A
  15. After a qspn_round the node B will have two routes to reach the gnode A. But in this case the gnode A isn't a contiguous gnode, so when B wants to reach a node which belongs to A, it will send the packet using only one route which may lead to the A gnode which hasn't the wanted node.
  16. So these are the real problems.
  17. In order to solve them it is necessary that every time two gnodes meets each
  18. other for the first time, one of them will redo the hook, in fact, this was
  19. the cause of all.
  20. When a gnode meets for the first time another gnode is like when a new node joins
  21. the network: it hooks with the other nodes. The same must be done for the
  22. gnode.
  23. = Hook of gnodes =
  24. The hook of two gnodes works in this way: only the gnode which has less
  25. nodes than the other will change (let's call the first gnode X and the second
  26. Y). If X and Y have the same number of nodes, the gnode which has the smaller
  27. gnode_id will change.
  28. The bnodes of X will start to re-hook, the other nodes will re-hook when
  29. they notice that a new rnode which belongs to Y comes up.
  30. Summing up: the bnodes re-hook first, then their rnodes, then the rnodes of
  31. the rnodes of the bnodes... and so on, all the nodes of the gnode have
  32. re-hooked.
  33. It doesn't matter that a gnode composed by 2^24 nodes changes all its IPs,
  34. since it will happen only very few times, i.e. when the gnode of the Europe
  35. meets that of the America.
  36. == Gnode count ==
  37. This method requires that the number of nodes present in a gnode has to be
  38. known, therefore the qspn_pkt which traverse gnodes stores also the number
  39. of nodes of each traversed gnode.
  40. == No first tracer_pkt ==
  41. While re-hooking, the first tracer_pkt won't be sent like in the normal hook
  42. 'cause if all the nodes of the gnode which is re-hooking send it, there
  43. would be a broadcast pkt for each node. The next qspn_round will let
  44. the other know the routes to reach them.
  45. == Re-hook of two equal, not contiguous gnodes ==
  46. When there are two nodes with the same ip, or gnodes with the
  47. same gid, one of them will re-hook, following the same rules we've described,
  48. but all the packets that the two (g)nodes will send each other will be routed
  49. by the daemons. For example if A wants to send a packet to A' it stores in the
  50. pkt the route it received with the last qspn_pkt, the other nodes will forward
  51. the packet to A' using that route, this is to avoid the problem described
  52. above.
  53. == Re-hook details ==
  54. The gnode X is re-hooking at the gnode Y.
  55. If the gnode Y hasn't enough free nodes for all the nodes of the
  56. gnode X then the situation evolves in this way:
  57. maxYnodes = maxmimum number of nodes in Y;
  58. curYnodes = current number of nodes in Y (gnode count of Y).
  59. diff = maxYnodes - curYnodes;
  60. `diff' is the number of new nodes which the gnode Y can accept inside.
  61. The bnodes of X will say to `diff'# nodes in X to re-hook in the gnode Y, all
  62. the other non-informed nodes will create a new gnode.
  63. Let's analyse the two cases.
  64. === informed nodes ===
  65. Remembering how the nodes re-hook (first the bnode, then its rnodes, then the
  66. rnodes of its rnodes, etc..) we adopt this strategy:
  67. join_rate=diff/number_of_X_bnodes - 1;
  68. Each bnode of X knows it can inform `join_rate'# nodes, so when its
  69. rnodes try to re-hook at it, they'll know that:
  70. * they will become part of the gnode Y
  71. * they can inform other `(join_rate-1)/(number_of_links-1)'# nodes
  72. The same procedure holds for recursively the rnodes of the rnodes of the
  73. bnode.
  74. When `join_rate' becomes zero the node becomes non-informed.
  75. === non-informed nodes ===
  76. The gid of the new gnode they create is based on the hash of their previous
  77. gid. In this way all the non-informed nodes will be in the same new gnode,
  78. cause they all generates the same hash. If the new gid is already taken in the
  79. map they'll increment it by one until they choose a non-taken gnode.
  80. == Counting the nodes ==
  81. At this point all seems to be solved, but it is not.
  82. Anyone can modify the qspn, so for example the X which has less nodes than Y
  83. can fake the number, and Y will be forced to re-hook.
  84. It this happens anyone can easily force a gnode of 2^24 nodes to change its
  85. IPs!
  86. Therefore the problem to be solved now is: how can the gnode Y verify that the
  87. gnode X has really more nodes?
  88. What is the main property of a network which has more nodes than another?
  89. The computability power!
  90. We assume that the average computability power for a gnode of the second level
  91. or greater is constant. (a gnode of the second level can have 2^16 nodes, in the
  92. third level 2^24). Therefore the gnode of level 1 won't be checked.
  93. Each node of the gnode which has to re-hook (in this case the gnode Y,
  94. since the gnode X is faking the qspn_pkt) will send a problem to solve to the
  95. other gnode and it wait for a very small time the reply with the solution in
  96. it. If the solution is right the node receiving it will re-hook, otherwise
  97. the gnode X will be banned and excluded from all the qspn floods.
  98. Only one challenge each T time can occur, where T is proportional to the size
  99. of the Y gnode. So say that Y has 16milions IPs, if it has already sent a
  100. challenge it will send another after 10 minutes.
  101. == Computability power ==
  102. But this system leaves opened another kind of attack: the gnode X can target a single
  103. node in Y, replying only to its reply and making it re-hook. In order to
  104. prevent this the nodes act in this way:
  105. * When a node hooks it creates a RSA key pair, then its rnodes get its public key.
  106. * When a node receives a reply to the problem, it broadcasts the reply inside its gnode,
  107. signing it with its public key. When its rnodes receive the pkt, check the signature.
  108. If it is valid they update the counter of received replies for the problems sent, then
  109. they substitute the signature with their own. The packet will propagate
  110. until it reaches all the nodes of the gnode.
  111. * The nodes will start to rehook only when all the replies will be
  112. received (during the wait time). Since it is not possible that all the reply are
  113. received it is allowed that 10% of replies are lost.
  114. The problem to solve sent by the nodes is:
  115. f(x) mod k
  116. where k is a random number between 2^16 and 2^32.
  117. f(x) is a function which is not easily computable with mod k.
  118. When x gets bigger the computation time increases.
  119. We are still deciding on what f() function using.
  120. === Dumb machines ===
  121. Generating the problem doesn't require a high computability power, in
  122. fact, the daemon will keep 8 or 16 problems cached, generated while the cpu
  123. isn't used.
  124. The machines which have a very low computability power won't reply and even
  125. try to solve the problems they receive (but only if they can't take the
  126. computability of the problem).
  127. = ANDNA changes =
  128. If a same hostname is registered in two separeted gnodes what happens when they meet?
  129. Which node will mantain the hostname?
  130. The node which is in the greater gnode wins: the hash_nodes of the smaller
  131. gnode, which re-hooks, will reset their uptime counter, in this way when they
  132. receive the update request from the node (which has changed its IP and must
  133. update its hname), they ask to the other gnode for the old andna_caches.
  134. Moreover the ANDNA_MIN_UPDATE_TIME (the minum amount of time to be waited
  135. before sending an update os the hname) has to be reduced to
  136. NEW_HOOK_WAIT_TIME, which is the minimum amount of time to be waited before
  137. re-hooking. This is necessary, because all the hname updates sent
  138. before ANDNA_MIN_UPDATE_TIME seconds have elapsed since the last update
  139. rejected. If a gnode re-hooked, the hostname of its nodes has to be
  140. updated, therefore the update request must be accepted.
  141. = And that's all =
  142. That's all folks.
  143. Alpt, Katolaz, Mancausoft, Uscinziatu
  144. ----
  145. related: [Netsukuku_RFC]