J-Sim Official

A Simple Four-host, Four-router, UDP and FSP Example

March 25, 2005

Similar to FTP, File Service Protocol (FSP) is a file transfer protocol.  Unlike FTP, it uses the datagram service provided by UDP (instead of the reliable byte stream service by TCP). In J-Sim, we have implemented a simplified version of FSP in the drcl.inet.application.fsp/fspd class. In this example, we will show how to set up, and run, a FSP session on top of UDP in a slightly more complicated network topology.

Figure 1: The scenario constructed in this example

 

Step 1. Create the Network Topology

Step 1.1.  We create a component directory to hold the components created for this example:

cd [mkdir drcl.comp.Component /example4]

Step 1.2. We create the topology:

puts "Create topology..."
set link_ [java::new drcl.inet.Link]
$link_ setPropDelay 0.1; # 100ms
set adjMatrix_ [java::new {int[][]} 8 {{2 3} {3 4} {0 3 5 6} {0 1 2 7} {1} {2} {2} {3}}]
java::call drcl.inet.InetUtil createTopology [! .] $adjMatrix_ $link_

Step 2. Configuring the nodal structure

Step 2.1.  We first create a router builder, a source host builder and a sink host builder.  Then, we build and configure the nodes (with the build method in the NodeBuilder class) and configure the bottleneck bandwidth and buffer size:

puts "build..."
# NodeBuilder:
set rb [mkdir drcl.inet.NodeBuilder .routerBuilder]
$rb setBandwidth 1.0e6; # 1Mbps
set hb [cp $rb .hostBuilder]
set hb6 [cp $rb .hostBuilder6]
set hb7 [cp $rb .hostBuilder7]
mkdir drcl.inet.transport.UDP $hb/udp
[mkdir drcl.inet.transport.TCP $hb6/tcp] setMSS 512; # bytes
mkdir drcl.inet.transport.TCPSink $hb7/tcpsink
$rb build [! n?]
$hb build [! h4-5]
$hb6 build [! h6]
$hb7 build [! h7]
! n2 setBandwidth 1 10.0e3; # 10Kbps at interface 1
! n2 setBufferSize 1 6000; # ~10 TCP packets at interface 1

Step 2.2. We set up the FSP server and client at host h5 and h4, respectively:

puts "set up fsp/fspd..."
set fspd_port 150
mkdir drcl.inet.application.fspd h5/fspd
mkdir drcl.inet.application.fsp h4/fsp
connect -c h4/udp/1001@up -and h4/fsp/down@
connect -c h5/udp/$fspd_port@up -and h5/fspd/down@

Step 2.3. We set up a bulk transfer connection on top of TCP between hosts h6 and h7:

! h6/tcp setPeer 7
set src_ [mkdir drcl.inet.application.BulkSource h6/source]
$src_ setDataUnit 512
connect -c $src_/down@ -and h6/tcp/up@

set sink_ [mkdir drcl.inet.application.BulkSink h7/sink]
connect -c $sink_/down@ -and h7/tcpsink/up@

Sidebar: Node Map

Similar to what we have done with node map in Example 2, we may use "node map" here to replace step 2.1-2.3 above:

set nb [mkdir drcl.inet.NodeBuilder .nodeBuilder]
$nb setBandwidth 1.0e6; #1Mbps
$nb build [! n?]
$nb build [! h4] {
udp drcl.inet.transport.UDP
fsp 1001/udp drcl.inet.application.fsp
}
$nb build [! h5] {
udp drcl.inet.transport.UDP
fspd 150/udp drcl.inet.application.fspd
}
$nb build [! h6] {
tcp drcl.inet.transport.TCP
source -/tcp drcl.inet.application.BulkSource
}
$nb build [! h7] {
tcpsink drcl.inet.transport.TCPSink
sink -/tcpsink drcl.inet.application.BulkSink
}
! h6-7/tcp* setMSS 512
! h6-7/s* setDataUnit 512
! h6/tcp setPeer 7
! n2 setBandwidth 1 1.0e4; # 10Kbps at interface 1
! n2 setBufferSize 1 6000; # ~10 packets at interface 1

Step 2.4. We set up a static route between hosts h4 and h5, and h6 and h7 using drcl.inet.InetUtil.setupRoutes(...):

puts "Set up static routes..."
java::call drcl.inet.InetUtil setupRoutes [! h4] [! h5] "bidirection"
java::call drcl.inet.InetUtil setupRoutes [! h6] [! h7] "bidirection"

Step 2.5. We set up two TrafficMonitor components and a Plotter component to on-line keep track of  the instantaneous throughput of the TCP connection as well as the FSP session:

set plot_ [mkdir drcl.comp.tool.Plotter .plot]
set tm0_ [mkdir drcl.net.tool.TrafficMonitor .tm0]
set tm1_ [mkdir drcl.net.tool.TrafficMonitor .tm1]
connect -c h5/fspd/down@ -to $tm0_/in@
connect -c h7/csl/6@up -to $tm1_/in@
connect -c $tm0_/bytecount@ -to $plot_/0@0
connect -c $tm1_/bytecount@ -to $plot_/1@0

Step 2.6. We set the debug flag in the FSP class so that a notification message is sent to the console when the file transfer is completed:

setflag debug true h4/fsp

Step 3.  Starting the Simulation

Step 3.1. We attach the simulator runtime, start the FSP server (h5/fspd), and start the bulk transfer:

# Attach the simulator runtime
set sim [attach_simulator .]
run .

Step 3.2. We transfer a file at the FSP client at time 100.0:

set cmd {! h4/fsp get "c:\\foo.jpg" "fsptest.jpg" 1024 5 $fspd_port}
script $cmd -at 100.0 -on $sim

Here we have used the get method in fsp to fetch a remote file, c:\\foo.jpg. The syntax of "get" is as follows:

<fsp_instance> get <remote_file_name> <local_file_name> <block_size> <peer_addr> <peer_port>

The command  fetches the file named <remote_file_name> from the server at the address <peer_addr> through <peer_port> and saves the file as a local file named <local_file_name>.  As FSP is laid on top of UDP, it transfers a file in blocks and <block_size> specifies the size of a block.  The file transferred by FSP is physically transferred (block by block) over the network from <remote_file_name> to <lcal_file_name>.

In this example, the block size is set to be 1024 bytes. The round-trip time for the fsp connection is ~1.7 second (without considering buffering, see below). The maximum attainable throughput  is thus 1024 * 8 / 1.7 ~ 4.8Kbps, which is corroborated in the following results.

* round-trip time calculation:
          propagation_delay = 0.1 sec/hop * 8 hops = 0.8 sec
          packet_size_FSP_request = 31 (FSP) + 8 (UDP) + 20 (IP) = 59 Bytes
          packet_size_FSP_reply = 1024 + 35 (FSP) + 8 (UDP) + 20 (IP) = 1087 Bytes
          transmission_delay = (1087*8/10k)*1hop + (1087*8/1M)*3hops + (59*8/1M)*4hops ~ 0.9 sec
          RTT = propagation_delay + transmission_delay ~ 1.7 sec

Results: After executing the above script, a window pops up that displays the instantaneous throughput attained by the bulk file transfer (on top of TCP) and the FSP file transfer (of a file of size 162 KB on top of UDP). 

The source code of this example is avalable here.


In summary, we have shown in this example

  1. How to set up and run (semi-)real applications on top of UDP/TCP and use J-Sim as a virtual networking environment.