Linux DevCenter    
 Published on Linux DevCenter (http://www.linuxdevcenter.com/)
 See this if you're having trouble printing code examples


Linux Network Administration

Creating Network Diagrams

02/15/2001

The complexity of network administration increases with the size of the network being managed. It's relatively easy to keep a good deal of information about a small network in your head, but when your network grows in size beyond about six routers or so, it makes good sense to maintain documentation that describes it.

The most important piece of network documentation is the network diagram. It is possible to capture a wide variety of important information on a diagram including the topology of the network, network device types, assigned network addresses, names of routers and important hosts, physical location of hosts and network equipment, contact telephone numbers, and on and on.

As a diagnostic resource the network diagram is essential. So I thought this month I'd take a quick look at some useful open-source tools available for Linux that will allow you to create and maintain useful network diagrams.

Things to look for in network diagramming tools

Also in Linux Network Administration

Dynamic Address Assignment

Exploring the /proc/net/ Directory

Building High Performance Linux Routers

Traffic Shaping

What is a Network Administrator Anyway?

If you're in a hurry you can use any sort of drawing package to produce network diagrams, but if you're going to be keeping them up to date, there are a few features that I believe are pretty much essential. I'm not a graphics wizard so the descriptions are simple and I hope the purists will forgive any terminology errors.

What's out there?

I've selected four common packages that are each reasonable choices for network diagramming purposes. While packages like GIMP are wonderful, they're designed for a completely different purpose and so it wouldn't be fair to include them.

I'll describe each in alphabetical order and then assess their relative merits for our network diagramming task.

While I've included URLs from where you can obtain the software, most of this software will be available in pre-packaged form from any modern Linux distribution, so check there first.


Dia

Copyright: Alexander Larsson, James Henstridge, et.al.
License: GPL
Version: 0.83
Available at: http://www.lysator.liu.se/~alla/dia/

Dia is a nicely presented drawing program designed to simplify the task of preparing a variety of different types of diagrams including UML, entity relationship, flowchart, electronic circuit, and network diagrams.

The user interface is well designed, iconic in nature and makes Dia very easy to use. It comes with a limited library of network diagram shapes, but you'll almost certainly want to add your own. Fortunately this is possible as Dia implements a means of adding new shapes to the library using XML encoded SVG, the Scalable Vector Graphic format. Dia shapes support connection points enabling the convenient drag-to-rearrange-diagram capability. The process for adding shapes isn't documented, but I worked out how to do it after about 20 minutes of poking around.

Probably the biggest weaknesses of Dia are its export formats and its lack of support for encapsulated diagrams. You can export to Computer Graphics Metaformat (CGM), Scalable Vector Graphics (SVG), Encapsulated PostScript, or the Dia native file format, but you cannot export to GIF, PNG, or JPG file formats. I suppose there are tools available to convert CGM or SVG into something more common but I haven't found any.

At first glance Dia diagram files look to be in a binary format, but there is a simple trick being played out here. The .dia files that Dia creates are compressed with gzip. If you uncompress them you'll find they're actually XML encoded plain-text files. This makes them particularly easy to read, interpret, and generate.

The Dia tool window showing some Network shapes
Figure 1. The Dia tool window showing some network shapes.


Tgif

Copyright: William Chia-Wei Cheng
License: BSD-like
Version: 4.1.34
Available at: http://bourbon.cs.umd.edu:8001/tgif/

The Tgif drawing program has some unique and interesting features that make it useful for network diagrams. The diagrams created are vector-based allowing smooth scaling, and the interface is object-based, providing the ability to build composite group objects but lacking any notion of connection points so rearranging diagrams can be a little laborious if you have lots of links.

There are no icons or drawing symbols provided with Tgif by default but unlike most of the other packages described you can create new symbols and store them in a library from within the Tgif application. This makes it quite quick and easy to develop your own symbol set. The symbols in Figure 2 are some that I created in about 15 minutes of playing (and probably look like it too!).

A snapshot of Tgif and a simple drawing.
Figure 2. A snapshot of Tgif and a simple drawing.

Tgif provides direct export capability to a number of useful and common formats including encapsulated PostScript, PNG, GIF, JPEG, and even to HTML imagemaps. Printing direct to printer is supported.

One of the real strengths of Tgif as compared to other packages described in this column is that of hierarchical view. Tgif provides very powerful and flexible mechanisms with which to build complex navigable diagrams. You could for example provide a high-level network diagram that shows a whole wide area network with icons representing each site or building. A middle-click on the mouse on any of these icons could change your view to that of a detailed view of the network of just that site. It is possible to use Tgif directly as a browser capable of navigating network accessible diagrams. You can pass Tgif a URL when you launch it, and it will retrieve the diagram at that location and move from diagram to diagram in the same way you'd move from web page to web page.

It is possible to add automation to your diagrams, such that a middle-click on an symbol in your diagram can launch a command. Each symbol in a Tgif diagram may have text attributes attached and these may be passed automatically as command-line arguments to the launched program.

The native Tgif file format is plain-text and looks pretty easy to understand. Although the syntax of the file isn't well documented, with appropriate reference to the source code and some simple sample files, you can work most of it out.


Tkined

Copyright: Juergen Schoenwaelder
License: BSD-like
Version: 1.5.0
Available at: ftp://ftp.ibr.cs.tu-bs.de/pub/local/tkined/

Tkined is the only open-source software package I'm aware of that was specifically designed for drawing network diagrams. While its user interface looks a little dated and old fashioned, Tkined is quite easy to use. Typically Tkined comes packaged with Scotty which is a set of very useful tools that can be invoked from within Tkined to provide a wide range of network-related automation for diagrams. We'll talk more about Scotty in a moment.

Tkined comes with a generous library of network-device type icons. To my eye many of them look a little obscure or dated, but it's a relatively simple process to add or edit icons should you wish to, so no real cause for complaint there. Again the process isn't documented and there is a small trick to be aware of. Each of the graphic icons is comprised of two X bitmaps (.xbm). The first is simply the black and white image that you wish to display in your diagrams. The second is a black and white image of precisely the same overall dimensions as the first, that is used to act as a mask when determining how to handle overlap. The mask will usually be a solid filled version of the first image. Take a look at the examples supplied with tkined for more explanation.

A snapshot of Tkined and a simple drawing.
Figure 3. A snapshot of Tkined and a simple drawing.

Export formats are quite limited with Tkined. You really only have a choice of PostScript or "TNM Map" formats. PostScript, of course, is ideal for printing purposes, so that's useful. TNM Map is a format native to a particular TCL language library that Scotty uses. I don't know anything more about them than that so at least for me they're not useful at all.

Tkined was designed for network diagramming purposes and therefore provides direct support for the idea of grouping of network elements into single symbols on a diagram. It is possible for example, to develop a diagram that provides a high-level view of an IP wide-area network that has cloud symbols representing a sub-network or geographical area. When you double-click on these symbols tkined will replace the symbol with another level of detail so you can "zoom-in" on the diagram on a particular area of interest. All of the detail is stored in a single Tkined drawing file which is very convenient. One shortcoming in the approach Tkined takes is that the exploded view simply replaces the original icon on the same diagram -- there is no concept of layers, or different views. To prepare an appropriately detailed diagram, it is first necessary to arrange all symbols with no grouping at all, and then to apply grouping later. This is the only reasonable way of ensuring there will be no overlap on the diagram after a group, or groups have been expanded.

One of the most powerful features of Tkined is the ease with which its functionality may be extended. Tkined was written using the TCL language and has been designed with extensibility in mind. A software package called Scotty illustrates this very effectively. Scotty provides a suite of network management tools including comprehensive SNMP support, IP, DNS, and other diagnostic tools and tools that automate the layout of network diagrams. Dynamic elements such as graphs of particular SNMP variables may be included on network diagrams. For small- to medium-sized networks Scotty can be quite a boon. Bringing network diagramming and network monitoring functions together can make for a simple but effective management solution.

To some extent, the automation features of Tkined obviate the need for an easily manipulated native file format as you can write a TCL module to export or import diagrams in whatever format you like. Despite this, the Tkined native file format (.tki) is very easy to understand. It's a plain ASCII format that again isn't well documented, but examining the syntax of a few simple examples will tell you most of what you need to know with little effort.


Xfig

Copyright: Supoj Sutanthavibul, Brian V. Smith, Paul King
License: BSD-like
Version: 3.2.3a
Available at: ftp://ftp.x.org/contrib/applications/drawing_tools/xfig/

The Xfig drawing package is a general-purpose vector drawing package. Its interface provides all the sorts of features I think are important for network diagramming packages including a "Smart Links" features which allows lines/links between symbols to be move when either symbol moves. The Xfig interface is clean and easy to learn once you become accustomed to the lack of a "select" tool; each tool has an built-in select function.

There are a good supply of drawing symbols supplied with the Xfig package, but the network icons seem better suited to presentation graphics rather than network diagrams. Nevertheless you can create and use your own. The library symbols are easily generated, they're simply Xfig drawings stored in a relevant subdirectory of a Xfig library directory.

A grab of Xfig showing part of the tool menu and a diagram.
Figure 4. A grab of Xfig showing part of the tool menu and a diagram.

A wide range of export formats are supported. Just about everything you could need is there including PostScript, HPGL, JPEG, GIF, and HTML imagemap. Some external programs are required to support some formats, but they're neatly integrated.

There is no support for hierarchically structured diagrams that I could find, but Xfig does support layered diagrams, so you could perhaps achieve a similar effect by placing each diagram at a different layer and simply turning or off the layers that you're interested in.

The Xfig native file format is documented! Some text files included in the source distribution describe the file format, and differences between each of the many versions of Xfig (the file format has changed a number of times as new features have been added). Xfig files are a plain-text format that will be very easy to manipulate and write, but would be very difficult to understand without a reference handy. Additionally the Xfig file format is pretty well supported by a number of other third-party applications including Gnuplot which can export graphs into Xfig diagrams.


How do they rate?

The following table summarizes my assessment of how well each of the packages meets the needs of a network diagram package.

All of these packages are readily available so the rule of thumb should be: If in doubt, try it out.

Package OO Interface Icon Library Export Hierarchical Views Open Format Rating
Dia 9 6 3 0 8 26
Tgif 3 1 8 8 7 27
Tkined 8 8 3 7 7 33
Xfig 9 7 9 5 9 39

My picks are Xfig and Tkined, but you should take a look at the others too. It's easy enough to try different tools, so use the one that best suits your needs. If you find a package that you think does a better job than the packages described here, please let me know.

If you want to assist any of the software projects described in this column, a good place to start if you're graphically inclined might be to contribute a set of symbols for the libraries to the source distribution.

Terry Dawson is the author of a number of network-related HOWTO documents for the Linux Documentation Project, a co-author of the 2nd edition of O'Reilly's Linux Network Administrators Guide, and is an active participant in a number of other Linux projects.


Read more Linux Network Administration columns.

Discuss this article in the O'Reilly Network Linux Forum.

Return to the Linux DevCenter.

Copyright © 2009 O'Reilly Media, Inc.