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.
Also in Linux Network Administration
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.
Icon or graphic symbol library
You'll want a standard way of representing different classes of entities on your diagram. Ideally you'll want the ability to modify existing images and to add images you've created yourself. You might for example want a standard symbol that represents an IP router, but also want to be able to differentiate a Linux-based router from a Cisco router from a Lucent router.
This allows you to do things such as connect router icons with network icons and attach descriptive text that stays with an icon as you move it. You will want to be able to easily move items around on your diagram without losing their associations in order to rearrange the layout of your diagram easily.
Export to graphic file or printer
A diagram is useless if you can't consume it. You must be able to print the diagram legibly to paper, and be able to export it to a common image format such as PNG, JPEG, or GIF if you wish to publish the diagram electronically.
Hierarchical or embedded views
It's convenient to be able to embed diagrams within diagrams and have some means of switching from one diagram to another, double-clicking on an icon for example. This saves you from being forced to maintain multiple image files that all relate to the same network and helps ensure some consistency among diagrams.
Well-documented diagram file format
You may want to generate your diagrams programmatically. For example, you might wish to read device and interface data from an SNMP data-collector and generate network diagrams directly from it. In the same way you may want to use the drawing package as a means of data input, perhaps generating configuration data directly from a diagram where it was initially input. You will need to understand the image format and have it be convenient to work with. A well-documented plain-text format can make it easy to develop scripts to process the image file data.
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.
Copyright: Alexander Larsson, James Henstridge, et.al.
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.
Figure 1. The Dia tool window showing some network shapes.
Copyright: William Chia-Wei Cheng
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!).
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.
Copyright: Juergen Schoenwaelder
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.
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
Copyright: Supoj Sutanthavibul, Brian V. Smith, Paul King
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.
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.
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|
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.