Hi,

I set up a scenario to test the speed of rtnet but my results aren't
satisfying.

Set up:
1. Notebook (#1) - IBM T42, Linux 2.6.19.7, Xenomai 2.3.1, RTNet 0.9.9,
driver rt_e1000
2. Notebook (#2) - ASUS A6000, Linux 2.6.19.7, Xenomai 2.3.1, RTNet 0.9.9,
driver rt_r8169

Because starting up in KDE mode gave IRQ conflicts, I had to use "CTRL-F1"
(I don't know how I have to call it).
I used the following code to startup RT-Net in CTRL-F1 mode (for #1)
--
ifconfig eth0 down
rmmod e1000
insmod /usr/local/rtnet/modules/rtnet.ko
insmod /usr/local/rtnet/modules/rtipv4.ko
insmod /usr/local/rtnet/modules/rtpacket.ko
insmod /usr/local/rtnet/modules/rt_e1000.ko
/usr/local/rtnet/sbin/rtifconfig rteth0 up 10.0.0.1
/usr/local/rtnet/sbin/rtroute add 10.0.0.2 "MAC-Adres" dev rteth0
--

#1 runs 2 programms, 1 in CTRL-F1, the packet sender. And 1 in CTRL-F2, the
packet receiver.
#2 runs 1 programm which rebounds the packets.
The programms are based on frag-ip and are in the attachment.

I got the following results with sending 1000 packets which have a size of
1514+10 bytes.
Period [ns]  Mean [ns]
50000          130189.90
100000        122516.10
150000        108576.57
250000        108763.02
500000        110926.49

The time is measured by making a timestamp on send time and comparing this
timestamp with the timestamp when received on the same notebook.

I don't know why the large times are caused.

My First question is, what could have caused these great time values?
Second is, does anyone else have some test results and scripts so I can
compare the results and set up.

If something is unclear feel free to ask for clarification

Thanks in advance,

Jeroen
/***
 *
 *  examples/xenomai/frag-ip.c
 *
 *  sends fragmented IP packets to another frag-ip instance - Xenomai version
 *
 *  Copyright (C) 2003-2005 Jan Kiszka <[EMAIL PROTECTED]>
 *
 *  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 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <signal.h>
#include <unistd.h>
#include <sys/mman.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>

#include <native/task.h>
#include <rtnet.h>
#include <native/timer.h>

unsigned int size = 1514;
unsigned int add_rtskbs = 75;

RT_TASK rt_recv_task;

#define PORT        37000

struct sockaddr_in dest_addr;
char *dest_ip_s = "10.0.0.2";

int sock;

char buffer_out[1514];
char buffer_in[1514];

void recv_msg(void *arg)
{
	int ret;
	struct msghdr msg;	// Incoming msg
	struct msghdr msg2;	// Outgoing msg
	struct iovec iov[3];
	struct iovec iov2[3];
	unsigned short msgsize;// = size;
	struct sockaddr_in addr;
	unsigned long long curTime;

	while (1) {
		iov[0].iov_base = &msgsize;
		iov[0].iov_len  = sizeof(msgsize);
		iov[1].iov_base = buffer_in;
		iov[1].iov_len  = size;
		iov[2].iov_base = &curTime;
		iov[2].iov_len  = sizeof(curTime);

		memset(&msg, 0, sizeof(msg));
		msg.msg_name    = &addr;
		msg.msg_namelen = sizeof(addr);
		msg.msg_iov     = iov;
		msg.msg_iovlen  = 3;
	    
	    	ret = rt_dev_recvmsg(sock, &msg, 0);
		if (ret <= 0) {
			printf(" rt_dev_recvmsg() = %d\n", ret);
			return;
		} else {
			unsigned long ip = ntohl(addr.sin_addr.s_addr);
	
			// printf("msgsize %d\n", msgsize);
			iov2[0].iov_base = &msgsize;
			iov2[0].iov_len  = sizeof(msgsize);
			iov2[1].iov_base = buffer_in;
			iov2[1].iov_len  = size;
			iov2[2].iov_base = &curTime;
			iov2[2].iov_len  = sizeof(curTime);
			
			memset(&msg2, 0, sizeof(msg2));
			msg2.msg_name    = &dest_addr;
			msg2.msg_namelen = sizeof(dest_addr);
			msg2.msg_iov     = iov2;
			msg2.msg_iovlen  = 3;		
			
      			//printf("Sending message of %d+2 bytes\n", size);
			ret = rt_dev_sendmsg(sock, &msg2, 0);
			if (ret == -EBADF) {
				return;
			}
			else if (ret != (int)(sizeof(msgsize) + size + sizeof(curTime))) {
				printf(" rt_dev_sendmsg() = %d!\n", ret);
			}
		}

	}
}



void catch_signal(int sig)
{
}


int main(int argc, char *argv[])
{
	int ret;
	unsigned int i;
	struct sockaddr_in local_addr;
	struct in_addr dest_ip;
	
	if (size > 65505)
		size = 65505;

	inet_aton(dest_ip_s, &dest_ip);

        printf("destination ip address %s=%08x\n", dest_ip_s, dest_ip.s_addr);

	signal(SIGTERM, catch_signal);
	signal(SIGINT, catch_signal);
	signal(SIGHUP, catch_signal);
	mlockall(MCL_CURRENT|MCL_FUTURE);
	
	/* fill output buffer with test pattern */
	for (i = 0; i < sizeof(buffer_out); i++)
		buffer_out[i] = i & 0xFF;
	
	/* create rt-socket */
	sock = rt_dev_socket(AF_INET,SOCK_DGRAM,0);
	if (sock < 0) {
		printf(" rt_dev_socket() = %d!\n", sock);
		return sock;
	}
	
	/* extend the socket pool */
	ret = rt_dev_ioctl(sock, RTNET_RTIOC_EXTPOOL, &add_rtskbs);
	if (ret != (int)add_rtskbs) {
		printf(" rt_dev_ioctl(RT_IOC_SO_EXTPOOL) = %d\n", ret);
		rt_dev_close(sock);
		return -1;
	}
	
	/* bind the rt-socket to a port */
	memset(&local_addr, 0, sizeof(struct sockaddr_in));
	local_addr.sin_family = AF_INET;
	local_addr.sin_port = htons(PORT);
	local_addr.sin_addr.s_addr = INADDR_ANY;
	ret = rt_dev_bind(sock, (struct sockaddr *)&local_addr,
			sizeof(struct sockaddr_in));
	if (ret < 0) {
		printf(" rt_dev_bind() = %d!\n", ret);
		rt_dev_close(sock);
		return ret;
	}
	
	/* set destination address */
	memset(&dest_addr, 0, sizeof(struct sockaddr_in));
	dest_addr.sin_family = AF_INET;
	dest_addr.sin_port = htons(PORT);
	dest_addr.sin_addr = dest_ip;
	
	/* You may have to start the system timer manually
	* on older Xenomai versions (2.0.x):
	* rt_timer_start(TM_ONESHOT); */
	
	ret = rt_task_create(&rt_recv_task, "Receiver", 0, 99, 0);
	if (ret != 0) {
		printf(" rt_task_create(recv) = %d!\n", ret);
		rt_dev_close(sock);
		return ret;
	}
	
	rt_task_start(&rt_recv_task, recv_msg, NULL);
	
	pause();
	
	/* In case you started it in this program, see comment above.
	* rt_timer_stop(); */
	
	/* Note: The following loop and the strict ordering "close before task
	*       termination" is no longer required since Xenomai 2.4. */
	while (rt_dev_close(sock) == -EAGAIN) {
		printf("frag-ip: Socket busy - waiting...\n");
		sleep(1);
	}


        if(ret = rt_task_delete(&rt_recv_task)) {
                printf("*** Error ***  rt_task_delete() = %d!\n", ret);
        } else {
                printf("*** Debug *** Deleting task OK\n");
        }
	return 0;
}
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <signal.h>
#include <unistd.h>
#include <sys/mman.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>

#include <native/task.h>
#include <rtnet.h>
#include <native/timer.h>

unsigned int size = 1514;
unsigned int add_rtskbs = 75;

#define CYCLE       1000*1000*1000   /* 1 s */
#define ONE_SEC		1000000000ULL
#define ONE_MIL		1000000ULL
#define ONE_MIC		1000ULL

RT_TASK rt_recv_task;

#define PORT        37000

struct sockaddr_in dest_addr;

int sock;

char buffer_in[1514];

typedef unsigned long long uint64;

uint64 curTime;
uint64 duration = 10 * ONE_MIL;
uint64 period   = 10 * ONE_MIC;
unsigned int iCycles;

FILE * fd;

void recv_msg(void *arg)
{
	int i, ret;
	struct msghdr msg;
	struct iovec iov[3];
	unsigned short msgsize;// = size;
	struct sockaddr_in addr;
	int cpt = 0;
	uint64 tijd_tabel[iCycles][2];
        char res_file_name[100];

	while (cpt < iCycles) {
		iov[0].iov_base = &msgsize;
		iov[0].iov_len  = sizeof(msgsize);
		iov[1].iov_base = buffer_in;
		iov[1].iov_len  = size;
		iov[2].iov_base = &curTime;
		iov[2].iov_len  = sizeof(curTime);

		memset(&msg, 0, sizeof(msg));
		msg.msg_name    = &addr;
		msg.msg_namelen = sizeof(addr);
		msg.msg_iov     = iov;
		msg.msg_iovlen  = 3;
	
		ret = rt_dev_recvmsg(sock, &msg, 0);
		if (ret <= 0) {
			printf(" rt_dev_recvmsg() = %d\n", ret);
			return;
		} else {
			tijd_tabel[cpt][1] = (uint64) rt_timer_tsc2ns(rt_timer_tsc());
			tijd_tabel[cpt][0] = (uint64) curTime;
		}
		cpt++;

	}
	printf("No cycles remaining\n");
	printf("Outputting Timetable, please wait\n");
	
	sprintf(res_file_name,"./results/res_%d_%d.txt",size,period);
	
	fd = fopen(res_file_name,"w+");
	if (fd == NULL){
		perror("Kon bestand niet openen");
		exit(2);
	}
	
	fprintf(fd,"# Size %d\n# Tijd %llu\n# Cycles %d\n# Period %d\n", ret, duration, iCycles, period);
	fprintf(fd,"#\tCycle\tSendTime\tReceiveTime\tDifference\n");
	
	for (i = 0; i < iCycles; i++) {
		fprintf(fd,"\t%d\t%llu\t%llu\t%llu\n",i,tijd_tabel[i][0], tijd_tabel[i][1], tijd_tabel[i][1]-tijd_tabel[i][0]);
	}

	fclose(fd);
	printf("Timetable printed in %s\n", res_file_name);
	printf("Finished\n");
}

void catch_signal(int sig)
{
}

int main(int argc, char *argv[])
{
	int ret;
	unsigned int i;
	struct sockaddr_in local_addr;
	
	if (size > 65505)
		size = 65505;
	
	signal(SIGTERM, catch_signal);
	signal(SIGINT, catch_signal);
	signal(SIGHUP, catch_signal);
	mlockall(MCL_CURRENT|MCL_FUTURE);
	
	iCycles = duration / period;

	/* create rt-socket */
	sock = rt_dev_socket(AF_INET,SOCK_DGRAM,0);
	if (sock < 0) {
		printf(" rt_dev_socket() = %d!\n", sock);
		return sock;
	}
	
	/* extend the socket pool */
	ret = rt_dev_ioctl(sock, RTNET_RTIOC_EXTPOOL, &add_rtskbs);
	if (ret != (int)add_rtskbs) {
		printf(" rt_dev_ioctl(RT_IOC_SO_EXTPOOL) = %d\n", ret);
		rt_dev_close(sock);
		return -1;
	}
	
	/* bind the rt-socket to a port */
	memset(&local_addr, 0, sizeof(struct sockaddr_in));
	local_addr.sin_family = AF_INET;
	local_addr.sin_port = htons(PORT);
	local_addr.sin_addr.s_addr = INADDR_ANY;
	ret = rt_dev_bind(sock, (struct sockaddr *)&local_addr,
			sizeof(struct sockaddr_in));
	if (ret < 0) {
		printf(" rt_dev_bind() = %d!\n", ret);
		rt_dev_close(sock);
		return ret;
	}
	
	ret = rt_task_create(&rt_recv_task, "Receiver", 0, 99, 0);
	if (ret != 0) {
		printf(" rt_task_create(recv) = %d!\n", ret);
		rt_dev_close(sock);
		return ret;
	}
	
	rt_task_start(&rt_recv_task, recv_msg, NULL);
	
	pause();
	
	/* Note: The following loop and the strict ordering "close before task
	*       termination" is no longer required since Xenomai 2.4. */
	while (rt_dev_close(sock) == -EAGAIN) {
		printf("frag-ip: Socket busy - waiting...\n");
		sleep(1);
	}

        if(ret = rt_task_delete(&rt_recv_task)) {
		printf("*** Error ***  rt_task_delete() = %d!\n", ret);
        } else {
                printf("*** Debug *** Deleting task OK\n");
        }

    	return 0;
}
/***
 *
 *  examples/xenomai/frag-ip.c
 *
 *  sends fragmented IP packets to another frag-ip instance - Xenomai version
 *
 *  Copyright (C) 2003-2005 Jan Kiszka <[EMAIL PROTECTED]>
 *
 *  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 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <signal.h>
#include <unistd.h>
#include <sys/mman.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>

#include <native/task.h>
#include <native/timer.h>
#include <rtnet.h>

char *dest_ip_s = "10.0.0.1";
//#define BUFF_SIZE	6500
unsigned int size = 1514;
unsigned int add_rtskbs = 75;

#define ONE_SEC		1000000000ULL
#define ONE_MIL		1000000ULL
#define ONE_MIC		1000ULL


RT_TASK rt_xmit_task;

#define PORT        37000

struct sockaddr_in dest_addr;

int sock;

char buffer_out[1514];

typedef unsigned long long uint64;

uint64 curTime;
uint64 duration = 10 * ONE_MIL;
uint64 period   = 10 * ONE_MIC;

unsigned int nb_cycles;

void xmit_msg(void *arg)
{
	int ret;
	int cpt = 0;
	struct msghdr msg;
	struct iovec iov[3];
	unsigned short msgsize = size;


	rt_task_set_periodic(NULL, TM_NOW, period);
	while (1) {
		if(cpt < nb_cycles)
		{	
		    curTime = rt_timer_tsc2ns(rt_timer_tsc());
		    //printf("verzonden tijd: %llu\n", curTime);

		    iov[0].iov_base = &msgsize;
		    iov[0].iov_len  = sizeof(msgsize);
		    iov[1].iov_base = buffer_out;
		    iov[1].iov_len  = size;
		    iov[2].iov_base = &curTime;
		    iov[2].iov_len  = sizeof(curTime);
	
		    memset(&msg, 0, sizeof(msg));
		    msg.msg_name    = &dest_addr;
		    msg.msg_namelen = sizeof(dest_addr);
		    msg.msg_iov     = iov;
		    msg.msg_iovlen  = 3;
		    // printf("Sending message of %d+2 bytes\n", (int)(sizeof(msgsize) + size + sizeof(curTime)));//size);
		    // printf("sizeof(msgsize): %d\nsize: %d\nsizeof(curTime): %d\n",sizeof(msgsize), size, sizeof(curTime));
		    ret = rt_dev_sendmsg(sock, &msg, 0);
		    if (ret == -EBADF)
			return;
		    else if (ret != (int)(sizeof(msgsize) + size + sizeof(curTime)))
			printf(" rt_dev_sendmsg() = %d!\n", ret);
		    // printf("ret: %d\tsize: %d\tsizeof(msgsize):%d\tsizeof(curTime):%d\ttotal:%d\n",ret,size,sizeof(msgsize),sizeof(curTime),(int)(sizeof(msgsize) + size + sizeof(curTime)));
		    cpt++;
		}
		if(cpt == nb_cycles) {
		    printf("No cycles remaining. Press Ctrl+C to quit.\n");
		    cpt++;
		}
		rt_task_wait_period(NULL);
	}
}

void catch_signal(int sig)
{
}


int main(int argc, char *argv[])
{
	int ret;
	unsigned int i;
	struct sockaddr_in local_addr;
	struct in_addr dest_ip;
	
	
	while (1) {
		switch (getopt(argc, argv, "d:s:")) {
		case 'd':
			dest_ip_s = optarg;
			break;
	
		case 's':
			size = atoi(optarg);
			break;
	
		case -1:
			goto end_of_opt;
	
		default:
			printf("usage: %s [-d <dest_ip>] [-s <size>]\n", argv[0]);
			return 0;
		}
	}
	end_of_opt:
	
	inet_aton(dest_ip_s, &dest_ip);
	
	if (size > 65505)
		size = 65505;
	
	signal(SIGTERM, catch_signal);
	signal(SIGINT, catch_signal);
	signal(SIGHUP, catch_signal);
	mlockall(MCL_CURRENT|MCL_FUTURE);
	
	printf("destination ip address %s=%08x\n", dest_ip_s, dest_ip.s_addr);
	printf("size %d\n", size);
	
	/* fill output buffer with test pattern */
	for (i = 0; i < sizeof(buffer_out); i++)
		buffer_out[i] = i & 0xFF;

	nb_cycles = duration / period;
	
	/* create rt-socket */
	sock = rt_dev_socket(AF_INET,SOCK_DGRAM,0);
	if (sock < 0) {
		printf(" rt_dev_socket() = %d!\n", sock);
		return sock;
	}
	
	/* extend the socket pool */
	ret = rt_dev_ioctl(sock, RTNET_RTIOC_EXTPOOL, &add_rtskbs);
	if (ret != (int)add_rtskbs) {
		printf(" rt_dev_ioctl(RT_IOC_SO_EXTPOOL) = %d\n", ret);
		rt_dev_close(sock);
		return -1;
	}
	
	/* bind the rt-socket to a port */
	memset(&local_addr, 0, sizeof(struct sockaddr_in));
	local_addr.sin_family = AF_INET;
	local_addr.sin_port = htons(PORT);
	local_addr.sin_addr.s_addr = INADDR_ANY;
	ret = rt_dev_bind(sock, (struct sockaddr *)&local_addr,
			sizeof(struct sockaddr_in));
	if (ret < 0) {
		printf(" rt_dev_bind() = %d!\n", ret);
		rt_dev_close(sock);
		return ret;
	}
	
	/* set destination address */
	memset(&dest_addr, 0, sizeof(struct sockaddr_in));
	dest_addr.sin_family = AF_INET;
	dest_addr.sin_port = htons(PORT);
	dest_addr.sin_addr = dest_ip;
	
	/* You may have to start the system timer manually
	* on older Xenomai versions (2.0.x):
	* rt_timer_start(TM_ONESHOT); */
	
	ret = rt_task_create(&rt_xmit_task, "Sender", 0, 98, 0);
	if (ret != 0) {
		printf(" rt_task_create(xmit) = %d!\n", ret);
		rt_dev_close(sock);
		return ret;
	}
	
	rt_task_start(&rt_xmit_task, xmit_msg, NULL);
	
	pause();
	
	/* In case you started it in this program, see comment above.
	* rt_timer_stop(); */
	
	/* Note: The following loop and the strict ordering "close before task
	*       termination" is no longer required since Xenomai 2.4. */
	while (rt_dev_close(sock) == -EAGAIN) {
		printf("frag-ip: Socket busy - waiting...\n");
		sleep(1);
	}

        if(ret = rt_task_delete(&rt_xmit_task)) {
                printf("*** Error ***  rt_task_delete() = %d!\n", ret);
        } else {
                printf("*** Debug *** Deleting task OK\n");
        }
    	return 0;
}
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
RTnet-users mailing list
RTnet-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rtnet-users

Reply via email to