Merge pull request #10963 from brummer-simon/gnrc_tcp-fix_test_setup
gnrc_tcp: change and verify addrs in use
This commit is contained in:
commit
dd664a88fd
@ -7,8 +7,9 @@ ifeq (native,$(BOARD))
|
|||||||
PORT ?= tap1
|
PORT ?= tap1
|
||||||
endif
|
endif
|
||||||
|
|
||||||
TCP_TARGET_ADDR ?= fe80::affe%5
|
TCP_SERVER_ADDR ?= 2001:db8::affe:0001
|
||||||
TCP_TARGET_PORT ?= 80
|
TCP_SERVER_PORT ?= 80
|
||||||
|
TCP_CLIENT_ADDR ?= 2001:db8::affe:0002
|
||||||
TCP_TEST_CYCLES ?= 3
|
TCP_TEST_CYCLES ?= 3
|
||||||
|
|
||||||
# Mark Boards with insufficient memory
|
# Mark Boards with insufficient memory
|
||||||
@ -21,10 +22,13 @@ BOARD_INSUFFICIENT_MEMORY := airfy-beacon arduino-duemilanove arduino-mega2560 \
|
|||||||
waspmote-pro wsn430-v1_3b wsn430-v1_4 yunjia-nrf51822 z1
|
waspmote-pro wsn430-v1_3b wsn430-v1_4 yunjia-nrf51822 z1
|
||||||
|
|
||||||
# Target Address, Target Port and number of Test Cycles
|
# Target Address, Target Port and number of Test Cycles
|
||||||
CFLAGS += -DTARGET_ADDR=\"$(TCP_TARGET_ADDR)\"
|
CFLAGS += -DSERVER_ADDR=\"$(TCP_SERVER_ADDR)\"
|
||||||
CFLAGS += -DTARGET_PORT=$(TCP_TARGET_PORT)
|
CFLAGS += -DSERVER_PORT=$(TCP_SERVER_PORT)
|
||||||
|
CFLAGS += -DCLIENT_ADDR=\"$(TCP_CLIENT_ADDR)\"
|
||||||
CFLAGS += -DCYCLES=$(TCP_TEST_CYCLES)
|
CFLAGS += -DCYCLES=$(TCP_TEST_CYCLES)
|
||||||
CFLAGS += -DGNRC_NETIF_IPV6_GROUPS_NUMOF=3
|
CFLAGS += -DGNRC_NETIF_IPV6_GROUPS_NUMOF=3
|
||||||
|
CFLAGS += -DGNRC_IPV6_NIB_CONF_ARSM=1
|
||||||
|
CFLAGS += -DGNRC_IPV6_NIB_CONF_QUEUE_PKT=1
|
||||||
|
|
||||||
# Modules to include
|
# Modules to include
|
||||||
USEMODULE += gnrc_netdev_default
|
USEMODULE += gnrc_netdev_default
|
||||||
@ -32,4 +36,7 @@ USEMODULE += auto_init_gnrc_netif
|
|||||||
USEMODULE += gnrc_ipv6_default
|
USEMODULE += gnrc_ipv6_default
|
||||||
USEMODULE += gnrc_tcp
|
USEMODULE += gnrc_tcp
|
||||||
|
|
||||||
|
# include this for IP address manipulation
|
||||||
|
USEMODULE += shell_commands
|
||||||
|
|
||||||
include $(RIOTBASE)/Makefile.include
|
include $(RIOTBASE)/Makefile.include
|
||||||
|
|||||||
@ -11,6 +11,7 @@
|
|||||||
#include "thread.h"
|
#include "thread.h"
|
||||||
#include "net/af.h"
|
#include "net/af.h"
|
||||||
#include "net/gnrc/ipv6.h"
|
#include "net/gnrc/ipv6.h"
|
||||||
|
#include "net/gnrc/netif.h"
|
||||||
#include "net/gnrc/tcp.h"
|
#include "net/gnrc/tcp.h"
|
||||||
|
|
||||||
#define ENABLE_DEBUG (0)
|
#define ENABLE_DEBUG (0)
|
||||||
@ -43,8 +44,26 @@ void *cli_thread(void *arg);
|
|||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
printf("\nStarting Client Threads. TARGET_ADDR=%s, TARGET_PORT=%d, ", TARGET_ADDR, TARGET_PORT);
|
gnrc_netif_t *netif;
|
||||||
printf("CONNS=%d, NBYTE=%d, CYCLES=%d\n\n", CONNS, NBYTE, CYCLES );
|
ipv6_addr_t addr;
|
||||||
|
|
||||||
|
if (!(netif = gnrc_netif_iter(NULL))) {
|
||||||
|
printf("No valid network interface found\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ipv6_addr_from_str(&addr, CLIENT_ADDR) == NULL) {
|
||||||
|
printf("Can't convert given string to IPv6 Address\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (gnrc_netif_ipv6_addr_add(netif, &addr, 64, GNRC_NETIF_IPV6_ADDRS_FLAGS_STATE_VALID) < 0) {
|
||||||
|
printf("Can't assign given IPv6 Address\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("\nStarting Client Threads. SERVER_ADDR=%s, SERVER_PORT=%d, ", SERVER_ADDR, SERVER_PORT);
|
||||||
|
printf("CONNS=%d, NBYTE=%d, CYCLES=%d\n\n", CONNS, NBYTE, CYCLES);
|
||||||
|
|
||||||
/* Start connection handling threads */
|
/* Start connection handling threads */
|
||||||
for (int i = 0; i < CONNS; i += 1) {
|
for (int i = 0; i < CONNS; i += 1) {
|
||||||
@ -70,8 +89,8 @@ void *cli_thread(void *arg)
|
|||||||
|
|
||||||
/* Copy peer address information. NOTE: This test uses link-local addresses
|
/* Copy peer address information. NOTE: This test uses link-local addresses
|
||||||
* -> The Device identifier is removed from target_addr in each iteration! */
|
* -> The Device identifier is removed from target_addr in each iteration! */
|
||||||
char target_addr[] = TARGET_ADDR;
|
char target_addr[] = SERVER_ADDR;
|
||||||
uint16_t target_port = TARGET_PORT;
|
uint16_t target_port = SERVER_PORT;
|
||||||
|
|
||||||
/* Initialize TCB */
|
/* Initialize TCB */
|
||||||
gnrc_tcp_tcb_init(&tcb);
|
gnrc_tcp_tcb_init(&tcb);
|
||||||
|
|||||||
@ -7,8 +7,8 @@ ifeq (native,$(BOARD))
|
|||||||
PORT ?= tap0
|
PORT ?= tap0
|
||||||
endif
|
endif
|
||||||
|
|
||||||
TCP_LOCAL_ADDR ?= fe80::affe
|
TCP_SERVER_ADDR ?= 2001:db8::affe:0001
|
||||||
TCP_LOCAL_PORT ?= 80
|
TCP_SERVER_PORT ?= 80
|
||||||
TCP_TEST_CYCLES ?= 3
|
TCP_TEST_CYCLES ?= 3
|
||||||
|
|
||||||
# Mark Boards with insufficient memory
|
# Mark Boards with insufficient memory
|
||||||
@ -20,14 +20,13 @@ BOARD_INSUFFICIENT_MEMORY := airfy-beacon arduino-duemilanove arduino-mega2560 \
|
|||||||
saml10-xpro saml11-xpro sb-430 sb-430h stm32f0discovery telosb \
|
saml10-xpro saml11-xpro sb-430 sb-430h stm32f0discovery telosb \
|
||||||
waspmote-pro wsn430-v1_3b wsn430-v1_4 yunjia-nrf51822 z1
|
waspmote-pro wsn430-v1_3b wsn430-v1_4 yunjia-nrf51822 z1
|
||||||
|
|
||||||
# This has to be the absolute path to the RIOT base directory:
|
|
||||||
RIOTBASE ?= $(CURDIR)/../..
|
|
||||||
|
|
||||||
# Local Address, Local Port and number of Test Cycles
|
# Local Address, Local Port and number of Test Cycles
|
||||||
CFLAGS += -DLOCAL_ADDR=\"$(TCP_LOCAL_ADDR)\"
|
CFLAGS += -DSERVER_ADDR=\"$(TCP_SERVER_ADDR)\"
|
||||||
CFLAGS += -DLOCAL_PORT=$(TCP_LOCAL_PORT)
|
CFLAGS += -DSERVER_PORT=$(TCP_SERVER_PORT)
|
||||||
CFLAGS += -DCYCLES=$(TCP_TEST_CYCLES)
|
CFLAGS += -DCYCLES=$(TCP_TEST_CYCLES)
|
||||||
CFLAGS += -DGNRC_NETIF_IPV6_GROUPS_NUMOF=3
|
CFLAGS += -DGNRC_NETIF_IPV6_GROUPS_NUMOF=3
|
||||||
|
CFLAGS += -DGNRC_IPV6_NIB_CONF_ARSM=1
|
||||||
|
CFLAGS += -DGNRC_IPV6_NIB_CONF_QUEUE_PKT=1
|
||||||
|
|
||||||
# Modules to include
|
# Modules to include
|
||||||
USEMODULE += gnrc_netdev_default
|
USEMODULE += gnrc_netdev_default
|
||||||
|
|||||||
@ -40,28 +40,32 @@
|
|||||||
uint8_t bufs[CONNS][NBYTE];
|
uint8_t bufs[CONNS][NBYTE];
|
||||||
uint8_t stacks[CONNS][THREAD_STACKSIZE_DEFAULT + THREAD_EXTRA_STACKSIZE_PRINTF];
|
uint8_t stacks[CONNS][THREAD_STACKSIZE_DEFAULT + THREAD_EXTRA_STACKSIZE_PRINTF];
|
||||||
|
|
||||||
/* "ifconfig" shell command */
|
|
||||||
extern int _gnrc_netif_config(int argc, char **argv);
|
|
||||||
|
|
||||||
/* Server thread */
|
/* Server thread */
|
||||||
void *srv_thread(void *arg);
|
void *srv_thread(void *arg);
|
||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
|
/* Set pre-configured IP address */
|
||||||
gnrc_netif_t *netif;
|
gnrc_netif_t *netif;
|
||||||
|
ipv6_addr_t addr;
|
||||||
|
|
||||||
if (!(netif = gnrc_netif_iter(NULL))) {
|
if (!(netif = gnrc_netif_iter(NULL))) {
|
||||||
printf("No valid network interface found\n");
|
printf("No valid network interface found\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set pre-configured IP address */
|
if (ipv6_addr_from_str(&addr, SERVER_ADDR) == NULL) {
|
||||||
char if_pid[] = {netif->pid + '0', '\0'};
|
printf("Can't convert given string to IPv6 Address\n");
|
||||||
char *cmd[] = {"ifconfig", if_pid, "add", "unicast", LOCAL_ADDR};
|
return -1;
|
||||||
_gnrc_netif_config(5, cmd);
|
}
|
||||||
|
|
||||||
|
if (gnrc_netif_ipv6_addr_add(netif, &addr, 64, GNRC_NETIF_IPV6_ADDRS_FLAGS_STATE_VALID) < 0) {
|
||||||
|
printf("Can't assign given IPv6 Address\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
/* Test configuration */
|
/* Test configuration */
|
||||||
printf("\nStarting server: LOCAL_ADDR=%s, LOCAL_PORT=%d, ", LOCAL_ADDR, LOCAL_PORT);
|
printf("\nStarting server: SERVER_ADDR=%s, SERVER_PORT=%d, ", SERVER_ADDR, SERVER_PORT);
|
||||||
printf("CONNS=%d, NBYTE=%d, CYCLES=%d\n\n", CONNS, NBYTE, CYCLES);
|
printf("CONNS=%d, NBYTE=%d, CYCLES=%d\n\n", CONNS, NBYTE, CYCLES);
|
||||||
|
|
||||||
/* Start Threads to handle connections */
|
/* Start Threads to handle connections */
|
||||||
@ -89,7 +93,7 @@ void *srv_thread(void *arg)
|
|||||||
gnrc_tcp_tcb_init(&tcb);
|
gnrc_tcp_tcb_init(&tcb);
|
||||||
|
|
||||||
/* Connect to peer */
|
/* Connect to peer */
|
||||||
int ret = gnrc_tcp_open_passive(&tcb, AF_INET6, NULL, LOCAL_PORT);
|
int ret = gnrc_tcp_open_passive(&tcb, AF_INET6, NULL, SERVER_PORT);
|
||||||
switch (ret) {
|
switch (ret) {
|
||||||
case 0:
|
case 0:
|
||||||
DEBUG("TID=%d : gnrc_tcp_open_passive() : 0 : ok\n", tid);
|
DEBUG("TID=%d : gnrc_tcp_open_passive() : 0 : ok\n", tid);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user