Skip to content

Commit 12cd62c

Browse files
committed
Introduction of RPL non-storing mode.
This implementation is based on RFC 6550 with addition of RFC 6554 (Source Routing Header for RPL). Both can be found under the following links: - http://tools.ietf.org/html/rfc6550 - http://tools.ietf.org/html/rfc6554 The PR provides basic functionality for handling and forwarding packages in non-storing mode. In addition the structure of the previous implemented RPL storing mode is now revised, so that readability and modularity is increased. The following features are implemented: - building function for a SRH and integration in common packets - source-route build algorithm based on the structure of the DODAG - an RPL-based interpretation of the SRH and removal at destination - new structure for RPl-module with extracted beaconing-functionality - leaf nodes are now supported There are some missed goals and should be included in future updates: - building a common routing table structure for different types of routing protocols - routing tables are statically assigned via source code, future update should have an optional variable at build-time, which sets the size of the routing table depending on the desired functionality of a node in the network (root, node, leaf)
1 parent b358d85 commit 12cd62c

File tree

32 files changed

+1955
-386
lines changed

32 files changed

+1955
-386
lines changed

sys/net/include/etx_beaconing.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,17 @@
66
* directory for more details.
77
*/
88

9+
/**
10+
* @ingroup rpl
11+
* @{
12+
* @file etx_beaconing.h
13+
*
14+
* Header-file, which includes all constants and functions used for ETX-based beaconing.
15+
*
16+
* @author Stephan Arndt <[email protected]>
17+
* @}
18+
*/
19+
920
#ifndef ETX_BEACONING_H_
1021
#define ETX_BEACONING_H_
1122
#include <stdint.h>

sys/net/include/rpl.h

Lines changed: 72 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,18 @@
77
*/
88

99
/**
10-
* @defgroup net_rpl RPL
11-
* @ingroup net
12-
* @brief Routing Protocol for Low power and Lossy Networks
13-
*
14-
* Header which includes all core RPL-functions. Normally it shouldn't be necessary to
15-
* modify this file.
16-
*
10+
* @ingroup rpl
1711
* @{
1812
*
1913
* @file rpl.h
2014
* @brief RPL header. Declaration of global variables and functions needed for
21-
* core functionality of RPL.
15+
* core functionality of RPL.
2216
*
23-
* @author Eric Engel <[email protected]>
24-
* @author Fabian Brandt <[email protected]>
17+
* Header which includes all core RPL-functions. Normally it shouldn't be necessary to
18+
* modify this file.
19+
*
20+
* @author Eric Engel <[email protected]>
21+
* @author Fabian Brandt <[email protected]>
2522
*/
2623

2724
#ifndef __RPL_H
@@ -44,11 +41,11 @@ extern "C" {
4441
#define CC1100_RADIO_MODE CC1100_MODE_WOR
4542

4643
#define RPL_PKT_RECV_BUF_SIZE 16
47-
#define RPL_PROCESS_STACKSIZE KERNEL_CONF_STACKSIZE_DEFAULT
44+
#define RPL_PROCESS_STACKSIZE KERNEL_CONF_STACKSIZE_MAIN
4845

4946
/* global variables */
50-
extern rpl_routing_entry_t rpl_routing_table[RPL_MAX_ROUTING_ENTRIES];
5147
extern kernel_pid_t rpl_process_pid;
48+
extern uint8_t rpl_max_routing_entries;
5249

5350
/* needed for receiving messages with ICMP-code 155. Received via IPC from ipv6.c */
5451
extern mutex_t rpl_recv_mutex;
@@ -95,7 +92,7 @@ void rpl_init_root(void);
9592
* @param[in] destination IPv6-address of the destination of the DIO. Should be a direct neighbor.
9693
*
9794
*/
98-
void send_DIO(ipv6_addr_t *destination);
95+
void rpl_send_DIO(ipv6_addr_t *destination);
9996

10097
/**
10198
* @brief Sends a DAO-message to a given destination
@@ -110,7 +107,7 @@ void send_DIO(ipv6_addr_t *destination);
110107
* @param[in] start_index Describes whether a DAO must be split because of too many routing entries.
111108
*
112109
*/
113-
void send_DAO(ipv6_addr_t *destination, uint8_t lifetime, bool default_lifetime, uint8_t start_index);
110+
void rpl_send_DAO(ipv6_addr_t *destination, uint8_t lifetime, bool default_lifetime, uint8_t start_index);
114111

115112
/**
116113
* @brief Sends a DIS-message to a given destination
@@ -122,7 +119,7 @@ void send_DAO(ipv6_addr_t *destination, uint8_t lifetime, bool default_lifetime,
122119
* @param[in] destination IPv6-address of the destination of the DIS. Should be a direct neighbor or multicast-address.
123120
*
124121
*/
125-
void send_DIS(ipv6_addr_t *destination);
122+
void rpl_send_DIS(ipv6_addr_t *destination);
126123

127124
/**
128125
* @brief Sends a DAO acknowledgment-message to a given destination
@@ -134,7 +131,7 @@ void send_DIS(ipv6_addr_t *destination);
134131
* @param[in] destination IPv6-address of the destination of the DAO_ACK. Should be a direct neighbor.
135132
*
136133
*/
137-
void send_DAO_ACK(ipv6_addr_t *destination);
134+
void rpl_send_DAO_ACK(ipv6_addr_t *destination);
138135

139136
/**
140137
* @brief Receives a DIO message
@@ -143,7 +140,7 @@ void send_DAO_ACK(ipv6_addr_t *destination);
143140
* this function just calls the receiving function of the chosen mode.
144141
*
145142
*/
146-
void recv_rpl_DIO(void);
143+
void rpl_recv_DIO(void);
147144

148145
/**
149146
* @brief Receives a DAO message
@@ -152,7 +149,7 @@ void recv_rpl_DIO(void);
152149
* this function just calls the receiving function of the chosen mode.
153150
*
154151
*/
155-
void recv_rpl_DAO(void);
152+
void rpl_recv_DAO(void);
156153

157154
/**
158155
* @brief Receives a DIS message
@@ -161,7 +158,7 @@ void recv_rpl_DAO(void);
161158
* this function just calls the receiving function of the chosen mode.
162159
*
163160
*/
164-
void recv_rpl_DIS(void);
161+
void rpl_recv_DIS(void);
165162

166163
/**
167164
* @brief Receives a DAO acknowledgment message
@@ -170,7 +167,7 @@ void recv_rpl_DIS(void);
170167
* this function just calls the receiving function of the chosen mode.
171168
*
172169
*/
173-
void recv_rpl_DAO_ACK(void);
170+
void rpl_recv_DAO_ACK(void);
174171

175172
/**
176173
* @brief Initialization of RPl-root.
@@ -255,9 +252,64 @@ void rpl_clear_routing_table(void);
255252
* */
256253
rpl_routing_entry_t *rpl_get_routing_table(void);
257254

255+
/**
256+
* @brief Returns the network status of the actual node
257+
*
258+
* @return 1 if root, 0 otherwise
259+
*
260+
* */
261+
uint8_t rpl_is_root(void);
262+
263+
#if RPL_DEFAULT_MOP == RPL_NON_STORING_MODE
264+
265+
/**
266+
* @brief Adds one pair of child and its parent to the source routing table
267+
*
268+
* @deprecated This function is obsolete and will be removed shortly. This will be replaced with a
269+
* common routing information base.
270+
*
271+
* @param[in] child Child IPv6-address
272+
* @param[in] parent Parent IPv6-address
273+
* @param[in] lifetime Lifetime of the relation
274+
*
275+
* */
276+
void rpl_add_srh_entry(ipv6_addr_t *child, ipv6_addr_t *parent, uint16_t lifetime);
277+
278+
/**
279+
* @brief Constructs a source routing header based on an original IPv6-header
280+
*
281+
* @param[in] act_ipv6_hdr Pointer to original IPv6-packet header
282+
* @return Source routing header or NULL
283+
*
284+
* */
285+
ipv6_srh_t *rpl_get_srh_header(ipv6_hdr_t *act_ipv6_hdr);
286+
287+
/**
288+
* @brief Manages sending an SRH-header integrated in an original IPv6-package to the next hop.
289+
*
290+
* @param[in] buf Pointer to original payload
291+
* @param[in] len Length of the original payload
292+
* @param[in] src Original source address
293+
* @param[in] dest Destination address
294+
* @param[in] srh_header Pre-build source routing header
295+
* @param[in] srh_length Length of the pre-built source routing header
296+
* @return Status of sending progress
297+
* */
298+
int rpl_srh_sendto(const void *buf, uint16_t len, ipv6_addr_t *src, ipv6_addr_t *dest, ipv6_srh_t *srh_header, uint8_t srh_length);
299+
300+
/**
301+
* @brief Sends IPC-message to the service, which is indicated by the next-header-field in the source routing header
302+
*
303+
* @param[in] ipv6_header Actual IPv6-header
304+
* @return IPv6-address of the next-hop. Is NULL on error occurrence.
305+
*
306+
* */
307+
void rpl_remove_srh_header(ipv6_hdr_t *ipv6_header, const void *buf, uint8_t nextheader);
308+
258309
#ifdef __cplusplus
259310
}
260311
#endif
261312

313+
#endif
262314
/** @} */
263315
#endif /* __RPL_H */

sys/net/include/rpl/rpl_config.h

Lines changed: 28 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
1+
/*
2+
* Copyright (C) 2013, 2014 INRIA.
3+
*
4+
* This file is subject to the terms and conditions of the GNU Lesser General
5+
* Public License v2.1. See the file LICENSE in the top level directory for more
6+
* details.
7+
*/
8+
19
/**
2-
* RPL data structs
10+
* @ingroup rpl
11+
* @{
312
*
4-
* Copyright (C) 2013, 2014 INRIA.
13+
* @file rpl_config.h
14+
* @brief RPL Config
515
*
6-
* This file is subject to the terms and conditions of the GNU Lesser
7-
* General Public License v2.1. See the file LICENSE in the top level
8-
* directory for more details.
16+
* Configuration file, which defines all environmental variables for RPL.
917
*
10-
* @ingroup rpl
11-
* @{
12-
* @file rpl_config.h
13-
* @brief RPL Config
14-
* @author Eric Engel <[email protected]>
18+
* @author Eric Engel <[email protected]>
1519
* @}
1620
*/
1721

@@ -42,11 +46,11 @@ extern "C" {
4246
#define DAO_ACK_LEN 4
4347
#define DAO_ACK_D_LEN 24
4448
#define RPL_OPT_LEN 2
45-
#define RPL_OPT_DODAG_CONF_LEN 14
46-
#define RPL_OPT_PREFIX_INFO_LEN 30
47-
#define RPL_OPT_SOLICITED_INFO_LEN 19
48-
#define RPL_OPT_TARGET_LEN 18
49-
#define RPL_OPT_TRANSIT_LEN 4
49+
#define RPL_OPT_DODAG_CONF_LEN 16
50+
#define RPL_OPT_PREFIX_INFO_LEN 32
51+
#define RPL_OPT_SOLICITED_INFO_LEN 21
52+
#define RPL_OPT_TARGET_LEN 20
53+
#define RPL_OPT_TRANSIT_LEN 22
5054

5155
/* message options */
5256
#define RPL_OPT_PAD1 0
@@ -68,22 +72,22 @@ extern "C" {
6872

6973
static inline uint8_t RPL_COUNTER_INCREMENT(uint8_t counter)
7074
{
71-
return (counter > RPL_COUNTER_LOWER_REGION ? (counter == RPL_COUNTER_MAX ? counter=0 : ++counter) : (counter == RPL_COUNTER_LOWER_REGION ? counter=0 : ++counter));
75+
return (counter > RPL_COUNTER_LOWER_REGION ? (counter == RPL_COUNTER_MAX ? counter = 0 : ++counter) : (counter == RPL_COUNTER_LOWER_REGION ? counter = 0 : ++counter));
7276
}
7377

7478
static inline bool RPL_COUNTER_IS_INIT(uint8_t counter)
7579
{
7680
return (counter > RPL_COUNTER_LOWER_REGION);
7781
}
7882

79-
static inline bool RPL_COUNTER_GREATER_THAN_LOCAL(uint8_t A,uint8_t B)
83+
static inline bool RPL_COUNTER_GREATER_THAN_LOCAL(uint8_t A, uint8_t B)
8084
{
81-
return (((A<B) && (RPL_COUNTER_LOWER_REGION + 1 - B + A < RPL_COUNTER_SEQ_WINDOW)) || ((A > B) && (A-B < RPL_COUNTER_SEQ_WINDOW)));
85+
return (((A < B) && (RPL_COUNTER_LOWER_REGION + 1 - B + A < RPL_COUNTER_SEQ_WINDOW)) || ((A > B) && (A - B < RPL_COUNTER_SEQ_WINDOW)));
8286
}
8387

84-
static inline bool RPL_COUNTER_GREATER_THAN(uint8_t A,uint8_t B)
88+
static inline bool RPL_COUNTER_GREATER_THAN(uint8_t A, uint8_t B)
8589
{
86-
return ((A>RPL_COUNTER_LOWER_REGION) ? ((B > RPL_COUNTER_LOWER_REGION ) ? RPL_COUNTER_GREATER_THAN_LOCAL(A,B) : 0): (( B>RPL_COUNTER_LOWER_REGION ) ? 1: RPL_COUNTER_GREATER_THAN_LOCAL(A,B)));
90+
return ((A > RPL_COUNTER_LOWER_REGION) ? ((B > RPL_COUNTER_LOWER_REGION) ? RPL_COUNTER_GREATER_THAN_LOCAL(A, B) : 0) : ((B > RPL_COUNTER_LOWER_REGION) ? 1 : RPL_COUNTER_GREATER_THAN_LOCAL(A, B)));
8791
}
8892

8993
/* Node Status */
@@ -123,7 +127,10 @@ static inline bool RPL_COUNTER_GREATER_THAN(uint8_t A,uint8_t B)
123127
#define RPL_MAX_DODAGS 3
124128
#define RPL_MAX_INSTANCES 1
125129
#define RPL_MAX_PARENTS 5
126-
#define RPL_MAX_ROUTING_ENTRIES 128
130+
#define RPL_MAX_ROUTING_ENTRIES_STORING 128
131+
#define RPL_MAX_ROUTING_ENTRIES_NON_STORING 128
132+
#define RPL_MAX_SRH_PATH_LENGTH 10;
133+
#define RPL_SRH_ENTRIES 15
127134
#define RPL_ROOT_RANK 256
128135
#define RPL_DEFAULT_LIFETIME 0xff
129136
#define RPL_LIFETIME_UNIT 2

sys/net/include/rpl/rpl_dodag.h

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
/**
2-
* RPL dodag prototypes
3-
*
1+
/*
42
* Copyright (C) 2013, 2014 INRIA.
53
*
64
* This file is subject to the terms and conditions of the GNU Lesser
@@ -9,9 +7,13 @@
97
*
108
* @ingroup rpl
119
* @{
12-
* @file rpl_dodag.h
13-
* @brief RPL dodag header
14-
* @author Eric Engel <[email protected]>
10+
*
11+
* @file rpl_dodag.h
12+
* @brief RPL DODAG header
13+
*
14+
* Header file, which defines all public known DODAG-related functions for RPL.
15+
*
16+
* @author Eric Engel <[email protected]>
1517
* @}
1618
*/
1719

0 commit comments

Comments
 (0)