diff --git a/offloading_binaries/UDPReceiver_mobile/Makefile b/offloading_binaries/UDPReceiver_mobile/Makefile deleted file mode 100644 index 7747fa4..0000000 --- a/offloading_binaries/UDPReceiver_mobile/Makefile +++ /dev/null @@ -1,21 +0,0 @@ -#CC = /media/Lucifer/android/lib/android-18-toolchain/bin/arm-linux-androideabi-gcc -CC = arm-linux-androideabi-gcc -CFLAGS = -pie -fPIE -TARGET = UDPReceiver_mobile - -OBJS = $(patsubst %.c, %.o, $(wildcard *.c)) -HEADERS = $(wildcard *.h) - -all: $(TARGET) - -%.o: %.c $(HEADERS) - $(CC) $(CFLAGS) -c $< -o $@ - -.PRECIOUS: $(TARGET) $(OBJS) - -$(TARGET): $(OBJS) - $(CC) $(OBJS) -Wall $(CFLAGS) -o $@ - -clean: - -rm -f *.o - -rm -f $(TARGET) diff --git a/offloading_binaries/UDPReceiver_mobile/UDPReceiver_mobile b/offloading_binaries/UDPReceiver_mobile/UDPReceiver_mobile deleted file mode 100755 index 492c9f7..0000000 Binary files a/offloading_binaries/UDPReceiver_mobile/UDPReceiver_mobile and /dev/null differ diff --git a/offloading_binaries/UDPReceiver_mobile/main.c b/offloading_binaries/UDPReceiver_mobile/main.c deleted file mode 100644 index 3d83642..0000000 --- a/offloading_binaries/UDPReceiver_mobile/main.c +++ /dev/null @@ -1,97 +0,0 @@ -/* - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define ETH_P_IP 0x0800 /* Internet Protocol packet */ -#define ETH_ALEN 6 /* from */ -#define ETH_P_ALL 0x0003 - -#define MY_DEST_MAC0 0xba -#define MY_DEST_MAC1 0xf6 -#define MY_DEST_MAC2 0xb1 -#define MY_DEST_MAC3 0x71 -#define MY_DEST_MAC4 0x09 -#define MY_DEST_MAC5 0x64 - -#define DEFAULT_IF "wlan0" -#define BUF_SIZ 8192 - -int main(int argc, char *argv[]) -{ - int slotLength = 10000; // in microseconds - int quota = 1000000000; // Bytes per slot, default 1GB/slot - int sentInSlot = 0, slot = 1; - double elapsedTime; - - struct iovec iov; - int sockfd, listenfd; - struct ifreq if_idx; - struct ifreq if_mac; - int tx_len = 0; - char sendbuf[BUF_SIZ]; - struct ether_header *eh = (struct ether_header *) sendbuf; - struct iphdr *iph = (struct iphdr *) (sendbuf + sizeof(struct ether_header)); - struct sockaddr_ll socket_address; - char ifName[IFNAMSIZ]; - int i, j, ret, sendsize=1488, packet_num=1000000000, offset = 0, port; - int fd; /* file descriptor for file to send */ - struct sockaddr_in servaddr,cliaddr; - socklen_t clilen; - struct timeval t_start,t_end,t_now; - - signal(SIGPIPE, SIG_IGN); - - if (argc > 1) - port = atoi(argv[1]); - else - { - printf("Usage: TCPServer port rate"); - exit(1); - } - - if (argc > 2) - packet_num = atoi(argv[2]); - - - listenfd = socket(AF_INET, SOCK_DGRAM, 0); - - - bzero(&servaddr,sizeof(servaddr)); - servaddr.sin_family = AF_INET; - servaddr.sin_addr.s_addr = htonl(INADDR_ANY); - servaddr.sin_port = htons(port); - bind(listenfd, (struct sockaddr *)&servaddr, sizeof(servaddr)); -// listen(listenfd, 1); - - for(;;) - { - clilen=sizeof(cliaddr); - ret = recvfrom(listenfd,sendbuf, 4096, 0, (struct sockaddr *)&cliaddr, &clilen); -// sockfd = accept(listenfd,(struct sockaddr *)&cliaddr, &clilen); - printf("Accepted.\n"); - - } - - close(fd); - - return 0; -} diff --git a/offloading_binaries/UDPReceiver_mobile/main.o b/offloading_binaries/UDPReceiver_mobile/main.o deleted file mode 100644 index 1cdaf9b..0000000 Binary files a/offloading_binaries/UDPReceiver_mobile/main.o and /dev/null differ diff --git a/offloading_binaries/server_recv_normaltcp/main.c b/offloading_binaries/server_recv_normaltcp/main.c index fdc5a54..e55d0e6 100644 --- a/offloading_binaries/server_recv_normaltcp/main.c +++ b/offloading_binaries/server_recv_normaltcp/main.c @@ -1,6 +1,6 @@ /* * Initial commit by Yibo @ Jul. 28, 2015 - * Last update by Yanzi @ Sept. 26, 2016 + * Last update by Yanzi @ Sept. 27, 2016 */ #include @@ -21,26 +21,9 @@ #include #include #include -#include #define BUF_SIZ 65536 -char isNumber(char number[]) -{ - int i = 0; - - //checking for negative numbers - if (number[0] == '-') - i = 1; - for (; number[i] != 0; i++) - { - //if (number[i] > '9' || number[i] < '0') - if (!isdigit(number[i])) - return 0; - } - return 1; -} - int main(int argc, char *argv[]) { // defaults @@ -71,7 +54,7 @@ int main(int argc, char *argv[]) port = atoi(argv[1]); if (argc > 2) - listenOnce = 1; + listenOnce = atoi(argv[2]); // listen to socket listenfd = socket(AF_INET, SOCK_STREAM, 0); @@ -145,5 +128,7 @@ int main(int argc, char *argv[]) break; } + close(listenfd); + return 0; } diff --git a/offloading_binaries/server_recv_normaludp/Makefile b/offloading_binaries/server_recv_normaludp/Makefile new file mode 100644 index 0000000..03a061e --- /dev/null +++ b/offloading_binaries/server_recv_normaludp/Makefile @@ -0,0 +1,18 @@ +#CC = /media/Lucifer/android/lib/android-18-toolchain/bin/arm-linux-androideabi-gcc +CC1 = arm-linux-androideabi-gcc +CC2 = gcc +CFLAGS = -pie -fPIE +TARGET1 = server_m_recv_normaludp +TARGET2 = server_recv_normaludp + +all: $(TARGET1) $(TARGET2) + +$(TARGET1): main.c + $(CC1) main.c -Wall $(CFLAGS) -o $@ + +$(TARGET2): main.c + $(CC2) main.c -Wall $(CFLAGS) -o $@ + +clean: + -rm -f $(TARGET1) + -rm -f $(TARGET2) diff --git a/offloading_binaries/server_recv_normaludp/main.c b/offloading_binaries/server_recv_normaludp/main.c new file mode 100644 index 0000000..e07d61d --- /dev/null +++ b/offloading_binaries/server_recv_normaludp/main.c @@ -0,0 +1,126 @@ +/* + * Initial commit by Yibo @ Jul. 28, 2015 + * Last update by Yanzi @ Sept. 27, 2016 + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define BUF_SIZ 65536 + +int main(int argc, char *argv[]) +{ + // defaults + uint total_bytes_recv = 0; + // for timing + double elapsedTime; + struct timeval t_start, t_end; + // for socket + int fd = 0; // file descriptor of file to write (receive) + int port; + int recvsize = 4096; + int listenfd; // fd + char recvbuf[BUF_SIZ]; + struct sockaddr_in servaddr, cliaddr; + socklen_t clilen; + // for misc + int ret; + + signal(SIGPIPE, SIG_IGN); + + if (argc < 2) + { + printf("Usage: %s <[optional] filepath>\n", argv[0]); + exit(0); + } + + port = atoi(argv[1]); + + // listen to socket + listenfd = socket(AF_INET, SOCK_DGRAM, 0); + // bind socket and listen + bzero(&servaddr, sizeof(servaddr)); + servaddr.sin_family = AF_INET; + servaddr.sin_addr.s_addr = htonl(INADDR_ANY); + servaddr.sin_port = htons(port); + bind(listenfd, (struct sockaddr *)&servaddr, sizeof(servaddr)); + + // infinity loop to listen + printf("Waiting on port %d...\n", port); + // clear total_bytes_recv to 0 + total_bytes_recv = 0; + + // if instrument to write to a file + if (argc > 2) + { + fd = open(argv[2], O_WRONLY | O_CREAT | O_TRUNC); + if (fd == -1) { + fprintf(stderr, "! Unable to open file %s.\n", argv[2]); + close(listenfd); + exit(1); + } + } + + // start timing + gettimeofday(&t_start, NULL); + + // start receiving + for (;;) + { + clilen = sizeof(cliaddr); + + // wait for one client and accept it once found + ret = recvfrom(listenfd, recvbuf, recvsize, 0, (struct sockaddr *)&cliaddr, &clilen); + printf("Accepted client at %s with %d len msg\n", inet_ntoa(cliaddr.sin_addr), ret); + + if (ret <= 0) + { + if (errno == 0) + break; + fprintf(stderr, "! Fail to recv: ret:%d, err:%d; quiting..\n", ret, errno); + exit(1); + } + + // a "code" to indicate UDP is done + // printf("%d %d %d", (recvbuf[0] == '='), (recvbuf[1] == '?'), (recvbuf[0] == '!')); + if ((recvbuf[0] == '=') && (recvbuf[1] == '?') && (recvbuf[2] == '!')) + break; + + if (argc > 2) + write(fd, recvbuf, ret); + + total_bytes_recv += ret; + // printf("total_bytes_recv %d\n", total_bytes_recv); + + } + + if (argc > 2) + close(fd); + + // end timing + gettimeofday(&t_end, NULL); + elapsedTime = (t_end.tv_sec - t_start.tv_sec) + (t_end.tv_usec - t_start.tv_usec) / 1000000.0; + printf( + "recv(bytes):%d\nduration(s):%lf\nthroughput(bps):%lf\n", + total_bytes_recv, elapsedTime, total_bytes_recv * 8 / elapsedTime); + + close(listenfd); + + return 0; +} diff --git a/offloading_binaries/server_recv_normaludp/server_m_recv_normaludp b/offloading_binaries/server_recv_normaludp/server_m_recv_normaludp new file mode 100755 index 0000000..14f4767 Binary files /dev/null and b/offloading_binaries/server_recv_normaludp/server_m_recv_normaludp differ diff --git a/offloading_binaries/server_recv_normaludp/server_recv_normaludp b/offloading_binaries/server_recv_normaludp/server_recv_normaludp new file mode 100755 index 0000000..7bdb2ef Binary files /dev/null and b/offloading_binaries/server_recv_normaludp/server_recv_normaludp differ