# # \brief Test for using netperf # \author Alexander Boettcher # \author Martin Stein # \date 2013-04-18 # # # To execute this run script on your Linux host you have to do some # preparation: # # 1) Setup a TAP device: # ! export USER=[YOUR_USER_NAME] # ! export FLAVOR=[YOUR_TEST_FLAVOR] # e.g. 'lwip_bridge' # ! export TAP_DEV=tap0 # ! sudo ip tuntap add dev $TAP_DEV mode tap user $USER # ! sudo ip address flush dev $TAP_DEV # ! sudo ip address add 10.0.2.1/24 brd 10.0.2.255 dev $TAP_DEV # ! sudo ip link set dev $TAP_DEV addr 02:00:00:ca:fe:01 # ! sudo ip link set dev $TAP_DEV up # # 2) Now, start the test: # ! cd build/x86_64 # ! make run/netperf_$FLAVOR KERNEL=linux BOARD=linux # # 3) Clean up your Linux when done testing: # ! sudo ip tuntap delete $TAP_DEV mode tap # if {[have_include "power_on/qemu"]} { puts "\nRun script does not support Qemu.\n" exit 0 } if {[have_board imx53_qsb_tz] || [have_board rpi]} { puts "Run script is not supported on this platform." exit 0 } proc unique_byte_per_platform { } { if {[expr ![have_include "power_on/qemu"]]} { if {[have_spec arm_v6]} { if {[have_board rpi]} { if {[have_spec hw]} { return 0; } } } if {[have_spec arm_v7a]} { if {[have_board imx53_qsb]} { if {[have_spec hw]} { return 1; } } if {[have_board imx6q_sabrelite]} { if {[have_spec hw]} { return 2; } if {[have_spec foc]} { return 3; } if {[have_spec sel4]} { return 4; } } if {[have_board imx7d_sabre]} { if {[have_spec hw]} { return 5; } if {[have_spec foc]} { return 6; } if {[have_spec sel4]} { return 7; } } if {[have_board zynq_usrp_e31x]} { if {[have_spec hw]} { return 8; } } } if {[have_spec arm_v8a]} { if {[have_board imx8q_evk]} { if {[have_spec hw]} { return 20; } } } if {[have_spec x86_32]} { if {[have_board linux]} { if {[have_spec linux]} { return 40; } } if {[have_board pc]} { if {[have_spec foc]} { return 41; } if {[have_spec sel4]} { return 42; } if {[have_spec nova]} { return 43; } if {[have_spec fiasco]} { return 44; } if {[have_spec okl4]} { return 45; } if {[have_spec pistachio]} { return 46; } } } if {[have_spec x86_64]} { if {[have_board linux]} { if {[have_spec linux]} { return 60; } } if {[have_board pc]} { if {[have_spec hw]} { return 61; } if {[have_spec foc]} { return 62; } if {[have_spec sel4]} { return 63; } if {[have_spec nova]} { return 64; } } } } puts "Failed to determine unique byte for target." exit -1 } proc server_data_port { } { return [expr 18000 + [unique_byte_per_platform]]; } proc server_ctrl_port { } { return 12865; } set bridge_mac "02:02:02:02:16:00" set version "2.6.0" # sanity check that the right version is used set wrong_version [catch { spawn netperf-$version -V expect { {Netperf version 2.6.0} { } eof { return } timeout { return } } }] if {$wrong_version} { puts -nonewline "\nPlease compile a netperf client of version $version " puts "for your host system." puts "The sources are available in 'contrib/netperf-' (after you " puts "prepared the port by calling 'tool/ports/prepare_port netperf')." puts "Please name the binary netperf-$version\n" exit 1; } # netperf configuration set netperf_tests "TCP_STREAM TCP_MAERTS" proc socket_fs_plugin {} { global use_lxip if { $use_lxip } { return lxip } return lwip } create_boot_directory set packages " [depot_user]/src/[base_src] [depot_user]/src/init [depot_user]/src/libc [depot_user]/src/posix [depot_user]/src/report_rom [depot_user]/src/vfs [depot_user]/src/nic_router " set use_nic_driver [expr !$use_usb_driver && !$use_wifi_driver] append_if $use_nic_driver packages " [depot_user]/pkg/[drivers_nic_pkg] " append_if [expr !$use_lxip] packages " [depot_user]/src/vfs_lwip " append_if $use_lxip packages " [depot_user]/src/vfs_lxip " append_if $use_nic_bridge packages " [depot_user]/src/nic_bridge " append_if $use_usb_driver packages " [depot_user]/pkg/test_usb_host-[board] " append_if $use_usb_driver packages " [depot_user]/src/usb_net " append_if $use_wifi_driver packages " [depot_user]/src/fs_rom " append_if $use_wifi_driver packages " [depot_user]/src/vfs_import " append_if $use_wifi_driver packages " [depot_user]/pkg/pc_wifi " append_if $use_wifi_driver packages " [depot_user]/src/acpi " append_if $use_wifi_driver packages " [depot_user]/src/pci_decode " append_if $use_wifi_driver packages " [depot_user]/src/platform " import_from_depot $packages build { app/netperf } # # Generate config # set lx_ip_addr "10.0.2.55" set config { } if { $use_wifi_driver } { append config { } append config "" append config { 2018-01-01 00:01 } } elseif { $use_usb_driver } { append config { } } else { append config { } } append config { } if {$use_nic_bridge} { append config { } } else { append config { } } append config { } append_if $use_nic_bridge config { } append config { 2018-01-01 00:01 <} [socket_fs_plugin] { dhcp="yes"/> } if { $use_nic_bridge } { append config { } } else { append config { } } append config { } install_config $config # # Define USB host controller config # if { $use_usb_driver } { set fd [open [run_dir]/genode/usb_host.config w] append usb_config {} append_if [have_board rpi] usb_config { } append_if [have_spec x86] usb_config { } append usb_config {} puts $fd $usb_config close $fd } build_boot_image [build_artifacts] # # Execute test case # set ip_match_string "nic_router\\\] \\\[uplink\\\] dynamic IP config: interface (\[0-9]{1,3}.\[0-9]{1,3}.\[0-9]{1,3}.\[0-9]{1,3}).*\n" set force_ports "-P [server_data_port],[server_data_port]" if {[have_spec linux]} { run_genode_until {.*family AF_INET.*\n} 60 } else { run_genode_until $ip_match_string 60 } set serial_id [output_spawn_id] if [have_spec linux] { set ip_addr $lx_ip_addr } else { regexp $ip_match_string $output all ip_addr puts "" } # give the TCP/IP stack some time to settle down sleep 3 # start netperf client connecting to netperf server running native on Genode foreach netperf_test $netperf_tests { puts "\n---------------------------- $netperf_test -----------------------" spawn netperf-$version -4 -H $ip_addr -P 1 -v 2 -f m -t $netperf_test -c -C -- $force_ports \ -k THROUGHPUT,THROUGHPUT_UNITS,LOCAL_TRANSPORT_RETRANS,MEAN_LATENCY,REMOTE_SEND_CALLS,REMOTE_RECV_CALLS,ELAPSED_TIME set netperf_id $spawn_id set spawn_id_list [list $netperf_id $serial_id] # reset output, so that we get on the second run not the result of the first set output "" run_genode_until "ELAPSED_TIME=.*\n" 120 $spawn_id_list set units "Mbit/s" # get throughput from netperf output regexp {THROUGHPUT=([\d\.]+)} $output dummy throughput # get elapsed time from netperf output regexp {ELAPSED_TIME=([\d\.]+)} $output dummy elapsed_time # get send calls from netperf output regexp {REMOTE_SEND_CALLS=([\d]+)} $output dummy send_calls # get recv calls from netperf output regexp {REMOTE_RECV_CALLS=([\d]+)} $output dummy recv_calls set sends_second [expr $send_calls / $elapsed_time] set recvs_second [expr $recv_calls / $elapsed_time] puts "" puts "[format %8.0f $sends_second] send()/s" puts "[format %8.0f $recvs_second] recv()/s" # format output parseable for post proccessing scripts puts -nonewline "! PERF: $netperf_test" if {$use_nic_bridge} { puts -nonewline "_bridge" } if {$use_usb_driver} { puts -nonewline "_xhci" } puts " $throughput $units ok" }