################################################ # # # ## ## ###### ####### ## ## ## ## ## # # ## ## ## ## ## ### ## ## ## ## # # ## ## ## ## #### ## ## ## ## # # ## ## ###### ###### ## ## ## ## ### # # ## ## ## ## ## #### ## ## ## # # ## ## ## ## ## ## ### ## ## ## # # ####### ###### ####### ## ## ## ## ## # # # ################################################ The following paper was originally presented at the Third Annual Tcl/Tk Workshop Toronto, Ontario, Canada, July 1995 sponsored by Unisys, Inc. and USENIX Association It was published by USENIX Association in the 1995 Tcl/Tk Workshop Proceedings. For more information about USENIX Association contact: 1. Phone: 510 528-8649 2. FAX: 510 548-5738 3. Email: office@usenix.org 4. WWW URL: https://www.usenix.org ^L From schoenw@ibr.cs.tu-bs.de Tue May 23 14:23:23 1995 Tcl Extensions for Network Management Applications J. Schoenwaelder H. Langendoerfer Department of Computer Science Technical University of Braunschweig, Germany This paper presents extensions to the Tool Command Language (Tcl) that have been designed to implement network management applications. Using Tcl, we were able to make our network management applications highly extensible. Experience has shown that many useful applications can be written with a few lines of Tcl code. Site specific adaptations are possible at very low cost. We have used our extensions to implement smart network management agents that can receive and execute management scripts provided by other management stations or agents. Introduction Network management is an area which has become very important over the last decade as todays networks have become critical for the success of many organizations. Network management software is designed to cope with problems from the size, complexity and heterogeneity of todays multi-protocol networks. The Internet and the OSI networking communities have developed network management architectures, which define the structure of network management information and protocols to retrieve and manipulate management information provided by agents running on the network elements [16]. Network management applications are in most cases embedded into network management platforms, which provide a runtime and development environment for management applications. Although the platform approach has many advantages, we have seen a lot of network management applications that fail to work in some particular network configurations. This is not necessarily a fault of the application designer, as it is very difficult to write management applications that take into account the huge number of different network configurations in use today. Things get even worse due to all kinds of bugs present in many network devices. As a consequence, many network management applications must be adapted to the target environment. This usually requires to write or to change existing C code. The C language programming interfaces to access network management services usually require a very good understanding of complex data structures before one can use them even for some trivial tasks. To overcome this problem, we started to design a network management platform which uses the Tool Command Language (Tcl) [10] to provide a higher level of abstraction. This paper presents Tcl extensions to access various network services. Some examples will be given to show how these extensions can be used to implement simple but powerful management scripts. The next section starts with a short description of the underlying event-driven model and section 3 introduces extensions that provide access to standard services of the TCP/IP protocol suite. In section 4, we present the interface to the management protocol of the Internet (SNMP) and section 5 describes an interface to the OSI management protocol (CMIP). A small example will demonstrate how both protocols can be used to solve a simple management problem. We will shortly review some more complex applications build with our extension in section 6. Distributed network management using smart management agents is another interesting application area for our extension. We discuss the implementation of smart management agents in section 7 and we conclude with a brief comparison with related work and some ideas for further improvements in section 8. Event-Driven Management Our extensions named Scotty are based on the event-driven programming paradigm well known to every Tk programmer [10]. A typical Scotty application loads an initialization script which installs some basic event handlers. Once initialization is complete, the application enters an event loop. Tcl scripts are evaluated to process events that are created when a message is received from the network or if a timer expires. The event loop terminates if no timer events are left and no more messages are accepted from the network. We are using the generic event management library of Tk 4.0 to create an event-driven Tcl interpreter without the rest of Tk. ------------------------------------------------------------ job create [] job info job current $j status [] $j command [] $j interval [] $j repetitions [] $j attribute [] Figure 1: The job command. ------------------------------------------------------------ Many management applications require to perform tasks periodically. We have build a job scheduler on top of the event management library to simplify the implementation of periodic tasks. Figure 1 shows the job command. A new job is created with the job create command. Following the object-oriented approach, a new command is created that represents the job object. Operations on the job object allow to modify the job state (e.g. suspending a job), to change the Tcl command bound to a job or scheduling parameters. The attribute command option allows to attach arbitrary attributes to a job. Attributes can store all information needed to execute a job and reduce the need for global variables. It is straight forward to implement a generic restart mechanism if all context information is attached to a job object. The event-driven programming paradigm works quite well in most cases. However, some networking extensions do not fit well with the event-driven programming style. For example, some SUN RPCs block for about 20 seconds before they return control. In these cases, a thread based implementation would be a big win. However, a threaded implementation would reduce the portability of our extensions as there is still no common thread library available. Basic TCP/IP Extensions Internet network management often starts with tests to ensure the reachability of hosts using the Internet Control Message Protocol (ICMP) [11]. Scotty provides access to the ICMP protocol with the icmp command shown in figure 2. ------------------------------------------------------------ icmp [] echo icmp [] mask icmp [] timestamp icmp [] ttl icmp [] trace Figure 2: The icmp command. ------------------------------------------------------------ The icmp command allows to send ICMP echo, mask or timestamp requests to a list of hosts. ICMP packets are send in a round-robin fashion while responses are collected. This allows to perform fast scans of entire IP address spaces. The return value of the icmp command is a list, wherein each element contains the host name and either the round trip time, the network mask or the time offset. The ttl and trace options send UDP packets to unused ports and catch the returned ICMP error message. This allows to create routing traces with a simple Tcl script as shown in figure 3. ------------------------------------------------------------ proc traceroute {ip {max 32}} { set ttl 1 set new "" while {$new != $ip && $ttl <= $max} { set old $new set hop [lindex [icmp trace $ttl $ip] 0] set new [lindex $hop 0] set rtt [lindex $hop 1] if {$old == $new} break puts [format "%3d %5d ms %s" $ttl $rtt $new] incr ttl } } Figure 3: A simple traceroute written in Tcl. ------------------------------------------------------------ Access to many services above the transport layer is provided by the tcp and udp commands (figure 4). They implement much the same functionality as other TCP extensions for Tcl, e.g. tcl-dp [15]. Both commands manipulate standard Tcl file handles that are bound to socket file descriptors. The info option can be used to retrieve socket specific information like source and destination addresses. ------------------------------------------------------------ tcp connect tcp listen [] tcp accept tcp shutdown tcp close tcp info [] udp open [] udp connect udp send [ ] udp receive udp close udp info [] Figure 4: The tcp and udp commands. ------------------------------------------------------------ Unlike other TCP extension, we preferred to distinguish between commands that manipulate TCP or UDP sockets. This makes Tcl code easier to understand, as there is a clear indication which kind of transport service is actually used. The main purpose of the tcp and udp commands is to access standard test services at the transport layer (e.g. echo, discard or chargen). However, there are a number of other useful services that can be accessed by writing a few lines of Tcl code. Examples are the finger service [19] or the whois service [6]. Another valuable source of information is the Domain Name System (DNS) [9]. A well maintained DNS does not only translate Internet names into IP addresses and back, it also offers information about machine types and operating systems. Access to the DNS is provided by the dns command shown in figure 5. ------------------------------------------------------------ dns [] address dns [] ptr
dns [] hinfo dns [] mx dns [] soa Figure 5: The dns command. ------------------------------------------------------------ The address and ptr options convert Internet host names into IP addresses and back while the hinfo option retrieves the host information record. The mail exchanger record for a domain name can be read with the mx option and the soa option returns the server which provides authoritative answers for a domain. Access to local network databases is implemented with the netdb command (figure 6). If called without any optional arguments, the netdb command will return a list of all known records. For example, the command netdb networks lists all locally defined networks. Each element contains a network name and a network address. ------------------------------------------------------------ netdb hosts [ ] netdb networks [ ] netdb protocols [ ] netdb services [ ] netdb sunrpcs [ ] Figure 6: The netdb command. ------------------------------------------------------------ You can lookup name or address information directly by supplying appropriate arguments. For example, netdb protocols name 1 will return icmp. Our extensions allow to access arbitrary documents on the Internet via the Hypertext Transfer Protocol (HTTP) [1]. HTTP is an application layer protocol that defines methods to retrieve (get, post), store (put) and delete arbitrary documents (which could be Tcl scripts) and is the protocol behind the popular World Wide Web. Supporting HTTP is attractive because it is easy to implement and it provides access to a wide variety of transport mechanisms by using HTTP gateways. These gateways are often termed proxy server, as they retrieve documents on behalf of the requesting client. HTTP gateways are usually configured to retrieve documents using other well known Internet protocols like FTP, WAIS or GOPHER. ------------------------------------------------------------ http proxy [] http head http get http post http put http delete http server [] http bind