CSE logo University of Washington Department of Computer Science & Engineering
 CSE 588 - Spring 2002 - Fishnet Documentation
  CSE Home     CSE 588 Home  About Us    Search    Contact Info 

Introduction to the Fishnet

Fishnet is a library which simplifies the process of building and deploying network protocols.

The term "Fishnet" is somewhat overloaded, and before going further we want to clarify what it means. First, it is a library (see the description of libfish.a below). This is also called the Fishnet development environment. Second, it is a running network of many nodes and a single fishhead (a key component described below). This is what we most commonly mean by a Fishnet. Note, however, that there are many potential Fishnets. You may all have independent, private Fishnets to develop and run your code, or you may want to combine your Fishnet with someone else's. Each Fishnet has a single Fishhead. Nodes within a Fishnet interact with the Fishhead they are pointed to. So if you want to run a shared Fishnet, you run a public, shared Fishhead.

Development Environment

Fishnet is only available for Linux, and only provides a C API. You have access to the blackbox cluster to develop and run your projects. The compiler we will use is gcc, and the debugger we will use is gdb. You can use any editor you prefer, such as emacs.

Fishnet Components

The Fishnet code is available for linux users or for Windows users with cygwin installed. See below for notes about using it with Windows. The package we provide you with contains the following key components:

fishhead

fishhead is a program that manages Fishnet nodes. A network can contain many nodes, but only one fishhead. The main function of the fishhead is to tell individual nodes who their neighbors are. It is important to understand that the fishhead manages the network topology and decides who is connected to whom, not you in your programs. (For the curious, the nodes of networks you operate are run as separate processes that communicate with each other using a UDP overlay.)

When you develop a Fishnet node and run it, one of the first things it will do is to join a Fishnet network by contacting the fishhead. This means that before you start one of your Fishnet nodes there must be a fishhead process running. You only need to start a fishhead for your network once, even though the nodes in the network can come and go.

libfish.a

The fish library implements all of the Fishnet functionality that you will need for your assignments. When you send a message using the fish_sendframe() function, for example, libfish.a is called to do the work of sending the packet. libfish.a also prints a large (but controllable) amount of debugging information to the console (stderr) to help you understand what is going on with your program. The library source code is available in the fishsrc directory so that you can see how the Fishnet really works and to help with your debugging. If you want to interact with other people's nodes, you should not change this code. In fact, you should not need to in general. If you feel the need, please let bart@cs.washington.edu know.

fish.h

This is the header file that you should include in your C program to gain access to the functionality implemented in the fish library. It contains the dozen or so Fishnet API functions that you can call, as well as the structures that define packet formats, and other Fishnet constants. You should read the comments in this file, as it contains the definitive Fishnet API documentation.

Sample

Here is a sample program (with source) to help you get started. You might want to look at the CSE461 web pages as well to get more information.

The program takes three whitespace separated command line arguments: first, a string representing the location of the fishhead, in the format "hostname:port"; second, the name of the domain which your node will belong to, which is simply a string and can be anything; third, the address you want for your Fishnet node, which is simply a small unique number.

When run, it joins the Fishnet described by the command line arguments using the fish_joinnetwork() call (you will need to have started the fishhead before running your program). Remember, you choose the address of the node, but the fishhead decides what other nodes it is connected to, and the neighbors can change as other nodes come and go.

Once running, it waits to get a line of input from the keyboard using fish_recvhook() and checks to see if the input is of the form "send <address> <message>", where <address> is a number representing the address of the node to send to, and <message> is a string that may contain spaces and is terminated by the end of the line.

When a command of this form has been received, the program sends a packet containing the message to a random neighbor using fish_send(). It does this by constructing a packet structure (struct packet) and filling in the source address, destination address, TTL, protocol, and packet contents as appropriate. In this example, the value of the TTL is the constant MAX_TTL, and the protocol is FISH_PROTOCOL_ECHO_REQUEST. These constants are defined in fish.h. The rest of the program described below will forward the packet through the network to its destination and cause an acknowledgement packet to be returned to the sending node.

The sample also waits to receive a packet from the network using fish_recvhook(). When a packet is received, it is dealt with as follows:

If the packet’s destination is not the current node, the TTL field is decremented. If the new value of the TTL is greater than 0, the packet will be forwarded to a random neighbor. Otherwise, the packet’s time to live has expired and it is dropped.

If the packet’s destination is the current node and the protocol is FISH_PROTOCOL_ECHO_REQUEST, the program (implementing that node) will print "Echo request from <address>: <message>", where <address> is the source of the packet and <message> is its data. It then makes a new packet with the protocol FISH_PROTOCOL_ECHO_RESPONSE and sends it back to the node that sent the original packet, with the original message as its data.

If the packet’s destination is the current node and the protocol is FISH_PROTOCOL_ECHO_RESPONSE, the program implementing that node will print "Echo response from <address>: <message>".

The sample program will repeat taking input, sending, receiving, and printing indefinitely, until you type "exit".

Some additional comments

Read fish.h. The comments in this file tell you what the Fishnet API calls are, what they do, what arguments they take and return, and so forth. You won’t find this information anywhere else.

Make sure you can log into the blackbox cluster ( check machine status, individuals are often down). You are by no means required to use this cluster, but it is there for you if you want it.

Start a fishhead process to manage a Fishnet by running the fishhead program that is inside the fishnet directory. Type './fishhead --help' to find out what command line arguments it accepts. You will need to give it a argument to indicate which port it should listen on for messages. Pick a number between 1024 and 32K. If the number you choose is the same as someone else’s fishhead will fail to start. The fishhead program runs indefinitely to keep the Fishnet it is running up. You should leave it running and create another window in which to do your development. When you’re done, stop it by typing CTRL-C (^C).

When testing your programs, you will probably find it easiest to bring up a separate window for each node, as well as the window for the fishhead. If you enabled libfish debugging messages using the fish_setdebuglevel() function, you should also see how your packets move through the network.

Windows users:

You have three options when using Fishnet:
  1. Use ssh to connect from remote to one of the blackbox cluster machines. You can setup ssh to tunnel X windows connections, so you can open up various windows from the blackbox cluster and see them on your local machine. This requires a reasonably good connection.
  2. Download and install cygwin on your local machine. Cygwin is a set of unix tools for Windows, including a shell and the gcc compiler. You can then download and use the modified Fishnet library, just as if you were on a unix machine. The only caveat is that the executables you build are not likely to be able to interoperate with executables built on real linux boxes. If you later wish to test your code on the cluster (using a large number of nodes, for instance), you will have to recompile. Recompiling should be easy, assuming you are using gcc and make.
  3. Thanks to Rajesh Hegde, we now have a Visual Studio port of fishnet. There is a version for Visual Studio 6 users and a version for Visual Studio .NET.

    When you unzip the file of your choice, you will get three directories:

    • WinFishLib: Created the Fish Library to be used by the FishHead and the Clients
    • WinFishNet: Creates the FishHead application
    • WinFishNetClient: Creates Sample Echo client
    For Visual Studio .NET the solution file can be found in WinFishNet directory. For Visual Studion 6, the DSW file can be found in WinFishLib directory.


CSE logo Department of Computer Science & Engineering
University of Washington
Box 352350
Seattle, WA  98195-2350
(206) 543-1695 voice, (206) 543-2969 FAX
[comments to owner-cse588]