Integration of Type Of Service patches from Glen Turner

TOS
Stephane Bortzmeyer 24 years ago
parent 84407f07e8
commit efde8f513c

@ -1,5 +1,8 @@
3.0.0 (2000-06-30)
3.0.0-gdt1 (2000-07-07)
* New option (-p) to set socket priority
* New option (-P) to set IP Type of Service octet
3.0.0 (2000-06-30)
* Autoconf/automake support
* Fix a bug in ICP timeout

@ -1,6 +1,6 @@
.\" $Id$
.TH echoping 1 "November 22, 1996" "ECHOPING" "echoping"
.TH echoping 1 "July 6, 2000" "ECHOPING" "echoping"
.SH NAME
echoping \- tests a remote host with TCP or UDP
@ -14,6 +14,8 @@ echoping \- tests a remote host with TCP or UDP
.RI [ -t\ number ]
.RI [ -h\ URL ]
.RI [ -i\ URL ]
.RI [ -p\ number ]
.RI [ -P\ number ]
.B hostname
[:port]
@ -69,23 +71,94 @@ be an absolute one. This is mostly for testing Squid Web proxy/caches.
Use T/TCP (if it has been compiled with it). See the INSTALL file for details.
.IP -f\ character
Fill the packet with this character (default is random filling)
.IP -p\ n
Send packets with the socket priority to the integer
.IR n .
The mapping of the socket priority into a network layer or a link
layer priority depends upon the network protocol and link protocol
in use. For more details see
.B SO_PRIORITY
in
.BR socket (7).
.IP -P\ n
Set the IP type of service octet in the transmitted packets to the
least significant eight bits of the integer
.IR n .
.SH EXAMPLES
.IP echoping\ \-v\ foobar.whoops.org
.IP echoping\ \-v\ foobar.example.com
Tests the remote machine with TCP echo (one test).
.IP echoping\ \-n\ 5\ \-w\ 10\ foobar.whoops.org
.IP echoping\ \-n\ 5\ \-w\ 10\ foobar.example.com
Tests the remote machine with TCP echo (five tests, every ten seconds).
.IP echoping\ \-h\ /\ foobar.whoops.org
.IP echoping\ \-h\ /\ foobar.example.com
Tests the remote Web server and asks its home page. Note you don't
indicate the whole URL.
.IP echoping\ \-h\ http://www.whoops.org/\ cache.whoops.org:3128
.IP echoping\ \-h\ http://www.example.com/\ cache.example.com:3128
Tests the remote Web proxy-cache and asks a Web page. Note that you must
indicate the whole URL.
.IP echoping\ -u\ \-P\ 0xa0\ foobar.example.com
Sends several UDP Echo packets with an IP Precedence of 5.
.SH IP TYPE OF SERVICE OCTET
The IP packet header contains 8 bits named the \"type of service octet\".
The value of the octet is set with the
.B \-P
option. The effects of the octet are defined differently in RFC791
.I "Internet Protocol"
and RFC2474
.IR "Definition of the Differentiated Services Field (DS Field) in the IPv4 and IPv6 Headers".
RFC791 defines
.I Precedence
which has ascending priorities 0 through to 7, and the bits
.IR Delay ,
.IR Throughput ,
.IR Reliability ,
and
.I Cost
which indicates the application's preference for the properties of
the packet's path through the network.
.I Precedence
is in the most significant three bits of the type of service octet,
followed in decending significance order by the
.IR D ,
.IR T ,
.I R
and
.I C
bits. The least significant bit must be zero. Only one of the
.IR D ,
.IR T ,
.I R
or
.I C
bits may be set.
RFC2474 defines the Distributed Services Code Point, or
DSCP.
This acts as a selector between 64 possible behaviours that the
network can apply to the packet. The
.I DSCP
is in the most significant six bits of the type of service octet.
The remaining least significant two bits of the octet must be
zero.
.SH BUGS
UDP isn't really useable with large packets because of sockets
limitations and the lack of workaround code.
The numeric arguments to
.B -p
and
.B -P
can be in decimal (such as 11), octal (such as 013) or hexadecimal
(such as 0x0b). So padding decimal arguments with leading zeros will
change the value read.
You may need to be superuser to set some
.B -p
or
.B -P
values.
ICP support is far from perfect, specially on the Alpha or when
something goes wrong (filtering for instance).
@ -107,5 +180,3 @@ See the README for information about other network measurements programs.
.SH AUTHOR
Stephane Bortzmeyer <bortz@users.sourceforge.net>

@ -98,6 +98,13 @@ main (argc, argv)
unsigned short stop_at_newlines = 1;
int priority;
int priority_requested = 0;
int tos;
int tos_requested = 0;
char *arg_end;
null_timeval.tv_sec = 0;
null_timeval.tv_usec = 0;
max_timeval.tv_sec = 1000000000;
@ -115,7 +122,7 @@ main (argc, argv)
results[i].valid = 0;
}
progname = argv[0];
while ((ch = getopt (argc, argv, "vs:n:w:dch:i:rut:f:")) != EOF)
while ((ch = getopt (argc, argv, "vs:n:w:dch:i:rut:f:p:P:")) != EOF)
{
switch (ch)
{
@ -154,6 +161,39 @@ main (argc, argv)
fill = *optarg;
fill_requested = 1;
break;
case 'p':
priority = (int)strtol( optarg,
&arg_end,
0);
if (arg_end == optarg || arg_end == '\0')
{
(void) fprintf (stderr,
"%s: socket priority (-p) should be numeric.\n",
progname);
exit (1);
}
else
{
priority_requested = 1;
}
break;
case 'P':
tos = (int)strtol( optarg,
&arg_end,
0);
if (arg_end == optarg || arg_end == '\0')
{
(void) fprintf (stderr,
"%s: IP type of service (-P) should be "
"numeric.\n",
progname);
exit (1);
}
else
{
tos_requested = 1;
}
break;
case 's':
size = atoi (optarg);
if (size > MAXLINE)
@ -416,6 +456,40 @@ main (argc, argv)
err_sys ("bind error");
}
}
if (priority_requested)
{
if (verbose)
{
printf ("Setting socket priority to %d (0x%02x)\n",
priority,
(unsigned int)priority);
}
if (setsockopt(sockfd,
SOL_SOCKET,
SO_PRIORITY,
(void *)&priority,
(socklen_t)sizeof(priority)))
{
err_sys("Failed setting socket priority");
}
}
if (tos_requested)
{
if (verbose)
{
printf ("Setting IP type of service octet to %d (0x%02x)\n",
tos,
(unsigned int)tos);
}
if (setsockopt(sockfd,
SOL_IP,
IP_TOS,
(void *)&tos,
(socklen_t)sizeof(tos)))
{
err_sys("Failed setting IP type of service octet");
}
}
if (verbose)
{
if (tcp)

@ -95,7 +95,11 @@ err_sys (va_alist)
void
usage ()
{
fprintf (stderr, "Usage: %s [-v] [-t timeout] [-c] [-d] [-u] [-s size] [-n number] [-w delay] [-h url] server-name[:port]\n", progname);
fprintf (stderr,
"Usage: %s [-v] [-t timeout] [-c] [-d] [-u] [-s size] "
"[-n number] [-w delay] [-h url] [-p priority] [-P tos] "
"server-name[:port]\n",
progname);
exit (1);
}

Loading…
Cancel
Save