|Similar to the Layer3 perl script, lf_firemod.pl, the
lf_generic_ping.pl script has been enhanced to use curl or other
commands with parameter expansions. The lf_curl.sh script is a
helper script that wraps curl commands and reports success or failure.
Introduced in LANforge 5.3.8.
Generic endpoints are effectively one-legged connections. You can ping an IP or use curl to download web content. Both of these types of connections can be pointed back at the LANforge itself. We can operate these connections from redirect interfaces. The same techniques can apply to WiFi stations, of course.
/home/lanforge$ . lanforge.profile
/home/lanforge$ ping -I 10.41.1.141 10.41.0.1
/home/lanforge$ curl -sq --interface 10.41.1.141 http://10.41.0.1/
In the /home/lanforge/scripts directory, the lf_generic_ping.pl script creates a wrapped ping command by default. There is another script, lfping, that reports ping results to LANforge. Here is an example of creating 1 ping endpoint:
/home/lanforge/scripts$ ./lf_generic_ping.pl --mgr localhost --resource 1 \ --dest 10.41.0.1 --interface r1b#0 --name pingtest
Create a ping endpoint for every MAC VLAN parented by r1b:
$ ./lf_generic_ping.pl --mgr localhost --resource 1 \ --dest 10.41.0.1 --parent r1b
Create a ping endpoint for every virtual station parented by wiphy0:
$ ./lf_generic_ping.pl --mgr localhost --resource 1 \ --dest 10.41.0.1 --radio wiphy0
Create a ping endpoint for every MAC VLAN beginning with r1b#1 (r1b#1, r1b#10):
$ ./lf_generic_ping.pl --mgr localhost --resource 1 \ --dest 10.41.0.1 --match 'r1b#1'
To use other commands with the script, you can create a --cmd parameter. You can use curl directly if desired, but curl's output is not formatted well for LANforge to understand. By default, commands do not understand what port or IP they should be interacting as. We need to provide special parameters to help.
The lf_generic_ping.pl script will look for these tokens in the --cmd parameter:
The scripts/lf_curl.sh script is a wrapper for curl that detects success or failure, and an operate the request in a loop. Expandable parameters are expanded by lf_generic_ping.pl, not lf_curl.sh.
You can use lf_curl.sh from the command line to test it out:
$ ./lf_curl.sh -i 10.41.1.141 -p r1b#1 -o /tmp/output -d http://example.com/
curl -sqLk --interface 10.0.0.1 -o /tmp/output_r1b#1 http://example.com/
So it is best used from lf_generic_ping.pl to construct commands referencing this script:
./lf_generic_ping.pl --mgr localhost --resource 1 \ --name curl_ex_ --match 'r1b#' --dest http://10.41.0.1/ \ --cmd 'lf_curl.sh -o /tmp/curl_%p.out -i %i -d %d -p %p'