• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

netinet/H26-Oct-2010-383198

.gitignoreH A D26-Oct-201017 43

HISTORYH A D26-Oct-2010720 2213

MakefileH A D26-Oct-2010946 4938

READMEH A D26-Oct-20104.9 KiB13892

README.OS2H A D26-Oct-20103 KiB9660

README.tracerouteH A D26-Oct-20103.7 KiB127107

netselect-aptH A D26-Oct-20106.4 KiB219159

netselect-apt.1H A D26-Oct-20101.9 KiB8770

netselect.1H A D26-Oct-20103.3 KiB134109

netselect.cH A D03-May-202226.7 KiB1,107843

README

1
2netselect 0.3
3=============
4
5This is netselect, an ultrafast intelligent parallelizing binary-search
6implementation of "ping."
7
8Now stop laughing and pay attention.
9
10netselect determines several facts about all of the hosts given on the
11command line, much faster you would if you manually tried to use ping and
12traceroute.  For example, if I type:
13
14	netselect -vv ftp.fceia.unr.edu.ar ftp.kulnet.kuleuven.ac.be \
15			ftp.cdrom.com ftp.debian.org ftp.de.debian.org
16
17It tells me this:
18
19ftp.fceia.unr.edu.ar                  2792 ms  23 hops  100% ok ( 1/ 1) [ 9213]
20ftp.kulnet.kuleuven.ac.be             9999 ms  30 hops    0% ok
21ftp.cdrom.com                           94 ms   8 hops  100% ok (10/10) [  169]
22ftp.debian.org                          46 ms  15 hops  100% ok (10/10) [  115]
23ftp.de.debian.org                     9999 ms  30 hops    0% ok
24  115 ftp.debian.org
25
26For each host, it figures out the approximate ping time (though not as
27accurately as "ping" does), the number of network "hops" to reach the
28target, and the percentage of ping requests that got through successfully.
29
30The value in brackets is the "score" of each operational host based on these
31values.  A lower score is better.  The last line shows the server with the
32best score.  If we had not used '-vv' on the command line, only this last
33line would have been printed.
34
35Note that for ftp.kulnet.kuleuven.ac.be and ftp.de.debian.org in this case,
36nothing got through at all.  That indicates that either the host doesn't
37exist, or it is down.
38
39For a bigger example, try netselect-apt to build your own sources.list for apt
40with the (possibily) fastest debian mirror.
41
42
43But Why?
44========
45
46Why do I want to know about my ping times to computers in Belgium?  Well,
47the main reason for netselect -- and its name gives you a hint -- is to help
48choose the "best" server for you from among a (possibly very large) list.
49
50Starting with version 0.2, netselect can make these decisions for you using
51its scoring mechanism.  If you want, however, you can still pass the raw
52results and score the servers as you like.  Try this, for example:
53
54	netselect -vv -s 0 $(cat <your_list_of_sites>)
55
56The "-s 0" option disables printing of scores at the bottom of the list, and
57"-vv" enables printing of the statistics.
58
59
60How does it work?
61=================
62
63First:
64
65 - decode each hostname into an IP address, and stores each IP address into
66   a table.  In netselect 0.2, this code was rewritten to resolve hostnames
67   much more quickly than before.
68
69Now for all hosts at once:
70
71 - start firing UDP packets with "random-guess" TTL values, much like
72   traceroute does.  Actually, the code for this is derived from traceroute.
73
74 - if an "ICMP TTL Expired" message comes back, then the TTL was too low:
75   the host is farther away than that.  Increase TTL next time.  Otherwise,
76   a "Port Unreachable" message comes back, meaning the TTL was large
77   enough.  Try a smaller one.  We do this until we narrow down the TTL.
78   (This is where the "binary search" comes in.)
79
80 - Meanwhile, collect timing statistics for all packets that reached the
81   host.  Packets that don't come back are considered lost.
82
83When all the hosts have had their TTL values narrowed down, and the "-t"
84minimum tries have expired, we're done.  Close the sockets and dump
85the statistics to stdout.
86
87
88
89Command-line Options
90====================
91
92Not much right now.
93
94	-v	-- verbose mode.  Displays nameserver resolution messages to
95		   stderr.  You probably want this so that you don't get
96		   bored waiting for a hundred name resolutions to finish.
97
98	-vv	-- very verbose mode.  Displays nameserver resolution and
99		   statistics (not just scores) to stderr and stdout.
100
101	-vvv	-- very very verbose mode.  Everything -vv prints, plus
102		   print every packet received as it happens.  Good for
103		   debugging or trying to figure out how it works.
104
105	-vvvv   -- very very very verbose mode. Everything -vvv prints,
106		   plus a trace of all packets sent.
107
108	-m #	-- maximum ttl.  Don't accept hosts with more hops than
109		   this.
110
111	-t #	-- make sure at least 50% of the hosts get tested with this
112		   many packets.  The more packets you use, the more
113		   accurate the results... and the longer it takes to run.
114		   The default is 10, which is usually okay.
115
116	-s #	-- print this many "top-scoring" servers at the end of
117		   the list.  "-s 0" disables printing of high scores.
118
119
120The Future
121==========
122
123
124Here are some possible improvements:
125
126	- try to estimate line bandwidth somehow.  The 'bing' program does
127	  it using two different ping packet sizes.
128
129	- try to improve 'ping time' estimate.  It's a problem right now
130	  because netselect writes a lot of packets in a quick stream (for
131	  speed reasons).  It's fair to each host, though:  they all put up
132	  with an equal amount of lag :)
133
134This program is highly experimental.  Please let me know what you think.
135
136	- Avery Pennarun
137	  <apenwarr@gmail.com>
138

README.OS2

1
2
3The OS/2 support is from Kyosuke TOKORO <tokoro@mx5.harmonix.ne.jp> (or
4maybe NBG01720@nifty.ne.jp).
5
6Thanks!
7
8Avery
9
10P.S. There's a great chance that I might have broken it since then.  Send me
11patches if you want it back.  Also send me patches if you want it to work on
12non-Linux Unix systems - it should be pretty easy to do.
13
14
15
16netselect.c
17~~~~~~~~~~~
18o Removed htons() to set the `ip_len' element.
19
20    This function causes the netselect.exe to hung.  It is not required
21  to set the `ip_len' on the OS/2 systems (and on the BSD systems, I
22  think.)
23
24
25o Added code to check the `EHOSTUNREACH' error and some others.	 They may
26  be returned from sendto().
27
28
29o Added _response() to expand a response file (@filename, the file filename
30  contains a list of arguments, one per line).
31
32    `netselect $(cat foo)' does not work when the shell is CMD.EXE.  Type
33  `netselect @foo' instead.
34
35    _response() is an orignail function supported by the `emx.'
36
37
38o Switch the mode of an unnamed pipe to binary from text (default).
39
40    On the OS/2 and the Windows operating systems, if pipe handle has been
41  created for reading in text mode, CR/LF pairs are translated to newline
42  characters and a Ctrl-Z character is discarded.  And, if pipe has been
43  created for writing in text mode, newline characters are translated to
44  CR/LF pairs.	These translations cause problem.
45
46
47netinet/ip.h
48~~~~~~~~~~~~
49    I don't know why the netselect has own `netinet/' headers.
50    May I compile the netselect with including standard headers in `/usr
51  /include/netinet/ (on the Debian GNU linux systems)' directory?
52
53    I compiled for the OS/2 systems with including the netselect's own
54  `netinet/' headers, instead of the headers in `/emx/include/netinet/'
55  directory.
56
57o The size of network messages is restricted to 32767 bytes.  This is a
58  limitation of IBM TCP/IP for OS/2.
59
60
61Makefile
62~~~~~~~~
63o To build OS/2 binary, type:
64	make OS2=1
65
66
67o To install on OS/2 system, type:
68	make OS2=1 install
69
70    GNU fileutil is required.  But, `install -s netselect.exe' does not
71  work correctly.  Because the OS/2 executable file is not in the a.out
72  format.  `emxbind -s -b' will be executed to delete symbols and to
73  create bound an `.exe' file.
74
75
76o `# (comment)' characters are moved to the top of each line.
77
78    When there is a tab character at the top of the line, GNU make executes
79  the shell.  When the shell is `/bin/sh' or something ported from unix.
80    a `#' starts a comment that extends to the end of the line.	 But, the
81  native OS/2 shell (CMD.EXE) does not recognize `#' as a comment.  To
82  resolve this problem, use the Makefile comments, instead of the shell
83  comments.  When there is a `#' character at the top of line, GNU make
84  recognizes its line as own comment, and does not execute shell.
85
86
87o fork() works only in programs linked by ld.  It does not work in programs
88  linked by LINK386 (OS/2 native linker).  This is a limitation of the
89  emx.
90
91
92debian-ftp-mirrors
93~~~~~~~~~~~~~~~~~~
94o Added Debian mirrors in Japan.
95
96

README.traceroute

1Tue Dec 27 06:24:24 PST 1988
2
3Traceroute is a system administrators utility to trace the route
4ip packets from the current system take in getting to some
5destination system.  See the comments at the front of the
6program for a description of its use.
7
8This program
9
10 a) can only be run by root (it uses raw ip sockets).
11
12 b) REQUIRES A KERNEL MOD to the raw ip output code to run.
13
14If you want to hack on your kernel, my modified version of the
15routine rip_output (in file /sys/netinet/raw_ip.c) is attached.
16This code may or may not resemble the code in your kernel.
17It may offer you a place to start but I make no promises.
18If you do hack your kernel, remember to test everything that uses
19raw ip sockets (e.g., ping and egpup/gated) & make sure they still
20work.  I wish you the best of luck and you're on your own.
21
22If your system has the ttl bug mentioned in the source, you
23might want to fix it while you're in the kernel.  (This bug
24appears in all releases of BSD up to but not including 4.3tahoe.
25If your version of netinet/ip_icmp.c is any earlier than 7.3
26(April, '87), it has the bug.)  The fix is just to add the line
27	ip->ip_ttl = MAXTTL;
28after the line
29	ip->ip_src = t;
30(or anywhere before the call to icmp_send) in routine icmp_reflect.
31
32If you're running this on a pre-4.3bsd system (e.g., Sun 3.x,
33Ultrix) that strips ip headers from icmp messages, add -DARCHAIC
34to CFLAGS in the Makefile.  Also note that rip_output contains
35a conditional for a 4.2/4.3 change in the location of a raw
36socket's protocol number.  I've checked this under 4.3 & Sun OS
373.5 but you should double-check your system to make sure the
38appropriate branch of the #if is taken (check the line that
39assigned to ip->ip_p in your system's original rip_output).
40
41A couple of awk programs to massage the traceroute output are
42included.  "mean.awk" and "median.awk" compute the mean and median
43time to each hop, respectively.  I've found that something like
44
45	traceroute -q 7 foo.somewhere >t
46	awk -f median.awk t | graph
47
48can give you a quick picture of the bad spots on a long
49path (median is usually a better noise filter than mean).
50
51Enjoy.
52
53 - Van Jacobson (van@helios.ee.lbl.gov)
54
55-------------------- rip_output from /sys/netinet/raw_ip.c
56rip_output(m, so)
57	register struct mbuf *m;
58	struct socket *so;
59{
60	register struct ip *ip;
61	int error;
62	struct rawcb *rp = sotorawcb(so);
63	struct sockaddr_in *sin;
64#if BSD>=43
65	short proto = rp->rcb_proto.sp_protocol;
66#else
67	short proto = so->so_proto->pr_protocol;
68#endif
69	/*
70	 * if the protocol is IPPROTO_RAW, the user handed us a
71	 * complete IP packet.  Otherwise, allocate an mbuf for a
72	 * header and fill it in as needed.
73	 */
74	if (proto != IPPROTO_RAW) {
75		/*
76		 * Calculate data length and get an mbuf
77		 * for IP header.
78		 */
79		int len = 0;
80		struct mbuf *m0;
81
82		for (m0 = m; m; m = m->m_next)
83			len += m->m_len;
84
85		m = m_get(M_DONTWAIT, MT_HEADER);
86		if (m == 0) {
87			m = m0;
88			error = ENOBUFS;
89			goto bad;
90		}
91		m->m_off = MMAXOFF - sizeof(struct ip);
92		m->m_len = sizeof(struct ip);
93		m->m_next = m0;
94
95		ip = mtod(m, struct ip *);
96		ip->ip_tos = 0;
97		ip->ip_off = 0;
98		ip->ip_p = proto;
99		ip->ip_len = sizeof(struct ip) + len;
100		ip->ip_ttl = MAXTTL;
101	} else
102		ip = mtod(m, struct ip *);
103
104	if (rp->rcb_flags & RAW_LADDR) {
105		sin = (struct sockaddr_in *)&rp->rcb_laddr;
106		if (sin->sin_family != AF_INET) {
107			error = EAFNOSUPPORT;
108			goto bad;
109		}
110		ip->ip_src.s_addr = sin->sin_addr.s_addr;
111	} else
112		ip->ip_src.s_addr = 0;
113
114	ip->ip_dst = ((struct sockaddr_in *)&rp->rcb_faddr)->sin_addr;
115
116#if BSD>=43
117	return (ip_output(m, rp->rcb_options, &rp->rcb_route,
118	   (so->so_options & SO_DONTROUTE) | IP_ALLOWBROADCAST));
119#else
120	return (ip_output(m, (struct mbuf *)0, &rp->rcb_route,
121	   (so->so_options & SO_DONTROUTE) | IP_ALLOWBROADCAST));
122#endif
123bad:
124	m_freem(m);
125	return (error);
126}
127