# -*- TCL -*- # BEGIN Constants set opt(OSID) "RHL90-STD"; # OS to use set opt(DSL_CLIENT_COUNT) "2"; # Number of DSL clients. set opt(CABLE_CLIENT_COUNT) "3"; # Number of Cable clients. set opt(DSLBW) "2Mb"; # Link bandwidth for the DSL clients. set opt(DSLLAT) "50ms"; # Link latency for the DSL clients. set opt(CABLEBW) "2Mb"; # Lan-link bandwidth for the cable clients. set opt(CABLELAT) "25ms"; # Lan-link latency for the cable clients. set opt(TPORT) 6969; set opt(USER) enk3; set opt(PROJECT) btsim; set opt(EXP) python; #Create a simulator object set ns [new Simulator] source tb_compat.tcl # Create a node to run the tracker and main seed on. set server [$ns node] tb-set-node-os $server $opt(OSID) # Have BitTornado install when the node is ready. tb-set-node-startcmd $server "cd /users/$opt(USER)/BitTornado-CVS/; sudo python setup.py install > /tmp/install.log &" # Create a router that we'll connect the server and some other routers to. set corerouter [$ns node] tb-set-node-os $corerouter $opt(OSID) set sclink [$ns duplex-link $server $corerouter 10Mb 0ms DropTail] set corelanstr "$corerouter" # Create an "event-timeline" that starts up the daemons on the server set servertl [$ns event-timeline] # Create another timeline, this one is used to start the clients set clienttl [$ns event-timeline] # Create another two timelines to use after the main experiment to stop all # processes and remove any created files (makes the experiment repeatable) set serverresettl [$ns event-timeline] set clientresettl [$ns event-timeline] ########################## # BEGIN Cable network set cablerouter [$ns node] tb-set-node-os $cablerouter $opt(OSID) append corelanstr " $cablerouter" # We will create three separate LANs (because the router only has four # interfaces) which we will use to attach the clients to the router. set cablelanstr0 "$cablerouter" set cablelanstr1 "$cablerouter" set cablelanstr2 "$cablerouter" for {set lpc 1} {$lpc <= $opt(CABLE_CLIENT_COUNT)} {incr lpc} { set cableclient($lpc) [$ns node] tb-set-node-os $cableclient($lpc) $opt(OSID) tb-set-node-startcmd $cableclient($lpc) "cd /users/$opt(USER)/BitTornado-CVS/; sudo python setup.py install > /tmp/install.log &" set lannum [expr $lpc % 3] append cablelanstr${lannum} " $cableclient($lpc)" # Remove the old torrent file (it might be stale?) set cabletorrentclear($lpc) [$cableclient($lpc) program-agent -command "/bin/rm -f /tmp/sharedfile.tgz.torrent"] # Copy the torrent file to a universally accessible location. set cabletorrentcopy($lpc) [$cableclient($lpc) program-agent -command "/bin/cp /users/$opt(USER)/sharedfile.tgz.torrent /tmp/"] # Now start the seeder and redirect its output to ~/logs. set cableclientlaunch($lpc) [$cableclient($lpc) program-agent -command "cd /tmp; /usr/bin/btdownloadheadless.py /tmp/sharedfile.tgz.torrent --saveas /tmp/sharedfile_received.tgz > /users/$opt(USER)/logs/cableclient($lpc).log"] $clienttl at 1s "$cabletorrentclear($lpc) start" $clienttl at 4s "$cabletorrentcopy($lpc) start" $clienttl at 9s "$cableclientlaunch($lpc) start" $clienttl at 14s "$ns log cableclient($lpc) is running" # These are added to make the experiment repeatable without a complete reboot. # Stop the BitTornado client processes, set cablestop($lpc) [$cableclient($lpc) program-agent -command "something to stop client processes"] # remove all downloaded files, set cablerm($lpc) [$cableclient($lpc) program-agent -command "/bin/rm -f /tmp/sharedfile* "] # and dump the hosts file. set cableclienthosts($lpc) [$cableclient($lpc) program-agent -command "/bin/cat /etc/hosts > /users/$opt(USER)/logs/cable($lpc)hosts"] # $clientresettl at 1s "$cablestop($lpc) start" $clientresettl at 6s "$cablerm($lpc) start" $clientresettl at 9s "$cableclienthosts($lpc) start" } set cablelan0 [$ns make-lan $cablelanstr0 $opt(CABLEBW) $opt(CABLELAT)] tb-set-node-lan-bandwidth $cablerouter $cablelan0 100Mb tb-set-node-lan-delay $cablerouter $cablelan0 0ms set cablelan1 [$ns make-lan $cablelanstr1 $opt(CABLEBW) $opt(CABLELAT)] tb-set-node-lan-bandwidth $cablerouter $cablelan1 100Mb tb-set-node-lan-delay $cablerouter $cablelan1 0ms set cablelan2 [$ns make-lan $cablelanstr2 $opt(CABLEBW) $opt(CABLELAT)] tb-set-node-lan-bandwidth $cablerouter $cablelan2 100Mb tb-set-node-lan-delay $cablerouter $cablelan2 0ms # END Cable ########################## # BEGIN DSL network set dslrouter [$ns node] tb-set-node-os $dslrouter $opt(OSID) append corelanstr " $dslrouter" # We will create two separate LANs (because the router only has four # interfaces) which we will use to attach the clients to the router. set dsllanstr0 "$dslrouter" set dsllanstr1 "$dslrouter" for {set lpc 1} {$lpc <= $opt(DSL_CLIENT_COUNT)} {incr lpc} { set dslclient($lpc) [$ns node] tb-set-node-os $dslclient($lpc) $opt(OSID) tb-set-node-startcmd $dslclient($lpc) "cd /users/$opt(USER)/BitTornado-CVS/; sudo python setup.py install > /tmp/install.log &" set lannum [expr $lpc % 2] append dsllanstr${lannum} " $dslclient($lpc)" # Remove the old torrent file (it might be stale?) set dsltorrentclear($lpc) [$dslclient($lpc) program-agent -command "/bin/rm -f /tmp/sharedfile.tgz.torrent"] # Copy the torrent file to a universally accessible location. set dsltorrentcopy($lpc) [$dslclient($lpc) program-agent -command "/bin/cp /users/$opt(USER)/sharedfile.tgz.torrent /tmp/"] # Now start the seeder and redirect its output to ~/logs. set dslclientlaunch($lpc) [$dslclient($lpc) program-agent -command "cd /tmp; /usr/bin/btdownloadheadless.py /tmp/sharedfile.tgz.torrent --saveas /tmp/sharedfile_received.tgz > /users/$opt(USER)/logs/dslclient($lpc).log"] $clienttl at 1s "$dsltorrentclear($lpc) start" $clienttl at 5s "$dsltorrentcopy($lpc) start" $clienttl at 10s "$dslclientlaunch($lpc) start" $clienttl at 15s "$ns log DSLclient($lpc) is running" # These are added to make the experiment repeatable without a complete reboot. # Stop the BitTornado client processes, set dslstop($lpc) [$dslclient($lpc) program-agent -command "something to stop client processes"] # remove all downloaded files, set dslrm($lpc) [$dslclient($lpc) program-agent -command "/bin/rm -f /tmp/sharedfile* "] # and dump the hosts file. set dslclienthosts($lpc) [$dslclient($lpc) program-agent -command "/bin/cat /etc/hosts > /users/$opt(USER)/logs/dsl($lpc)hosts"] # $clientresettl at 2s "$dslstop($lpc) start" $clientresettl at 7s "$dslrm($lpc) start" $clientresettl at 10s "$dslclienthosts($lpc) start" } set dsllan0 [$ns make-lan $dsllanstr0 $opt(DSLBW) $opt(DSLLAT)] tb-set-node-lan-bandwidth $dslrouter $dsllan0 100Mb tb-set-node-lan-delay $dslrouter $dsllan0 0ms set dsllan1 [$ns make-lan $dsllanstr1 $opt(DSLBW) $opt(DSLLAT)] tb-set-node-lan-bandwidth $dslrouter $dsllan1 100Mb tb-set-node-lan-delay $dslrouter $dsllan1 0ms # END DSL set corelan [$ns make-lan $corelanstr 100Mb 0ms] tb-set-ip $server 10.1.3.2 # Create "program agents" on the server that we will use to run the tracker and seeder programs. # First, generate the file on the local disk on the server, then set filegenerate [$server program-agent -command "/proj/$opt(PROJECT)/scripts/genfile.pl -z 104857600 -o /tmp/sharedfile.tgz"] # Start the tracker... set trackerlaunch [$server program-agent -command "cd /tmp; /usr/bin/bttrack.py --port $opt(TPORT) --dfile dstate > /users/$opt(USER)/logs/server.log &"] # ... remove the old torrent file (it might be stale?) set torrentclear [$server program-agent -command "/bin/rm -f /tmp/sharedfile.tgz.torrent"] # ... create a new torrent file. set torrentmake [$server program-agent -command "/usr/bin/btmakemetafile.py http://server.$opt(EXP).$opt(PROJECT).emulab.net:$opt(TPORT)/announce /tmp/sharedfile.tgz"] # Copy the torrent file to a universally accessible location. set torrentcopy [$server program-agent -command "/bin/cp /tmp/sharedfile.tgz.torrent /users/$opt(USER)/"] # Now start the seeder. set seederlaunch [$server program-agent -command "/usr/bin/btdownloadheadless.py /tmp/sharedfile.tgz.torrent --saveas /tmp/sharedfile.tgz"] $servertl at 5s "$filegenerate start" $servertl at 10s "$trackerlaunch start" $servertl at 15s "$torrentclear start" $servertl at 20s "$torrentmake start" $servertl at 30s "$torrentcopy start" $servertl at 35s "$seederlaunch start" $servertl at 40s "$ns log Seed is running" # These are added to make the experiment repeatable without a complete reboot. # Stop the BitTornado server processes, set seederstop [$server program-agent -command "something to stop the seeder"] set trackerstop [$server program-agent -command "something to stop the tracker"] # and remove all created files. set serverrm [$server program-agent -command "/bin/rm -f /users/$opt(USER)/sharedfile* /tmp/sharedfile*"] # Now the server's hosts file. set serverhosts [$server program-agent -command "/bin/cat /etc/hosts > /users/$opt(USER)/logs/serverhosts"] #$serverresettl at 1s "$seederstop start" #$serverresettl at 5s "$trackerstop start" $serverresettl at 10s "$serverrm start" $serverresettl at 15s "$serverhosts start" ### insert congestion code here ### # Create the sequence of events that run everything. set doit [$ns event-sequence { # ... start the server programs, and $servertl run # ... THEN start the clients. $clienttl run $ns message "BitTorrent setup is running." # Finally, send a report back to the experimenter. $ns report }] set reset [$ns event-sequence { # First, stop all processes on the server $serverresettl start # ...now stop the clients, delete their downloaded files, and dump all hosts files $clientresettl start $ns message "BitTorrent setup has stopped." }] #Enable routing $ns rtproto Session $ns run # To start program agents, run this on users.emulab.net: # tevc -e btsim/python now doit start # To reset all agents, run this on users.emulab.net: # tevc -e btsim/python now reset start # To monitor the tracker, load this web address: # http://server.python.btsim.emulab.net:6969/