Version 19 of Netinfo

Updated 2009-10-01 23:28:25 by Stu

Netinfo - Protocol, service, network, host and ether info

Directions to find it at Stu

Netinfo version 0.5, October 2009.

  • Added "ethers" db

Netinfo version 0.4, September 2007.

  • Added "networks" db
  • A bit of cleanup/adjustment
  • Documentation improvements

2009-01-03 Stu TkNib (Tk Netinfo Browser, included with Netinfo) is a GUI frontend to Netinfo. TkNib loads and displays all available information from the five system databases supported by Netinfo. Columns can be sorted by clicking on their headers. It's a very simple program; an example of working with Netinfo, Ttk, Tk and Tcl. Thanks to dkf's widget demo for the sort proc.

2009-10-01 Stu I removed TkNib from this page; it's included with Netinfo.


Netinfo is also the name of a OS subsystem handling these issues in NEXTSTEP and MacOS X. What relation, if any, is there between that and Stu's package?

Stu sez: No relationship. I was unaware of the NEXTSTEP and MacOS X subsystem until now. Netinfo was originally called Netutil but it turned out to be more info-ish than util-ish. Do you think this will cause any problems? Netinfo 0.3 was released a year ago and I haven't had any complains although I have no idea if anyone is using it.


One example of usage would be to look up hostnames (usually taken from /etc/hosts) using Netinfo and creating sockets (aka ceps) using Ceptcl and the -noresolve option. This way, one can avoid the potential delays caused by the operating system looking up the hostname.

From the man page:

       The netinfo Tcl extension provides access to system proto-
       col, service, network, host and ether information which is
       retrieved  from  system  databases  and made available for
       querying.  This functionality  is  somewhat  analogous  to
       that  provided  by some of the functions referenced in the
        C include file usually found on unix-like  oper-
       ating systems (gethostbyname, getservbyport, etc).  Unlike
       those functions, netinfo does not  go  beyond  referencing
       the  data stored in the system databases; netinfo does not
       access the databases per query, rather it loads  the  data
       and  parses it into an internal ready-for-querying format.
       If any changes are made to  the  databases  after  loading
       then  the  affected databases would need to be reloaded if
       the changes are to be available to netinfo queries.
       Normal usage involves optionally specifying  any  database
       files  if  the defaults do not match your reality, calling
       as many of the "load" commands as are necessary (depending
       on  what  data  you  need to access; netinfo does not load
       anything at startup) and using the querying and extraction
       commands to retrieve info.

Examples:

       # Results noted with #=>
       package require netinfo
       namespace import ::netinfo::*
       loadProtocolData; loadServiceData; loadNetworkData; loadHostData; loadEtherData

       protocolData [protocol -number 123] -comment
       #=> Performance Transparency Protocol
       protocolData [protocol -number 123] -comment -name
       #=> {Performance Transparency Protocol} ptp

       service -port 9
       #=> discard 9 {sink null} {} tcp
       service -port 9 -protocol udp
       #=> discard 9 {sink null} {} udp
       service -port 9 -protocol *
       #=> {discard 9 {sink null} {} tcp} {discard 9 {sink null} {} udp}
       serviceData [lindex [service -port 9 -protocol *] 1] -protocol -port
       #=> udp 9

       network -number 127
       #=> loopback loop {} 127
       networkData [network -number 224] -name
       #=> BASE-ADDRESS.MCAST.NET

       hostData [host -aliases localhost] -address
       #=> 127.0.0.1
       hostData [host -aliases localhost -domain inet6] -address
       #=> ::1

        etherData [ether -name toaster] -address
       #=> 00:01:6a:e3:df:0a

       # List all services:
       service -name *