diff --git a/OffloadingDemo/.idea/misc.xml b/OffloadingDemo/.idea/misc.xml
index 95f0f03..1caa136 100755
--- a/OffloadingDemo/.idea/misc.xml
+++ b/OffloadingDemo/.idea/misc.xml
@@ -37,7 +37,7 @@
-
+
diff --git a/OffloadingDemo/mobile/mobile.iml b/OffloadingDemo/mobile/mobile.iml
index bd78d65..ece0ef9 100755
--- a/OffloadingDemo/mobile/mobile.iml
+++ b/OffloadingDemo/mobile/mobile.iml
@@ -82,7 +82,6 @@
-
diff --git a/OffloadingDemo/wear/wear.iml b/OffloadingDemo/wear/wear.iml
index 37ff89b..57a96cb 100755
--- a/OffloadingDemo/wear/wear.iml
+++ b/OffloadingDemo/wear/wear.iml
@@ -94,7 +94,6 @@
-
diff --git a/offloading_binaries/BypassL3Binary/Makefile b/offloading_binaries/BypassL3Binary/Makefile
new file mode 100644
index 0000000..7b6c665
--- /dev/null
+++ b/offloading_binaries/BypassL3Binary/Makefile
@@ -0,0 +1,21 @@
+CC = arm-linux-androideabi-gcc
+#CC = gcc
+CFLAGS = -pie -fPIE -lm
+TARGET = bypassl3
+
+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 $@
+ cp $(TARGET) /media/Lucifer/yanzi/projects/offloading/RDMAMobileDemo/app/src/main/assets/
+clean:
+ -rm -f *.o
+ -rm -f $(TARGET)
diff --git a/offloading_binaries/BypassL3Binary/bypassl3 b/offloading_binaries/BypassL3Binary/bypassl3
new file mode 100755
index 0000000..5189a90
Binary files /dev/null and b/offloading_binaries/BypassL3Binary/bypassl3 differ
diff --git a/offloading_binaries/BypassL3Binary/main.c b/offloading_binaries/BypassL3Binary/main.c
new file mode 100644
index 0000000..fba88fe
--- /dev/null
+++ b/offloading_binaries/BypassL3Binary/main.c
@@ -0,0 +1,206 @@
+/*
+ * 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
+
+#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 DEFAULT_IF "eth1"
+#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;
+ double packetPerSlot;
+
+ struct iovec iov;
+ int sockfd;
+ 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=1500, packet_num, offset = 0;
+ int fd; /* file descriptor for file to send */
+ struct timeval t_start, t_end, t_now;
+
+ if (argc > 4)
+ sendsize = atoi(argv[4]);
+
+ if (argc > 1)
+ packet_num = atoi(argv[1])/sendsize;
+ else
+ packet_num = 166666;
+
+ if (argc > 2)
+ quota = atoi(argv[2]) / (1000000 / slotLength);
+ else {
+ printf("Usage: ./bypassl3 ");
+ exit(-1);
+ }
+
+ if (argc > 3) {
+ /* get the name of the interface */
+ strcpy(ifName, argv[3]);
+ } else {
+ strcpy(ifName, DEFAULT_IF);
+ }
+
+ // fix packet size problem
+ packetPerSlot = ceil(((double)quota) / sendsize);
+ slotLength = (int)(packetPerSlot * sendsize / quota * slotLength);
+ quota = (int)packetPerSlot * sendsize;
+
+
+ /* Open RAW socket to send on */
+ //sendsize -= 14;
+ //if ((sockfd = socket(AF_PACKET, SOCK_DGRAM, IPPROTO_RAW)) == -1) {
+ if ((sockfd = socket(AF_PACKET, SOCK_RAW, IPPROTO_RAW)) == -1) {
+ perror("socket");
+ }
+
+ /* Get the index of the interface to send on */
+ memset(&if_idx, 0, sizeof(struct ifreq));
+ strncpy(if_idx.ifr_name, ifName, IFNAMSIZ-1);
+ if (ioctl(sockfd, SIOCGIFINDEX, &if_idx) < 0)
+ perror("SIOCGIFINDEX");
+ /* Get the MAC address of the interface to send on */
+ memset(&if_mac, 0, sizeof(struct ifreq));
+ strncpy(if_mac.ifr_name, ifName, IFNAMSIZ-1);
+ if (ioctl(sockfd, SIOCGIFHWADDR, &if_mac) < 0)
+ perror("SIOCGIFHWADDR");
+
+ /* Construct the Ethernet header */
+ memset(sendbuf, 0, BUF_SIZ);
+ /* Ethernet header */
+
+ eh->ether_shost[0] = ((uint8_t *)&if_mac.ifr_hwaddr.sa_data)[0];
+ eh->ether_shost[1] = ((uint8_t *)&if_mac.ifr_hwaddr.sa_data)[1];
+ eh->ether_shost[2] = ((uint8_t *)&if_mac.ifr_hwaddr.sa_data)[2];
+ eh->ether_shost[3] = ((uint8_t *)&if_mac.ifr_hwaddr.sa_data)[3];
+ eh->ether_shost[4] = ((uint8_t *)&if_mac.ifr_hwaddr.sa_data)[4];
+ eh->ether_shost[5] = ((uint8_t *)&if_mac.ifr_hwaddr.sa_data)[5];
+ eh->ether_dhost[0] = MY_DEST_MAC0;
+ eh->ether_dhost[1] = MY_DEST_MAC1;
+ eh->ether_dhost[2] = MY_DEST_MAC2;
+ eh->ether_dhost[3] = MY_DEST_MAC3;
+ eh->ether_dhost[4] = MY_DEST_MAC4;
+ eh->ether_dhost[5] = MY_DEST_MAC5;
+ eh->ether_type = htons(ETH_P_IP);
+ tx_len += sizeof(struct ether_header);
+
+
+ /* Packet data */
+ /*
+ sendbuf[tx_len++] = 0xde;
+ sendbuf[tx_len++] = 0xad;
+ sendbuf[tx_len++] = 0xbe;
+ sendbuf[tx_len++] = 0xef;
+ */
+
+ /* Index of the network device */
+ socket_address.sll_ifindex = if_idx.ifr_ifindex;
+ /* Address length*/
+ socket_address.sll_halen = ETH_ALEN;
+ /* Destination MAC */
+ socket_address.sll_addr[0] = MY_DEST_MAC0;
+ socket_address.sll_addr[1] = MY_DEST_MAC1;
+ socket_address.sll_addr[2] = MY_DEST_MAC2;
+ socket_address.sll_addr[3] = MY_DEST_MAC3;
+ socket_address.sll_addr[4] = MY_DEST_MAC4;
+ socket_address.sll_addr[5] = MY_DEST_MAC5;
+ //test
+ //socket_address.sll_family = AF_PACKET;
+ //socket_address.sll_protocol = htons(ETH_P_ALL);
+
+// fd = open("bigfile");
+ fd = open("/data/local/tmp/bigfile", O_RDONLY);
+ if (fd == -1) {
+ fprintf(stderr, "unable to open the file.\n");
+ exit(1);
+ }
+
+ /*
+ if (bind(sockfd,(struct sockaddr*)&socket_address, sizeof(struct sockaddr_ll)) == -1)
+ {
+ perror("bind error.\n");
+ exit(1);
+ }
+ */
+ /* Send packet */
+ gettimeofday(&t_start, NULL);
+ read(fd, sendbuf+tx_len, sendsize-tx_len);
+ for (i = 0; i < packet_num;)
+ {
+ if (((packet_num - i) * sendsize) < quota)
+ {
+ quota = (packet_num - i) * sendsize;
+ }
+
+ while (sentInSlot < quota)
+ {
+ //ret = sendfile(sockfd, fd, (off_t *)&offset, sendsize);
+ //printf("%d\t%d\n", ret, errno);
+ //read(fd, sendbuf, sendsize);
+ ret = sendto(sockfd, sendbuf, sendsize, MSG_DONTWAIT, (struct sockaddr*)&socket_address, sizeof(struct sockaddr_ll));
+// printf("%d\t%d\n", ret, errno);
+ if (ret == sendsize)
+ {
+ read(fd, sendbuf+tx_len, sendsize-tx_len);
+ i++;
+ sentInSlot = sentInSlot + ret;
+ }
+ else
+ {
+ //printf("sendto error\n");
+ usleep(100);
+ }
+ }
+ gettimeofday(&t_now, NULL);
+ elapsedTime = (t_now.tv_sec-t_start.tv_sec)*1000000.0+(t_now.tv_usec-t_start.tv_usec);
+ if (elapsedTime < slotLength * slot)
+ {
+ //printf("sent %d, quota %d, packet_num %d, usleep %lf\n", i, quota, packet_num, slotLength * slot - elapsedTime);
+ usleep((int)(slotLength * slot - elapsedTime));
+ }
+ sentInSlot = 0;
+ slot++;
+ }
+ gettimeofday(&t_end, NULL);
+ printf("%lf\n", (t_end.tv_sec-t_start.tv_sec)*1000.0+(t_end.tv_usec-t_start.tv_usec)/1000.0);
+
+
+ return 0;
+}
diff --git a/offloading_binaries/BypassL3_lo/Makefile b/offloading_binaries/BypassL3_lo/Makefile
new file mode 100644
index 0000000..8937390
--- /dev/null
+++ b/offloading_binaries/BypassL3_lo/Makefile
@@ -0,0 +1,21 @@
+CC = arm-linux-androideabi-gcc
+#CC = gcc
+CFLAGS = -pie -fPIE -lm
+TARGET = bypassl3_lo
+
+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 $@
+ cp $(TARGET) /media/Lucifer/yanzi/projects/offloading/RDMAMobileDemo/app/src/main/assets/
+clean:
+ -rm -f *.o
+ -rm -f $(TARGET)
diff --git a/offloading_binaries/BypassL3_lo/bypassl3_lo b/offloading_binaries/BypassL3_lo/bypassl3_lo
new file mode 100755
index 0000000..5189a90
Binary files /dev/null and b/offloading_binaries/BypassL3_lo/bypassl3_lo differ
diff --git a/offloading_binaries/BypassL3_lo/main.c b/offloading_binaries/BypassL3_lo/main.c
new file mode 100644
index 0000000..fba88fe
--- /dev/null
+++ b/offloading_binaries/BypassL3_lo/main.c
@@ -0,0 +1,206 @@
+/*
+ * 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
+
+#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 DEFAULT_IF "eth1"
+#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;
+ double packetPerSlot;
+
+ struct iovec iov;
+ int sockfd;
+ 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=1500, packet_num, offset = 0;
+ int fd; /* file descriptor for file to send */
+ struct timeval t_start, t_end, t_now;
+
+ if (argc > 4)
+ sendsize = atoi(argv[4]);
+
+ if (argc > 1)
+ packet_num = atoi(argv[1])/sendsize;
+ else
+ packet_num = 166666;
+
+ if (argc > 2)
+ quota = atoi(argv[2]) / (1000000 / slotLength);
+ else {
+ printf("Usage: ./bypassl3 ");
+ exit(-1);
+ }
+
+ if (argc > 3) {
+ /* get the name of the interface */
+ strcpy(ifName, argv[3]);
+ } else {
+ strcpy(ifName, DEFAULT_IF);
+ }
+
+ // fix packet size problem
+ packetPerSlot = ceil(((double)quota) / sendsize);
+ slotLength = (int)(packetPerSlot * sendsize / quota * slotLength);
+ quota = (int)packetPerSlot * sendsize;
+
+
+ /* Open RAW socket to send on */
+ //sendsize -= 14;
+ //if ((sockfd = socket(AF_PACKET, SOCK_DGRAM, IPPROTO_RAW)) == -1) {
+ if ((sockfd = socket(AF_PACKET, SOCK_RAW, IPPROTO_RAW)) == -1) {
+ perror("socket");
+ }
+
+ /* Get the index of the interface to send on */
+ memset(&if_idx, 0, sizeof(struct ifreq));
+ strncpy(if_idx.ifr_name, ifName, IFNAMSIZ-1);
+ if (ioctl(sockfd, SIOCGIFINDEX, &if_idx) < 0)
+ perror("SIOCGIFINDEX");
+ /* Get the MAC address of the interface to send on */
+ memset(&if_mac, 0, sizeof(struct ifreq));
+ strncpy(if_mac.ifr_name, ifName, IFNAMSIZ-1);
+ if (ioctl(sockfd, SIOCGIFHWADDR, &if_mac) < 0)
+ perror("SIOCGIFHWADDR");
+
+ /* Construct the Ethernet header */
+ memset(sendbuf, 0, BUF_SIZ);
+ /* Ethernet header */
+
+ eh->ether_shost[0] = ((uint8_t *)&if_mac.ifr_hwaddr.sa_data)[0];
+ eh->ether_shost[1] = ((uint8_t *)&if_mac.ifr_hwaddr.sa_data)[1];
+ eh->ether_shost[2] = ((uint8_t *)&if_mac.ifr_hwaddr.sa_data)[2];
+ eh->ether_shost[3] = ((uint8_t *)&if_mac.ifr_hwaddr.sa_data)[3];
+ eh->ether_shost[4] = ((uint8_t *)&if_mac.ifr_hwaddr.sa_data)[4];
+ eh->ether_shost[5] = ((uint8_t *)&if_mac.ifr_hwaddr.sa_data)[5];
+ eh->ether_dhost[0] = MY_DEST_MAC0;
+ eh->ether_dhost[1] = MY_DEST_MAC1;
+ eh->ether_dhost[2] = MY_DEST_MAC2;
+ eh->ether_dhost[3] = MY_DEST_MAC3;
+ eh->ether_dhost[4] = MY_DEST_MAC4;
+ eh->ether_dhost[5] = MY_DEST_MAC5;
+ eh->ether_type = htons(ETH_P_IP);
+ tx_len += sizeof(struct ether_header);
+
+
+ /* Packet data */
+ /*
+ sendbuf[tx_len++] = 0xde;
+ sendbuf[tx_len++] = 0xad;
+ sendbuf[tx_len++] = 0xbe;
+ sendbuf[tx_len++] = 0xef;
+ */
+
+ /* Index of the network device */
+ socket_address.sll_ifindex = if_idx.ifr_ifindex;
+ /* Address length*/
+ socket_address.sll_halen = ETH_ALEN;
+ /* Destination MAC */
+ socket_address.sll_addr[0] = MY_DEST_MAC0;
+ socket_address.sll_addr[1] = MY_DEST_MAC1;
+ socket_address.sll_addr[2] = MY_DEST_MAC2;
+ socket_address.sll_addr[3] = MY_DEST_MAC3;
+ socket_address.sll_addr[4] = MY_DEST_MAC4;
+ socket_address.sll_addr[5] = MY_DEST_MAC5;
+ //test
+ //socket_address.sll_family = AF_PACKET;
+ //socket_address.sll_protocol = htons(ETH_P_ALL);
+
+// fd = open("bigfile");
+ fd = open("/data/local/tmp/bigfile", O_RDONLY);
+ if (fd == -1) {
+ fprintf(stderr, "unable to open the file.\n");
+ exit(1);
+ }
+
+ /*
+ if (bind(sockfd,(struct sockaddr*)&socket_address, sizeof(struct sockaddr_ll)) == -1)
+ {
+ perror("bind error.\n");
+ exit(1);
+ }
+ */
+ /* Send packet */
+ gettimeofday(&t_start, NULL);
+ read(fd, sendbuf+tx_len, sendsize-tx_len);
+ for (i = 0; i < packet_num;)
+ {
+ if (((packet_num - i) * sendsize) < quota)
+ {
+ quota = (packet_num - i) * sendsize;
+ }
+
+ while (sentInSlot < quota)
+ {
+ //ret = sendfile(sockfd, fd, (off_t *)&offset, sendsize);
+ //printf("%d\t%d\n", ret, errno);
+ //read(fd, sendbuf, sendsize);
+ ret = sendto(sockfd, sendbuf, sendsize, MSG_DONTWAIT, (struct sockaddr*)&socket_address, sizeof(struct sockaddr_ll));
+// printf("%d\t%d\n", ret, errno);
+ if (ret == sendsize)
+ {
+ read(fd, sendbuf+tx_len, sendsize-tx_len);
+ i++;
+ sentInSlot = sentInSlot + ret;
+ }
+ else
+ {
+ //printf("sendto error\n");
+ usleep(100);
+ }
+ }
+ gettimeofday(&t_now, NULL);
+ elapsedTime = (t_now.tv_sec-t_start.tv_sec)*1000000.0+(t_now.tv_usec-t_start.tv_usec);
+ if (elapsedTime < slotLength * slot)
+ {
+ //printf("sent %d, quota %d, packet_num %d, usleep %lf\n", i, quota, packet_num, slotLength * slot - elapsedTime);
+ usleep((int)(slotLength * slot - elapsedTime));
+ }
+ sentInSlot = 0;
+ slot++;
+ }
+ gettimeofday(&t_end, NULL);
+ printf("%lf\n", (t_end.tv_sec-t_start.tv_sec)*1000.0+(t_end.tv_usec-t_start.tv_usec)/1000.0);
+
+
+ return 0;
+}
diff --git a/offloading_binaries/BypassL3_lo/main.o b/offloading_binaries/BypassL3_lo/main.o
new file mode 100644
index 0000000..b92680c
Binary files /dev/null and b/offloading_binaries/BypassL3_lo/main.o differ
diff --git a/offloading_binaries/BypassL3_recv/Makefile b/offloading_binaries/BypassL3_recv/Makefile
new file mode 100644
index 0000000..e1bce73
--- /dev/null
+++ b/offloading_binaries/BypassL3_recv/Makefile
@@ -0,0 +1,20 @@
+CC = arm-linux-androideabi-gcc
+CFLAGS = -pie -fPIE
+TARGET = bypassl3_recv
+
+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 $@
+ cp $(TARGET) /media/Lucifer/yanzi/projects/offloading/RDMAMobileDemo/app/src/main/assets/
+clean:
+ -rm -f *.o
+ -rm -f $(TARGET)
diff --git a/offloading_binaries/BypassL3_recv/bypassl3_recv b/offloading_binaries/BypassL3_recv/bypassl3_recv
new file mode 100755
index 0000000..2c01307
Binary files /dev/null and b/offloading_binaries/BypassL3_recv/bypassl3_recv differ
diff --git a/offloading_binaries/BypassL3_recv/main.c b/offloading_binaries/BypassL3_recv/main.c
new file mode 100644
index 0000000..ebbc6e7
--- /dev/null
+++ b/offloading_binaries/BypassL3_recv/main.c
@@ -0,0 +1,125 @@
+/*
+ * 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
+
+#define ETH_P_IP 0x0800 /* Internet Protocol packet */
+#define ETH_ALEN 6 /* from */
+#define ETH_P_ALL 0x0003
+
+#define ETHER_TYPE 0x0800 /* Customize */
+
+#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[])
+{
+ struct iovec iov;
+ int sockfd, socktrigger;
+ int sockopt;
+ struct ifreq ifopts; /* set promiscuous mode */
+ struct ifreq if_ip; /* get ip addr */
+ ssize_t numbytes;
+ 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;
+ struct sockaddr_in servaddr;
+ char ifName[IFNAMSIZ];
+ int i, j, ret, sendsize=1500, packet_num, offset = 0, port = 32000;
+ int fd; /* file descriptor for file to send */
+ struct timeval t_start,t_end;
+
+ /* Get interface name */
+ strcpy(ifName, DEFAULT_IF);
+
+ if (argc > 1)
+ packet_num = atoi(argv[1])/sendsize;
+ else
+ packet_num = 166666;
+
+ sockfd = socket(AF_INET, SOCK_DGRAM, 0);
+ bzero(&servaddr,sizeof(servaddr));
+ servaddr.sin_family = AF_INET;
+ servaddr.sin_addr.s_addr=inet_addr("128.111.68.220");
+ servaddr.sin_port=htons(port);
+ sendto(sockfd, "0\n",strlen("0\n"),0, (struct sockaddr *)&servaddr, sizeof(servaddr));
+
+
+ if ((sockfd = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL))) == -1) {
+ perror("listener: socket");
+ return -1;
+ }
+
+ strncpy(ifopts.ifr_name, ifName, IFNAMSIZ-1);
+ ioctl(sockfd, SIOCGIFFLAGS, &ifopts);
+ ifopts.ifr_flags |= IFF_PROMISC;
+ ioctl(sockfd, SIOCSIFFLAGS, &ifopts);
+
+ if (setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, &sockopt, sizeof sockopt) == -1) {
+ perror("setsockopt");
+ close(sockfd);
+ exit(EXIT_FAILURE);
+ }
+
+ if (setsockopt(sockfd, SOL_SOCKET, SO_BINDTODEVICE, ifName, IFNAMSIZ-1) == -1) {
+ perror("SO_BINDTODEVICE");
+ close(sockfd);
+ exit(EXIT_FAILURE);
+ }
+
+
+ fd = open("/data/local/tmp/bigfile_w", O_WRONLY | O_CREAT | O_TRUNC);
+ if (fd == -1) {
+ fprintf(stderr, "unable to open the file.\n");
+ exit(1);
+ }
+
+ /* Recv packet */
+ gettimeofday(&t_start, NULL);
+ for (i = 0; i < packet_num;)
+ {
+
+ numbytes = recvfrom(sockfd, sendbuf, sendsize, 0, NULL, NULL);
+ //printf("listener: got packet %lu bytes\n", numbytes);
+
+ if (sendbuf[50] == '0')
+ {
+ write(fd, sendbuf, sendsize);
+ i++;
+ }
+ else
+ {
+ usleep(100);
+ }
+ }
+ gettimeofday(&t_end, NULL);
+ printf("%lf\n", (t_end.tv_sec-t_start.tv_sec)*1000.0+(t_end.tv_usec-t_start.tv_usec)/1000.0);
+
+ return 0;
+}
diff --git a/offloading_binaries/BypassL3_recv/main.o b/offloading_binaries/BypassL3_recv/main.o
new file mode 100644
index 0000000..b19ea68
Binary files /dev/null and b/offloading_binaries/BypassL3_recv/main.o differ
diff --git a/offloading_binaries/BypassL3_recv_lo/Makefile b/offloading_binaries/BypassL3_recv_lo/Makefile
new file mode 100644
index 0000000..a5e7006
--- /dev/null
+++ b/offloading_binaries/BypassL3_recv_lo/Makefile
@@ -0,0 +1,20 @@
+CC = arm-linux-androideabi-gcc
+CFLAGS = -pie -fPIE
+TARGET = bypassl3_recv_lo
+
+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 $@
+ cp $(TARGET) /media/Lucifer/yanzi/projects/offloading/RDMAMobileDemo/app/src/main/assets/
+clean:
+ -rm -f *.o
+ -rm -f $(TARGET)
diff --git a/offloading_binaries/BypassL3_recv_lo/bypassl3_recv_lo b/offloading_binaries/BypassL3_recv_lo/bypassl3_recv_lo
new file mode 100755
index 0000000..7a17840
Binary files /dev/null and b/offloading_binaries/BypassL3_recv_lo/bypassl3_recv_lo differ
diff --git a/offloading_binaries/BypassL3_recv_lo/main.c b/offloading_binaries/BypassL3_recv_lo/main.c
new file mode 100644
index 0000000..4c1bc87
--- /dev/null
+++ b/offloading_binaries/BypassL3_recv_lo/main.c
@@ -0,0 +1,125 @@
+/*
+ * 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
+
+#define ETH_P_IP 0x0800 /* Internet Protocol packet */
+#define ETH_ALEN 6 /* from */
+#define ETH_P_ALL 0x0003
+
+#define ETHER_TYPE 0x0800 /* Customize */
+
+#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[])
+{
+ struct iovec iov;
+ int sockfd, socktrigger;
+ int sockopt;
+ struct ifreq ifopts; /* set promiscuous mode */
+ struct ifreq if_ip; /* get ip addr */
+ ssize_t numbytes;
+ 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;
+ struct sockaddr_in servaddr;
+ char ifName[IFNAMSIZ];
+ int i, j, ret, sendsize=1500, packet_num, offset = 0, port = 32000;
+ int fd; /* file descriptor for file to send */
+ struct timeval t_start,t_end;
+
+ /* Get interface name */
+ strcpy(ifName, DEFAULT_IF);
+
+ if (argc > 1)
+ packet_num = atoi(argv[1])/sendsize;
+ else
+ packet_num = 166666;
+
+ sockfd = socket(AF_INET, SOCK_DGRAM, 0);
+ bzero(&servaddr,sizeof(servaddr));
+ servaddr.sin_family = AF_INET;
+ servaddr.sin_addr.s_addr=inet_addr("192.168.1.15");
+ servaddr.sin_port=htons(port);
+ sendto(sockfd, "0\n",strlen("0\n"),0, (struct sockaddr *)&servaddr, sizeof(servaddr));
+
+
+ if ((sockfd = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL))) == -1) {
+ perror("listener: socket");
+ return -1;
+ }
+
+ strncpy(ifopts.ifr_name, ifName, IFNAMSIZ-1);
+ ioctl(sockfd, SIOCGIFFLAGS, &ifopts);
+ ifopts.ifr_flags |= IFF_PROMISC;
+ ioctl(sockfd, SIOCSIFFLAGS, &ifopts);
+
+ if (setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, &sockopt, sizeof sockopt) == -1) {
+ perror("setsockopt");
+ close(sockfd);
+ exit(EXIT_FAILURE);
+ }
+
+ if (setsockopt(sockfd, SOL_SOCKET, SO_BINDTODEVICE, ifName, IFNAMSIZ-1) == -1) {
+ perror("SO_BINDTODEVICE");
+ close(sockfd);
+ exit(EXIT_FAILURE);
+ }
+
+
+ fd = open("/data/local/tmp/bigfile_w", O_WRONLY | O_CREAT | O_TRUNC);
+ if (fd == -1) {
+ fprintf(stderr, "unable to open the file.\n");
+ exit(1);
+ }
+
+ /* Recv packet */
+ gettimeofday(&t_start, NULL);
+ for (i = 0; i < packet_num;)
+ {
+
+ numbytes = recvfrom(sockfd, sendbuf, sendsize, 0, NULL, NULL);
+ //printf("listener: got packet %lu bytes\n", numbytes);
+
+ if (sendbuf[50] == '0')
+ {
+ write(fd, sendbuf, sendsize);
+ i++;
+ }
+ else
+ {
+ usleep(100);
+ }
+ }
+ gettimeofday(&t_end, NULL);
+ printf("%lf\n", (t_end.tv_sec-t_start.tv_sec)*1000.0+(t_end.tv_usec-t_start.tv_usec)/1000.0);
+
+ return 0;
+}
diff --git a/offloading_binaries/BypassL3_recv_lo/main.o b/offloading_binaries/BypassL3_recv_lo/main.o
new file mode 100644
index 0000000..0c85b10
Binary files /dev/null and b/offloading_binaries/BypassL3_recv_lo/main.o differ
diff --git a/offloading_binaries/BypassL3_usb/Makefile b/offloading_binaries/BypassL3_usb/Makefile
new file mode 100644
index 0000000..34e1833
--- /dev/null
+++ b/offloading_binaries/BypassL3_usb/Makefile
@@ -0,0 +1,21 @@
+CC = arm-linux-androideabi-gcc
+#CC = gcc
+CFLAGS = -pie -fPIE -lm
+TARGET = bypassl3_usb
+
+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 $@
+ cp $(TARGET) /media/Lucifer/yanzi/projects/offloading/RDMAMobileDemo/app/src/main/assets/
+clean:
+ -rm -f *.o
+ -rm -f $(TARGET)
diff --git a/offloading_binaries/BypassL3_usb/bypassl3_usb b/offloading_binaries/BypassL3_usb/bypassl3_usb
new file mode 100755
index 0000000..139a0ae
Binary files /dev/null and b/offloading_binaries/BypassL3_usb/bypassl3_usb differ
diff --git a/offloading_binaries/BypassL3_usb/main.c b/offloading_binaries/BypassL3_usb/main.c
new file mode 100644
index 0000000..77fefdd
--- /dev/null
+++ b/offloading_binaries/BypassL3_usb/main.c
@@ -0,0 +1,206 @@
+/*
+ * 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
+
+#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 "usb0"
+//#define DEFAULT_IF "eth1"
+#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;
+ double packetPerSlot;
+
+ struct iovec iov;
+ int sockfd;
+ 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=1500, packet_num, offset = 0;
+ int fd; /* file descriptor for file to send */
+ struct timeval t_start, t_end, t_now;
+
+ if (argc > 4)
+ sendsize = atoi(argv[4]);
+
+ if (argc > 1)
+ packet_num = atoi(argv[1])/sendsize;
+ else
+ packet_num = 166666;
+
+ if (argc > 2)
+ quota = atoi(argv[2]) / (1000000 / slotLength);
+ else {
+ printf("Usage: ./bypassl3 ");
+ exit(-1);
+ }
+
+ if (argc > 3) {
+ /* get the name of the interface */
+ strcpy(ifName, argv[3]);
+ } else {
+ strcpy(ifName, DEFAULT_IF);
+ }
+
+ // fix packet size problem
+ packetPerSlot = ceil(((double)quota) / sendsize);
+ slotLength = (int)(packetPerSlot * sendsize / quota * slotLength);
+ quota = (int)packetPerSlot * sendsize;
+
+
+ /* Open RAW socket to send on */
+ //sendsize -= 14;
+ //if ((sockfd = socket(AF_PACKET, SOCK_DGRAM, IPPROTO_RAW)) == -1) {
+ if ((sockfd = socket(AF_PACKET, SOCK_RAW, IPPROTO_RAW)) == -1) {
+ perror("socket");
+ }
+
+ /* Get the index of the interface to send on */
+ memset(&if_idx, 0, sizeof(struct ifreq));
+ strncpy(if_idx.ifr_name, ifName, IFNAMSIZ-1);
+ if (ioctl(sockfd, SIOCGIFINDEX, &if_idx) < 0)
+ perror("SIOCGIFINDEX");
+ /* Get the MAC address of the interface to send on */
+ memset(&if_mac, 0, sizeof(struct ifreq));
+ strncpy(if_mac.ifr_name, ifName, IFNAMSIZ-1);
+ if (ioctl(sockfd, SIOCGIFHWADDR, &if_mac) < 0)
+ perror("SIOCGIFHWADDR");
+
+ /* Construct the Ethernet header */
+ memset(sendbuf, 0, BUF_SIZ);
+ /* Ethernet header */
+
+ eh->ether_shost[0] = ((uint8_t *)&if_mac.ifr_hwaddr.sa_data)[0];
+ eh->ether_shost[1] = ((uint8_t *)&if_mac.ifr_hwaddr.sa_data)[1];
+ eh->ether_shost[2] = ((uint8_t *)&if_mac.ifr_hwaddr.sa_data)[2];
+ eh->ether_shost[3] = ((uint8_t *)&if_mac.ifr_hwaddr.sa_data)[3];
+ eh->ether_shost[4] = ((uint8_t *)&if_mac.ifr_hwaddr.sa_data)[4];
+ eh->ether_shost[5] = ((uint8_t *)&if_mac.ifr_hwaddr.sa_data)[5];
+ eh->ether_dhost[0] = MY_DEST_MAC0;
+ eh->ether_dhost[1] = MY_DEST_MAC1;
+ eh->ether_dhost[2] = MY_DEST_MAC2;
+ eh->ether_dhost[3] = MY_DEST_MAC3;
+ eh->ether_dhost[4] = MY_DEST_MAC4;
+ eh->ether_dhost[5] = MY_DEST_MAC5;
+ eh->ether_type = htons(ETH_P_IP);
+ tx_len += sizeof(struct ether_header);
+
+
+ /* Packet data */
+ /*
+ sendbuf[tx_len++] = 0xde;
+ sendbuf[tx_len++] = 0xad;
+ sendbuf[tx_len++] = 0xbe;
+ sendbuf[tx_len++] = 0xef;
+ */
+
+ /* Index of the network device */
+ socket_address.sll_ifindex = if_idx.ifr_ifindex;
+ /* Address length*/
+ socket_address.sll_halen = ETH_ALEN;
+ /* Destination MAC */
+ socket_address.sll_addr[0] = MY_DEST_MAC0;
+ socket_address.sll_addr[1] = MY_DEST_MAC1;
+ socket_address.sll_addr[2] = MY_DEST_MAC2;
+ socket_address.sll_addr[3] = MY_DEST_MAC3;
+ socket_address.sll_addr[4] = MY_DEST_MAC4;
+ socket_address.sll_addr[5] = MY_DEST_MAC5;
+ //test
+ //socket_address.sll_family = AF_PACKET;
+ //socket_address.sll_protocol = htons(ETH_P_ALL);
+
+// fd = open("bigfile");
+ fd = open("/data/local/tmp/bigfile", O_RDONLY);
+ if (fd == -1) {
+ fprintf(stderr, "unable to open the file.\n");
+ exit(1);
+ }
+
+ /*
+ if (bind(sockfd,(struct sockaddr*)&socket_address, sizeof(struct sockaddr_ll)) == -1)
+ {
+ perror("bind error.\n");
+ exit(1);
+ }
+ */
+ /* Send packet */
+ gettimeofday(&t_start, NULL);
+ read(fd, sendbuf+tx_len, sendsize-tx_len);
+ for (i = 0; i < packet_num;)
+ {
+ if (((packet_num - i) * sendsize) < quota)
+ {
+ quota = (packet_num - i) * sendsize;
+ }
+
+ while (sentInSlot < quota)
+ {
+ //ret = sendfile(sockfd, fd, (off_t *)&offset, sendsize);
+ //printf("%d\t%d\n", ret, errno);
+ //read(fd, sendbuf, sendsize);
+ ret = sendto(sockfd, sendbuf, sendsize, MSG_DONTWAIT, (struct sockaddr*)&socket_address, sizeof(struct sockaddr_ll));
+// printf("%d\t%d\n", ret, errno);
+ if (ret == sendsize)
+ {
+ read(fd, sendbuf+tx_len, sendsize-tx_len);
+ i++;
+ sentInSlot = sentInSlot + ret;
+ }
+ else
+ {
+ //printf("sendto error\n");
+ usleep(100);
+ }
+ }
+ gettimeofday(&t_now, NULL);
+ elapsedTime = (t_now.tv_sec-t_start.tv_sec)*1000000.0+(t_now.tv_usec-t_start.tv_usec);
+ if (elapsedTime < slotLength * slot)
+ {
+ //printf("sent %d, quota %d, packet_num %d, usleep %lf\n", i, quota, packet_num, slotLength * slot - elapsedTime);
+ usleep((int)(slotLength * slot - elapsedTime));
+ }
+ sentInSlot = 0;
+ slot++;
+ }
+ gettimeofday(&t_end, NULL);
+ printf("%lf\n", (t_end.tv_sec-t_start.tv_sec)*1000.0+(t_end.tv_usec-t_start.tv_usec)/1000.0);
+
+
+ return 0;
+}
diff --git a/offloading_binaries/BypassL3_usb/main.o b/offloading_binaries/BypassL3_usb/main.o
new file mode 100644
index 0000000..c305dbb
Binary files /dev/null and b/offloading_binaries/BypassL3_usb/main.o differ
diff --git a/offloading_binaries/Normal/Makefile b/offloading_binaries/Normal/Makefile
new file mode 100644
index 0000000..a99fb5f
--- /dev/null
+++ b/offloading_binaries/Normal/Makefile
@@ -0,0 +1,23 @@
+CC = arm-linux-androideabi-gcc
+CFLAGS = -pie -fPIE -llog
+#STATICLIB = -llog -l/media/Lucifer/android/ndk-profiler/obj/local/armeabi-v7a/libandroid-ndk-profiler.a
+TARGET = normal
+
+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 $@
+ cp $(TARGET) /media/Lucifer/yanzi/projects/offloading/RDMAMobileDemo/app/src/main/assets/
+clean:
+ -rm -f *.o
+ -rm -f $(TARGET)
+
+#$(call import-module,android-ndk-profiler)
diff --git a/offloading_binaries/Normal/main.c b/offloading_binaries/Normal/main.c
new file mode 100644
index 0000000..537e790
--- /dev/null
+++ b/offloading_binaries/Normal/main.c
@@ -0,0 +1,126 @@
+/*
+ * Initial commit by Yibo @ Jul. 28, 2015
+ * Last update by Yanzi @ Sept. 23, 2016
+ */
+
+#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;
+ 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, offset = 0;
+ int fd; /* file descriptor for file to send */
+ struct timeval t_start,t_end,t_now;
+
+ struct sockaddr_in servaddr;
+
+ if (argc > 1)
+ packet_num = atoi(argv[1]);
+ else
+ packet_num = 166666*sendsize;
+
+ if (argc > 2)
+ quota = atoi(argv[2]) / (1000000 / slotLength);
+
+ sockfd = socket(AF_INET, SOCK_STREAM, 0);
+
+ bzero(&servaddr,sizeof(servaddr));
+ servaddr.sin_family = AF_INET;
+ servaddr.sin_addr.s_addr=inet_addr("10.0.0.169");
+ servaddr.sin_port=htons(4444);
+
+
+
+ fd = open("/data/local/tmp/bigfile", O_RDONLY);
+ if (fd == -1) {
+ fprintf(stderr, "unable to open the file.\n");
+ exit(1);
+ }
+
+ gettimeofday(&t_start, NULL);
+ if (connect(sockfd, (struct sockaddr *)&servaddr, sizeof(servaddr)) < 0)
+ {
+ fprintf(stderr, "unable to connect the server.\n");
+ exit(1);
+ }
+ while (offset < packet_num)
+ {
+ if ((packet_num - offset) < quota)
+ {
+ quota = packet_num - offset;
+ }
+ while (sentInSlot < quota)
+ {
+ read(fd, sendbuf, (quota - sentInSlot < 4096) ? quota - sentInSlot : 4096);
+ ret = send(sockfd, sendbuf, (quota - sentInSlot < 4096) ? quota - sentInSlot : 4096, 0);
+// printf("%d\t%d\n", ret, errno);
+ if (ret <= 0)
+ {
+ printf("send fail\n");
+ usleep(100);
+ continue;
+ }
+ offset += ret;
+ sentInSlot = sentInSlot + ret;
+ }
+ gettimeofday(&t_now, NULL);
+ elapsedTime = (t_now.tv_sec-t_start.tv_sec)*1000000.0+(t_now.tv_usec-t_start.tv_usec);
+ if (elapsedTime < slotLength * slot)
+ {
+ //printf("sent %d, quota %d, packet_num %d, usleep %lf\n", offset, quota, packet_num, slotLength * slot - elapsedTime);
+ usleep((int)(slotLength * slot - elapsedTime));
+ }
+ sentInSlot = 0;
+ slot++;
+
+ }
+ close(sockfd);
+ gettimeofday(&t_end, NULL);
+ printf("%lf\n", (t_end.tv_sec-t_start.tv_sec)*1000.0+(t_end.tv_usec-t_start.tv_usec)/1000.0);
+
+ close(fd);
+
+// moncleanup();
+ return 0;
+}
diff --git a/offloading_binaries/Normal/main.o b/offloading_binaries/Normal/main.o
new file mode 100644
index 0000000..62833f1
Binary files /dev/null and b/offloading_binaries/Normal/main.o differ
diff --git a/offloading_binaries/Normal/normal b/offloading_binaries/Normal/normal
new file mode 100755
index 0000000..7da3ec2
Binary files /dev/null and b/offloading_binaries/Normal/normal differ
diff --git a/offloading_binaries/Normal_donothing/Makefile b/offloading_binaries/Normal_donothing/Makefile
new file mode 100644
index 0000000..a15cbec
--- /dev/null
+++ b/offloading_binaries/Normal_donothing/Makefile
@@ -0,0 +1,21 @@
+CC = arm-linux-androideabi-gcc
+CFLAGS = -pie -fPIE -llog
+TARGET = normal_readonly
+
+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 $@
+# cp $(TARGET) /media/Lucifer/yanzi/projects/mobileOffloading/RDMAMobileDemo/app/src/main/assets/
+
+clean:
+ -rm -f *.o
+ -rm -f $(TARGET)
diff --git a/offloading_binaries/Normal_donothing/main.c b/offloading_binaries/Normal_donothing/main.c
new file mode 100644
index 0000000..2b8bc44
--- /dev/null
+++ b/offloading_binaries/Normal_donothing/main.c
@@ -0,0 +1,130 @@
+/*
+ * 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
+//#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 DEFAULT_IF "eth0"
+#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;
+ 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, offset = 0;
+ int fd; /* file descriptor for file to send */
+ struct timeval t_start,t_end,t_now;
+
+ struct sockaddr_in servaddr;
+
+monstartup("normal_readonly.so");
+ if (argc > 1)
+ packet_num = atoi(argv[1]);
+ else
+ packet_num = 166666*sendsize;
+
+ if (argc > 2)
+ quota = atoi(argv[2]) / (1000000 / slotLength);
+
+// sockfd = socket(AF_INET, SOCK_STREAM, 0);
+
+// bzero(&servaddr,sizeof(servaddr));
+// servaddr.sin_family = AF_INET;
+// servaddr.sin_addr.s_addr=inet_addr("128.111.68.220");
+// servaddr.sin_port=htons(4444);
+
+
+
+ fd = open("/data/local/tmp/bigfile", O_RDONLY);
+ if (fd == -1) {
+ fprintf(stderr, "unable to open the file.\n");
+ exit(1);
+ }
+
+ gettimeofday(&t_start, NULL);
+// if (connect(sockfd, (struct sockaddr *)&servaddr, sizeof(servaddr)) < 0)
+// {
+// fprintf(stderr, "unable to connect the server.\n");
+// exit(1);
+// }
+ while (offset < packet_num)
+ {
+ if ((packet_num - offset) < quota)
+ {
+ quota = packet_num - offset;
+ }
+ while (sentInSlot < quota)
+ {
+ read(fd, sendbuf, (quota - sentInSlot < 4096) ? quota - sentInSlot : 4096);
+ //ret = send(sockfd, sendbuf, (quota - sentInSlot < 4096) ? quota - sentInSlot : 4096, 0);
+ //if (ret <= 0)
+ //{
+ // printf("send fail\n");
+ // usleep(100);
+ // continue;
+ //}
+ ret = 100;
+ offset += ret;
+ sentInSlot = sentInSlot + ret;
+ }
+ gettimeofday(&t_now, NULL);
+ elapsedTime = (t_now.tv_sec-t_start.tv_sec)*1000000.0+(t_now.tv_usec-t_start.tv_usec);
+ if (elapsedTime < slotLength * slot)
+ {
+ //printf("sent %d, quota %d, packet_num %d, usleep %lf\n", offset, quota, packet_num, slotLength * slot - elapsedTime);
+ usleep((int)(slotLength * slot - elapsedTime));
+ }
+ sentInSlot = 0;
+ slot++;
+
+ }
+// close(sockfd);
+ gettimeofday(&t_end, NULL);
+ printf("%lf\n", (t_end.tv_sec-t_start.tv_sec)*1000.0+(t_end.tv_usec-t_start.tv_usec)/1000.0);
+
+// close(fd);
+moncleanup();
+ return 0;
+}
diff --git a/offloading_binaries/Normal_donothing/normal_readonly b/offloading_binaries/Normal_donothing/normal_readonly
new file mode 100755
index 0000000..6052a63
Binary files /dev/null and b/offloading_binaries/Normal_donothing/normal_readonly differ
diff --git a/offloading_binaries/Normal_lo/Makefile b/offloading_binaries/Normal_lo/Makefile
new file mode 100644
index 0000000..e92bc6b
--- /dev/null
+++ b/offloading_binaries/Normal_lo/Makefile
@@ -0,0 +1,23 @@
+CC = arm-linux-androideabi-gcc
+CFLAGS = -pie -fPIE -llog
+#STATICLIB = -llog -l/media/Lucifer/android/ndk-profiler/obj/local/armeabi-v7a/libandroid-ndk-profiler.a
+TARGET = normal_lo
+
+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 $@
+ cp $(TARGET) /media/Lucifer/yanzi/projects/offloading/RDMAMobileDemo/app/src/main/assets/
+clean:
+ -rm -f *.o
+ -rm -f $(TARGET)
+
+#$(call import-module,android-ndk-profiler)
diff --git a/offloading_binaries/Normal_lo/main.c b/offloading_binaries/Normal_lo/main.c
new file mode 100644
index 0000000..de3d00f
--- /dev/null
+++ b/offloading_binaries/Normal_lo/main.c
@@ -0,0 +1,131 @@
+/*
+ * 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 "/media/Lucifer/android/ndk-profiler/jni/prof.h"
+
+#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;
+ 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, offset = 0;
+ int fd; /* file descriptor for file to send */
+ struct timeval t_start,t_end,t_now;
+
+ struct sockaddr_in servaddr;
+
+// monstartup("normal");
+
+ if (argc > 1)
+ packet_num = atoi(argv[1]);
+ else
+ packet_num = 166666*sendsize;
+
+ if (argc > 2)
+ quota = atoi(argv[2]) / (1000000 / slotLength);
+
+ sockfd = socket(AF_INET, SOCK_STREAM, 0);
+
+ bzero(&servaddr,sizeof(servaddr));
+ servaddr.sin_family = AF_INET;
+ servaddr.sin_addr.s_addr=inet_addr("192.168.1.15");
+ servaddr.sin_port=htons(4444);
+
+
+
+ fd = open("/data/local/tmp/bigfile", O_RDONLY);
+ if (fd == -1) {
+ fprintf(stderr, "unable to open the file.\n");
+ exit(1);
+ }
+
+ gettimeofday(&t_start, NULL);
+ if (connect(sockfd, (struct sockaddr *)&servaddr, sizeof(servaddr)) < 0)
+ {
+ fprintf(stderr, "unable to connect the server.\n");
+ exit(1);
+ }
+ while (offset < packet_num)
+ {
+ if ((packet_num - offset) < quota)
+ {
+ quota = packet_num - offset;
+ }
+ while (sentInSlot < quota)
+ {
+ read(fd, sendbuf, (quota - sentInSlot < 4096) ? quota - sentInSlot : 4096);
+ ret = send(sockfd, sendbuf, (quota - sentInSlot < 4096) ? quota - sentInSlot : 4096, 0);
+// printf("%d\t%d\n", ret, errno);
+ if (ret <= 0)
+ {
+ printf("send fail\n");
+ usleep(100);
+ continue;
+ }
+ offset += ret;
+ sentInSlot = sentInSlot + ret;
+ }
+ gettimeofday(&t_now, NULL);
+ elapsedTime = (t_now.tv_sec-t_start.tv_sec)*1000000.0+(t_now.tv_usec-t_start.tv_usec);
+ if (elapsedTime < slotLength * slot)
+ {
+ //printf("sent %d, quota %d, packet_num %d, usleep %lf\n", offset, quota, packet_num, slotLength * slot - elapsedTime);
+ usleep((int)(slotLength * slot - elapsedTime));
+ }
+ sentInSlot = 0;
+ slot++;
+
+ }
+ close(sockfd);
+ gettimeofday(&t_end, NULL);
+ printf("%lf\n", (t_end.tv_sec-t_start.tv_sec)*1000.0+(t_end.tv_usec-t_start.tv_usec)/1000.0);
+
+ close(fd);
+
+// moncleanup();
+ return 0;
+}
diff --git a/offloading_binaries/Normal_lo/main.o b/offloading_binaries/Normal_lo/main.o
new file mode 100644
index 0000000..53f3881
Binary files /dev/null and b/offloading_binaries/Normal_lo/main.o differ
diff --git a/offloading_binaries/Normal_lo/normal_lo b/offloading_binaries/Normal_lo/normal_lo
new file mode 100755
index 0000000..01c850f
Binary files /dev/null and b/offloading_binaries/Normal_lo/normal_lo differ
diff --git a/offloading_binaries/Normal_memory/Makefile b/offloading_binaries/Normal_memory/Makefile
new file mode 100644
index 0000000..792847a
--- /dev/null
+++ b/offloading_binaries/Normal_memory/Makefile
@@ -0,0 +1,20 @@
+CC = arm-linux-androideabi-gcc
+CFLAGS = -pie -fPIE
+TARGET = normal_memory
+
+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 $@
+ cp $(TARGET) /media/Lucifer/yanzi/projects/offloading/RDMAMobileDemo/app/src/main/assets/
+clean:
+ -rm -f *.o
+ -rm -f $(TARGET)
diff --git a/offloading_binaries/Normal_memory/main.c b/offloading_binaries/Normal_memory/main.c
new file mode 100644
index 0000000..e30688b
--- /dev/null
+++ b/offloading_binaries/Normal_memory/main.c
@@ -0,0 +1,100 @@
+/*
+ * 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
+
+#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[])
+{
+ struct iovec iov;
+ int sockfd;
+ 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, offset = 0;
+ int fd; /* file descriptor for file to send */
+ struct timeval t_start,t_end;
+
+ struct sockaddr_in servaddr;
+
+ if (argc > 1)
+ packet_num = atoi(argv[1])*sendsize;
+ else
+ packet_num = 166666*sendsize;
+
+ sockfd = socket(AF_INET, SOCK_STREAM, 0);
+
+ bzero(&servaddr,sizeof(servaddr));
+ servaddr.sin_family = AF_INET;
+ servaddr.sin_addr.s_addr=inet_addr("128.111.68.220");
+ servaddr.sin_port=htons(4444);
+
+
+
+ fd = open("/data/local/tmp/bigfile");
+ if (fd == -1) {
+ fprintf(stderr, "unable to open the file.\n");
+ exit(1);
+ }
+ read(fd, sendbuf, 4096);
+
+ gettimeofday(&t_start, NULL);
+ if (connect(sockfd, (struct sockaddr *)&servaddr, sizeof(servaddr)) < 0)
+ {
+ fprintf(stderr, "unable to connect the server.\n");
+ exit(1);
+ }
+ while (offset < packet_num)
+ {
+ ret = send(sockfd, sendbuf, 4096, 0);
+ if (ret <= 0)
+ {
+ printf("send fail\n");
+ usleep(100);
+ continue;
+ }
+ offset += ret;
+ }
+ close(sockfd);
+ gettimeofday(&t_end, NULL);
+ printf("%lf\n", (t_end.tv_sec-t_start.tv_sec)*1000.0+(t_end.tv_usec-t_start.tv_usec)/1000.0);
+
+ close(fd);
+
+ return 0;
+}
diff --git a/offloading_binaries/Normal_memory/normal_memory b/offloading_binaries/Normal_memory/normal_memory
new file mode 100755
index 0000000..259244d
Binary files /dev/null and b/offloading_binaries/Normal_memory/normal_memory differ
diff --git a/offloading_binaries/Normal_recv/Makefile b/offloading_binaries/Normal_recv/Makefile
new file mode 100644
index 0000000..42e30bf
--- /dev/null
+++ b/offloading_binaries/Normal_recv/Makefile
@@ -0,0 +1,20 @@
+CC = arm-linux-androideabi-gcc
+CFLAGS = -pie -fPIE
+TARGET = normal_recv
+
+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 $@
+ cp $(TARGET) /media/Lucifer/yanzi/projects/offloading/RDMAMobileDemo/app/src/main/assets/
+clean:
+ -rm -f *.o
+ -rm -f $(TARGET)
diff --git a/offloading_binaries/Normal_recv/main.c b/offloading_binaries/Normal_recv/main.c
new file mode 100644
index 0000000..535d67e
--- /dev/null
+++ b/offloading_binaries/Normal_recv/main.c
@@ -0,0 +1,102 @@
+/*
+ * 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
+
+#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 sockfd, listenfd;
+ socklen_t clilen;
+ 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, offset = 0, port = 4445;
+ int fd; /* file descriptor for file to send */
+ struct timeval t_start,t_end;
+
+ struct sockaddr_in servaddr,cliaddr;
+
+ if (argc > 1)
+ packet_num = atoi(argv[1]);
+ else
+ packet_num = 166666*sendsize;
+
+ if (argc > 2)
+ port = atoi(argv[2]);
+
+ sockfd = socket(AF_INET, SOCK_STREAM, 0);
+
+ bzero(&servaddr,sizeof(servaddr));
+ servaddr.sin_family = AF_INET;
+ servaddr.sin_addr.s_addr=inet_addr("128.111.68.220");
+ servaddr.sin_port=htons(port);
+
+ fd = open("/data/local/tmp/bigfile_w", O_WRONLY | O_CREAT | O_TRUNC);
+ if (fd == -1) {
+ fprintf(stderr, "unable to open the file.\n");
+ exit(1);
+ }
+
+ gettimeofday(&t_start, NULL);
+ if (connect(sockfd, (struct sockaddr *)&servaddr, sizeof(servaddr)) < 0)
+ {
+ fprintf(stderr, "unable to connect the server.\n");
+ exit(1);
+ }
+
+ while (offset < packet_num)
+ {
+ ret = recv(sockfd, sendbuf, 4096, 0);
+ if (ret <= 0)
+ {
+ printf("recv fail\n");
+ usleep(100);
+ continue;
+ }
+ write(fd, sendbuf, ret);
+ offset += ret;
+ }
+ close(sockfd);
+ gettimeofday(&t_end, NULL);
+ printf("%lf\n", (t_end.tv_sec-t_start.tv_sec)*1000.0+(t_end.tv_usec-t_start.tv_usec)/1000.0);
+
+ close(fd);
+
+ return 0;
+}
diff --git a/offloading_binaries/Normal_recv/normal_recv b/offloading_binaries/Normal_recv/normal_recv
new file mode 100755
index 0000000..2193f5f
Binary files /dev/null and b/offloading_binaries/Normal_recv/normal_recv differ
diff --git a/offloading_binaries/Normal_recv_lo/Makefile b/offloading_binaries/Normal_recv_lo/Makefile
new file mode 100644
index 0000000..939332d
--- /dev/null
+++ b/offloading_binaries/Normal_recv_lo/Makefile
@@ -0,0 +1,20 @@
+CC = arm-linux-androideabi-gcc
+CFLAGS = -pie -fPIE
+TARGET = normal_recv_lo
+
+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 $@
+ cp $(TARGET) /media/Lucifer/yanzi/projects/offloading/RDMAMobileDemo/app/src/main/assets/
+clean:
+ -rm -f *.o
+ -rm -f $(TARGET)
diff --git a/offloading_binaries/Normal_recv_lo/main.c b/offloading_binaries/Normal_recv_lo/main.c
new file mode 100644
index 0000000..945d914
--- /dev/null
+++ b/offloading_binaries/Normal_recv_lo/main.c
@@ -0,0 +1,102 @@
+/*
+ * 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
+
+#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 sockfd, listenfd;
+ socklen_t clilen;
+ 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, offset = 0, port = 4445;
+ int fd; /* file descriptor for file to send */
+ struct timeval t_start,t_end;
+
+ struct sockaddr_in servaddr,cliaddr;
+
+ if (argc > 1)
+ packet_num = atoi(argv[1]);
+ else
+ packet_num = 166666*sendsize;
+
+ if (argc > 2)
+ port = atoi(argv[2]);
+
+ sockfd = socket(AF_INET, SOCK_STREAM, 0);
+
+ bzero(&servaddr,sizeof(servaddr));
+ servaddr.sin_family = AF_INET;
+ servaddr.sin_addr.s_addr=inet_addr("192.168.1.15");
+ servaddr.sin_port=htons(port);
+
+ fd = open("/data/local/tmp/bigfile_w", O_WRONLY | O_CREAT | O_TRUNC);
+ if (fd == -1) {
+ fprintf(stderr, "unable to open the file.\n");
+ exit(1);
+ }
+
+ gettimeofday(&t_start, NULL);
+ if (connect(sockfd, (struct sockaddr *)&servaddr, sizeof(servaddr)) < 0)
+ {
+ fprintf(stderr, "unable to connect the server.\n");
+ exit(1);
+ }
+
+ while (offset < packet_num)
+ {
+ ret = recv(sockfd, sendbuf, 4096, 0);
+ if (ret <= 0)
+ {
+ printf("recv fail\n");
+ usleep(100);
+ continue;
+ }
+ write(fd, sendbuf, ret);
+ offset += ret;
+ }
+ close(sockfd);
+ gettimeofday(&t_end, NULL);
+ printf("%lf\n", (t_end.tv_sec-t_start.tv_sec)*1000.0+(t_end.tv_usec-t_start.tv_usec)/1000.0);
+
+ close(fd);
+
+ return 0;
+}
diff --git a/offloading_binaries/Normal_recv_lo/main.o b/offloading_binaries/Normal_recv_lo/main.o
new file mode 100644
index 0000000..b4afb87
Binary files /dev/null and b/offloading_binaries/Normal_recv_lo/main.o differ
diff --git a/offloading_binaries/Normal_recv_lo/normal_recv_lo b/offloading_binaries/Normal_recv_lo/normal_recv_lo
new file mode 100755
index 0000000..514b9c1
Binary files /dev/null and b/offloading_binaries/Normal_recv_lo/normal_recv_lo differ
diff --git a/offloading_binaries/Normal_udp/Makefile b/offloading_binaries/Normal_udp/Makefile
new file mode 100644
index 0000000..3bdff0a
--- /dev/null
+++ b/offloading_binaries/Normal_udp/Makefile
@@ -0,0 +1,21 @@
+CC = arm-linux-androideabi-gcc
+#CC = gcc
+CFLAGS = -pie -fPIE -lm
+TARGET = normal_udp
+
+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 $@
+ cp $(TARGET) /media/Lucifer/yanzi/projects/offloading/RDMAMobileDemo/app/src/main/assets/
+clean:
+ -rm -f *.o
+ -rm -f $(TARGET)
diff --git a/offloading_binaries/Normal_udp/main.c b/offloading_binaries/Normal_udp/main.c
new file mode 100644
index 0000000..e226700
--- /dev/null
+++ b/offloading_binaries/Normal_udp/main.c
@@ -0,0 +1,123 @@
+/*
+ * 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
+#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;
+ double packetPerSlot;
+
+ 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=1458, packet_num, 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;
+ if (argc > 1)
+ packet_num = atoi(argv[1]);
+ else
+ packet_num = 166666*sendsize;
+
+ if (argc > 2)
+ quota = atoi(argv[2]) / (1000000 / slotLength);
+ else
+ {
+ printf("Usage: UDPSender bytes rate");
+ exit(1);
+ }
+
+ // fix packet size problem
+ packetPerSlot = ceil(((double)quota) / sendsize);
+ slotLength = (int)(packetPerSlot * sendsize / quota * slotLength);
+ quota = (int)packetPerSlot * sendsize;
+
+ sockfd=socket(AF_INET, SOCK_DGRAM, 0);
+ bzero(&servaddr,sizeof(servaddr));
+ servaddr.sin_family = AF_INET;
+ servaddr.sin_addr.s_addr=inet_addr("128.111.68.220");
+ servaddr.sin_port=htons(9876);
+
+ gettimeofday(&t_start, NULL);
+ while (offset < packet_num)
+ {
+ if ((packet_num - offset) < quota)
+ {
+ quota = packet_num - offset;
+ }
+ while (sentInSlot < quota)
+ {
+ ret = sendto(sockfd, sendbuf, sendsize, 0, (struct sockaddr *)&servaddr, sizeof(servaddr));
+ if (ret < sendsize)
+ {
+ printf("send fail\n");
+ usleep(100);
+ continue;
+ }
+ offset += ret;
+ sentInSlot = sentInSlot + ret;
+ }
+ gettimeofday(&t_now, NULL);
+ elapsedTime = (t_now.tv_sec-t_start.tv_sec)*1000000.0+(t_now.tv_usec-t_start.tv_usec);
+ //printf("sent %d, quota %d, packet_num %d, usleep %lf\n", offset, quota, packet_num, slotLength * slot - elapsedTime);
+ if (elapsedTime < slotLength * slot)
+ {
+ usleep((int)(slotLength * slot - elapsedTime));
+ }
+ sentInSlot = 0;
+ slot++;
+
+ }
+ close(sockfd);
+ gettimeofday(&t_end, NULL);
+ printf("%lf\n", (t_end.tv_sec-t_start.tv_sec)*1000.0+(t_end.tv_usec-t_start.tv_usec)/1000.0);
+
+ close(fd);
+
+ return 0;
+}
diff --git a/offloading_binaries/Normal_udp/main.o b/offloading_binaries/Normal_udp/main.o
new file mode 100644
index 0000000..cefe867
Binary files /dev/null and b/offloading_binaries/Normal_udp/main.o differ
diff --git a/offloading_binaries/Normal_udp/normal_udp b/offloading_binaries/Normal_udp/normal_udp
new file mode 100755
index 0000000..efdea1a
Binary files /dev/null and b/offloading_binaries/Normal_udp/normal_udp differ
diff --git a/offloading_binaries/Normal_udp_lo/Makefile b/offloading_binaries/Normal_udp_lo/Makefile
new file mode 100644
index 0000000..5c13655
--- /dev/null
+++ b/offloading_binaries/Normal_udp_lo/Makefile
@@ -0,0 +1,21 @@
+CC = arm-linux-androideabi-gcc
+#CC = gcc
+CFLAGS = -pie -fPIE -lm
+TARGET = normal_udp_lo
+
+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 $@
+ cp $(TARGET) /media/Lucifer/yanzi/projects/offloading/RDMAMobileDemo/app/src/main/assets/
+clean:
+ -rm -f *.o
+ -rm -f $(TARGET)
diff --git a/offloading_binaries/Normal_udp_lo/main.c b/offloading_binaries/Normal_udp_lo/main.c
new file mode 100644
index 0000000..ab72016
--- /dev/null
+++ b/offloading_binaries/Normal_udp_lo/main.c
@@ -0,0 +1,124 @@
+/*
+ * 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
+#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 327680
+
+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;
+ double packetPerSlot;
+
+ 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=58320, packet_num, 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;
+ if (argc > 1)
+ packet_num = atoi(argv[1]);
+ else
+ packet_num = 166666*sendsize;
+
+ if (argc > 2)
+ quota = atoi(argv[2]) / (1000000 / slotLength);
+ else
+ {
+ printf("Usage: UDPSender bytes rate");
+ exit(1);
+ }
+
+ // fix packet size problem
+ packetPerSlot = ceil(((double)quota) / sendsize);
+ slotLength = (int)(packetPerSlot * sendsize / quota * slotLength);
+ quota = (int)packetPerSlot * sendsize;
+
+ sockfd=socket(AF_INET, SOCK_DGRAM, 0);
+ bzero(&servaddr,sizeof(servaddr));
+ servaddr.sin_family = AF_INET;
+ servaddr.sin_addr.s_addr=inet_addr("192.168.1.15");
+ servaddr.sin_port=htons(9876);
+
+ gettimeofday(&t_start, NULL);
+ while (offset < packet_num)
+ {
+ if ((packet_num - offset) < quota)
+ {
+ quota = packet_num - offset;
+ }
+ while (sentInSlot < quota)
+ {
+ ret = sendto(sockfd, sendbuf, sendsize, 0, (struct sockaddr *)&servaddr, sizeof(servaddr));
+// printf("%d, %d\n", ret, errno);
+ if (ret < sendsize)
+ {
+ printf("send fail\n");
+ usleep(100);
+ continue;
+ }
+ offset += ret;
+ sentInSlot = sentInSlot + ret;
+ }
+ gettimeofday(&t_now, NULL);
+ elapsedTime = (t_now.tv_sec-t_start.tv_sec)*1000000.0+(t_now.tv_usec-t_start.tv_usec);
+ //printf("sent %d, quota %d, packet_num %d, usleep %lf\n", offset, quota, packet_num, slotLength * slot - elapsedTime);
+ if (elapsedTime < slotLength * slot)
+ {
+ usleep((int)(slotLength * slot - elapsedTime));
+ }
+ sentInSlot = 0;
+ slot++;
+
+ }
+ close(sockfd);
+ gettimeofday(&t_end, NULL);
+ printf("%lf\n", (t_end.tv_sec-t_start.tv_sec)*1000.0+(t_end.tv_usec-t_start.tv_usec)/1000.0);
+
+ close(fd);
+
+ return 0;
+}
diff --git a/offloading_binaries/Normal_udp_lo/main.o b/offloading_binaries/Normal_udp_lo/main.o
new file mode 100644
index 0000000..297265b
Binary files /dev/null and b/offloading_binaries/Normal_udp_lo/main.o differ
diff --git a/offloading_binaries/Normal_udp_lo/normal_udp_lo b/offloading_binaries/Normal_udp_lo/normal_udp_lo
new file mode 100755
index 0000000..8475673
Binary files /dev/null and b/offloading_binaries/Normal_udp_lo/normal_udp_lo differ
diff --git a/offloading_binaries/Normal_udp_recv/Makefile b/offloading_binaries/Normal_udp_recv/Makefile
new file mode 100644
index 0000000..34bb5e8
--- /dev/null
+++ b/offloading_binaries/Normal_udp_recv/Makefile
@@ -0,0 +1,21 @@
+#CC = gcc
+CC = arm-linux-androideabi-gcc
+CFLAGS = -pie -fPIE
+TARGET = normal_udp_recv
+
+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 $@
+ cp $(TARGET) /media/Lucifer/yanzi/projects/offloading/RDMAMobileDemo/app/src/main/assets/
+clean:
+ -rm -f *.o
+ -rm -f $(TARGET)
diff --git a/offloading_binaries/Normal_udp_recv/main.c b/offloading_binaries/Normal_udp_recv/main.c
new file mode 100644
index 0000000..898a192
--- /dev/null
+++ b/offloading_binaries/Normal_udp_recv/main.c
@@ -0,0 +1,111 @@
+/*
+ * 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 sockfd, listenfd;
+ socklen_t clilen;
+ 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=1458, packet_num, offset = 0, port = 32000;
+ int fd; /* file descriptor for file to send */
+ struct timeval t_start,t_end;
+
+ struct sockaddr_in servaddr,cliaddr;
+//printf("init");
+ if (argc > 1)
+ packet_num = atoi(argv[1]);
+ else
+ packet_num = 166666*sendsize;
+
+ if (argc > 2)
+ port = atoi(argv[2]);
+
+ sockfd = socket(AF_INET, SOCK_DGRAM, 0);
+//printf("sockfd");
+ bzero(&servaddr,sizeof(servaddr));
+ servaddr.sin_family = AF_INET;
+ servaddr.sin_addr.s_addr=inet_addr("128.111.68.220");
+ servaddr.sin_port=htons(port);
+//printf("servaddr");
+// bind(sockfd, (struct sockaddr *)&servaddr,sizeof(servaddr));
+ fd = open("/data/local/tmp/bigfile_w", O_WRONLY | O_CREAT | O_TRUNC);
+ if (fd == -1) {
+ fprintf(stderr, "unable to open the file.\n");
+ exit(1);
+ }
+
+ gettimeofday(&t_start, NULL);
+//printf("gettime");
+ // if (bind(sockfd, (struct sockaddr *)&servaddr, sizeof(servaddr)) < 0)
+// {
+// fprintf(stderr, "unable to connect the server.\n");
+// exit(1);
+// }
+// printf("bind");
+ sendto(sockfd, "0\n",strlen("0\n"),0, (struct sockaddr *)&servaddr, sizeof(servaddr));
+
+ while (offset < packet_num)
+ {
+ // clilen= sizeof(cliaddr);
+ ret = recvfrom(sockfd, sendbuf, sendsize, 0, NULL, NULL);
+// printf("%d\t%d\n", ret, errno);
+ if (ret <= 0)
+ {
+ printf("recv fail\n");
+ usleep(100);
+ continue;
+ }
+ if (sendbuf[50] != '0') continue;
+ write(fd, sendbuf, ret);
+ offset += ret;
+// printf("%d\n", offset);
+ }
+// close(sockfd);
+ gettimeofday(&t_end, NULL);
+ printf("%lf\n", (t_end.tv_sec-t_start.tv_sec)*1000.0+(t_end.tv_usec-t_start.tv_usec)/1000.0);
+
+ close(fd);
+
+ return 0;
+}
diff --git a/offloading_binaries/Normal_udp_recv/main.o b/offloading_binaries/Normal_udp_recv/main.o
new file mode 100644
index 0000000..35d3a2e
Binary files /dev/null and b/offloading_binaries/Normal_udp_recv/main.o differ
diff --git a/offloading_binaries/Normal_udp_recv/normal_udp_recv b/offloading_binaries/Normal_udp_recv/normal_udp_recv
new file mode 100755
index 0000000..9167568
Binary files /dev/null and b/offloading_binaries/Normal_udp_recv/normal_udp_recv differ
diff --git a/offloading_binaries/Normal_udp_recv_lo/Makefile b/offloading_binaries/Normal_udp_recv_lo/Makefile
new file mode 100644
index 0000000..b0aab9c
--- /dev/null
+++ b/offloading_binaries/Normal_udp_recv_lo/Makefile
@@ -0,0 +1,21 @@
+#CC = gcc
+CC = arm-linux-androideabi-gcc
+CFLAGS = -pie -fPIE
+TARGET = normal_udp_recv_lo
+
+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 $@
+ cp $(TARGET) /media/Lucifer/yanzi/projects/offloading/RDMAMobileDemo/app/src/main/assets/
+clean:
+ -rm -f *.o
+ -rm -f $(TARGET)
diff --git a/offloading_binaries/Normal_udp_recv_lo/main.c b/offloading_binaries/Normal_udp_recv_lo/main.c
new file mode 100644
index 0000000..cb3805c
--- /dev/null
+++ b/offloading_binaries/Normal_udp_recv_lo/main.c
@@ -0,0 +1,111 @@
+/*
+ * 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 sockfd, listenfd;
+ socklen_t clilen;
+ 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=1458, packet_num, offset = 0, port = 32000;
+ int fd; /* file descriptor for file to send */
+ struct timeval t_start,t_end;
+
+ struct sockaddr_in servaddr,cliaddr;
+//printf("init");
+ if (argc > 1)
+ packet_num = atoi(argv[1]);
+ else
+ packet_num = 166666*sendsize;
+
+ if (argc > 2)
+ port = atoi(argv[2]);
+
+ sockfd = socket(AF_INET, SOCK_DGRAM, 0);
+//printf("sockfd");
+ bzero(&servaddr,sizeof(servaddr));
+ servaddr.sin_family = AF_INET;
+ servaddr.sin_addr.s_addr=inet_addr("192.168.1.15");
+ servaddr.sin_port=htons(port);
+//printf("servaddr");
+// bind(sockfd, (struct sockaddr *)&servaddr,sizeof(servaddr));
+ fd = open("/data/local/tmp/bigfile_w", O_WRONLY | O_CREAT | O_TRUNC);
+ if (fd == -1) {
+ fprintf(stderr, "unable to open the file.\n");
+ exit(1);
+ }
+
+ gettimeofday(&t_start, NULL);
+//printf("gettime");
+ // if (bind(sockfd, (struct sockaddr *)&servaddr, sizeof(servaddr)) < 0)
+// {
+// fprintf(stderr, "unable to connect the server.\n");
+// exit(1);
+// }
+// printf("bind");
+ sendto(sockfd, "0\n",strlen("0\n"),0, (struct sockaddr *)&servaddr, sizeof(servaddr));
+
+ while (offset < packet_num)
+ {
+ // clilen= sizeof(cliaddr);
+ ret = recvfrom(sockfd, sendbuf, sendsize, 0, NULL, NULL);
+// printf("%d\t%d\n", ret, errno);
+ if (ret <= 0)
+ {
+ printf("recv fail\n");
+ usleep(100);
+ continue;
+ }
+ if (sendbuf[50] != '0') continue;
+ write(fd, sendbuf, ret);
+ offset += ret;
+// printf("%d\n", offset);
+ }
+// close(sockfd);
+ gettimeofday(&t_end, NULL);
+ printf("%lf\n", (t_end.tv_sec-t_start.tv_sec)*1000.0+(t_end.tv_usec-t_start.tv_usec)/1000.0);
+
+ close(fd);
+
+ return 0;
+}
diff --git a/offloading_binaries/Normal_udp_recv_lo/main.o b/offloading_binaries/Normal_udp_recv_lo/main.o
new file mode 100644
index 0000000..3ad2ad5
Binary files /dev/null and b/offloading_binaries/Normal_udp_recv_lo/main.o differ
diff --git a/offloading_binaries/Normal_udp_recv_lo/normal_udp_recv_lo b/offloading_binaries/Normal_udp_recv_lo/normal_udp_recv_lo
new file mode 100755
index 0000000..1542a67
Binary files /dev/null and b/offloading_binaries/Normal_udp_recv_lo/normal_udp_recv_lo differ
diff --git a/offloading_binaries/Normal_udp_usb/Makefile b/offloading_binaries/Normal_udp_usb/Makefile
new file mode 100644
index 0000000..87d82c4
--- /dev/null
+++ b/offloading_binaries/Normal_udp_usb/Makefile
@@ -0,0 +1,21 @@
+CC = arm-linux-androideabi-gcc
+#CC = gcc
+CFLAGS = -pie -fPIE -lm
+TARGET = normal_udp_usb
+
+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 $@
+ cp $(TARGET) /media/Lucifer/yanzi/projects/offloading/RDMAMobileDemo/app/src/main/assets/
+clean:
+ -rm -f *.o
+ -rm -f $(TARGET)
diff --git a/offloading_binaries/Normal_udp_usb/main.c b/offloading_binaries/Normal_udp_usb/main.c
new file mode 100644
index 0000000..d7bda03
--- /dev/null
+++ b/offloading_binaries/Normal_udp_usb/main.c
@@ -0,0 +1,124 @@
+/*
+ * 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