forked from dtaht/deBloat
-
Notifications
You must be signed in to change notification settings - Fork 0
/
netperf.lua
73 lines (56 loc) · 1.55 KB
/
netperf.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
-- Various wrappers for netperf
-- netperf -P 0 -H 172.30.48.1 -j MIN_LATENCY,P95_LATENCY -v 0 -t TCP_STREAM -t TCP_RR
-- -P 0 - no headers -v 0 no extra info, just the result -t TCP_STREAM
-- l testlen
-- -D secs
-- I would prefer to set the test duration in bytes....
-- Demo mode gives me one result per second but it is not compiled in. Sigh
module(...,package.seeall)
tests { TCP_RR, TCP_STREAM, TCP_MAERTS, TCP_CRR, UDP_STREAM, UDP_RR }
--[[
STREAM_STREAM
STREAM_RR
DG_STREAM
DG_RR
SCTP_STREAM
SCTP_STREAM_MANY
SCTP_RR
SCTP_RR_MANY
LOC_CPU
REM_CPU
--]]
require "cero"
-- FIXME: I still kind of want objects here
-- so that I can pass a tcp_rr object, process it
-- etc
local popen = cero:popen
local exec = cero:exec
local sf = string.format
local NETPERF = cero:findexe("netperf")
local NETSERVER = cero:findexe("netserver")
local function ns()
return popen(sf("%s %s",NETSERVER,s))
end
local function np(s)
return popen(sf("%s -P 0 -v 0 %s",NETPERF,s))
end
function tcp_rr (c,ip)
return np(sf("-l %d -H %s -t TCP_RR",c,ip))
end
function tcp_stream (c,ip)
return np(sf("-l %d -H %s -t TCP_STREAM",c,ip))
end
function udp_stream (c,ip)
return np(sf("-l %d -H %s -t UDP_STREAM",c,ip))
end
function udp_rr (c,ip)
return np(sf("-l %d -H %s -t UDP_RR",c,ip))
end
function tcp_rr (c,ip)
return np(sf("-l %d -H %s -t TCP_MAERTS",c,ip))
end
-- We want to get sanely formatted results out of
-- various netperf tests
-- as well as additional information about the test
-- table to json
-- csv to table