Commit 84cdb74b authored by Arne Øslebø's avatar Arne Øslebø Committed by yorn

Videreutvikling UNINETT

blant annet mtp multicast
parent ea78f2bf
......@@ -22,10 +22,20 @@ START NOW
## 1000 packets/second with 1000 bytes/packet = 1000kbytes/sec
##
## 1 second from that the flow is turned off...
##
1000 0030 ON 3002 10.1.1.1:10001 CONSTANT 200 250
3000 0030 MODIFY CONSTANT 400 500
4000 0030 MODIFY CONSTANT 1000 1000
1000 0030 ON 1030 192.168.1.1:1031 CONSTANT 200 250
#2000 0030 MODIFY CONSTANT 400 500
#4000 0030 MODIFY CONSTANT 1000 1000
# IPv4 multicast address
#1000 0030 ON 1030 224.0.2.123:1031 CONSTANT 10 256
# IPv6 unicast address
#1000 0030 ON 1030 2001:718:1:b:21f:d0ff:feae:64b2:1031 CONSTANT 10 512
# ipv6 multicast address
#1000 0030 ON 1030 FF3E:040:2001:718:2:981:ACAC:ACCA:1031 CONSTANT 10 1024
5000 0030 OFF
## FLOW 2: (flow ID = 25)
......@@ -36,16 +46,16 @@ START NOW
## Sets the TOS for this flow to LOW_DELAY (0x10)
##
## 9 seconds after that the flow is turned off...
##
0000 0025 ON 3001 10.1.1.1:10001 CONSTANT 400 100
TOS 0025 0x10
9000 0025 OFF
#
#0000 0025 ON 1025 hostname.domain.com:1026 CONSTANT 400 100
#TOS 0025 0x10
#9000 0025 OFF
## FLOW 3: (flow ID = 1)
##
## This flow acts as specified in the TRACE configuration file.
## Read the README.rude file for the command and file syntax
##
0000 1 ON 3111 10.1.1.1:10001 TRACE trace_file.txt
9999 1 OFF
#0000 1 ON 1001 10.1.1.1:1002 TRACE trace_file.txt
#9999 1 OFF
## ... and that's it.
# Generated automatically from Makefile.in by configure.
# $Id: Makefile.in,v 1.1 2005/05/31 07:12:38 ubik Exp $
#
# autoconf/Makefile.in - the main Makefile template for RUDE and CRUDE
#
# Authors: Juha Laine <james@cs.tut.fi>
# Sampo Saaristo <sambo@cc.tut.fi>
#
# Copyright (C) 1999 Juha Laine, Tampere, Finland
# All rights reserved
#
##############################################################################
SHELL = /bin/sh
SUBDIRS = rude crude
all:
@for i in $(SUBDIRS); do \
(cd $$i && $(MAKE) all) \
done
clean:
rm -f *~ config.cache config.log config.status
@for i in $(SUBDIRS); do \
(cd $$i && $(MAKE) clean) \
done
distclean:
rm -f *~ config.cache config.log config.status configure Makefile
rm -f doc/*~ autoconf/config.hin include/config.h include/stamp.h
@for i in $(SUBDIRS); do \
(cd $$i && $(MAKE) distclean) \
done
rude:
cd rude && $(MAKE) all
crude:
cd crude && $(MAKE) all
install:
@for i in $(SUBDIRS); do \
(cd $$i && $(MAKE) install) \
done
##############################################################################
# Rules for autoconfiguration file REmaking
##############################################################################
update: include/stamp.h
include/stamp.h: autoconf/config.hin configure autoconf/Makefile.in rude/Makefile.in crude/Makefile.in
./configure
autoconf/config.hin: autoconf/acconfig.h
@autoheader -l ./autoconf
@touch autoconf/config.hin
@echo "****************************"
@echo "* header templates updated *"
@echo "****************************"
configure: autoconf/configure.in
rm -f config.*
@autoconf autoconf/configure.in > configure; chmod 755 configure
@echo "****************************"
@echo "* configure script updated *"
@echo "****************************"
##############################################################################
# $Id$
# $Id: Makefile.in,v 1.1 2005/05/31 07:12:38 ubik Exp $
#
# autoconf/Makefile.in - the main Makefile template for RUDE and CRUDE
#
......
/* autoconf/config.hin. Generated automatically from configure.in by autoheader 2.13. */
/***************************************************************************
* autoconfig/acconfig.h *
* - is the template file for autoconfig/config.hin which is generated *
* by the autoheader command *
* *
* autoconfig/config.hin *
* - is the template for include/config.h, that will be gererated by *
* the ./configure script *
* *
* include/config.h *
* - is the file that has the definitions/options for the pre-processor *
* *
***************************************************************************/
/* Define to empty if the keyword does not work. */
#undef const
/* Define to `int' if <sys/types.h> doesn't define. */
#undef gid_t
/* Define if you have <sys/wait.h> that is POSIX.1 compatible. */
#undef HAVE_SYS_WAIT_H
/* Define if you need to in order for stat and other things to work. */
#undef _POSIX_SOURCE
/* Define if you have the ANSI C header files. */
#undef STDC_HEADERS
/* Define if you can safely include both <sys/time.h> and <time.h>. */
#undef TIME_WITH_SYS_TIME
/* Define if your <sys/time.h> declares struct tm. */
#undef TM_IN_SYS_TIME
/* Define to `int' if <sys/types.h> doesn't define. */
#undef uid_t
/* Define if you have the gettimeofday function. */
#undef HAVE_GETTIMEOFDAY
/* Define if you have the munlockall function. */
#undef HAVE_MUNLOCKALL
/* Define if you have the select function. */
#undef HAVE_SELECT
/* Define if you have the sigaction function. */
#undef HAVE_SIGACTION
/* Define if you have the strerror function. */
#undef HAVE_STRERROR
/* Define if you have the <signal.h> header file. */
#undef HAVE_SIGNAL_H
/* Define if you have the <sys/time.h> header file. */
#undef HAVE_SYS_TIME_H
/* Define if you have the <unistd.h> header file. */
#undef HAVE_UNISTD_H
/* Amount of DEBUGGING output */
#undef DEBUG
/* End of file */
# $Id$
# $Id: configure.in,v 1.1 2005/05/31 07:12:38 ubik Exp $
#
# autoconf/configure.in for RUDE and CRUDE
#
......
This diff is collapsed.
# Generated automatically from Makefile.in by configure.
# $Id: Makefile.in,v 1.2 2005/06/30 12:02:49 juranek Exp $
#
# Makefile.in for CRUDE
#
# Authors: Juha Laine <james@cs.tut.fi>
# Sampo Saaristo <sambo@cc.tut.fi>
#
# Copyright (C) 1999 Juha Laine, Tampere, Finland
# All rights reserved
#
##############################################################################
SHELL = /bin/sh
prefix = /usr/local
exec_prefix = ${prefix}
bindir = ${exec_prefix}/bin
mandir = ${prefix}/man/man8
sbindir = ${exec_prefix}/sbin
srcdir = .
INSTALL = /usr/bin/install -c -o root -g root -m 0755
CC = gcc
CFLAGS = -O2 -I../include
LDFLAGS =
DEFS = -DHAVE_CONFIG_H
LIBS = -lm
MAN8 = crude.8
CRUDE_OBJS = main.o ../rude/mcast.o
##############################################################################
# Rules for make
##############################################################################
.c.o:
$(CC) $(CFLAGS) $(DEFS) -c -o $*.o $<
all: crude
crude: $(CRUDE_OBJS)
$(CC) $(CFLAGS) $(LIBS) $(DEFS) $(LDFLAGS) -o crude $(CRUDE_OBJS)
clean:
rm -f *~ *.o crude
distclean:
rm -f *~ *.o crude Makefile
install: crude
@if [ ! -d $(bindir) ]; then mkdir -m 0755 $(bindir); fi;
$(INSTALL) crude $(bindir)
@if [ ! -d $(mandir) ]; then mkdir -m 0755 $(mandir); fi;
$(INSTALL) crude.8 $(mandir)
##############################################################################
# $Id$
# $Id: Makefile.in,v 1.2 2005/06/30 12:02:49 juranek Exp $
#
# Makefile.in for CRUDE
#
......@@ -29,7 +29,7 @@ DEFS = @DEFS@
LIBS = @LIBS@
MAN8 = crude.8
CRUDE_OBJS = main.o
CRUDE_OBJS = main.o ../rude/mcast.o
##############################################################################
# Rules for make
......
File added
This diff is collapsed.
File added
/* include/config.h. Generated automatically by configure. */
/* autoconf/config.hin. Generated automatically from configure.in by autoheader 2.13. */
/***************************************************************************
* autoconfig/acconfig.h *
* - is the template file for autoconfig/config.hin which is generated *
* by the autoheader command *
* *
* autoconfig/config.hin *
* - is the template for include/config.h, that will be gererated by *
* the ./configure script *
* *
* include/config.h *
* - is the file that has the definitions/options for the pre-processor *
* *
***************************************************************************/
/* Define to empty if the keyword does not work. */
/* #undef const */
/* Define to `int' if <sys/types.h> doesn't define. */
/* #undef gid_t */
/* Define if you have <sys/wait.h> that is POSIX.1 compatible. */
#define HAVE_SYS_WAIT_H 1
/* Define if you need to in order for stat and other things to work. */
/* #undef _POSIX_SOURCE */
/* Define if you have the ANSI C header files. */
#define STDC_HEADERS 1
/* Define if you can safely include both <sys/time.h> and <time.h>. */
#define TIME_WITH_SYS_TIME 1
/* Define if your <sys/time.h> declares struct tm. */
/* #undef TM_IN_SYS_TIME */
/* Define to `int' if <sys/types.h> doesn't define. */
/* #undef uid_t */
/* Define if you have the gettimeofday function. */
#define HAVE_GETTIMEOFDAY 1
/* Define if you have the munlockall function. */
#define HAVE_MUNLOCKALL 1
/* Define if you have the select function. */
#define HAVE_SELECT 1
/* Define if you have the sigaction function. */
#define HAVE_SIGACTION 1
/* Define if you have the strerror function. */
#define HAVE_STRERROR 1
/* Define if you have the <signal.h> header file. */
#define HAVE_SIGNAL_H 1
/* Define if you have the <sys/time.h> header file. */
#define HAVE_SYS_TIME_H 1
/* Define if you have the <unistd.h> header file. */
#define HAVE_UNISTD_H 1
/* Amount of DEBUGGING output */
/* #undef DEBUG */
/* End of file */
/*
* C Implementation: %{$MODULE}
*
* Description:
*
*
*
* Copyright: See COPYING file that comes with this distribution
*
*/
#include <mcast.h>
#include <rude.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
#include <stdio.h>
#include <errno.h>
#include <unistd.h>
#include <stdlib.h>
#include <time.h>
#include <net/if.h>
#include <sys/ioctl.h>
int
isMulticastAddr(struct sockaddr_storage *addr)
{
int retVal;
retVal=-1;
switch (addr->ss_family) {
case AF_INET: {
struct sockaddr_in *addr4=(struct sockaddr_in *)addr;
retVal = IN_MULTICAST(ntohl(addr4->sin_addr.s_addr));
} break;
case AF_INET6: {
struct sockaddr_in6 *addr6=(struct sockaddr_in6 *)addr;
retVal = IN6_IS_ADDR_MULTICAST(&addr6->sin6_addr);
} break;
default:
;
}
return retVal;
}
int joinGroup(int sockfd, int loopBack, unsigned int mcastTTL,struct sockaddr_storage *addr,int interface)
{
int r1, r2, r3, retval;
retval=-1;
switch (addr->ss_family) {
case AF_INET: {
struct ip_mreq mreq;
//zjistit adresu interfacu(v parametru je jeho index),INADDR_ANY je pro defaultni
mreq.imr_multiaddr.s_addr=
((struct sockaddr_in *)addr)->sin_addr.s_addr;
if(interface < 0){
mreq.imr_interface.s_addr= INADDR_ANY;
RUDEBUG7("joinGroup: using inaddr_any interface\n");
}
else{
struct ifreq ifr;
char name[IF_NAMESIZE];
RUDEBUG7("joinGroup: using interface %i\n",interface);
if(!if_indextoname(interface,name)){
RUDEBUG1("joinGroup: interface doesnt exist.\n");
return retval;
}
strcpy(ifr.ifr_name, name);
if(ioctl(sockfd,SIOCGIFADDR,&ifr)==-1){
RUDEBUG1("joinGroup() - ioctl failed for getting interface address: %s\n",strerror(errno));
return retval;
}
struct sockaddr_in *si = (struct sockaddr_in*)&ifr.ifr_addr;
RUDEBUG7("joinGroup(): interface address: %s\n",inet_ntoa(si->sin_addr));
//mreq.imr_interface.s_addr = si->sin_addr.s_addr;
memcpy(&mreq.imr_interface,&(si->sin_addr),sizeof(struct in_addr));
//mreq.imr_interface = si->sin_addr;
}
r1= setsockopt(sockfd, IPPROTO_IP, IP_MULTICAST_LOOP,
&loopBack, sizeof(loopBack));
if (r1<0)
RUDEBUG1("joinGroup:: IP_MULTICAST_LOOP:: ");
r2= setsockopt(sockfd, IPPROTO_IP, IP_MULTICAST_TTL,
&mcastTTL, sizeof(mcastTTL));
if (r2<0)
RUDEBUG1("joinGroup:: IP_MULTICAST_TTL:: ");
r3= setsockopt(sockfd, IPPROTO_IP, IP_ADD_MEMBERSHIP,
(const void *)&mreq, sizeof(mreq));
if (r3<0)
RUDEBUG1("joinGroup:: IP_ADD_MEMBERSHIP:: ");
} break;
case AF_INET6: {
struct ipv6_mreq mreq6;
memcpy(&mreq6.ipv6mr_multiaddr,
&(((struct sockaddr_in6 *)addr)->sin6_addr),
sizeof(struct in6_addr));
if(interface < 0){
mreq6.ipv6mr_interface= 0;
RUDEBUG7("joinGroup: using default interface\n");
}else{
mreq6.ipv6mr_interface= interface;
RUDEBUG7("joinGroup: using interface with index: %d\n",interface);
}
r1= setsockopt(sockfd, IPPROTO_IPV6, IPV6_MULTICAST_LOOP,
&loopBack, sizeof(loopBack));
if (r1<0)
RUDEBUG1("joinGroup(): IPV6_MULTICAST_LOOP error");
r2= setsockopt(sockfd, IPPROTO_IPV6, IPV6_MULTICAST_HOPS,
&mcastTTL, sizeof(mcastTTL));
if (r2<0)
RUDEBUG1("joinGroup() IPV6_MULTICAST_HOPS error ");
r3=setsockopt(sockfd,IPPROTO_IPV6,IPV6_JOIN_GROUP,&mreq6,sizeof(mreq6));
//r3=setsockopt(sockfd,IPPROTO_IPV6,IP_ADD_MEMBERSHIP,&mreq6,sizeof(mreq6));
if (r3<0)
RUDEBUG1("joinGroup() IPV6_JOIN_GROUP error ");
} break;
default:
r1=r2=r3=-1;
}
if ((r1>=0) && (r2>=0) && (r3>=0))
retval=0;
return retval;
}
//
// C++ Interface: %{MODULE}
//
// Description:
//
//
// Author: %{AUTHOR} <%{EMAIL}>, (C) %{YEAR}
//
// Copyright: See COPYING file that comes with this distribution
//
//
#include <netinet/in.h> /* for struct sockaddr_in */
int isMulticastAddr(struct sockaddr_storage *addr);
int joinGroup(int sockfd, int loopBack, unsigned int mcastTTL,struct sockaddr_storage *addr,int interface);
File added
......@@ -29,11 +29,14 @@
#define DNMAXLEN 128
#define TMAXLEN 32
#define PMINSIZE 20 /* Minimum accepted UDP-data field/packet size */
#define PMINSIZE 24 /* Minimum accepted UDP-data field/packet size, in previouse version it was 20 */
#define PMINSIZE_V6 40 /* Minimum accepted UDP-data field/packet size for ipv6 */
#define PMAXSIZE 32768 /* Maximum accepted UDP-data field/packet size */
#define MINDURAT 0.001 /* Minimum allowed flow duration in seconds (float) */
#define VERSION "0.62"
#define DEBUG 5
#define VERSION "0.7-multicast"
/*
* Enumeration definition for different (known) flow types
......@@ -51,8 +54,10 @@ typedef enum {
*/
struct cbr_params{
f_type ftype; /* Flow TRAFFIC TYPE */
int rate; /* Flow PACKET RATE (per second) */
int rate; /* Flow PACKET RATE - PACKAGE RATE per PERIOD */
int psize; /* Flow PACKET SIZE */
int package_size; /* Flow NUMBER OF PACKETS IN ONE PACKAGE*/
int time_period; /* Flow TIME_PERIOD */
};
/*
......@@ -76,16 +81,17 @@ struct trace_params{
* The main building block for flows
*/
struct flow_cfg {
struct flow_cfg *next; /* Pointer to NEXT flow */
struct flow_cfg *mod_flow; /* Next action-block for the flow */
struct sockaddr_in dst; /* Destination information */
int send_sock; /* Socket to be used by this flow */
long int flow_id; /* Flow IDENTIFICATION number */
unsigned short flow_sport; /* Flow SOURCE PORT number */
struct timeval flow_start; /* Absolute flow cmd START TIME */
struct timeval flow_stop; /* Absolute flow cmd END TIME */
struct timeval next_tx; /* Absolute next packet TX TIME */
struct flow_cfg *next; /* Pointer to NEXT flow */
struct flow_cfg *mod_flow; /* Next action-block for the flow */
struct sockaddr_storage dst; /* Destination information */
int send_sock; /* Socket to be used by this flow */
long int flow_id; /* Flow IDENTIFICATION number */
unsigned short flow_sport; /* Flow SOURCE PORT number */
struct timeval flow_start; /* Absolute flow cmd START TIME */
struct timeval flow_stop; /* Absolute flow cmd END TIME */
struct timeval next_tx; /* Absolute next packet TX TIME */
void (*send_func)(struct flow_cfg*); /* TX function for this flow */
......@@ -94,7 +100,8 @@ struct flow_cfg {
int sequence_nmbr; /* */
int tos; /* IP TOS byte if positive */
char *localIf; /* local interface to be used with multicast */
char prefferedVersion; /*preffered ip version(4 or 6)*/
union {
f_type ftype;
struct cbr_params cbr;
......@@ -111,7 +118,7 @@ struct udp_data{
unsigned long tx_time_seconds;
unsigned long tx_time_useconds;
unsigned long flow_id;
unsigned long dest_addr;
struct sockaddr_storage dest_addr;
}__attribute__ ((packed));
......@@ -121,9 +128,10 @@ struct udp_data{
struct crude_struct{
unsigned long rx_time_seconds;
unsigned long rx_time_useconds;
unsigned long src_addr;
//struct in6_addr src_addr;
long pkt_size;
unsigned short src_port;
struct sockaddr_storage src;
//unsigned short src_port;
unsigned short dest_port;
};
......@@ -157,4 +165,17 @@ struct crude_struct{
} while (0)
#endif
#ifndef timespecsub
#define timespecsub(tsp, usp, vsp) \
do { \
(vsp)->tv_sec = (tsp)->tv_sec - (usp)->tv_sec; \
(vsp)->tv_nsec = (tsp)->tv_nsec - (usp)->tv_nsec; \
if ((vsp)->tv_nsec < 0) { \
(vsp)->tv_sec--; \
(vsp)->tv_nsec += 1000000000L; \
} \
} while (0)
#endif
#endif /* _RUDE_H */
# Generated automatically from Makefile.in by configure.
# $Id: Makefile.in,v 1.2 2005/06/30 12:02:49 juranek Exp $
#
# Makefile.in for RUDE
#
# Authors: Juha Laine <james@cs.tut.fi>
# Sampo Saaristo <sambo@cc.tut.fi>
#
# Copyright (C) 1999 Juha Laine, Tampere, Finland
# All rights reserved
#
##############################################################################
SHELL = /bin/sh
prefix = /usr/local
exec_prefix = ${prefix}
bindir = ${exec_prefix}/bin
mandir = ${prefix}/man/man8
sbindir = ${exec_prefix}/sbin
srcdir = .
INSTALL = /usr/bin/install -c -o root -g root -m 0755
CC = gcc
CFLAGS = -O2 -I../include
LDFLAGS =
DEFS = -DHAVE_CONFIG_H
LIBS = -lm
MAN8 = rude.8
RUDE_OBJS = flow_cntl.o flow_txmit.o main.o parse.o mcast.o
##############################################################################
# Rules for make
##############################################################################
.c.o:
$(CC) $(CFLAGS) $(DEFS) -c -o $*.o $<
all: rude
rude: $(RUDE_OBJS)
$(CC) $(CFLAGS) $(LIBS) $(DEFS) $(LDFLAGS) -o rude $(RUDE_OBJS)
clean:
rm -f *~ *.o rude
distclean:
rm -f *~ *.o rude Makefile
install: rude
@if [ ! -d $(bindir) ]; then mkdir -m 0755 $(bindir); fi;
$(INSTALL) rude $(bindir)
@if [ ! -d $(mandir) ]; then mkdir -m 0755 $(mandir); fi;
$(INSTALL) rude.8 $(mandir)
##############################################################################
# $Id$
# $Id: Makefile.in,v 1.2 2005/06/30 12:02:49 juranek Exp $
#
# Makefile.in for RUDE
#
......@@ -29,7 +29,7 @@ DEFS = @DEFS@
LIBS = @LIBS@
MAN8 = rude.8
RUDE_OBJS = flow_cntl.o flow_txmit.o main.o parse.o
RUDE_OBJS = flow_cntl.o flow_txmit.o main.o parse.o mcast.o
##############################################################################
# Rules for make
......
......@@ -43,13 +43,25 @@ extern struct flow_cfg *head;
extern struct udp_data *data;
extern char *buffer;
struct timespec pre_nano_sleep = {0,10005};//10us+5nanos...see man nanosleep
/*
* wait_for_xmit(): Wait for certain period of time in busy-loop
*/
__inline__ void wait_for_xmit(struct timeval *target, struct timeval *now)
{
while(1){
//try wait with nanosleep, then active loop
gettimeofday(now,NULL);
if(timercmp(now,target,<)){
//nanosleep has a resolution 10ms on i386 architectures
struct timespec now_spec = {now->tv_sec,now->tv_usec*1000};
struct timespec target_spec = {target->tv_sec,target->tv_usec*1000};
struct timespec diff;
timespecsub(&target_spec,&now_spec,&diff); //dif = now-target - pre_nano_sleep
timespecsub(&diff, &pre_nano_sleep, &diff);
if(diff.tv_sec >= 0 && diff.tv_nsec >= 0)
nanosleep(&diff, NULL);
}
while(1){
gettimeofday(now,NULL);
if(timercmp(now,target,<)){
/* FIXME: check if the timegap is large => use [u | nano]sleep() */
......@@ -71,9 +83,11 @@ void send_cbr(struct flow_cfg *flow)
struct cbr_params *p = &flow->params.cbr;
struct timeval now = {0,0};
int written = 0;
int i = 0;
/* Do the initialization and wait if necessary */
data->dest_addr = flow->dst.sin_addr.s_addr;
data->dest_addr = flow->dst;
//printf("size: %d\n",sizeof(flow->dst));
data->flow_id = htonl(flow->flow_id);
data->sequence_number = htonl(flow->sequence_nmbr);
wait_for_xmit(&flow->next_tx, &now);
......@@ -84,20 +98,34 @@ void send_cbr(struct flow_cfg *flow)
/* Write the data to the socket and check the result for errors */
/* Increase the status and sequence number counters. */
written = sendto(flow->send_sock, buffer, p->psize, 0,
(struct sockaddr *)&flow->dst,sizeof(struct sockaddr));
if(written != p->psize){
flow->errors++;
RUDEBUG7("send_cbr(): sendto() error for flow=%ld (%d/%d): %s\n",
flow->flow_id,written,p->psize,strerror(errno));
} else {
flow->success++;
/* Write whole package - package_size * one packet */
for( i = 0; i < p -> package_size; i++){
//pokud budu posilat jeste dalsi v baliku tak bych mohl zvysit sequence number
if( i > 0){
data->sequence_number = htonl( ++(flow->sequence_nmbr) );
gettimeofday(&now,NULL);
/* ...and fill in the actual times */
data->tx_time_seconds = htonl(now.tv_sec);
data->tx_time_useconds = htonl(now.tv_usec);
}
written = sendto(flow->send_sock, buffer, p->psize, 0,