Hi,
I am planning to use netmap-rumptcpip to increase the performance. So, I
was trying to measure the PPS and CPS by writing a small client server
program.
But, unfortunately I am getting very small CPS, it is coming in the range
of few hundreds where as if I use without this I get in thousands. So, I am
thinking I might be doing something wrong in using netmap-rumptcpip. Would
it be possible for you to have a look at it and advice why I am getting
such a low rate.
I have modified the netmapcat program to measure the number of tcp
connections it can accept per second. I have attached the program.
Changes are as below:
1. Server keeps on accepting the connection and closes once it gets
connected (just to see the no. of connection).
2. when SIGINT is passed it prints the numbers and exit.
3. client keeps on connecting in a infinite loop.
Command:
server:
./netmapcat vale:1 1.2.3.4 listen 8090
client:
./netmapcat vale:2 1.2.3.5 connect 1.2.3.4 8090
output of server :
~/netmap-rumptcpip/examples$ sudo ./netmapcat_s vale:1 1.2.3.4 listen 8090
netmap0 configured!
waiting for connection ...^CNumber of connections=765
Time = 7.18446744073709227090
average cps=109
Also, If cps number with respect to the rumptcpip is already measured,
Could you please share it.
Thanks
/*
* A very simple "netcat" workalike, to demonstrate one way to use
* the netmap backing interface with a rump kernel TCP/IP stack.
*/
#include <sys/types.h>
#include <sys/time.h>
#include <err.h>
#include <errno.h>
#include <inttypes.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#include <rump/rump.h>
#include <rump/rump_syscalls.h>
#include <rump/netconfig.h>
static void
usage(void)
{
fprintf(stderr, "usage: netmapcat netmapif [ip|dhcp] [connect|listen] "
"[addr port|port]\n");
exit(1);
}
unsigned long count=0;
struct timeval tv,tv2;
void signal_handler()
{
gettimeofday(&tv2,NULL);
printf("Number of connections=%lu\n",count);
printf("Time = %lu.%lu\n",(tv2.tv_sec - tv.tv_sec),(tv2.tv_usec - tv.tv_usec));
printf("average cps=%lu\n",(count/(tv2.tv_sec - tv.tv_sec)));
exit(-1);
}
static void
server(const char *port)
{
//char buf[1024];
struct sockaddr_in sin;
//ssize_t nn;
int s, s2, firstFlag=0;
socklen_t slen;
signal(SIGINT,signal_handler);
s = rump_sys_socket(RUMP_PF_INET, RUMP_SOCK_STREAM, 0);
if (s == -1) {
fprintf(stderr, "socket %d\n", errno);
return;
}
memset(&sin, 0, sizeof(sin));
sin.sin_family = RUMP_AF_INET;
sin.sin_port = htons(atoi(port));
sin.sin_addr.s_addr = INADDR_ANY;
if (rump_sys_bind(s, (struct sockaddr *)&sin, sizeof(sin)) == -1) {
fprintf(stderr, "bind %d\n", errno);
return;
}
if (rump_sys_listen(s, 1) == -1) {
fprintf(stderr, "listen %d\n", errno);
return;
}
fprintf(stderr, "waiting for connection ...");
for(;;)
{
slen = sizeof(sin);
if ((s2 = rump_sys_accept(s, (struct sockaddr *)&sin, &slen)) == -1) {
fprintf(stderr, "accept errno %d\n", errno);
return;
}
if(firstFlag==0)
{
gettimeofday(&tv,NULL);
firstFlag = 1;
}
count++;
rump_sys_close(s2);
}
#if 0
slen = sizeof(sin);
if ((s2 = rump_sys_accept(s, (struct sockaddr *)&sin, &slen)) == -1) {
fprintf(stderr, "accept %d\n", errno);
return;
}
fprintf(stderr, "connected!\n");
while ((nn = rump_sys_read(s2, buf, sizeof(buf))) > 0) {
if (write(STDOUT_FILENO, buf, nn) != nn) {
fprintf(stderr, "stdout write failed\n");
return;
}
}
if (nn != 0) {
fprintf(stderr, "socket read failed: %d\n", errno);
} else {
fprintf(stderr, "EOF\n");
}
#endif
rump_sys_close(s2);
}
static void
client(const char *addr, const char *port)
{
//char buf[1024];
struct sockaddr_in sin;
//ssize_t nn;
int s;
memset(&sin, 0, sizeof(sin));
sin.sin_family = RUMP_AF_INET;
sin.sin_port = htons(atoi(port));
sin.sin_addr.s_addr = inet_addr(addr);
signal(SIGINT,signal_handler);
gettimeofday(&tv,NULL);
while(1) {
s = rump_sys_socket(RUMP_PF_INET, RUMP_SOCK_STREAM, 0);
if (s == -1) {
fprintf(stderr, "socket %d\n", errno);
return;
}
#if 0
memset(&sin, 0, sizeof(sin));
sin.sin_family = RUMP_AF_INET;
sin.sin_port = htons(atoi(port));
sin.sin_addr.s_addr = inet_addr(addr);
// fprintf(stderr, "connecting ... ");
#endif
if (rump_sys_connect(s, (struct sockaddr *)&sin, sizeof(sin)) == -1) {
fprintf(stderr, "connect failed: %d\n", errno);
return;
}
// fprintf(stderr, "connected!\n");
#if 0
while ((nn = read(STDIN_FILENO, buf, sizeof(buf))) > 0) {
if (rump_sys_write(s, buf, nn) != nn) {
fprintf(stderr, "socket write failed\n");
return;
}
}
if (nn != 0) {
fprintf(stderr, "stdin read failed: %d\n", errno);
} else {
fprintf(stderr, "EOF\n");
}
#endif
count++;
rump_sys_close(s);
}
sleep(1); /* give a chance for everything to be transmitted */
}
#define IS_SERVER (strcmp(role, "listen") == 0)
int
main(int argc, char *argv[])
{
const char *netmapif = argv[1];
const char *ifaddr = argv[2];
const char *role = argv[3];
int error;
if (IS_SERVER && argc != 5)
usage();
if (!IS_SERVER && argc != 6)
usage();
rump_init();
error = rump_pub_netconfig_ifcreate("netmap0");
if (error)
errx(1, "ifcreate %d", error);
error = rump_pub_netconfig_ifsetlinkstr("netmap0", netmapif);
if (error)
errx(1, "linkstr %d", error);
if (strcmp(ifaddr, "dhcp") == 0) {
error = rump_pub_netconfig_dhcp_ipv4_oneshot("netmap0");
} else {
error = rump_pub_netconfig_ipv4_ifaddr("netmap0",
ifaddr, "255.255.255.0");
}
if (error)
errx(1, "interface configuration failed: %d\n", error);
fprintf(stderr, "netmap0 configured!\n");
if (IS_SERVER)
server(argv[4]);
else
client(argv[4], argv[5]);
rump_sys_reboot(0, NULL);
exit(0);
}
------------------------------------------------------------------------------
Is your legacy SCM system holding you back? Join Perforce May 7 to find out:
• 3 signs your SCM is hindering your productivity
• Requirements for releasing software faster
• Expert tips and advice for migrating your SCM now
http://p.sf.net/sfu/perforce
_______________________________________________
rumpkernel-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/rumpkernel-users