Skip to content

Commit 8934c9d

Browse files
committed
add dump_interval for astf traffic start
Signed-off-by: Leo Ma <[email protected]>
1 parent d2dfea5 commit 8934c9d

File tree

3 files changed

+256
-2
lines changed

3 files changed

+256
-2
lines changed

src/main/java/com/cisco/trex/stateful/TRexAstfClient.java

Lines changed: 64 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package com.cisco.trex.stateful;
22

33
import com.cisco.trex.ClientBase;
4+
import com.cisco.trex.stateful.model.FlowInfoData;
5+
import com.cisco.trex.stateful.model.FlowInfoResult;
46
import com.cisco.trex.stateful.model.ServerStatus;
57
import com.cisco.trex.stateful.model.stats.AstfStatistics;
68
import com.cisco.trex.stateful.model.stats.LatencyPortData;
@@ -17,6 +19,7 @@
1719
import com.google.gson.JsonElement;
1820
import com.google.gson.JsonObject;
1921
import java.io.IOException;
22+
import java.math.BigInteger;
2023
import java.nio.charset.StandardCharsets;
2124
import java.security.MessageDigest;
2225
import java.security.NoSuchAlgorithmException;
@@ -154,21 +157,46 @@ public void startTraffic(
154157
* @param mult
155158
* @param nc
156159
*/
160+
public void startTraffic(
161+
String profileId,
162+
long clientMask,
163+
double duration,
164+
boolean ipv6,
165+
int latencyPps,
166+
int mult,
167+
boolean nc) {
168+
startTraffic(profileId, clientMask, duration, ipv6, latencyPps, mult, nc, 0);
169+
}
170+
171+
/**
172+
* start traffic on all ports on loaded profile associated with specified profile id
173+
*
174+
* @param profileId
175+
* @param clientMask
176+
* @param duration
177+
* @param ipv6
178+
* @param latencyPps
179+
* @param mult
180+
* @param nc
181+
* @param dumpInterval
182+
*/
157183
public void startTraffic(
158184
String profileId,
159185
long clientMask,
160186
double duration,
161187
boolean ipv6,
162188
int latencyPps,
163189
int mult,
164-
boolean nc) {
190+
boolean nc,
191+
float dumpInterval) {
165192
Map<String, Object> payload = createPayload(profileId);
166193
payload.put("client_mask", clientMask);
167194
payload.put("duration", duration);
168195
payload.put("ipv6", ipv6);
169196
payload.put("latency_pps", latencyPps);
170197
payload.put("mult", mult);
171198
payload.put("nc", nc);
199+
payload.put("dump_interval", dumpInterval);
172200
this.callMethod("start", payload);
173201
}
174202

@@ -521,7 +549,7 @@ public Map<String, AstfStatistics> getTemplateGroupStatistics(
521549
/**
522550
* get template group statistics
523551
*
524-
* @return Map key:tgName, value:AstfStatistics
552+
* @return ServerStatus
525553
*/
526554
public ServerStatus syncWithServer() {
527555
Map<String, Object> payload = createPayload("*");
@@ -548,4 +576,38 @@ private Map<String, Integer> translateNames2Ids(String profileId, List<String> t
548576

549577
return name2Id;
550578
}
579+
580+
/**
581+
* Get flow information for a profile
582+
*
583+
* @param profileId
584+
* @return FlowInfo
585+
*/
586+
public List<FlowInfoResult> getProfileInfo(String profileId) {
587+
List<FlowInfoResult> results = new ArrayList<>();
588+
589+
Map<String, Object> payload = createPayload(profileId);
590+
String json = callMethod("get_flow_info", payload);
591+
JsonArray jsonArray = getResultFromResponse(json).getAsJsonArray();
592+
Iterator<JsonElement> iterator = jsonArray.iterator();
593+
BigInteger index = null;
594+
Map<String, FlowInfoData> flowInfoDataMap;
595+
while (iterator.hasNext()) {
596+
flowInfoDataMap = new HashMap<>();
597+
JsonObject flowInfoJsonObject = iterator.next().getAsJsonObject();
598+
for (Map.Entry<String, JsonElement> info : flowInfoJsonObject.entrySet()) {
599+
600+
if (info.getKey().equals("index")) {
601+
index = new BigInteger(info.getValue().getAsString());
602+
} else {
603+
FlowInfoData flowInfoData = GSON.fromJson(info.getValue(), FlowInfoData.class);
604+
flowInfoDataMap.put(info.getKey(), flowInfoData);
605+
}
606+
}
607+
FlowInfoResult flowResult = new FlowInfoResult(index, flowInfoDataMap);
608+
results.add(flowResult);
609+
}
610+
611+
return results;
612+
}
551613
}
Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
package com.cisco.trex.stateful.model;
2+
3+
import com.fasterxml.jackson.annotation.JsonProperty;
4+
5+
/** counters for flow info */
6+
public class FlowInfoData {
7+
8+
@JsonProperty("duration")
9+
private double duration;
10+
11+
@JsonProperty("last_data_recv")
12+
private long lastDataRecv;
13+
14+
@JsonProperty("options")
15+
private String options;
16+
17+
@JsonProperty("origin")
18+
private String origin;
19+
20+
@JsonProperty("rcv_mss")
21+
private long rcvMss;
22+
23+
@JsonProperty("rcv_nxt")
24+
private long rcvNxt;
25+
26+
@JsonProperty("rcv_ooopack")
27+
private long rcvOoopack;
28+
29+
@JsonProperty("rcv_space")
30+
private long rcvSpace;
31+
32+
@JsonProperty("rcv_wscale")
33+
private short rcvWscale;
34+
35+
@JsonProperty("rto")
36+
private long rto;
37+
38+
@JsonProperty("rtt")
39+
private long rtt;
40+
41+
@JsonProperty("rttvar")
42+
private long rttvar;
43+
44+
@JsonProperty("snd_cwnd")
45+
private long sndCwnd;
46+
47+
@JsonProperty("snd_mss")
48+
private long sndMss;
49+
50+
@JsonProperty("snd_nxt")
51+
private long sndNxt;
52+
53+
@JsonProperty("snd_rexmitpack")
54+
private long sndRexmitpack;
55+
56+
@JsonProperty("snd_ssthresh")
57+
private long sndSsthresh;
58+
59+
@JsonProperty("snd_wnd")
60+
private long sndWnd;
61+
62+
@JsonProperty("snd_wscale")
63+
private short sndWscale;
64+
65+
@JsonProperty("snd_zerowin")
66+
private long sndZerowin;
67+
68+
@JsonProperty("state")
69+
private long state;
70+
71+
public double getDuration() {
72+
return duration;
73+
}
74+
75+
public long getLastDataRecv() {
76+
return lastDataRecv;
77+
}
78+
79+
public String getOptions() {
80+
return options;
81+
}
82+
83+
public String getOrigin() {
84+
return origin;
85+
}
86+
87+
public long getRcvMss() {
88+
return rcvMss;
89+
}
90+
91+
public long getRcvNxt() {
92+
return rcvNxt;
93+
}
94+
95+
public long getRcvOoopack() {
96+
return rcvOoopack;
97+
}
98+
99+
public long getRcvSpace() {
100+
return rcvSpace;
101+
}
102+
103+
public short getRcvWscale() {
104+
return rcvWscale;
105+
}
106+
107+
public long getRto() {
108+
return rto;
109+
}
110+
111+
public long getRtt() {
112+
return rtt;
113+
}
114+
115+
public long getRttvar() {
116+
return rttvar;
117+
}
118+
119+
public long getSndCwnd() {
120+
return sndCwnd;
121+
}
122+
123+
public long getSndMss() {
124+
return sndMss;
125+
}
126+
127+
public long getSndNxt() {
128+
return sndNxt;
129+
}
130+
131+
public long getSndRexmitpack() {
132+
return sndRexmitpack;
133+
}
134+
135+
public long getSndSsthresh() {
136+
return sndSsthresh;
137+
}
138+
139+
public long getSndWnd() {
140+
return sndWnd;
141+
}
142+
143+
public short getSndWscale() {
144+
return sndWscale;
145+
}
146+
147+
public long getSndZerowin() {
148+
return sndZerowin;
149+
}
150+
151+
public long getState() {
152+
return state;
153+
}
154+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package com.cisco.trex.stateful.model;
2+
3+
import java.math.BigInteger;
4+
import java.util.Map;
5+
6+
/** Data returned from get_flow_info API */
7+
public class FlowInfoResult {
8+
9+
private BigInteger index;
10+
private Map<String, FlowInfoData> flowInfoDataMap;
11+
12+
public FlowInfoResult(BigInteger index,
13+
Map<String, FlowInfoData> flowInfoDataMap) {
14+
this.index = index;
15+
this.flowInfoDataMap = flowInfoDataMap;
16+
}
17+
18+
/**
19+
* Get base index in memory
20+
*
21+
* @return
22+
*/
23+
public BigInteger getIndex() {
24+
return index;
25+
}
26+
27+
/**
28+
* Get flow info data map, as format of <string to present traffic direction , a flowInfoData object containsing flow info counters>
29+
* ex.,
30+
* key is "1.1.1.1:41668-1.1.2.1:20"
31+
* value is flowInfoData object refer to {@link FlowInfoData}
32+
*
33+
* @return
34+
*/
35+
public Map<String, FlowInfoData> getFlowInfoDataMap() {
36+
return flowInfoDataMap;
37+
}
38+
}

0 commit comments

Comments
 (0)