-
Notifications
You must be signed in to change notification settings - Fork 4
routing
Routing IP packets is an alternative to the bridging setup and will work over any network configuration. Here you create a seperate network (read IPv6 prefix) for each emulated node or tap device - remember that each executed minimal-net target application will create its own tap device/network. What you want to do is to create a Wifi running on different prefix than your WSN, and tell the node which can access both to forward IPv6 traffic between them. We will create two networks for that and tell the Linux system to forward between both.
The webserver6.minimal-net does not work out of the box for this setup. When configuring a Contiki as a router, the setup below will not work since the Contiki IP stack does not know where to route packets to and silently drops all packets which are not from its prefix. To disable the routing functionality, add this line to platform/minimal-net/contiki-conf.h:
#define UIP_CONF_ROUTER 0
and recomplile the webserver6 sample. Then start the minimal-net webserver6:
$ ./webserver6.minimal-net
ifconfig tap0 up
*******Contiki-3.x-1850-g5d1feac online*******
IPV6 Addresss: [aaaa::206:98ff:fe00:232]
IPV6 Addresss: [fe80::206:98ff:fe00:232]
This creates the tap0 device and tells you that the webserver is now reachable on address aaaa::206:98ff:fe00:232. However the linux node and no other nodes do know about the network prefix aaaa::/64. So we need to configure the router advertisment daemon, which lets everybody know about this new network. Let's install the radvd, if you don't know how try the Building Linux Packages Guide. You will also need to install the flex and bison packages. Once you installed the radvd you can create a configuration file in """/etc/radvd.conf""" with this content:
interface wlan0 {
## (Send advertisement messages to other hosts)
AdvSendAdvert on;
## IPv6 subnet prefix
prefix bbbb::1/64 {
AdvOnLink on;
AdvAutonomous on;
};
};
interface tap0 {
## (Send advertisement messages to other hosts)
AdvSendAdvert on;
## IPv6 subnet prefix
prefix aaaa::1/64 {
AdvOnLink on;
AdvAutonomous on;
};
};
This will instruct all nodes in the wlan0 to join the bbbb::/64 network. And to consider the linux node running radvd as a possible route to all other IPv6 networks. So, imagine three nodes: a wsn node reachable on network aaaa::/64 on tap0, a linux node made of the tap0 (on the aaaa::/64) interface and the wlan0 interface (joined on the bbbb://64 network), and a third node which is connected via wifi as well (also reachable on the bbbb::/ prefix). If the third node now wants to reach to node one it will need to direct all packets to node two, which then forwards the packets. However to get node two to do that you still need to switch on ipv6 ip packet forwarding:
$ echo 1 > /proc/sys/net/ipv6/conf/all/forwarding
Now again you should be able to ping the Contiki webserver from a node connected only to the wifi network. Check on the Edison that all interface have an ipv6 on the right network:
$ ifconfig tap0
tap0 Link encap:Ethernet HWaddr 06:b9:ff:c3:58:7f
inet6 addr: aaaa::4b9:ffff:fec3:587f/64 Scope:Global
inet6 addr: fe80::4b9:ffff:fec3:587f/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:21 errors:0 dropped:0 overruns:0 frame:0
TX packets:524 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:500
RX bytes:1886 (1.8 KiB) TX bytes:59820 (58.4 KiB)
$ ifconfig wlan0
wlan0 Link encap:Ethernet HWaddr fc:c2:de:34:94:85
inet addr:192.168.0.19 Bcast:192.168.0.255 Mask:255.255.255.0
inet6 addr: bbbb::fec2:deff:fe34:9485/64 Scope:Global
inet6 addr: fe80::fcc2:de34:9495/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:943 errors:0 dropped:0 overruns:0 frame:0
TX packets:180 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:130878 (127.8 KiB) TX bytes:22178 (21.6 KiB)
If there are no ipv6 auto-configured addresses on either wlan0 or tap0 you will need to activate ipv6 on this interface by assigning a link-local address:
$ ifconfig tap0 inet6 add fe80::1234/64
for example.
Maybe use RPL to dynamically build routes to each WSN node, i.e. have one default router for a single prefix and let RPL built single node routing rules for each node. This way all traffic will go through the default router. This means there will be one central router, the RPL DAG head which knows how to route to each WSN node.
Per default, Linux does not accept any RA while in forwarding (router) mode. To enable this anyways use:
echo 2 > /proc/sys/net/ipv6/conf/wlan0/accept_ra
More info here3. This is however not strictly neccesary.
The default contiki configuration (for the minimal-net target) assumes the aaaa:: prefix for the tap0 link. This is a hard-coded configuration that needs to be disabled when using radvd for configuring the tap0 link. If you see a segfault, this is likely to be the problem. To fix change the 'platforms/minimal-net/contiki-main.c' file starting from line 305 to:
//if(!uip_ds6_prefix_add(&ipaddr, UIP_DEFAULT_PREFIX_LEN, 0)) {
// fprintf(stderr,"uip_ds6_prefix_add() failed.\n");
// exit(EXIT_FAILURE);
//}
#endif /* UIP_CONF_ROUTER */
uip_ds6_set_addr_iid(&ipaddr, &uip_lladdr);
//uip_ds6_addr_add(&ipaddr, 0, ADDR_AUTOCONF);
I.e. uncomment the static configuration of the aaaa:: prefix and adding the ip address. If you like to use a static configuration use the uip_ds6_defrt_add(ipaddr, lifetime)
to add the default route.