AC_INIT(mtr.c)
-AM_INIT_AUTOMAKE(mtr, 0.71)
+AM_INIT_AUTOMAKE(mtr, 0.72)
AC_SUBST(GTK_OBJ)
extern char LocalHostname[];
extern int fstTTL;
extern int maxTTL;
-extern int packetsize;
+extern int cpacketsize;
extern int bitpattern;
extern int tos;
extern float WaitTime;
/* more stuffs added by Min */
if (tolower(c) == 's') {
- mvprintw(2, 0, "Change Packet Size: %d\n", packetsize );
- mvprintw(3, 0, "Size Range: %d-%d, <0 random.\n", MINPACKET, MAXPACKET);
+ mvprintw(2, 0, "Change Packet Size: %d\n", cpacketsize );
+ mvprintw(3, 0, "Size Range: %d-%d, < 0:random.\n", MINPACKET, MAXPACKET);
move(2,20);
refresh();
while ( (c=getch ()) != '\n' && i < MAXFLD ) {
buf[i++] = c; /* need more checking on 'c' */
}
buf[i] = '\0';
- packetsize = atoi ( buf );
- if( packetsize >=0 ) {
- if ( packetsize < MINPACKET ) packetsize = MINPACKET;
- if ( packetsize > MAXPACKET ) packetsize = MAXPACKET;
- } else {
- packetsize =
- - (int)(MINPACKET + (MAXPACKET-MINPACKET)*(rand()/(RAND_MAX+0.1)));
- }
-
+ cpacketsize = atoi ( buf );
return ActionNone;
}
if (tolower(c) == 'b') {
mvprintw(1, 0, "%s (%s)", LocalHostname, net_localaddr());
/*
printw("(tos=0x%X ", tos);
- printw("psize=%d ", abs(packetsize) );
+ printw("psize=%d ", packetsize );
printw("bitpattern=0x%02X)", (unsigned char)(abs(bitpattern)));
- if( packetsize>0 ){
- printw("psize=%d ", packetsize);
+ if( cpacketsize > 0 ){
+ printw("psize=%d ", cpacketsize);
} else {
- printw("psize=rand(%d,%d) ",MINPACKET, MAXPACKET);
+ printw("psize=rand(%d,%d) ",MINPACKET, -cpacketsize);
}
if( bitpattern>=0 ){
printw("bitpattern=0x%02X)", (unsigned char)(bitpattern));
#ifdef ENABLE_IPV6
/* Returns an ip6.arpa character string. */
void addr2ip6arpa( ip_t * ip, char * buf ) {
- char * p = (char *) ip;
+ unsigned char * p = (unsigned char *) ip;
char * b = buf;
int i;
These options or a trailing PACKETSIZE on the commandline sets
the packet size used for probing.
It is in bytes inclusive IP and ICMP headers
+
+If set to a negative number, every iteration will use a different, random
+packetsize upto that number.
.TP
.B \-t
.TP
char *InterfaceAddress = NULL;
char LocalHostname[128];
int dns = 1;
-int packetsize = 64; /* default packet size */
+int cpacketsize = 64; /* default packet size */
int bitpattern = 0;
int tos = 0;
int af = DEFAULT_AF;
ForceMaxPing = 1;
break;
case 's':
- packetsize = atoi (optarg);
- if (packetsize >=0) {
- if (packetsize < MINPACKET) packetsize = MINPACKET;
- if (packetsize > MAXPACKET) packetsize = MAXPACKET;
- }
+ cpacketsize = atoi (optarg);
break;
case 'a':
InterfaceAddress = optarg;
Hostname = argv[optind++];
if (argc > optind) {
- packetsize = atoi (argv[optind]);
- if (packetsize >=0 ) {
- if (packetsize < MINPACKET) packetsize = MINPACKET;
- if (packetsize > MAXPACKET) packetsize = MAXPACKET;
- }
+ cpacketsize = atoi (argv[optind]);
}
}
extern int fstTTL; /* initial hub(ttl) to ping byMin */
extern int maxTTL; /* last hub to ping byMin*/
-extern int packetsize; /* packet size used by ping */
+extern int cpacketsize; /* packet size used by ping */
+static int packetsize; /* packet size used by ping */
extern int bitpattern; /* packet bit pattern used by ping */
extern int tos; /* type of service set in ping packet*/
extern int af; /* address family of remote target */
bitpattern<0. abs(packetsize) and/or abs(bitpattern) will be used
*/
if( batch_at < fstTTL ) {
- if( packetsize < 0 ) {
- packetsize =
- - (int)(MINPACKET + (MAXPACKET-MINPACKET)*(rand()/(RAND_MAX+0.1)));
+ if( cpacketsize < 0 ) {
+ /* Someone used a formula here that tried to correct for the
+ "end-error" in "rand()". By "end-error" I mean that if you
+ have a range for "rand()" that runs to 32768, and the
+ destination range is 10000, you end up with 4 out of 32768
+ 0-2768's and only 3 out of 32768 for results 2769 .. 9999.
+ As our detination range (in the example 10000) is much
+ smaller (reasonable packet sizes), and our rand() range much
+ larger, this effect is insignificant. Oh! That other formula
+ didn't work. -- REW */
+ packetsize = MINPACKET + rand () % (-cpacketsize - MINPACKET);
+ } else {
+ packetsize = cpacketsize;
}
if( bitpattern < 0 ) {
bitpattern = - (int)(256 + 255*(rand()/(RAND_MAX+0.1)));
}
}
+ /* printf ("cpacketsize = %d, packetsize = %d\n", cpacketsize, packetsize); */
+
net_send_query(batch_at);
for (i=fstTTL-1;i<batch_at;i++) {
extern char *Hostname;
extern int fstTTL;
extern int maxTTL;
-extern int packetsize;
+extern int cpacketsize;
extern int bitpattern;
extern int tos;
extern int MaxPing;
printf("<MTR SRC=%s DST=%s", LocalHostname, Hostname);
printf(" TOS=0x%X", tos);
- if( packetsize>=0 ){
- printf(" PSIZE=%d", packetsize);
+ if(cpacketsize >= 0) {
+ printf(" PSIZE=%d", cpacketsize);
} else {
- printf(" PSIZE=rand(%d-%d)",MINPACKET, MAXPACKET);
+ printf(" PSIZE=rand(%d-%d)",MINPACKET, -cpacketsize);
}
if( bitpattern>=0 ) {
printf(" BITPATTERN=0x%02X", (unsigned char)(bitpattern));
/* Caption */
printf("<SRC=%s DST=%s", LocalHostname, Hostname);
printf(" TOS=0x%X", tos);
- if( packetsize>=0 ){
- printf(" PSIZE=%d", packetsize);
+ if(cpacketsize >= 0) {
+ printf(" PSIZE=%d", cpacketsize);
} else {
- printf(" PSIZE=rand(%d-%d)",MINPACKET, MAXPACKET);
+ printf(" PSIZE=rand(%d-%d)",MINPACKET, -cpacketsize);
}
if( bitpattern>=0 ) {
printf(" BITPATTERN=0x%02X", (unsigned char)(bitpattern));