SimpleNetSim: A Java Network Simulator
Overview
SimpleNetSim is a basic network simulator written in Java
for the entire purpose of teaching core ideas in network protocols,
in particular, the datalink, network and transport layers.
The GUI-based simulator handles the application and physical layers,
handles generation of packets, and provides statistics.
What you need to know:
- The code comes in an executable jar file, which when executed
brings up a GUI.
- There is a self-explanatory parameter file that describes the network topology,
among other things.
- There are well-defined Java interfaces for the three layers of interest.
- There are sample (dummy) implementations of those interfaces,
i.e., three layers that provide bare-bones functionality. This code
can be examined to see how the layers could interact.
- You can debug in several ways: (1) by assigning colors to packets
so that you can see (by animation) what's going on; (2) by turning
"debug" on in the GUI, and writing to
Debug.println(). This writes to a debug.data file
in your directory, which you can later examine.
- The simulator counts time in discrete steps. Thus,
there is time step 1, time step 2, ... and so on.
- Node addresses are simple integers: 0, 1, 2, ... etc.
Installation
- Make a working directory for your self.
- Download and unpack SimpleNetSim.zip into your working directory.
This should produce an executable jar file called
simplenetsim.jar and a directory called /examples.
- Enter the directory called /examples:
cd examples
- Compile the dummy implementations:
javac -cp ../simplenetsim.jar *.java
- Edit the file test1.dat and edit the line that
begins with fullDirPath so that it reflects the full
path to the current directory. Remember to use the correct slash,
depending on which operating system you are using.
- Execute SimpleNetSim:
java -jar ../simplenetsim.jar
This should bring up the SimpleNetSim GUI. If it doesn't, something
did not work with either the directory path or there was a typo.
- What to try in the GUI:
- Click on "Load", which loads the default parameter file test1.dat.
- Click on "Debug", which turns on debugging.
- Set animation to "Slow".
- Click on "Reset".
- Click on "Go".
- Now watch the animation. This parameter file creates data for
only a single connection from Node 0 to Node 1. It should take
about 20-30 seconds to run.
- Examine the file
debug.data
in a text editor. This will be rather
incomprehensible at first but it gives you an idea of what happens
at each time step.
- Read through the SimpleNetSim
API, starting with the interfaces for the transport, network
and datalink layers.
- The next best thing to do is to examine the default (dummy)
implementations to see how they implement the layers.
The STTP protocol
SimpleNetSim provides a sample "web browser" application that
abstracts away just about all detail but the basic idea.
Let's try this in the GUI:
- Before starting up
simplenetsim,
examine the file
index.stml
in the directory. As you can see, it's a simple text file.
- Now run
simplenetsim
as before:
java -jar ../simplenetsim.jar
- Click on "Load", which loads the default parameter file test1.dat.
- Click on "Debug", which turns on debugging.
- Set animation to "Fast".
- Click on "Reset".
- Right click on node 1, the second node from the left and click
on "Start browser". This will bring up a separate browser window,
a really simple browser.
- Enter "0:index.stml" in the URL textbox and click "Get".
- Click on "Go" in the main window. Note: this may obscure the
browser window. Move the main
simplenetsim
window to reveal the browser window.
- You should see some packets move back and forth and the
contents of
index.stml
appear in the default browser's window.
What exactly is going on?
- STTP stands for: Simple Text Transfer Protocol.
- The browser lets you enter a URL of the type:
0:index.stml.
=> What this means: this fetches the file index.stml from
node 0.
- Every node by default runs a webserver on port 80 and a
webbrowser when brought up through a right-click (as above).
- Read through the code in DefaultWebBrowser and
DefaultWebServer to see how it works.
- The idea is, you can implement a more sophisticated web browser
that implements the
WebServer interface.