rewrote normal udp and tcp client receiver
remove redundant files; add normal udp and tcp client receiver to makeall.sh
This commit is contained in:
parent
73dae97938
commit
f10f497f6e
|
|
@ -1,102 +0,0 @@
|
||||||
/*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <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.
|
|
@ -1,102 +0,0 @@
|
||||||
/*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <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.
|
|
@ -1,21 +0,0 @@
|
||||||
#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)
|
|
||||||
|
|
@ -1,111 +0,0 @@
|
||||||
/*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <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.
|
|
@ -1,21 +0,0 @@
|
||||||
#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)
|
|
||||||
|
|
@ -1,111 +0,0 @@
|
||||||
/*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <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.
|
|
@ -1,6 +1,7 @@
|
||||||
CC = arm-linux-androideabi-gcc
|
CC = arm-linux-androideabi-gcc
|
||||||
|
# CC = gcc
|
||||||
CFLAGS = -pie -fPIE
|
CFLAGS = -pie -fPIE
|
||||||
TARGET = normal_recv
|
TARGET = client_recv_normaltcp
|
||||||
|
|
||||||
OBJS = $(patsubst %.c, %.o, $(wildcard *.c))
|
OBJS = $(patsubst %.c, %.o, $(wildcard *.c))
|
||||||
HEADERS = $(wildcard *.h)
|
HEADERS = $(wildcard *.h)
|
||||||
|
|
@ -14,7 +15,7 @@ all: $(TARGET)
|
||||||
|
|
||||||
$(TARGET): $(OBJS)
|
$(TARGET): $(OBJS)
|
||||||
$(CC) $(OBJS) -Wall $(CFLAGS) -o $@
|
$(CC) $(OBJS) -Wall $(CFLAGS) -o $@
|
||||||
cp $(TARGET) /media/Lucifer/yanzi/projects/offloading/RDMAMobileDemo/app/src/main/assets/
|
|
||||||
clean:
|
clean:
|
||||||
-rm -f *.o
|
-rm -f *.o
|
||||||
-rm -f $(TARGET)
|
-rm -f $(TARGET)
|
||||||
Binary file not shown.
|
|
@ -0,0 +1,116 @@
|
||||||
|
/*
|
||||||
|
* Initial commit by Yibo @ Jul. 28, 2015
|
||||||
|
* Last update by Yanzi @ Sept. 27, 2016
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <arpa/inet.h>
|
||||||
|
#include <linux/if_packet.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <sys/ioctl.h>
|
||||||
|
#include <sys/socket.h>
|
||||||
|
#include <sys/stat.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 <fcntl.h>
|
||||||
|
|
||||||
|
#define BUF_SIZ 65536
|
||||||
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
// defaults
|
||||||
|
uint total_bytes_recv = 0;
|
||||||
|
// for timing
|
||||||
|
double elapsedTime;
|
||||||
|
struct timeval t_start, t_end, t_now;
|
||||||
|
// for socket
|
||||||
|
int fd; // file descriptor of file to send
|
||||||
|
int sockfd; // socket
|
||||||
|
char recvbuf[BUF_SIZ];
|
||||||
|
struct sockaddr_in servaddr;
|
||||||
|
// for misc
|
||||||
|
int ret;
|
||||||
|
int recvsize = 4096;
|
||||||
|
|
||||||
|
if (argc < 3)
|
||||||
|
{
|
||||||
|
printf("Usage: %s <ip> <port> <[optional] recvsize (bytes)> <[optional] filepath>\n", argv[0]);
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
// set sendsize (if larger than 1460 will do packetization (fragmentation))
|
||||||
|
if (argc > 3)
|
||||||
|
recvsize = atoi(argv[3]);
|
||||||
|
|
||||||
|
// bind socket
|
||||||
|
sockfd = socket(AF_INET, SOCK_STREAM, 0);
|
||||||
|
bzero(&servaddr, sizeof(servaddr));
|
||||||
|
servaddr.sin_family = AF_INET;
|
||||||
|
servaddr.sin_addr.s_addr = inet_addr(argv[2]);
|
||||||
|
servaddr.sin_port = htons(atoi(argv[3]));
|
||||||
|
|
||||||
|
// connect socket
|
||||||
|
if (connect(sockfd, (struct sockaddr *)&servaddr, sizeof(servaddr)) < 0)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "! Unable to connect the server.\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// if instrument to write to a file
|
||||||
|
if (argc > 4)
|
||||||
|
{
|
||||||
|
fd = open(argv[4], O_WRONLY | O_CREAT | O_TRUNC);
|
||||||
|
if (fd == -1) {
|
||||||
|
fprintf(stderr, "! Unable to open file %s.\n", argv[2]);
|
||||||
|
close(sockfd);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// start timing
|
||||||
|
gettimeofday(&t_start, NULL);
|
||||||
|
|
||||||
|
// start to receive
|
||||||
|
for (;;)
|
||||||
|
{
|
||||||
|
// printf("before: total_bytes_recv %d\n", total_bytes_recv);
|
||||||
|
ret = recv(sockfd, recvbuf, recvsize, 0);
|
||||||
|
|
||||||
|
if (ret <= 0)
|
||||||
|
{
|
||||||
|
if (errno == 0)
|
||||||
|
{
|
||||||
|
if (argc > 4)
|
||||||
|
close(fd);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
fprintf(stderr, "! Fail to recv: ret:%d, err:%d; quiting..\n", ret, errno);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
// write to file if specified filename
|
||||||
|
if (argc > 4)
|
||||||
|
write(fd, recvbuf, ret);
|
||||||
|
// count how many bytes received
|
||||||
|
total_bytes_recv += ret;
|
||||||
|
// printf("after: total_bytes_recv %d\n", total_bytes_recv);
|
||||||
|
}
|
||||||
|
|
||||||
|
// end timing
|
||||||
|
gettimeofday(&t_end, NULL);
|
||||||
|
elapsedTime = (t_end.tv_sec - t_start.tv_sec) + (t_end.tv_usec - t_start.tv_usec) / 1000000.0;
|
||||||
|
printf(
|
||||||
|
"recv(bytes):%d\nduration(s):%lf\nthroughput(bps):%lf\n",
|
||||||
|
total_bytes_recv, elapsedTime, total_bytes_recv * 8 / elapsedTime);
|
||||||
|
|
||||||
|
close(sockfd);
|
||||||
|
if (argc > 4)
|
||||||
|
close(fd);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
Binary file not shown.
|
|
@ -1,6 +1,7 @@
|
||||||
CC = arm-linux-androideabi-gcc
|
CC = arm-linux-androideabi-gcc
|
||||||
|
# CC = gcc
|
||||||
CFLAGS = -pie -fPIE
|
CFLAGS = -pie -fPIE
|
||||||
TARGET = normal_recv_lo
|
TARGET = client_recv_normaludp
|
||||||
|
|
||||||
OBJS = $(patsubst %.c, %.o, $(wildcard *.c))
|
OBJS = $(patsubst %.c, %.o, $(wildcard *.c))
|
||||||
HEADERS = $(wildcard *.h)
|
HEADERS = $(wildcard *.h)
|
||||||
|
|
@ -14,7 +15,7 @@ all: $(TARGET)
|
||||||
|
|
||||||
$(TARGET): $(OBJS)
|
$(TARGET): $(OBJS)
|
||||||
$(CC) $(OBJS) -Wall $(CFLAGS) -o $@
|
$(CC) $(OBJS) -Wall $(CFLAGS) -o $@
|
||||||
cp $(TARGET) /media/Lucifer/yanzi/projects/offloading/RDMAMobileDemo/app/src/main/assets/
|
|
||||||
clean:
|
clean:
|
||||||
-rm -f *.o
|
-rm -f *.o
|
||||||
-rm -f $(TARGET)
|
-rm -f $(TARGET)
|
||||||
Binary file not shown.
|
|
@ -0,0 +1,120 @@
|
||||||
|
/*
|
||||||
|
* Initial commit by Yibo @ Jul. 28, 2015
|
||||||
|
* Last update by Yanzi @ Sept. 27, 2016
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <arpa/inet.h>
|
||||||
|
#include <linux/if_packet.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <sys/ioctl.h>
|
||||||
|
#include <sys/socket.h>
|
||||||
|
#include <sys/stat.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 <fcntl.h>
|
||||||
|
|
||||||
|
#define BUF_SIZ 65536
|
||||||
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
// defaults
|
||||||
|
uint total_bytes_recv = 0;
|
||||||
|
// for timing
|
||||||
|
double elapsedTime;
|
||||||
|
struct timeval t_start, t_end;
|
||||||
|
// for socket
|
||||||
|
int fd = 0; // file descriptor of file to write (receive)
|
||||||
|
int sockfd; // socket
|
||||||
|
char recvbuf[BUF_SIZ];
|
||||||
|
struct sockaddr_in servaddr, cliaddr;
|
||||||
|
socklen_t clilen;
|
||||||
|
// for misc
|
||||||
|
int ret;
|
||||||
|
int recvsize = 4096;
|
||||||
|
|
||||||
|
if (argc < 3)
|
||||||
|
{
|
||||||
|
printf("Usage: %s <ip> <port> <[optional] recvsize (bytes)> <[optional] filepath>\n", argv[0]);
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
// set sendsize (if larger than 1460 will do packetization (fragmentation))
|
||||||
|
if (argc > 3)
|
||||||
|
recvsize = atoi(argv[3]);
|
||||||
|
|
||||||
|
// bind socket
|
||||||
|
sockfd = socket(AF_INET, SOCK_DGRAM, 0);
|
||||||
|
bzero(&servaddr, sizeof(servaddr));
|
||||||
|
servaddr.sin_family = AF_INET;
|
||||||
|
servaddr.sin_addr.s_addr = inet_addr(argv[2]);
|
||||||
|
servaddr.sin_port = htons(atoi(argv[3]));
|
||||||
|
|
||||||
|
// if instrument to write to a file
|
||||||
|
if (argc > 4)
|
||||||
|
{
|
||||||
|
fd = open(argv[4], O_WRONLY | O_CREAT | O_TRUNC);
|
||||||
|
if (fd == -1) {
|
||||||
|
fprintf(stderr, "! Unable to open file %s.\n", argv[2]);
|
||||||
|
close(sockfd);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = sendto(sockfd, "!?=\n", 4, 0, (struct sockaddr *)&servaddr, sizeof(servaddr));
|
||||||
|
if (ret <= 0)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "! Unable to initialize data transfer. errno:%d.\n", errno);
|
||||||
|
close(sockfd);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// start timing
|
||||||
|
gettimeofday(&t_start, NULL);
|
||||||
|
|
||||||
|
// start to receive
|
||||||
|
for (;;)
|
||||||
|
{
|
||||||
|
// printf("before: total_bytes_recv %d\n", total_bytes_recv);
|
||||||
|
ret = recvfrom(sockfd, recvbuf, recvsize, 0, NULL, NULL);
|
||||||
|
|
||||||
|
if (ret <= 0)
|
||||||
|
{
|
||||||
|
if (errno == 0)
|
||||||
|
break;
|
||||||
|
fprintf(stderr, "! Fail to recv: ret:%d, err:%d; quiting..\n", ret, errno);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// a "code" to indicate UDP is done
|
||||||
|
// printf("%d %d %d", (recvbuf[0] == '='), (recvbuf[1] == '?'), (recvbuf[0] == '!'));
|
||||||
|
if ((recvbuf[0] == '=') && (recvbuf[1] == '?') && (recvbuf[2] == '!'))
|
||||||
|
break;
|
||||||
|
|
||||||
|
if (argc > 4)
|
||||||
|
write(fd, recvbuf, ret);
|
||||||
|
|
||||||
|
// count how many bytes received
|
||||||
|
total_bytes_recv += ret;
|
||||||
|
// printf("after: total_bytes_recv %d\n", total_bytes_recv);
|
||||||
|
}
|
||||||
|
|
||||||
|
// end timing
|
||||||
|
gettimeofday(&t_end, NULL);
|
||||||
|
elapsedTime = (t_end.tv_sec - t_start.tv_sec) + (t_end.tv_usec - t_start.tv_usec) / 1000000.0;
|
||||||
|
printf(
|
||||||
|
"recv(bytes):%d\nduration(s):%lf\nthroughput(bps):%lf\n",
|
||||||
|
total_bytes_recv, elapsedTime, total_bytes_recv * 8 / elapsedTime);
|
||||||
|
|
||||||
|
close(sockfd);
|
||||||
|
if (argc > 4)
|
||||||
|
close(fd);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
Binary file not shown.
|
|
@ -10,3 +10,11 @@ cd client_send_normaltcp && make clean && make
|
||||||
cd ../
|
cd ../
|
||||||
cd client_readfile_only && make clean && make
|
cd client_readfile_only && make clean && make
|
||||||
cd ../
|
cd ../
|
||||||
|
cd client_recv_normaltcp && make clean && make
|
||||||
|
cd ../
|
||||||
|
cd client_recv_normaludp && make clean && make
|
||||||
|
cd ../
|
||||||
|
cd server_recv_normaltcp && make clean && make
|
||||||
|
cd ../
|
||||||
|
cd server_recv_normaludp && make clean && make
|
||||||
|
cd ../
|
||||||
|
|
|
||||||
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue