Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

aodvv2: port to new network stack #3445

Closed
wants to merge 41 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
bce377d
aodvv2: port to new network stack
Lotterleben Jul 17, 2015
d75a9f0
address comments
Lotterleben Jul 18, 2015
55f32a6
no more HTONS
Lotterleben Jul 18, 2015
b1bff67
add Martin as author
Lotterleben Jul 18, 2015
1299b72
add missing newlines to debug output
Lotterleben Jul 19, 2015
2ec9180
addressed comments (untestedga 3)
Lotterleben Jul 20, 2015
529af37
remove silly error
Lotterleben Jul 23, 2015
f78a068
fix iid and address registration
Lotterleben Aug 27, 2015
eb428e0
set correct src address
Lotterleben Aug 27, 2015
af4a3e1
fix rebase fuckup in Makefile.dep
Lotterleben Aug 31, 2015
f36f6b1
re-add deleted files
Lotterleben Jan 12, 2016
8736403
include timex.h
Lotterleben Jan 12, 2016
8242cc5
get rid of sock_snd
Lotterleben Jan 13, 2016
9027676
add gnrc_ipv6_router_default and gnrc_conn_udp to MAkefile.dep, rm ng…
Lotterleben Jan 14, 2016
e9a1e94
move files from net/routing to net/gnrc/routing
Lotterleben Mar 11, 2016
f49c1f4
ng_ -> gnrc_
Lotterleben Mar 11, 2016
1054ae6
more ng_ -> gnrc_
Lotterleben Mar 11, 2016
85cada5
adjust to fib changes
Lotterleben Mar 11, 2016
5537359
cleanup
Lotterleben Mar 11, 2016
a3d8c65
add message queue to fib thread, rename other queues
Lotterleben Mar 30, 2016
6260369
some fib-realted renamings
Lotterleben Mar 30, 2016
f80e55c
small fixes
Lotterleben Mar 31, 2016
3da9b40
reader: improve comments
Lotterleben Apr 9, 2016
ab84a68
adjust thread prios
Lotterleben Apr 9, 2016
912029c
rm debug output
Lotterleben Apr 9, 2016
f9ef4f6
aodvv2: update to latest RIOT master
smlng Jun 28, 2016
b08eb6a
Makefile: whitelist native
Lotterleben Jun 30, 2016
2cc2328
Makefile: rm unnecessary includes
Lotterleben Jun 30, 2016
4fa036d
undo changes to gnrc_networking makefile
Lotterleben Jun 30, 2016
99f92e4
rm dead SUPER HACKY FIX code
Lotterleben Jul 19, 2016
1d46e30
don't malloc tmp_rt_entry, make routingtable api more convenient to d…
Lotterleben Jul 19, 2016
d99d49c
example app: update copyright info
Lotterleben Jul 19, 2016
625f97d
add test folder
Lotterleben Jul 19, 2016
544b266
add unit tests (first steps)
Lotterleben Aug 16, 2016
30ffa70
routingtable.h: rm outdated functions
Lotterleben Aug 16, 2016
8b839db
routingtable: small editorial fixes, unify api
Lotterleben Aug 30, 2016
d88edda
small editorial fixes, finish basic routing table tests
Lotterleben Sep 27, 2016
264b65a
cleanup, renaming
Lotterleben Sep 27, 2016
d8bc580
rm mallocs. !! WIP; contrains race condition, debug output & TODOs !!
Lotterleben Oct 17, 2016
10fbc4e
rm unnecessary folder in tests (has all been moved to tests/unittests)
Lotterleben Oct 17, 2016
6d1fef3
redo aodv.c, switch from 3 threads to 1 (WIP; UNTESTED)
Lotterleben Oct 17, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions Makefile.dep
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,16 @@ ifneq (,$(filter gnrc_ipv6_hdr,$(USEMODULE)))
USEMODULE += gnrc_pktbuf
endif

ifneq (,$(filter aodvv2,$(USEMODULE)))
USEMODULE += gnrc_ipv6_router_default
USEMODULE += gnrc_conn_udp
USEMODULE += xtimer
USEMODULE += oonf_common
USEMODULE += oonf_rfc5444
USEMODULE += fib
USEMODULE += timex
endif

ifneq (,$(filter sixlowpan,$(USEMODULE)))
USEMODULE += ipv6_hdr
endif
Expand Down
39 changes: 39 additions & 0 deletions examples/gnrc_aodvv2/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# name of your application
APPLICATION = gnrc_aodvv2

# If no BOARD is found in the environment, use this default:
BOARD ?= native

# This has to be the absolute path to the RIOT base directory:
RIOTBASE ?= $(CURDIR)/../..
CFLAGS += -DTEST_SETUP #-DDEVELHELP

BOARD_WHITELIST := native

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this list and add a whitelist with native only, for now.

# Include packages that pull up and auto-init the link layer.
# NOTE: 6LoWPAN will be included if IEEE802.15.4 devices are present
USEMODULE += gnrc_netdev_default
USEMODULE += auto_init_gnrc_netif
# Specify the mandatory networking modules for IPv6 and UDP
USEMODULE += gnrc_ipv6_router_default
USEMODULE += gnrc_udp
# Add a routing protocol
USEMODULE += aodvv2
# This application dumps received packets to STDIO using the pktdump module
USEMODULE += gnrc_pktdump
# Add also the shell, some shell commands
USEMODULE += shell
USEMODULE += shell_commands
USEMODULE += ps
USEMODULE += netstats_l2
USEMODULE += netstats_ipv6

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should only have modules actually required for AODVv2 testing, otherwise its only a copy of examples/gnrc_networking with /rpl/aodvv2/; don't you @Lotterleben think?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Get rid of gnrc_pktdump, and both netstats_*.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If that's the case it should rather go in tests instead of examples.

# Comment this out to disable code in RIOT that does safety checking
# which is not needed in a production environment but helps in the
# development process:
CFLAGS += -DDEVELHELP

# Change this to 0 show compiler invocation lines by default:
QUIET ?= 1

include $(RIOTBASE)/Makefile.include
142 changes: 142 additions & 0 deletions examples/gnrc_aodvv2/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
# gnrc_networking example

This example shows you how to try out the code in two different ways: Either by communicating
between the RIOT machine and its Linux host, or by communicating between two RIOT instances.
Note that the former only works with native, i.e. if you run RIOT on your Linux machine.

## Connecting RIOT native and the Linux host

> **Note:** RIOT does not support IPv4, so you need to stick to IPv6 anytime. To
establish a connection between RIOT and the Linux host, you will need `netcat`
(with IPv6 support). Ubuntu 14.04 comes with netcat IPv6 support pre-installed.
On Debian it's available in the package `netcat-openbsd`. Be aware that many
programs require you to add an option such as -6 to tell them to use IPv6, otherwise they
will fail. If you're using a _Raspberry Pi_, run `sudo modprobe ipv6` before trying
this example, because raspbian does not load the IPv6 module automatically.
On some systems (openSUSE for example), the _firewall_ may interfere, and prevent
some packets to arrive at the application (they will however show up in Wireshark,
which can be confusing). So be sure to adjust your firewall rules, or turn it off
(who needs security anyway).

First, create a tap interface:

sudo ip tuntap add tap0 mode tap user ${USER}
sudo ip link set tap0 up

Now you can start the `gnrc_networking` example by invoking `make term`. This should
automatically connect to the `tap0` interface. If this doesn't work for any reason,
run make term with the tap0 interface as the PORT environment variable:

PORT=tap0 make term

To verify that there is connectivity between RIOT and Linux, go to the RIOT console and run `ifconfig`:

> ifconfig
Iface 7 HWaddr: ce:f5:e1:c5:f7:5a
inet6 addr: ff02::1/128 scope: local [multicast]
inet6 addr: fe80::ccf5:e1ff:fec5:f75a/64 scope: local
inet6 addr: ff02::1:ffc5:f75a/128 scope: local [multicast]

Copy the [link-local address](https://en.wikipedia.org/wiki/Link-local_address)
of the RIOT node (prefixed with `fe80`) and try to ping it **from the Linux node**:

ping6 fe80::ccf5:e1ff:fec5:f75a%tap0

Note that the interface on which to send the ping needs to be appended to the IPv6
address, `%tap0` in the above example. When talking to the RIOT node, you always want
to send to/receive from the `tap0` interface.

If the pings succeed you can go on to send UDP packets. To do that, first start a
UDP server on the RIOT node:

> udp server start 8808
Success: started UDP server on port 8808

Now, on the Linux host, you can run netcat to connect with RIOT's UDP server:

nc -6uv fe80::ccf5:e1ff:fec5:f75a%tap0 8808

The `-6` option is necessary to tell netcat to use IPv6 only, the `-u` option tells
it to use UDP only, and the `-v` option makes it give more verbose output (this one is optional).

You should now see that UDP messages are received on the RIOT side. Opening a UDP
server on the Linux side is also possible. To do that, write down the IP address
of the host (run on Linux):

ifconfig tap0
tap0 Link encap:Ethernet HWaddr ce:f5:e1:c5:f7:59
inet6 addr: fe80::4049:5fff:fe17:b3ae/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:6 errors:0 dropped:0 overruns:0 frame:0
TX packets:36 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:488 (488.0 B) TX bytes:3517 (3.5 KB)

Then open a UDP server on Linux (the `-l` option makes netcat listen for incoming connections):

nc -6ul 8808

Now, on the RIOT side, send a UDP packet using:

udp send fe80::4049:5fff:fe17:b3ae 8808 testmessage

You should see `testmessage` appear in netcat. Instead of using netcat, you can of
course write your own software, but you may have to bind the socket to a specific
interface (tap0 in this case). For an example that shows how to do so, see
[here](https://gist.github.com/backenklee/dad5e80b764b3b3d0d3e).

## Connecting two RIOT instances

When using native (i.e. when you're trying this on your Linux machine), you first
need to set up two tap devices and a bridge that connects them. This constitutes a
virtual network that the RIOT instances can use to communicate.

./../../dist/tools/tapsetup/tapsetup --create 2

Then, make sure you've compiled the application by calling `make` and start the
first RIOT instance by invoking `make term`. In the RIOT shell, get to know the
IP address of this node:

> ifconfig
Iface 7 HWaddr: ce:f5:e1:c5:f7:5a
inet6 addr: ff02::1/128 scope: local [multicast]
inet6 addr: fe80::ccf5:e1ff:fec5:f75a/64 scope: local
inet6 addr: ff02::1:ffc5:f75a/128 scope: local [multicast]

and start a UDP server.

> udp server start 8808

This node is now ready to receive data on port `8808`.

In a second terminal, start a second RIOT instance, this time listening on `tap1`:

PORT=tap1 make term

In the RIOT shell, you can now send a message to the first RIOT instance:

> udp send fe80::ccf5:e1ff:fec5:f75 8808 testmessage

*(Make sure to copy the actual
[link-local address](https://en.wikipedia.org/wiki/Link-local_address) of your first
RIOT instance into the above command)*

In your first terminal, you should now see output that looks like this.

> PKTDUMP: data received:
~~ SNIP 0 - size: 11 byte, type: NETTYPE_UNDEF (0)
000000 74 65 73 74 6d 65 73 73 61 67 65
~~ SNIP 1 - size: 8 byte, type: NETTYPE_UDP (3)
src-port: 8808 dst-port: 8808
length: 19 cksum: 0x4d95f
~~ SNIP 2 - size: 40 byte, type: NETTYPE_IPV6 (1)
traffic class: 0x00 (ECN: 0x0, DSCP: 0x00)
flow label: 0x00000
length: 19 next header: 17 hop limit: 64
source address: fe80::a08a:84ff:fe68:544f
destination address: fe80::60fc:3cff:fe5e:40df
~~ SNIP 3 - size: 20 byte, type: NETTYPE_NETIF (-1)
if_pid: 6 rssi: 0 lqi: 0
src_l2addr: a2:8a:84:68:54:4f
dst_l2addr: 62:fc:3c:5e:40:df
~~ PKT - 4 snips, total size: 79 byte
65 changes: 65 additions & 0 deletions examples/gnrc_aodvv2/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/*
* Copyright (C) 2016 HAW Hamburg
*
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level
* directory for more details.
*/

/**
* @ingroup examples
* @{
*
* @file
* @brief Example application for demonstrating the RIOT network stack
*
* @author Sebastian Meiling <sebastian.meiling@haw-hamburg.de>
*
* @}
*/

#include <stdio.h>

#include "shell.h"
#include "msg.h"
#include "net/ipv6/addr.h"
#include "net/gnrc/netif.h"
#include "net/gnrc/ipv6/netif.h"
#include "net/gnrc/aodvv2.h"

#define MAIN_QUEUE_SIZE (8)
static msg_t _main_msg_queue[MAIN_QUEUE_SIZE];

extern int udp_cmd(int argc, char **argv);

static const shell_command_t shell_commands[] = {
{ "udp", "send data over UDP and listen on UDP ports", udp_cmd },
{ NULL, NULL, NULL }
};

int main(void)
{
/* we need a message queue for the thread running the shell in order to
* receive potentially fast incoming networking packets */
msg_init_queue(_main_msg_queue, MAIN_QUEUE_SIZE);

/* get interface on which aodv is running */
kernel_pid_t ifs[GNRC_NETIF_NUMOF];
size_t numof = gnrc_netif_get(ifs);
if(numof <= 0) {
printf("no interface available: dropping packet.");
return -1;
}
/* use the first interface */
aodv_init(ifs[0]);

puts("RIOT network stack example application");

/* start shell */
puts("All up, running the shell now");
char line_buf[SHELL_DEFAULT_BUFSIZE];
shell_run(shell_commands, line_buf, SHELL_DEFAULT_BUFSIZE);

/* should be never reached */
return 0;
}
Loading