From f643d39168aacc3d798f34f81d81957e7abc55ad Mon Sep 17 00:00:00 2001 From: Nicolas Van Wambeke Date: Fri, 3 Apr 2020 11:36:58 +0200 Subject: [PATCH] Changes to use random port numbers (depend on user's uid) rather than a static port. Allows all students to use the same machine (for Covid-19 mitigation) --- Makefile | 4 +++- include/api/mictcp_core.h | 9 ++++++--- tsock_video | 7 ++++--- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index 18fd838..e8a02cb 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,7 @@ DATE := `date +'%Y%m%d'` TAG := moodle-$(USER) +PORT := $(shell expr `id -u` % 2000 + 12487) +PORT2 := $(shell expr $(PORT) + 1) ifneq ($(tag),) TAG := $(TAG)-$(tag) @@ -25,7 +27,7 @@ vpath %.c $(SRC_DIR) define make-goal $1/%.o: %.c - $(CC) -std=gnu99 -Wall -g -I $(INCLUDES) -c $$< -o $$@ + $(CC) -DAPI_CS_Port=$(PORT) -DAPI_SC_Port=$(PORT2) -std=gnu99 -Wall -g -I $(INCLUDES) -c $$< -o $$@ endef .PHONY: all checkdirs clean diff --git a/include/api/mictcp_core.h b/include/api/mictcp_core.h index 234653c..0e61c95 100644 --- a/include/api/mictcp_core.h +++ b/include/api/mictcp_core.h @@ -22,9 +22,12 @@ unsigned long get_now_time_usec(); /********************************************************************** * Private core functions, should not be used for implementing mictcp * **********************************************************************/ - -#define API_CS_Port 8524 -#define API_SC_Port 8525 +#ifndef API_CS_Port + #define API_CS_Port 8524 +#endif +#ifndef API_SC_Port + #define API_SC_Port 8525 +#endif #define API_HD_Size 15 typedef struct ip_payload diff --git a/tsock_video b/tsock_video index 7a43230..320bb83 100755 --- a/tsock_video +++ b/tsock_video @@ -3,6 +3,7 @@ puits=false sourc=false protocol="tcp" +port=`expr \`id -u\` % 3000 + 14578` usage() { echo "Usage: $0 [[-p|-s] [-t (tcp|mictcp)]" 1>&2; exit 1; } @@ -35,11 +36,11 @@ fi if [ "$puits" = true ]; then echo "Lancement du puits, protocole " $protocol - cvlc rtp://127.0.0.1:1234 > /dev/null 2>&1 & + cvlc rtp://127.0.0.1:$port > /dev/null 2>&1 & if [ "$protocol" = "mictcp" ]; then cd build - ./gateway -p -t $protocol 1234 & + ./gateway -p -t $protocol $port & cd .. fi fi @@ -48,7 +49,7 @@ if [ "$sourc" = true ]; then echo "Lancement de la source, protocol " $protocol cd build - ./gateway -s -t $protocol 127.0.0.1 1234 & + ./gateway -s -t $protocol 127.0.0.1 $port & cd .. fi