Open kallisti5 opened 10 years ago
As for IPv6.. ff05:: maybe? that range is considered site-local multi-cast.
Are you suggesting that a multicast address should be directly assigned to a client endpoint? (wrt IPv6)
I shouldn't post after drinking a lot of port, lol. Yeah... no multi-cast :-)
fe80::/10 may be better as that is link local and non-routeable. Maybe paired with 169.254.0.0/16 for IPv4?
I didn't want to mention auto-config on IPv4 as 65534 addresses is pretty limiting :-\
Does the random_ip function check for in-use addresses?
Here we go:
fd6E:746B::/7
6e 74 6b is ascii ntk in hex.
fc00::/7 is local uni-cast.
well.. maybe fd6E:746B::/32 if we want to keep ntk mesh nodes to themselves?
diff --git a/src/gmap.c b/src/gmap.c
index 4dad050..74974ad 100644
--- a/src/gmap.c
+++ b/src/gmap.c
@@ -572,11 +572,31 @@ random_ip(inet_prefix * ipstart, int final_level, int final_gid,
for (;;) {
/*
* Let's choose a completely random ip.
+ * New gnodes are limited to:
+ * IPv4: 172.16.0.0/12
+ * IPv6: fe6e:746b::/32
*/
levels = total_levels;
- if (my_family == AF_INET)
- idata[0] = rand();
- else {
+ if (my_family == AF_INET) {
+ int i = 0;
+ while (i < 4) {
+ int octet = 0;
+ switch (i) {
+ case 0:
+ octet = 172;
+ break;
+ case 1:
+ octet = (rand() % (31-16)) + 16;
+ break;
+ default:
+ octet = rand() % 255;
+ break;
+ }
+ idata[0] |= (octet << (i * 8));
+ i++;
+ }
+ } else {
+ // TODO: Generate a random address in fe6e:746b::/32
idata[0] = rand();
idata[1] = rand();
idata[2] = rand();
Typo in your patch, gives fe6e instead of fd6e twice in comments. Obviously currently harmless given the lack of matching code, but still.
I would personally shy away from absorbing an entire /12 in common use, and would instead slice a /12 (or so) out of the ever-popular private class A. Say, 10.176.0.0/12.
You can also generate an IP address using rand() (assuming it outputs at least 20 bits of decent pseudorandom data, which it really doesn't) in a much shorter process.
idata[0] = (rand() & 0x000FFFFF) | 0x0AB00000;
(AND away the network bits of a random address using the inverse of the subnet mask, OR in the appropriate bits from the target network)
Yeah, that is a lot easier way to do it :-)
I went ahead and reverted that commit in my forked repo. Any thoughts on the pull request?
Major things:
From trying to use this stuff.. I think it could use a small bit of simplification. (the random_ip changes are a good example of that) Mesh nodes on ipv4 (or ipv6) will likely be disconnected from the public network. Whats up with assigning the gnode IP on all interfaces? Seems like that would blow away internet connections on most systems (that may have them). Excluding eth0 on my machine doesn't seem to make netsukuku not mess with it.
as for the ipv6 addresses.. sorry for bouncing around.
http://en.wikipedia.org/wiki/Unique_local_address
you're right, my commit should of mentioned fd00
so..
fd6e:746b::/32 (fd6e:746b::-fd6e:746b:ffff:ffff:ffff:ffff:ffff:ffff) 79228162514264337593543950336 hosts and 10.160.0.0/12 (10.160.0.1 - 10.191.255.254) 2097150 hosts
These defaults for new network groups could be configurable. random_ip takes a network and a cidr and spits out a random network in that range. (however, lets set it to a sane "default" for those who don't care :-)
Hmmm, Netsukuku doesn't. to my knowledge, Have any method of checking if it's ip address already exists. Moreover, Netsukuku is currently set at 10.xxx.xxx.xxx for testing, I'll look into fixing this so we can test this. Also, I need to look into how much of IPv6 is actually implemented.
I will accept your pull requests if you make them, I'll have to look it over first.
The reason I set it to always send a set number of bytes, Was so that the server and client always knew when to stop listening. My previous code was much more complex before I realised I could do that.
Can you elaborate on what you mean by "set gnode ip to all interfaces"? Gnodes are supposed to be groups of nodes that from the outside appear to be one node, For routing purposes. I believe it would be like Manhattan and then the block. I think it kind of works like NAT? I've not read the documentation on this in a while. I need to refresh my memory.
I am now working on a feature defined in one of the original Netsukuku RFCs called: "netsplit". I will provide a link to the RFC soon. It allows two networks to share the same address space without conflicts through specifying realms associated with addresses and their associated routes.
This will negate the need for a restricted mode at all, Which has the purpose of providing compatibility with the internet through a specified address space, Defaulting to 10.x.x.x
Without restricted mode activated, Netsukuku does not try to be compatible with the internet, And uses the entire IPv4 address space.
(IPv6 testing is needed)
I will, However, Need to know what should be the default, And if restricted mode should even exist after netpsplit has been properly implemented.
Did you ever have any progress with this?
hook.c generates a truly random IP when it needs a new g node. (see radom_ip in gmap.c) This is generally a big issue as it could result in ip address conflicts with public IP addresses.
Maybe hook.c should generate a random address in 172.16.0.0/12? That would limit netsukuku mesh networks to 1,048,576 hosts, but would cause the fewest conflicts as private networks are generally class C or class A.