put up offloading binaries

need to further optimize them
This commit is contained in:
HappyZ 2016-09-25 22:58:41 -07:00
parent 617e87e9d3
commit 495b4861e1
122 changed files with 5146 additions and 3 deletions

View File

@ -37,7 +37,7 @@
<ConfirmationsSetting value="0" id="Add" />
<ConfirmationsSetting value="0" id="Remove" />
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
<component name="ProjectType">

View File

@ -82,7 +82,6 @@
<sourceFolder url="file://$MODULE_DIR$/src/test/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/shaders" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/build/Icon&#13;" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/blame" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/appcompat-v7/23.0.1/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/mediarouter-v7/22.2.0/jars" />

View File

@ -94,7 +94,6 @@
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/rs" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/symbols" />
<excludeFolder url="file://$MODULE_DIR$/build/outputs" />
<excludeFolder url="file://$MODULE_DIR$/build/tmp" />
</content>
<orderEntry type="jdk" jdkName="Android API 23 Platform" jdkType="Android SDK" />
<orderEntry type="sourceFolder" forTests="false" />

View File

@ -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)

Binary file not shown.

View File

@ -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 <arpa/inet.h>
#include <linux/if_packet.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <net/if.h>
#include <netinet/ether.h>
#include <sys/sendfile.h>
#include <errno.h>
#include <sys/time.h>
#include <math.h>
#define ETH_P_IP 0x0800 /* Internet Protocol packet */
#define ETH_ALEN 6 /* from <net/ethernet.h> */
#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 <bytes> <datarate> <optional:interface> <optional:sendsize>");
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;
}

View File

@ -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)

Binary file not shown.

View File

@ -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 <arpa/inet.h>
#include <linux/if_packet.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <net/if.h>
#include <netinet/ether.h>
#include <sys/sendfile.h>
#include <errno.h>
#include <sys/time.h>
#include <math.h>
#define ETH_P_IP 0x0800 /* Internet Protocol packet */
#define ETH_ALEN 6 /* from <net/ethernet.h> */
#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 <bytes> <datarate> <optional:interface> <optional:sendsize>");
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;
}

Binary file not shown.

View File

@ -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)

Binary file not shown.

View File

@ -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 <arpa/inet.h>
#include <linux/if_packet.h>
#include <linux/ip.h>
#include <linux/udp.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <net/if.h>
#include <netinet/ether.h>
#include <sys/sendfile.h>
#include <errno.h>
#include <sys/time.h>
#define ETH_P_IP 0x0800 /* Internet Protocol packet */
#define ETH_ALEN 6 /* from <net/ethernet.h> */
#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;
}

Binary file not shown.

View File

@ -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)

Binary file not shown.

View File

@ -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 <arpa/inet.h>
#include <linux/if_packet.h>
#include <linux/ip.h>
#include <linux/udp.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <net/if.h>
#include <netinet/ether.h>
#include <sys/sendfile.h>
#include <errno.h>
#include <sys/time.h>
#define ETH_P_IP 0x0800 /* Internet Protocol packet */
#define ETH_ALEN 6 /* from <net/ethernet.h> */
#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;
}

Binary file not shown.

View File

@ -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)

Binary file not shown.

View File

@ -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 <arpa/inet.h>
#include <linux/if_packet.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <net/if.h>
#include <netinet/ether.h>
#include <sys/sendfile.h>
#include <errno.h>
#include <sys/time.h>
#include <math.h>
#define ETH_P_IP 0x0800 /* Internet Protocol packet */
#define ETH_ALEN 6 /* from <net/ethernet.h> */
#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 <bytes> <datarate> <optional:interface> <optional:sendsize>");
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;
}

Binary file not shown.

View File

@ -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)

View File

@ -0,0 +1,126 @@
/*
* Initial commit by Yibo @ Jul. 28, 2015
* Last update by Yanzi @ Sept. 23, 2016
*/
#include <arpa/inet.h>
#include <linux/if_packet.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <net/if.h>
#include <netinet/ether.h>
#include <sys/sendfile.h>
#include <errno.h>
#include <sys/time.h>
#include <sys/socket.h>
#include <netinet/in.h>
#define ETH_P_IP 0x0800 /* Internet Protocol packet */
#define ETH_ALEN 6 /* from <net/ethernet.h> */
#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;
}

Binary file not shown.

BIN
offloading_binaries/Normal/normal Executable file

Binary file not shown.

View File

@ -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)

View File

@ -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 <ezp.hpp>
#include <arpa/inet.h>
#include <linux/if_packet.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <net/if.h>
#include <netinet/ether.h>
#include <sys/sendfile.h>
#include <errno.h>
#include <sys/time.h>
#include <sys/socket.h>
#include <netinet/in.h>
//#include <unistd.h>
#include <fcntl.h>
#define ETH_P_IP 0x0800 /* Internet Protocol packet */
#define ETH_ALEN 6 /* from <net/ethernet.h> */
#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;
}

Binary file not shown.

View File

@ -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)

View File

@ -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 <arpa/inet.h>
#include <linux/if_packet.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <net/if.h>
#include <netinet/ether.h>
#include <sys/sendfile.h>
#include <errno.h>
#include <sys/time.h>
#include <sys/socket.h>
#include <netinet/in.h>
//#include "/media/Lucifer/android/ndk-profiler/jni/prof.h"
#define ETH_P_IP 0x0800 /* Internet Protocol packet */
#define ETH_ALEN 6 /* from <net/ethernet.h> */
#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;
}

Binary file not shown.

Binary file not shown.

View File

@ -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)

View File

@ -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 <arpa/inet.h>
#include <linux/if_packet.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <net/if.h>
#include <netinet/ether.h>
#include <sys/sendfile.h>
#include <errno.h>
#include <sys/time.h>
#include <sys/socket.h>
#include <netinet/in.h>
#define ETH_P_IP 0x0800 /* Internet Protocol packet */
#define ETH_ALEN 6 /* from <net/ethernet.h> */
#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;
}

Binary file not shown.

View File

@ -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)

View File

@ -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 <arpa/inet.h>
#include <linux/if_packet.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <net/if.h>
#include <netinet/ether.h>
#include <sys/sendfile.h>
#include <errno.h>
#include <sys/time.h>
#include <sys/socket.h>
#include <netinet/in.h>
#define ETH_P_IP 0x0800 /* Internet Protocol packet */
#define ETH_ALEN 6 /* from <net/ethernet.h> */
#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;
}

Binary file not shown.

View File

@ -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)

View File

@ -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 <arpa/inet.h>
#include <linux/if_packet.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <net/if.h>
#include <netinet/ether.h>
#include <sys/sendfile.h>
#include <errno.h>
#include <sys/time.h>
#include <sys/socket.h>
#include <netinet/in.h>
#define ETH_P_IP 0x0800 /* Internet Protocol packet */
#define ETH_ALEN 6 /* from <net/ethernet.h> */
#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;
}

Binary file not shown.

Binary file not shown.

View File

@ -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)

View File

@ -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 <arpa/inet.h>
#include <linux/if_packet.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <net/if.h>
#include <netinet/ether.h>
#include <sys/sendfile.h>
#include <errno.h>
#include <sys/time.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <signal.h>
#include <math.h>
#define ETH_P_IP 0x0800 /* Internet Protocol packet */
#define ETH_ALEN 6 /* from <net/ethernet.h> */
#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;
}

Binary file not shown.

Binary file not shown.

View File

@ -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)

View File

@ -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 <arpa/inet.h>
#include <linux/if_packet.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <net/if.h>
#include <netinet/ether.h>
#include <sys/sendfile.h>
#include <errno.h>
#include <sys/time.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <signal.h>
#include <math.h>
#define ETH_P_IP 0x0800 /* Internet Protocol packet */
#define ETH_ALEN 6 /* from <net/ethernet.h> */
#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;
}

Binary file not shown.

Binary file not shown.

View File

@ -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)

View File

@ -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 <arpa/inet.h>
#include <linux/if_packet.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <net/if.h>
#include <netinet/ether.h>
#include <sys/sendfile.h>
#include <errno.h>
#include <sys/time.h>
#include <sys/socket.h>
#include <netinet/in.h>
//#include <sys/fcntl.h>
#define ETH_P_IP 0x0800 /* Internet Protocol packet */
#define ETH_ALEN 6 /* from <net/ethernet.h> */
#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;
}

Binary file not shown.

Binary file not shown.

View File

@ -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)

View File

@ -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 <arpa/inet.h>
#include <linux/if_packet.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <net/if.h>
#include <netinet/ether.h>
#include <sys/sendfile.h>
#include <errno.h>
#include <sys/time.h>
#include <sys/socket.h>
#include <netinet/in.h>
//#include <sys/fcntl.h>
#define ETH_P_IP 0x0800 /* Internet Protocol packet */
#define ETH_ALEN 6 /* from <net/ethernet.h> */
#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;
}

Binary file not shown.

Binary file not shown.

View File

@ -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)

View File

@ -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 <arpa/inet.h>
#include <linux/if_packet.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <net/if.h>
#include <netinet/ether.h>
#include <sys/sendfile.h>
#include <errno.h>
#include <sys/time.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <signal.h>
#include <math.h>
#define ETH_P_IP 0x0800 /* Internet Protocol packet */
#define ETH_ALEN 6 /* from <net/ethernet.h> */
#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 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("10.42.0.1");
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;
}

Binary file not shown.

Binary file not shown.

View File

@ -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_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)
#$(call import-module,android-ndk-profiler)

View File

@ -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 <arpa/inet.h>
#include <linux/if_packet.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <net/if.h>
#include <netinet/ether.h>
#include <sys/sendfile.h>
#include <errno.h>
#include <sys/time.h>
#include <sys/socket.h>
#include <netinet/in.h>
//#include "/media/Lucifer/android/ndk-profiler/jni/prof.h"
#define ETH_P_IP 0x0800 /* Internet Protocol packet */
#define ETH_ALEN 6 /* from <net/ethernet.h> */
#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 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("10.42.0.1");
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;
}

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,20 @@
CC = arm-linux-androideabi-gcc
CFLAGS = -pie -fPIE
TARGET = sendfile
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)

View File

@ -0,0 +1,127 @@
/*
* 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 <arpa/inet.h>
#include <linux/if_packet.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <net/if.h>
#include <netinet/ether.h>
#include <sys/sendfile.h>
#include <errno.h>
#include <sys/time.h>
#include <sys/socket.h>
#include <netinet/in.h>
#define ETH_P_IP 0x0800 /* Internet Protocol packet */
#define ETH_ALEN 6 /* from <net/ethernet.h> */
#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;
int sockfd;
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;
int outstanding;
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("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)
{
ret = sendfile(sockfd, fd, (off_t *)&offset, quota - sentInSlot);
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++;
//ioctl(sockfd, SIOCOUTQ, &outstanding);
//if (outstanding > 0)
//{
// continue;
//}
//ret = sendfile(sockfd, fd, (off_t *)&offset, 4096);
}
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;
}

View File

@ -0,0 +1,94 @@
/*
* 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 <arpa/inet.h>
#include <linux/if_packet.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <net/if.h>
#include <netinet/ether.h>
#include <sys/sendfile.h>
#include <errno.h>
#include <sys/time.h>
#include <sys/socket.h>
#include <netinet/in.h>
#define ETH_P_IP 0x0800 /* Internet Protocol packet */
#define ETH_ALEN 6 /* from <net/ethernet.h> */
#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=4096, 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]);
else
packet_num = 166666*1488;
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);
connect(sockfd, (struct sockaddr *)&servaddr, sizeof(servaddr));
fd = open("bigfile");
if (fd == -1) {
fprintf(stderr, "unable to open the file.\n");
exit(1);
}
gettimeofday(&t_start, NULL);
while (offset < packet_num)
{
ret = sendfile(sockfd, fd, (off_t *)&offset, sendsize);
if (ret <= 0)
{
printf("sendfile fail\n");
usleep(100);
continue;
}
offset += sendsize;
}
gettimeofday(&t_end, NULL);
printf("time cost is: %lfms.\n", (t_end.tv_sec-t_start.tv_sec)*1000.0+(t_end.tv_usec-t_start.tv_usec)/1000.0);
close(fd);
close(sockfd);
return 0;
}

Binary file not shown.

View File

@ -0,0 +1,20 @@
CC = arm-linux-androideabi-gcc
CFLAGS = -pie -fPIE
TARGET = sendfile_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)

View File

@ -0,0 +1,128 @@
/*
* 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 <arpa/inet.h>
#include <linux/if_packet.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <net/if.h>
#include <netinet/ether.h>
#include <sys/sendfile.h>
#include <errno.h>
#include <sys/time.h>
#include <sys/socket.h>
#include <netinet/in.h>
#define ETH_P_IP 0x0800 /* Internet Protocol packet */
#define ETH_ALEN 6 /* from <net/ethernet.h> */
#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;
int sockfd;
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;
int outstanding;
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("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)
{
ret = sendfile(sockfd, fd, (off_t *)&offset, quota - sentInSlot);
// printf("err: %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++;
//ioctl(sockfd, SIOCOUTQ, &outstanding);
//if (outstanding > 0)
//{
// continue;
//}
//ret = sendfile(sockfd, fd, (off_t *)&offset, 4096);
}
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;
}

Binary file not shown.

View File

@ -0,0 +1,94 @@
/*
* 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 <arpa/inet.h>
#include <linux/if_packet.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <net/if.h>
#include <netinet/ether.h>
#include <sys/sendfile.h>
#include <errno.h>
#include <sys/time.h>
#include <sys/socket.h>
#include <netinet/in.h>
#define ETH_P_IP 0x0800 /* Internet Protocol packet */
#define ETH_ALEN 6 /* from <net/ethernet.h> */
#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=4096, 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]);
else
packet_num = 166666*1488;
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);
connect(sockfd, (struct sockaddr *)&servaddr, sizeof(servaddr));
fd = open("bigfile");
if (fd == -1) {
fprintf(stderr, "unable to open the file.\n");
exit(1);
}
gettimeofday(&t_start, NULL);
while (offset < packet_num)
{
ret = sendfile(sockfd, fd, (off_t *)&offset, sendsize);
if (ret <= 0)
{
printf("sendfile fail\n");
usleep(100);
continue;
}
offset += sendsize;
}
gettimeofday(&t_end, NULL);
printf("time cost is: %lfms.\n", (t_end.tv_sec-t_start.tv_sec)*1000.0+(t_end.tv_usec-t_start.tv_usec)/1000.0);
close(fd);
close(sockfd);
return 0;
}

Binary file not shown.

View File

@ -0,0 +1,20 @@
CC = arm-linux-androideabi-gcc
CFLAGS = -pie -fPIE
TARGET = sendfile_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)

View File

@ -0,0 +1,128 @@
/*
* 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 <arpa/inet.h>
#include <linux/if_packet.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <net/if.h>
#include <netinet/ether.h>
#include <sys/sendfile.h>
#include <errno.h>
#include <sys/time.h>
#include <sys/socket.h>
#include <netinet/in.h>
#define ETH_P_IP 0x0800 /* Internet Protocol packet */
#define ETH_ALEN 6 /* from <net/ethernet.h> */
#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 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;
int sockfd;
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;
int outstanding;
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.42.0.1");
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)
{
ret = sendfile(sockfd, fd, (off_t *)&offset, quota - sentInSlot);
// printf("err: %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++;
//ioctl(sockfd, SIOCOUTQ, &outstanding);
//if (outstanding > 0)
//{
// continue;
//}
//ret = sendfile(sockfd, fd, (off_t *)&offset, 4096);
}
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;
}

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,20 @@
CC = arm-linux-androideabi-gcc
CFLAGS = -pie -fPIE
TARGET = splice
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)

View File

@ -0,0 +1,172 @@
/*
* 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 <arpa/inet.h>
#include <linux/if_packet.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <net/if.h>
#include <netinet/ether.h>
#include <sys/sendfile.h>
#include <errno.h>
#include <sys/time.h>
#include <sys/socket.h>
#include <netinet/in.h>
#define _GNU_SOURCE /* See feature_test_macros(7) */
#include <fcntl.h>
#include <sys/uio.h>
#include <netinet/tcp.h>
#define ETH_P_IP 0x0800 /* Internet Protocol packet */
#define ETH_ALEN 6 /* from <net/ethernet.h> */
#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=0, sendsize=1488, packet_num, offset = 0;
int fd; /* file descriptor for file to send */
int outstanding;
struct timeval t_start,t_end,t_now;
ssize_t bytes, bytes_sent, bytes_in_pipe;
size_t total_bytes_sent = 0;
int filedes [2];
ret = pipe (filedes);
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("128.111.68.220");
servaddr.sin_port=htons(4444);
connect(sockfd, (struct sockaddr *)&servaddr, sizeof(servaddr));
fd = open("/data/local/tmp/bigfile", O_RDONLY);
if (fd == -1) {
fprintf(stderr, "unable to open the file.\n");
exit(1);
}
//setsockopt(sockfd, IPPROTO_TCP, TCP_NODELAY, (char *) &ret, sizeof(int));
//ioctl(sockfd, SIOCOUTQ, &outstanding);
//printf("outstanding:%d\n", outstanding);
gettimeofday(&t_start, NULL);
while (total_bytes_sent < packet_num)
{
if ((packet_num - total_bytes_sent) < quota)
{
quota = packet_num - offset;
}
while (sentInSlot < quota)
{
// Splice the data from in_fd into the pipe
if ((bytes_sent = splice(fd, NULL, filedes[1], NULL,
quota - sentInSlot,
SPLICE_F_MORE | SPLICE_F_MOVE)) <= 0) {
if (errno == EINTR || errno == EAGAIN) {
// Interrupted system call/try again
// Just skip to the top of the loop and try again
continue;
}
perror("splice");
return -1;
}
// Splice the data from the pipe into out_fd
bytes_in_pipe = bytes_sent;
while (bytes_in_pipe > 0) {
if ((bytes = splice(filedes[0], NULL, sockfd, NULL, bytes_in_pipe,
SPLICE_F_MORE | SPLICE_F_MOVE)) <= 0) {
if (errno == EINTR || errno == EAGAIN) {
// Interrupted system call/try again
// Just skip to the top of the loop and try again
continue;
}
perror("splice");
return -1;
}
bytes_in_pipe -= bytes;
}
total_bytes_sent += bytes_sent;
sentInSlot += bytes_sent;
}
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++;
/*
for(;;)
{
ioctl(sockfd, SIOCOUTQ, &outstanding);
printf("outstanding:%d\n", outstanding);
if (outstanding>0)
{
usleep(100);
}
else
{
break;
}
}
*/
}
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;
}

BIN
offloading_binaries/Splice/splice Executable file

Binary file not shown.

View File

@ -0,0 +1,20 @@
CC = arm-linux-androideabi-gcc
CFLAGS = -pie -fPIE
TARGET = splice_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)

View File

@ -0,0 +1,172 @@
/*
* 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 <arpa/inet.h>
#include <linux/if_packet.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <net/if.h>
#include <netinet/ether.h>
#include <sys/sendfile.h>
#include <errno.h>
#include <sys/time.h>
#include <sys/socket.h>
#include <netinet/in.h>
#define _GNU_SOURCE /* See feature_test_macros(7) */
#include <fcntl.h>
#include <sys/uio.h>
#include <netinet/tcp.h>
#define ETH_P_IP 0x0800 /* Internet Protocol packet */
#define ETH_ALEN 6 /* from <net/ethernet.h> */
#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=0, sendsize=1488, packet_num, offset = 0;
int fd; /* file descriptor for file to send */
int outstanding;
struct timeval t_start,t_end,t_now;
ssize_t bytes, bytes_sent, bytes_in_pipe;
size_t total_bytes_sent = 0;
int filedes [2];
ret = pipe (filedes);
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("192.168.1.15");
servaddr.sin_port=htons(4444);
connect(sockfd, (struct sockaddr *)&servaddr, sizeof(servaddr));
fd = open("/data/local/tmp/bigfile", O_RDONLY);
if (fd == -1) {
fprintf(stderr, "unable to open the file.\n");
exit(1);
}
//setsockopt(sockfd, IPPROTO_TCP, TCP_NODELAY, (char *) &ret, sizeof(int));
//ioctl(sockfd, SIOCOUTQ, &outstanding);
//printf("outstanding:%d\n", outstanding);
gettimeofday(&t_start, NULL);
while (total_bytes_sent < packet_num)
{
if ((packet_num - total_bytes_sent) < quota)
{
quota = packet_num - offset;
}
while (sentInSlot < quota)
{
// Splice the data from in_fd into the pipe
if ((bytes_sent = splice(fd, NULL, filedes[1], NULL,
quota - sentInSlot,
SPLICE_F_MORE | SPLICE_F_MOVE)) <= 0) {
if (errno == EINTR || errno == EAGAIN) {
// Interrupted system call/try again
// Just skip to the top of the loop and try again
continue;
}
perror("splice");
return -1;
}
// Splice the data from the pipe into out_fd
bytes_in_pipe = bytes_sent;
while (bytes_in_pipe > 0) {
if ((bytes = splice(filedes[0], NULL, sockfd, NULL, bytes_in_pipe,
SPLICE_F_MORE | SPLICE_F_MOVE)) <= 0) {
if (errno == EINTR || errno == EAGAIN) {
// Interrupted system call/try again
// Just skip to the top of the loop and try again
continue;
}
perror("splice");
return -1;
}
bytes_in_pipe -= bytes;
}
total_bytes_sent += bytes_sent;
sentInSlot += bytes_sent;
}
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++;
/*
for(;;)
{
ioctl(sockfd, SIOCOUTQ, &outstanding);
printf("outstanding:%d\n", outstanding);
if (outstanding>0)
{
usleep(100);
}
else
{
break;
}
}
*/
}
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;
}

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,20 @@
CC = arm-linux-androideabi-gcc
CFLAGS = -pie -fPIE
TARGET = splice_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)

View File

@ -0,0 +1,177 @@
/*
* 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 <arpa/inet.h>
#include <linux/if_packet.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <net/if.h>
#include <netinet/ether.h>
#include <sys/sendfile.h>
#include <errno.h>
#include <sys/time.h>
#include <sys/socket.h>
#include <netinet/in.h>
#define _GNU_SOURCE /* See feature_test_macros(7) */
#include <fcntl.h>
#include <sys/uio.h>
#include <netinet/tcp.h>
#define ETH_P_IP 0x0800 /* Internet Protocol packet */
#define ETH_ALEN 6 /* from <net/ethernet.h> */
#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=0, sendsize=1488, packet_num, offset = 0, port = 4445;
int fd; /* file descriptor for file to send */
int outstanding;
struct timeval t_start,t_end;
ssize_t bytes, bytes_sent, bytes_in_pipe;
size_t total_bytes_sent = 0;
struct sockaddr_in servaddr,cliaddr;
int filedes [2];
ret = pipe (filedes);
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(4444);
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);
}
//setsockopt(sockfd, IPPROTO_TCP, TCP_NODELAY, (char *) &ret, sizeof(int));
//ioctl(sockfd, SIOCOUTQ, &outstanding);
//printf("outstanding:%d\n", outstanding);
gettimeofday(&t_start, NULL);
if (connect(sockfd, (struct sockaddr *)&servaddr, sizeof(servaddr)) < 0)
{
fprintf(stderr, "unable to connect the server.\n");
exit(1);
}
while (total_bytes_sent < packet_num)
{
// Splice the data from in_fd into the pipe
if ((bytes_sent = splice(sockfd, NULL, filedes[1], NULL,
4096,
SPLICE_F_MORE | SPLICE_F_MOVE)) <= 0) {
if (errno == EINTR || errno == EAGAIN) {
// Interrupted system call/try again
// Just skip to the top of the loop and try again
printf("in error: %d\n", bytes_sent);
fflush(stdout);
usleep(100);
continue;
}
perror("splice");
return -1;
}
//printf("%d\n", bytes_sent);
//fflush(stdout);
// Splice the data from the pipe into out_fd
bytes_in_pipe = bytes_sent;
while (bytes_in_pipe > 0) {
if ((bytes = splice(filedes[0], NULL, fd, NULL, bytes_in_pipe,
SPLICE_F_MORE | SPLICE_F_MOVE)) <= 0) {
if (errno == EINTR || errno == EAGAIN) {
// Interrupted system call/try again
// Just skip to the top of the loop and try again
printf("out error: %d\n", bytes_sent);
fflush(stdout);
continue;
}
perror("splice");
return -1;
}
bytes_in_pipe -= bytes;
}
//printf("%d, %d\n", bytes_sent, total_bytes_sent);
//fflush(stdout);
total_bytes_sent += bytes_sent;
/*
for(;;)
{
ioctl(sockfd, SIOCOUTQ, &outstanding);
printf("outstanding:%d\n", outstanding);
if (outstanding>0)
{
usleep(100);
}
else
{
break;
}
}
*/
//ret = splice (fd, (off64_t *)&offset, filedes[1], NULL, sendsize, SPLICE_F_MORE | SPLICE_F_MOVE);
//ret = sendfile(sockfd, fd, (off_t *)&offset, sendsize);
//offset += total_bytes_sent;
//printf("sent:%d, total:%d\n", bytes_sent, total_bytes_sent);
}
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;
}

Binary file not shown.

View File

@ -0,0 +1,20 @@
CC = arm-linux-androideabi-gcc
CFLAGS = -pie -fPIE
TARGET = splice_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)

View File

@ -0,0 +1,176 @@
/*
* 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 <arpa/inet.h>
#include <linux/if_packet.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <net/if.h>
#include <netinet/ether.h>
#include <sys/sendfile.h>
#include <errno.h>
#include <sys/time.h>
#include <sys/socket.h>
#include <netinet/in.h>
#define _GNU_SOURCE /* See feature_test_macros(7) */
#include <fcntl.h>
#include <sys/uio.h>
#include <netinet/tcp.h>
#define ETH_P_IP 0x0800 /* Internet Protocol packet */
#define ETH_ALEN 6 /* from <net/ethernet.h> */
#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=0, sendsize=1488, packet_num, offset = 0, port = 4445;
int fd; /* file descriptor for file to send */
int outstanding;
struct timeval t_start,t_end;
ssize_t bytes, bytes_sent, bytes_in_pipe;
size_t total_bytes_sent = 0;
struct sockaddr_in servaddr,cliaddr;
int filedes [2];
ret = pipe (filedes);
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(4444);
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);
}
//setsockopt(sockfd, IPPROTO_TCP, TCP_NODELAY, (char *) &ret, sizeof(int));
//ioctl(sockfd, SIOCOUTQ, &outstanding);
//printf("outstanding:%d\n", outstanding);
gettimeofday(&t_start, NULL);
if (connect(sockfd, (struct sockaddr *)&servaddr, sizeof(servaddr)) < 0)
{
fprintf(stderr, "unable to connect the server.\n");
exit(1);
}
while (total_bytes_sent < packet_num)
{
// Splice the data from in_fd into the pipe
if ((bytes_sent = splice(sockfd, NULL, filedes[1], NULL,
4096,
SPLICE_F_MORE | SPLICE_F_MOVE)) <= 0) {
if (errno == EINTR || errno == EAGAIN) {
// Interrupted system call/try again
// Just skip to the top of the loop and try again
printf("in error: %d\n", bytes_sent);
fflush(stdout);
usleep(100);
continue;
}
perror("splice");
return -1;
}
// printf("%d\n", bytes_sent);
// fflush(stdout);
// Splice the data from the pipe into out_fd
bytes_in_pipe = bytes_sent;
while (bytes_in_pipe > 0) {
if ((bytes = splice(filedes[0], NULL, fd, NULL, bytes_in_pipe,
SPLICE_F_MORE | SPLICE_F_MOVE)) <= 0) {
if (errno == EINTR || errno == EAGAIN) {
// Interrupted system call/try again
// Just skip to the top of the loop and try again
printf("out error: %d\n", bytes_sent);
fflush(stdout);
continue;
}
perror("splice");
return -1;
}
bytes_in_pipe -= bytes;
}
// printf("%d, %d\n", bytes_sent, total_bytes_sent);
// fflush(stdout);
total_bytes_sent += bytes_sent;
/*
for(;;)
{
ioctl(sockfd, SIOCOUTQ, &outstanding);
printf("outstanding:%d\n", outstanding);
if (outstanding>0)
{
usleep(100);
}
else
{
break;
}
}
*/
//ret = splice (fd, (off64_t *)&offset, filedes[1], NULL, sendsize, SPLICE_F_MORE | SPLICE_F_MOVE);
//ret = sendfile(sockfd, fd, (off_t *)&offset, sendsize);
//offset += total_bytes_sent;
//printf("sent:%d, total:%d\n", bytes_sent, total_bytes_sent);
}
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;
}

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,21 @@
#CC = /media/Lucifer/android/lib/android-18-toolchain/bin/arm-linux-androideabi-gcc
CC = arm-linux-androideabi-gcc
CFLAGS = -pie -fPIE
TARGET = TCPReceiver_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)

Binary file not shown.

View File

@ -0,0 +1,121 @@
/*
* 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 <arpa/inet.h>
#include <linux/if_packet.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <net/if.h>
#include <netinet/ether.h>
#include <sys/sendfile.h>
#include <errno.h>
#include <sys/time.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <signal.h>
#define ETH_P_IP 0x0800 /* Internet Protocol packet */
#define ETH_ALEN 6 /* from <net/ethernet.h> */
#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_STREAM, 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);
sockfd = accept(listenfd,(struct sockaddr *)&cliaddr, &clilen);
printf("Accepted.\n");
//setsockopt(sd, SOL_SOCKET, SO_NOSIGPIPE, (void *)&set, sizeof(int));
// fd = open("/data/local/tmp/bigfile_w", O_WRONLY | O_CREAT | O_TRUNC);
offset = 0;
if (fd == -1) {
fprintf(stderr, "unable to open the file.\n");
exit(1);
}
gettimeofday(&t_start, NULL);
while (offset < packet_num)
{
ret = recv(sockfd, sendbuf, 4096, 0);
if (ret <= 0)
{
printf("recv fail\n");
usleep(100);
break;
}
// 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;
}

Binary file not shown.

View File

@ -0,0 +1,21 @@
CC = /media/Lucifer/android/lib/android-18-toolchain/bin/arm-linux-androideabi-gcc
#CC = arm-linux-androideabi-gcc
CFLAGS = -pie -fPIE
TARGET = TCPSender_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)

Binary file not shown.

Some files were not shown because too many files have changed in this diff Show More