By default, web servers (like Apache or Nginx) are designed to respond by giving content. Receiving content requires some add-on to accept incoming uploads. The notable methods are CGI and WebDAV. WebDAV configurations are specific to either Apache or Nginx, so we will focus this cookbook on the CGI method, with PHP as the CGI engine. PHP is installed by default with LANforge systems.
Continual traffic generation is a scenario that would fill the space of any web server. This cookbook describes a technique that will not save uploaded data, and thus should allow an indefinite duration of upload traffic. Specifically, processes that accept uploaded data do not need to save it. The technique used by up.php relies on the files being uploaded to /tmp which on most recent LANforge systems is a tmpfs RAM-based filesystem.
There is no good way to ignore the uploaded output. It goes immediately to the filesystem.
The default fedora upload location is /tmp. This is a RAM-based filesystem. You will crash your LANforge nginx server, and possibly the machine itself if your uploads take up more than half your ram.
If you want to upload a lot of data per upload, it is going to have to live on the LANforge’s SSD.
In /etc/php.ini, set upload_tmp_dir = “/home/lanforge/tmp”
Consider that SSDs have a writes-per-lifetime limit. Continual writing adds wear to the drive.
SSDs can only write between 30-500MB/s (4000 Mbps). This depends on the model of SSD, the speed of the SATA bus, and the write-caching and wear leveling techniques the SSD uses.
If doing HTTP uploads is a performance test, we suggest building a system with hundreds of gigabytes of RAM for tmpfs
space.
To handle large numbers of stations doing uploads, set the upload size limit small to avoid filling up RAM.
Monitor free RAM with htop. On a ct521a, there is 4GB of RAM, total. Thus you have up to 2GB of free space in /tmp:
Remeber that as while the LANforge GUI runs, it consumes RAM itself. Depending on the duration of the report, it can consume most of the remaining ram. Consider running the LANforge GUI on a separate machine.
In /etc/php.ini, set your post_max_size and upload_max_filesize parameters to (2GB / number of Layer 4 connections):
For 16 stations with one Layer 4 connection each:
2 x 1024 x 1024 x 1024 / 16 = 134,217,728 ~= 134MB
For 32 stations with two Layer 2 connections each:
2 x 1024 x 1024 x 1024 / 64 = 33,554,432 ~= 33MB
The php.ini default max upload size is set at 2MB:
post_max_size = 8M upload_max_filesize = 2M
These system defaults permit 1024 simultaneous uploads.
Copy up.php to /usr/local/lanforge/nginx/html
In the Port Mgr tab, modify your port and select the ☑HTTP checkbox and click Apply. In this example, the port is eth1 (192.168.48.92). Keep the window open.
In a terminal, edit /home/lanforge/vr_conf/nginx_eth1.conf
location /up.php { include /usr/local/lanforge/nginx/conf/fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_pass unix:/run/php-fpm/www.sock; fastcgi_index index.php; }
1 # Remove the first line '# Autogenerated by ...' and edit the file as 2 # desired for a custom config file. 3 4 worker_processes 1; 5 error_log logs/eth1_error.log; 6 pid /home/lanforge/vr_conf/nginx_eth1.pid; 7 events { 8 worker_connections 1024; 9 } 10 11 http { 12 include /usr/local/lanforge/nginx/conf/mime.types; 13 default_type application/octet-stream; 14 access_log logs/eth1_access.log; 15 sendfile on; 16 keepalive_timeout 65; 17 18 server { 19 listen 192.168.48.92:80 bind_dev=eth1; 20 server_name localhost; 21 access_log logs/eth1_host.access.log; 22 23 location / { 24 root html; 25 index index.html index.htm; 26 } 27 error_page 500 502 503 504 /50x.html; 28 location = /50x.html { 29 root html; 30 } 31 location /up.php { 32 include /usr/local/lanforge/nginx/conf/fastcgi_params; 33 fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 34 fastcgi_pass unix:/run/php-fpm/www.sock; 35 fastcgi_index index.php; 36 } 37 } 38 }1. Save the file.
/etc/php-fpm.d/www.conf
filenobody
To monitor the nginx log file:
sudo -s
Permission Denied errors:
/etc/php-fpm/www.conf
file mentioned above and restart the php-fpm service.There a token files to upload, located in /var/www/html
named dataslug{size}.bin.
The curl -F
command will issue a POST in the multipart-form manner.
The filename=
parameter is the name of the form's [input]
parameter that matches the [input type=file]
element in the page.
The @/var/www/html/data_slug_256K.bin
is curl syntax for opening the named file.
Start off by practicing the vrf_exec.bash command from a terminal:
./vrf_exec.bash wlan0 curl -F 'filename=@/var/www/html/data_slug_256K.bin' http://192.168.48.92/up.php
Once that works, go to the LANforge GUI Generic tab and create a new endpoint:
./vrf_exec.bash wlan0 curl -F 'filename=@/var/www/html/data_slug_256K.bin' http://192.168.48.92/up.php
In the Generic tab, select your connection and click Start
Double click the connection
In the Create/Modify Generic Endpoint window, click the Sync button (at the bottom).
You will see the HTML text of the result.
Dload Upload Total Spent Left Speed 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0 100 256k 0 622 100 256k 24960 10.0M --:--:-- --:--:-- --:--:-- 10.4M <!DOCTYPE html> <html lang="en"> <head> <title>Layer 4 Upload Test</title> <meta charset="utf-8"> <style> body { font-family: "Century Gothic", "DejaVu Sans",Arial,Helvetica,sans-serif; margin: 1em auto; } h1 { text-align: center; } </style> </head> <body> <h1>Layer 4 File Upload Test</h1> <h1>Result:</h1> <ul> <li>File name: <tt><data_slug_256K.bin></tt></li> <li>File size: <tt><262144></tt></li> <li>File tmp: <tt></tmp/phpRLHVa2></tt></li> </ul> </body></html>
A command that might provide better output could look like:
./vrf_exec.bash wlan0 curl -s -o/tmp/$$.html -F 'filename=@/var/www/html/data_slug_256K.bin' http://192.168.48.92/up.php; grep File /tmp/$$.html
It provides terse output like:
<h1>Layer 4 File Upload Test</h1> <li>File name: <tt>[data_slug_256K.bin]</tt></li> <li>File size: <tt>[262144]</tt></li> <li>File tmp: <tt>[/tmp/phpfhDFMf]</tt></li>
You can copy the up.php page as text from here: