-
Notifications
You must be signed in to change notification settings - Fork 0
Using the filetransfer plug in
The filetransfer plug-in is used to transfer files between virtual nodes. It contains very simple and custom implementations of an HTTP client and an HTTP server. The client sends GET requests to the server, and the server responds with the file contents.
<software [...] arguments="arg1 arg2 arg3 [...]" />
The arguments attribute of the software XML element specifies application arguments for configuring a node's instance of the plug-in. Each argument is separated by a space. For the filetransfer plug-in, the first item of the arguments attribute specifies the mode, one of either client or server, and client mode can either be single mode (download n times from one server) or multi mode (download multiple times from multiple servers).
- the string 'server'
- the port on which the server will listen for connections
- the path to the document root to be served
- the string 'client'
- the string 'single'
- the file server's hostname
- the port on which to connect to the HTTP server (the server's listen port)
- the string 'none', or the hostname of a SOCKS proxy server
- the string '0', or the port on which to connect to the SOCKS proxy server
- the number of times to download the file
- the path of the file to download, relative to the server's docroot (must begin with '/')
- the string 'client'
- the string 'multi'
- the path to a download specification file
- the string 'none', or the hostname of a SOCKS proxy server
- the string '0', or the port on which to connect to the SOCKS proxy server
- the path to a think-time CDF file
- the string '-1', or the maximum number of seconds to run before shutting down
- the string '-1', or the maximum number of files to download before shutting down
Each line of a download specification file should contain three items separated by a ':' (colon): a server's name, the server's port, and the file to download. This allows specification of multiple files from multiple servers. For each download, the client chooses a random line and downloads as specified. The format is like:
server1name:80:/myfile1
server2name:80:/myfile2
Each line of a think-time CDF file should contain two items separated by a ' ' (space): the cumulative value of the think time in milliseconds (the time to pause after finishing one download and before starting the next), and the percentile of that value (between 0 and 1).
1000.000 0.2000000000
2000.000 0.4000000000
3000.000 0.6000000000
4000.000 0.8000000000
5000.000 1.0000000000
To simulate file downloads of X KiB each, first create a file in what will become our server root directory:
mkdir docroot
dd if=/dev/urandom of=docroot/myfile bs=1024 count=X
Then, we create a hosts.xml with the following:
<plugin id="filex" path="~/.shadow/plugins/libshadow-plugin-filetransfer.so" />
<software id="serverapp" plugin="filex" time="10" arguments="server 80 docroot/" />
<node id="servername" software="serverapp" />
<software id="clientapp" plugin="filex" time="20" arguments="client single servername 80 none 0 5 /myfile" />
<node id="clientname" software="clientapp" />
<kill time="600" />
Make sure you have the ~/.shadow/share/topology.xml
file installed, then run the example:
shadow ~/.shadow/share/topology.xml hosts.xml | grep fg-download-complete
The output should look like:
[fg-download-complete] got first bytes in 0.229 seconds and 10240 of 10240 bytes in 0.294 seconds (download 1 of 5)
[fg-download-complete] got first bytes in 0.208 seconds and 10240 of 10240 bytes in 0.272 seconds (download 2 of 5)
[fg-download-complete] got first bytes in 0.443 seconds and 10240 of 10240 bytes in 0.813 seconds (download 3 of 5)
[fg-download-complete] got first bytes in 0.213 seconds and 10240 of 10240 bytes in 0.420 seconds (download 4 of 5)
[fg-download-complete] got first bytes in 0.321 seconds and 10240 of 10240 bytes in 0.478 seconds (download 5 of 5)
The server can handle multiple connections at once to various clients, but only one file may be downloaded over each connection. The client can only download one file at a time.