forked from pktgen/Pktgen-DPDK
-
Notifications
You must be signed in to change notification settings - Fork 0
/
PktgenGUI.lua
115 lines (99 loc) · 2.13 KB
/
PktgenGUI.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
--
-- PktgenGUI.lua
--
-- SPDX-License-Identifier: BSD-3-Clause
gui = {}
function gui.msg(...)
str = strfmt("msg=%s\n",strfmt(...));
io.write(str);
io.flush();
end
function gui.dumpStats(func, name, portlist)
stats = func(portlist);
printf("%s={ ", name);
st = stats[0];
for k,v in pairs(st) do
printf("%s ", k);
end
printf("},");
for i = 0, (stats.n - 1) do
st = stats[i];
printf("%d={ ", i);
for k,v in pairs(st) do
printf("%d ", v);
end
if ( i == (stats.n - 1) ) then
printf("}\n");
else
printf("},");
end
end
end
function gui.dumpInfo(func, name, portlist)
stats = func(portlist);
printf("%s={ ", name);
st = stats[0];
for k,v in pairs(st) do
printf("%s ", k);
end
printf("},");
for i = 0, (stats.n - 1) do
st = stats[i];
printf("%d={ ", i);
for k,v in pairs(st) do
printf("%s ", v);
end
if ( i == (stats.n - 1) ) then
printf("}\n");
else
printf("},");
end
end
end
function gui.getPktStats(portlist)
gui.dumpStats(pktgen.pktStats, "pktStats", portlist)
end
function gui.getPortStats(portlist)
gui.dumpStats(pktgen.portStats, "portStats", portlist)
end
function gui.getRateStats(portlist)
gui.dumpStats(pktgen.rateStats, "rateStats", portlist)
end
function gui.getPortSizes(portlist)
gui.dumpStats(pktgen.portSizes, "portSizes", portlist)
end
function gui.getPortInfo(portlist)
gui.dumpInfo(pktgen.portInfo, "portInfo", portlist)
end
function gui.getLinkState(portlist)
links = pktgen.linkState(portlist);
printf("linkState={ ");
for k,v in pairs(links) do
if ( k == "n" ) then break; end
printf("%d=%s ", k, v);
end
printf("}\n");
end
function gui.getPortFlags(portlist)
links = pktgen.portFlags(portlist);
printf("portFlags={ ");
for k,v in pairs(links) do
if ( k == "n" ) then break; end
printf("%d=%s ", k, v);
end
printf("}\n");
end
function gui.startTransmitting(portlist)
-- gui.msg("=== Start Transmit %s", portlist);
pktgen.start(portlist);
end
function gui.stopTransmitting(portlist)
-- gui.msg("=== Stop Transmit %s", portlist);
pktgen.stop(portlist);
end
function gui.clearAllStats()
pktgen.clear("all");
end
function gui.noop()
-- Do nothing
end