From d888dec4ca4d246a86b5cec0f886e28ab109a13c Mon Sep 17 00:00:00 2001 From: Johann Date: Thu, 6 Jun 2024 16:15:04 +0200 Subject: [PATCH 1/6] remove old iPerf3 code, write own parser --- .../Iperf3/Interval/Interval.java | 15 ++++ .../Iperf3/Interval/Streams/Stream.java | 30 +++++++ .../Iperf3/Interval/Streams/Streams.java | 30 +++++++ .../Interval/Streams/TCP/TCP_DL_STREAM.java | 14 +++ .../Interval/Streams/TCP/TCP_STREAM.java | 14 +++ .../Interval/Streams/TCP/TCP_UL_STREAM.java | 27 ++++++ .../Interval/Streams/UDP/UDP_DL_STREAM.java | 22 +++++ .../Interval/Streams/UDP/UDP_STREAM.java | 15 ++++ .../Interval/Streams/UDP/UDP_UL_STREAM.java | 14 +++ .../Iperf3/Intervals.java | 16 ++++ .../Iperf3/Iperf3Fragment.java | 2 +- .../Iperf3/Iperf3LogFragment.java | 89 +++++++++++++++++-- .../Iperf3/Iperf3Parser.java | 69 ++++++++++++++ .../Iperf3/Iperf3RecyclerViewAdapter.java | 2 +- .../Iperf3/Iperf3ToLineProtocolWorker.java | 3 - .../Iperf3/JSON/Connected.java | 32 ------- .../Iperf3/JSON/ConnectingTo.java | 24 ----- .../Iperf3/JSON/CpuUtilizationPercent.java | 35 -------- .../Iperf3/JSON/End.java | 40 --------- .../Iperf3/JSON/Interval.java | 25 ------ .../Iperf3/JSON/Receiver.java | 39 -------- .../Iperf3/JSON/Root.java | 28 ------ .../Iperf3/JSON/Sender.java | 57 ------------ .../Iperf3/JSON/Start.java | 55 ------------ .../Iperf3/JSON/Stream.java | 74 --------------- .../Iperf3/JSON/Stream__1.java | 21 ----- .../Iperf3/JSON/Sum.java | 54 ----------- .../Iperf3/JSON/SumReceived.java | 47 ---------- .../Iperf3/JSON/SumSent.java | 50 ----------- .../Iperf3/JSON/TestStart.java | 48 ---------- .../Iperf3/JSON/Timestamp.java | 24 ----- .../Iperf3/JSON/Udp.java | 51 ----------- .../Iperf3/JSON/start/Connected.java | 21 +++++ .../Iperf3/JSON/start/ConnectingTo.java | 14 +++ .../Iperf3/JSON/start/Start.java | 48 ++++++++++ .../Iperf3/JSON/start/TestStart.java | 36 ++++++++ .../Iperf3/JSON/start/Timestamp.java | 14 +++ docs/iperf3.md | 53 +++++++++++ 38 files changed, 537 insertions(+), 715 deletions(-) create mode 100644 app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Interval.java create mode 100644 app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Streams/Stream.java create mode 100644 app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Streams/Streams.java create mode 100644 app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Streams/TCP/TCP_DL_STREAM.java create mode 100644 app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Streams/TCP/TCP_STREAM.java create mode 100644 app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Streams/TCP/TCP_UL_STREAM.java create mode 100644 app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Streams/UDP/UDP_DL_STREAM.java create mode 100644 app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Streams/UDP/UDP_STREAM.java create mode 100644 app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Streams/UDP/UDP_UL_STREAM.java create mode 100644 app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Intervals.java create mode 100644 app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Iperf3Parser.java delete mode 100644 app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/Connected.java delete mode 100644 app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/ConnectingTo.java delete mode 100644 app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/CpuUtilizationPercent.java delete mode 100644 app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/End.java delete mode 100644 app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/Interval.java delete mode 100644 app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/Receiver.java delete mode 100644 app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/Root.java delete mode 100644 app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/Sender.java delete mode 100644 app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/Start.java delete mode 100644 app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/Stream.java delete mode 100644 app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/Stream__1.java delete mode 100644 app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/Sum.java delete mode 100644 app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/SumReceived.java delete mode 100644 app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/SumSent.java delete mode 100644 app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/TestStart.java delete mode 100644 app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/Timestamp.java delete mode 100644 app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/Udp.java create mode 100644 app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/start/Connected.java create mode 100644 app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/start/ConnectingTo.java create mode 100644 app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/start/Start.java create mode 100644 app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/start/TestStart.java create mode 100644 app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/start/Timestamp.java diff --git a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Interval.java b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Interval.java new file mode 100644 index 00000000..5f55a747 --- /dev/null +++ b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Interval.java @@ -0,0 +1,15 @@ +package de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.Interval; + +import com.influxdb.client.JSON; +import de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.Interval.Streams.Streams; +import org.json.JSONObject; + +public class Interval { + private Streams streams; + public Interval(){ + streams = new Streams(); + } + public void parse(JSONObject data){ + streams.parse(data); + } +} diff --git a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Streams/Stream.java b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Streams/Stream.java new file mode 100644 index 00000000..92371da1 --- /dev/null +++ b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Streams/Stream.java @@ -0,0 +1,30 @@ +package de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.Interval.Streams; + +import org.json.JSONException; +import org.json.JSONObject; + +public class Stream { + private int socket; + private int start; + private double end; + private double seconds; + private long bytes; + private double bits_per_second; + private boolean omitted; + private boolean sender; + + public Stream(){ + } + public void parse(JSONObject data) throws JSONException { + this.socket = data.getInt("socket"); + this.start = data.getInt("start"); + this.end = data.getDouble("end"); + this.seconds = data.getDouble("seconds"); + this.bytes = data.getLong("bytes"); + this.bits_per_second = data.getDouble("bits_per_second"); + this.omitted = data.getBoolean("omitted"); + this.sender = data.getBoolean("sender"); + + } + +} diff --git a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Streams/Streams.java b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Streams/Streams.java new file mode 100644 index 00000000..607e3955 --- /dev/null +++ b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Streams/Streams.java @@ -0,0 +1,30 @@ +package de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.Interval.Streams; + +import java.util.ArrayList; +import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; + +public class Streams { + private ArrayList streams; + public Streams(){ + this.streams = new ArrayList<>(); + } + + public void parse(JSONObject data) throws JSONException { + JSONArray streams = data.getJSONArray("streams"); + for (int i = 0; i < streams.length(); i++) { + JSONObject stream = streams.getJSONObject(i); + Stream s = new Stream(); + s.parse(stream); + addStream(s); + } + } + + public void addStream(Stream stream){ + streams.add(stream); + } + public Stream getStream(int i) { + return streams.get(i); + } +} diff --git a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Streams/TCP/TCP_DL_STREAM.java b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Streams/TCP/TCP_DL_STREAM.java new file mode 100644 index 00000000..73fe9b90 --- /dev/null +++ b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Streams/TCP/TCP_DL_STREAM.java @@ -0,0 +1,14 @@ +package de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.Interval.Streams.TCP; + +import de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.Interval.Streams.Stream; +import org.json.JSONException; +import org.json.JSONObject; + +public class TCP_DL_STREAM extends TCP_STREAM { + public TCP_DL_STREAM(){ + super(); + } + public void parse(JSONObject data) throws JSONException { + super.parse(data); + } +} diff --git a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Streams/TCP/TCP_STREAM.java b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Streams/TCP/TCP_STREAM.java new file mode 100644 index 00000000..784d0ab3 --- /dev/null +++ b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Streams/TCP/TCP_STREAM.java @@ -0,0 +1,14 @@ +package de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.Interval.Streams.TCP; + +import de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.Interval.Streams.Stream; +import org.json.JSONException; +import org.json.JSONObject; + +public class TCP_STREAM extends Stream { + public TCP_STREAM(){ + super(); + } + public void parse(JSONObject data) throws JSONException { + super.parse(data); + } +} diff --git a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Streams/TCP/TCP_UL_STREAM.java b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Streams/TCP/TCP_UL_STREAM.java new file mode 100644 index 00000000..d9e85aec --- /dev/null +++ b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Streams/TCP/TCP_UL_STREAM.java @@ -0,0 +1,27 @@ +package de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.Interval.Streams.TCP; + +import de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.Interval.Streams.Stream; +import org.json.JSONException; +import org.json.JSONObject; + +public class TCP_UL_STREAM extends TCP_STREAM { + private int retransmits; + private int snd_cwnd; + private int snd_wnd; + private int rtt; + private int rttvar; + private int pmtu; + + public TCP_UL_STREAM(){ + super(); + } + public void parse(JSONObject data) throws JSONException { + super.parse(data); + this.retransmits = data.getInt("retransmits"); + this.snd_cwnd = data.getInt("snd_cwnd"); + this.snd_wnd = data.getInt("snd_wnd"); + this.rtt = data.getInt("rtt"); + this.rttvar = data.getInt("rttvar"); + this.pmtu = data.getInt("pmtu"); + } +} diff --git a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Streams/UDP/UDP_DL_STREAM.java b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Streams/UDP/UDP_DL_STREAM.java new file mode 100644 index 00000000..7e6a9bdc --- /dev/null +++ b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Streams/UDP/UDP_DL_STREAM.java @@ -0,0 +1,22 @@ +package de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.Interval.Streams.UDP; + +import de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.Interval.Streams.Stream; +import org.json.JSONException; +import org.json.JSONObject; + +public class UDP_DL_STREAM extends UDP_STREAM { + public double jitter_ms; + public int lost_packets; + public int packets; + public int lost_percent; + public UDP_DL_STREAM(){ + super(); + } + public void parse(JSONObject data) throws JSONException { + super.parse(data); + this.jitter_ms = data.getDouble("jitter_ms"); + this.lost_packets = data.getInt("lost_packets"); + this.packets = data.getInt("packets"); + this.lost_percent = data.getInt("lost_percent"); + } +} diff --git a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Streams/UDP/UDP_STREAM.java b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Streams/UDP/UDP_STREAM.java new file mode 100644 index 00000000..4fe5eca3 --- /dev/null +++ b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Streams/UDP/UDP_STREAM.java @@ -0,0 +1,15 @@ +package de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.Interval.Streams.UDP; + +import de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.Interval.Streams.Stream; +import org.json.JSONException; +import org.json.JSONObject; + +public class UDP_STREAM extends Stream { + public int packets; + public UDP_STREAM(){ + super(); + } + public void parse(JSONObject data) throws JSONException { + super.parse(data); + } +} diff --git a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Streams/UDP/UDP_UL_STREAM.java b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Streams/UDP/UDP_UL_STREAM.java new file mode 100644 index 00000000..a86021e2 --- /dev/null +++ b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Streams/UDP/UDP_UL_STREAM.java @@ -0,0 +1,14 @@ +package de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.Interval.Streams.UDP; + +import de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.Interval.Streams.Stream; +import org.json.JSONException; +import org.json.JSONObject; + +public class UDP_UL_STREAM extends UDP_STREAM { + public UDP_UL_STREAM(){ + super(); + } + public void parse(JSONObject data) throws JSONException { + super.parse(data); + } +} diff --git a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Intervals.java b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Intervals.java new file mode 100644 index 00000000..ccefc7a6 --- /dev/null +++ b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Intervals.java @@ -0,0 +1,16 @@ +package de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3; + +import de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.Interval.Interval; +import java.util.ArrayList; + +public class Intervals { + private ArrayList intervals;; + + public Intervals(){ + this.intervals = new ArrayList<>(); + } + public void addInterval(Interval interval){ + intervals.add(interval); + } + +} diff --git a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Iperf3Fragment.java b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Iperf3Fragment.java index 55cfdbef..80d4c28f 100644 --- a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Iperf3Fragment.java +++ b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Iperf3Fragment.java @@ -649,7 +649,7 @@ private String parseInput() { input.iperf3OneOff = true; } if (iperf3Json.isChecked()) { - stb.add("--json"); + stb.add("--json-stream"); input.iperf3Json = true; } diff --git a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Iperf3LogFragment.java b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Iperf3LogFragment.java index 2dc8b13e..1a6a1dbf 100644 --- a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Iperf3LogFragment.java +++ b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Iperf3LogFragment.java @@ -29,6 +29,7 @@ import androidx.core.widget.TextViewCompat; import androidx.fragment.app.Fragment; +import com.github.anastr.speedviewlib.SpeedView; import java.io.BufferedReader; import java.io.File; import java.io.FileNotFoundException; @@ -36,6 +37,10 @@ import java.io.IOException; import de.fraunhofer.fokus.OpenMobileNetworkToolkit.R; +import java.util.ArrayList; +import java.util.Locale; +import org.json.JSONException; +import org.json.JSONObject; public class Iperf3LogFragment extends Fragment { @@ -51,8 +56,15 @@ public class Iperf3LogFragment extends Fragment { private ImageView uploadIconView; private TextView iperf3OutputViewer; + private SpeedView speedView; private LinearLayout parameterLL; private Context ct; + private TextView mean; + private TextView median; + private TextView max; + private TextView min; + private TextView last; + private ArrayList meanList = new ArrayList<>(); public Iperf3LogFragment() { // Required empty public constructor } @@ -66,6 +78,9 @@ public void onCreate(Bundle savedInstanceState) { private void setFields(Iperf3RunResult iperf3RunResult) { + } + private String getSpeedString(double speed) { + return String.format(Locale.getDefault(), "%.2f Mbit/s", speed/1e+6); } private final Runnable logUpdate = new Runnable() { @Override @@ -76,6 +91,7 @@ public void run() { runIconView.setImageDrawable(runIcon); uploadIcon = Iperf3Utils.getDrawableUpload(ct, iperf3RunResult.result, iperf3RunResult.uploaded); uploadIconView.setImageDrawable(uploadIcon); + BufferedReader br = null; StringBuilder text = new StringBuilder(); @@ -88,8 +104,22 @@ public void run() { } String line; try { + double max_value = Double.MIN_VALUE; + double min_value = Double.MAX_VALUE; while ((line = br.readLine()) != null) { - text.append(line); + JSONObject obj = new JSONObject(line); + String pageName = obj.getString("event"); + if(pageName.equals("interval")) { + double last_value = obj.getJSONObject("data").getJSONObject("sum").getDouble("bits_per_second"); + meanList.add(last_value); + mean.setText(String.format(" %s", getSpeedString(meanList.stream().mapToDouble(a -> a).sum()/meanList.size()))); + median.setText(String.format(" %s", getSpeedString(meanList.get(meanList.size()/2)))); + max_value = Math.max(max_value, last_value); + min_value = Math.min(min_value, last_value); + last.setText(String.format(" %s", getSpeedString(last_value))); + max.setText(String.format(" %s", getSpeedString(max_value))); + min.setText(String.format(" %s", getSpeedString(min_value))); + } text.append('\n'); } br.close(); @@ -99,6 +129,9 @@ public void run() { logHandler.removeCallbacks(logUpdate); Log.d(TAG, "onCreateView: failed"); return; + } catch (JSONException e) { + logHandler.removeCallbacks(logUpdate); + Log.d(TAG, "onCreateView: json failed"); } @@ -106,15 +139,45 @@ public void run() { logHandler.removeCallbacks(logUpdate); return; } - - - setFields(iperf3RunResult); logHandler.removeCallbacks(logUpdate); logHandler.postDelayed(this, 1000); } }; + + + private LinearLayout createLL(String key) { + LinearLayout ll = new LinearLayout(ct); + ll.setOrientation(LinearLayout.HORIZONTAL); + TextView keyView = new TextView(ct); + keyView.setText(key); + ll.addView(keyView); + switch (key){ + case "mean": + mean = new TextView(ct); + ll.addView(mean); + break; + case "median": + median = new TextView(ct); + ll.addView(median); + break; + case "max": + max = new TextView(ct); + ll.addView(max); + break; + case "min": + min = new TextView(ct); + ll.addView(min); + break; + case "last": + last = new TextView(ct); + ll.addView(last); + break; + } + return ll; + } + @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { @@ -249,8 +312,22 @@ public void onClick(View v) { 1, 10, 1, TypedValue.COMPLEX_UNIT_SP); iperf3OutputViewer.setTextIsSelectable(true); - scrollView.addView(iperf3OutputViewer); - secondRow.addView(scrollView); + LinearLayout cardViewResult = new LinearLayout(ct); + LinearLayout.LayoutParams cardParams = new LinearLayout.LayoutParams( + LinearLayout.LayoutParams.MATCH_PARENT, + LinearLayout.LayoutParams.WRAP_CONTENT + ); + cardViewResult.setOrientation(LinearLayout.VERTICAL); + cardViewResult.setLayoutParams(cardParams); + + cardViewResult.addView(createLL("mean")); + cardViewResult.addView(createLL("median")); + cardViewResult.addView(createLL("max")); + cardViewResult.addView(createLL("min")); + cardViewResult.addView(createLL("last")); + + + secondRow.addView(cardViewResult); mainLL.addView(secondRow); if(iperf3RunResult.input.iperf3rawIperf3file == null){ diff --git a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Iperf3Parser.java b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Iperf3Parser.java new file mode 100644 index 00000000..3afe715d --- /dev/null +++ b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Iperf3Parser.java @@ -0,0 +1,69 @@ +package de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3; + +import de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.Interval.Interval; +import de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.JSON.start.Start; +import java.io.BufferedReader; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileReader; +import org.json.JSONObject; + + +public class Iperf3Parser { + + private String pathToFile; + private File file; + private BufferedReader br = null; + + private Start start; + private Intervals intervals = new Intervals(); + Iperf3Parser(String pathToFile) { + this.pathToFile = pathToFile; + this.file = new File(pathToFile); + try { + br = new BufferedReader(new FileReader(file)); + } catch (FileNotFoundException ex) { + System.out.println("File not found"); + return; + } + + } + public void parse(){ + String line; + try { + while ((line = br.readLine()) != null) { + JSONObject obj = new JSONObject(line); + String event = obj.getString("event"); + JSONObject data = obj.getJSONObject("data"); + switch (event) { + case "start": + start = new Start(); + start.parseStart(data); + break; + case "interval": + Interval interval = new Interval(); + interval.parse(data); + intervals.addInterval(interval); + break; + case "end": + System.out.println("End"); + break; + default: + System.out.println("Unknown event"); + break; + } + + + + + + } + } catch (Exception e) { + System.out.println("Error reading file"); + } + } + + + + +} diff --git a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Iperf3RecyclerViewAdapter.java b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Iperf3RecyclerViewAdapter.java index 464a39cd..dfc37e1e 100644 --- a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Iperf3RecyclerViewAdapter.java +++ b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Iperf3RecyclerViewAdapter.java @@ -204,6 +204,7 @@ private LinearLayout thirdRow(LinearLayout ll){ Iperf3Utils.getLayoutParams(0, ViewGroup.LayoutParams.WRAP_CONTENT, 0.1F)); return ll; } + public ViewHolder(View itemView) { super(itemView); Log.d(TAG, "ViewHolder: " + itemView); @@ -221,7 +222,6 @@ public ViewHolder(View itemView) { linearLayout.addView(firstRow(new LinearLayout(context))); linearLayout.addView(secondRow(new LinearLayout(context))); linearLayout.addView(thirdRow(new LinearLayout(context))); - itemView.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { diff --git a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Iperf3ToLineProtocolWorker.java b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Iperf3ToLineProtocolWorker.java index 7f057f57..a102ad7e 100644 --- a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Iperf3ToLineProtocolWorker.java +++ b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Iperf3ToLineProtocolWorker.java @@ -39,9 +39,6 @@ import de.fraunhofer.fokus.OpenMobileNetworkToolkit.GlobalVars; import de.fraunhofer.fokus.OpenMobileNetworkToolkit.InfluxDB2x.InfluxdbConnection; import de.fraunhofer.fokus.OpenMobileNetworkToolkit.InfluxDB2x.InfluxdbConnections; -import de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.JSON.Interval; -import de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.JSON.Root; -import de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.JSON.Stream; public class Iperf3ToLineProtocolWorker extends Worker { private static final String TAG = "Iperf3UploadWorker"; diff --git a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/Connected.java b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/Connected.java deleted file mode 100644 index d0f22178..00000000 --- a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/Connected.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2023 Peter Hasse - * SPDX-FileCopyrightText: 2023 Johann Hackler - * SPDX-FileCopyrightText: 2023 Fraunhofer FOKUS - * - * SPDX-License-Identifier: BSD-3-Clause-Clear - */ - -package de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.JSON; - -import com.google.gson.annotations.Expose; -import com.google.gson.annotations.SerializedName; - -public class Connected { - - @SerializedName("socket") - @Expose - public int socket; - @SerializedName("local_host") - @Expose - public String localHost; - @SerializedName("local_port") - @Expose - public int localPort; - @SerializedName("remote_host") - @Expose - public String remoteHost; - @SerializedName("remote_port") - @Expose - public int remotePort; - -} diff --git a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/ConnectingTo.java b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/ConnectingTo.java deleted file mode 100644 index 76189230..00000000 --- a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/ConnectingTo.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2023 Peter Hasse - * SPDX-FileCopyrightText: 2023 Johann Hackler - * SPDX-FileCopyrightText: 2023 Fraunhofer FOKUS - * - * SPDX-License-Identifier: BSD-3-Clause-Clear - */ - -package de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.JSON; - - -import com.google.gson.annotations.Expose; -import com.google.gson.annotations.SerializedName; - -public class ConnectingTo { - - @SerializedName("host") - @Expose - public String host; - @SerializedName("port") - @Expose - public int port; - -} diff --git a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/CpuUtilizationPercent.java b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/CpuUtilizationPercent.java deleted file mode 100644 index 4c100394..00000000 --- a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/CpuUtilizationPercent.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2023 Peter Hasse - * SPDX-FileCopyrightText: 2023 Johann Hackler - * SPDX-FileCopyrightText: 2023 Fraunhofer FOKUS - * - * SPDX-License-Identifier: BSD-3-Clause-Clear - */ - -package de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.JSON; - -import com.google.gson.annotations.Expose; -import com.google.gson.annotations.SerializedName; - -public class CpuUtilizationPercent { - - @SerializedName("host_total") - @Expose - public float hostTotal; - @SerializedName("host_user") - @Expose - public float hostUser; - @SerializedName("host_system") - @Expose - public float hostSystem; - @SerializedName("remote_total") - @Expose - public float remoteTotal; - @SerializedName("remote_user") - @Expose - public float remoteUser; - @SerializedName("remote_system") - @Expose - public float remoteSystem; - -} diff --git a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/End.java b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/End.java deleted file mode 100644 index 1f6bd544..00000000 --- a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/End.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2023 Peter Hasse - * SPDX-FileCopyrightText: 2023 Johann Hackler - * SPDX-FileCopyrightText: 2023 Fraunhofer FOKUS - * - * SPDX-License-Identifier: BSD-3-Clause-Clear - */ - -package de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.JSON; - -import com.google.gson.annotations.Expose; -import com.google.gson.annotations.SerializedName; - -import java.util.List; - -public class End { - - @SerializedName("streams") - @Expose - public List streams; - @SerializedName("sum") - @Expose - public Sum sum; - @SerializedName("sum_sent") - @Expose - public SumSent sumSent; - @SerializedName("sum_received") - @Expose - public SumReceived sumReceived; - @SerializedName("cpu_utilization_percent") - @Expose - public CpuUtilizationPercent cpuUtilizationPercent; - @SerializedName("sender_tcp_congestion") - @Expose - public String senderTcpCongestion; - @SerializedName("receiver_tcp_congestion") - @Expose - public String receiverTcpCongestion; - -} diff --git a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/Interval.java b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/Interval.java deleted file mode 100644 index d4ed5933..00000000 --- a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/Interval.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2023 Peter Hasse - * SPDX-FileCopyrightText: 2023 Johann Hackler - * SPDX-FileCopyrightText: 2023 Fraunhofer FOKUS - * - * SPDX-License-Identifier: BSD-3-Clause-Clear - */ - -package de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.JSON; - -import com.google.gson.annotations.Expose; -import com.google.gson.annotations.SerializedName; - -import java.util.List; - -public class Interval { - - @SerializedName("streams") - @Expose - public List streams = null; - @SerializedName("sum") - @Expose - public Sum sum; - -} diff --git a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/Receiver.java b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/Receiver.java deleted file mode 100644 index 87eba891..00000000 --- a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/Receiver.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2023 Peter Hasse - * SPDX-FileCopyrightText: 2023 Johann Hackler - * SPDX-FileCopyrightText: 2023 Fraunhofer FOKUS - * - * SPDX-License-Identifier: BSD-3-Clause-Clear - */ - -package de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.JSON; - - -import com.google.gson.annotations.Expose; -import com.google.gson.annotations.SerializedName; - -public class Receiver { - - @SerializedName("socket") - @Expose - public int socket; - @SerializedName("start") - @Expose - public int start; - @SerializedName("end") - @Expose - public float end; - @SerializedName("seconds") - @Expose - public float seconds; - @SerializedName("bytes") - @Expose - public long bytes; - @SerializedName("bits_per_second") - @Expose - public float bitsPerSecond; - @SerializedName("sender") - @Expose - public boolean sender; - -} diff --git a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/Root.java b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/Root.java deleted file mode 100644 index f615b5fc..00000000 --- a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/Root.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2023 Peter Hasse - * SPDX-FileCopyrightText: 2023 Johann Hackler - * SPDX-FileCopyrightText: 2023 Fraunhofer FOKUS - * - * SPDX-License-Identifier: BSD-3-Clause-Clear - */ - -package de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.JSON; - -import com.google.gson.annotations.Expose; -import com.google.gson.annotations.SerializedName; - -import java.util.List; - -public class Root { - - @SerializedName("start") - @Expose - public Start start; - @SerializedName("intervals") - @Expose - public List intervals = null; - @SerializedName("end") - @Expose - public End end; - -} diff --git a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/Sender.java b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/Sender.java deleted file mode 100644 index 93a9d870..00000000 --- a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/Sender.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2023 Peter Hasse - * SPDX-FileCopyrightText: 2023 Johann Hackler - * SPDX-FileCopyrightText: 2023 Fraunhofer FOKUS - * - * SPDX-License-Identifier: BSD-3-Clause-Clear - */ - -package de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.JSON; - - -import com.google.gson.annotations.Expose; -import com.google.gson.annotations.SerializedName; - -public class Sender { - - @SerializedName("socket") - @Expose - public int socket; - @SerializedName("start") - @Expose - public int start; - @SerializedName("end") - @Expose - public float end; - @SerializedName("seconds") - @Expose - public float seconds; - @SerializedName("bytes") - @Expose - public long bytes; - @SerializedName("bits_per_second") - @Expose - public float bitsPerSecond; - @SerializedName("retransmits") - @Expose - public int retransmits; - @SerializedName("max_snd_cwnd") - @Expose - public int maxSndCwnd; - @SerializedName("max_snd_wnd") - @Expose - public int maxSndWnd; - @SerializedName("max_rtt") - @Expose - public int maxRtt; - @SerializedName("min_rtt") - @Expose - public int minRtt; - @SerializedName("mean_rtt") - @Expose - public int meanRtt; - @SerializedName("sender") - @Expose - public boolean sender; - -} diff --git a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/Start.java b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/Start.java deleted file mode 100644 index 1f2a29b4..00000000 --- a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/Start.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2023 Peter Hasse - * SPDX-FileCopyrightText: 2023 Johann Hackler - * SPDX-FileCopyrightText: 2023 Fraunhofer FOKUS - * - * SPDX-License-Identifier: BSD-3-Clause-Clear - */ - -package de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.JSON; - -import com.google.gson.annotations.Expose; -import com.google.gson.annotations.SerializedName; - -import java.util.List; - -public class Start { - - @SerializedName("connected") - @Expose - public List connected = null; - @SerializedName("version") - @Expose - public String version; - @SerializedName("system_info") - @Expose - public String systemInfo; - @SerializedName("timestamp") - @Expose - public Timestamp timestamp; - @SerializedName("connecting_to") - @Expose - public ConnectingTo connectingTo; - @SerializedName("cookie") - @Expose - public String cookie; - @SerializedName("tcp_mss_default") - @Expose - public int tcpMssDefault; - @SerializedName("target_bitrate") - @Expose - public int targetBitrate; - @SerializedName("sock_bufsize") - @Expose - public int sockBufsize; - @SerializedName("sndbuf_actual") - @Expose - public int sndbufActual; - @SerializedName("rcvbuf_actual") - @Expose - public int rcvbufActual; - @SerializedName("test_start") - @Expose - public TestStart testStart; - -} diff --git a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/Stream.java b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/Stream.java deleted file mode 100644 index 0ff3d252..00000000 --- a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/Stream.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2023 Peter Hasse - * SPDX-FileCopyrightText: 2023 Johann Hackler - * SPDX-FileCopyrightText: 2023 Fraunhofer FOKUS - * - * SPDX-License-Identifier: BSD-3-Clause-Clear - */ - -package de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.JSON; - -import com.google.gson.annotations.Expose; -import com.google.gson.annotations.SerializedName; - -public class Stream { - - @SerializedName("socket") - @Expose - public int socket; - @SerializedName("start") - @Expose - public float start; - @SerializedName("end") - @Expose - public float end; - @SerializedName("seconds") - @Expose - public float seconds; - @SerializedName("bytes") - @Expose - public long bytes; - @SerializedName("bits_per_second") - @Expose - public float bitsPerSecond; - @SerializedName("retransmits") - @Expose - public int retransmits; - @SerializedName("snd_cwnd") - @Expose - public int sndCwnd; - @SerializedName("packets") - @Expose - public int packets; - @SerializedName("jitter_ms") - @Expose - public float jitterMs; - @SerializedName("lost_packets") - @Expose - public int lostPackets; - @SerializedName("lost_percent") - @Expose - public float lostPercent; - @SerializedName("snd_wnd") - @Expose - public int sndWnd; - @SerializedName("rtt") - @Expose - public int rtt; - @SerializedName("rttvar") - @Expose - public int rttvar; - @SerializedName("pmtu") - @Expose - public int outOfOrder; - @SerializedName("out_of_order") - @Expose - public int pmtu; - @SerializedName("omitted") - @Expose - public boolean omitted; - @SerializedName("sender") - @Expose - public boolean sender; - -} diff --git a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/Stream__1.java b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/Stream__1.java deleted file mode 100644 index 7add7207..00000000 --- a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/Stream__1.java +++ /dev/null @@ -1,21 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2023 Peter Hasse - * SPDX-FileCopyrightText: 2023 Johann Hackler - * SPDX-FileCopyrightText: 2023 Fraunhofer FOKUS - * - * SPDX-License-Identifier: BSD-3-Clause-Clear - */ - -package de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.JSON; - - -import com.google.gson.annotations.Expose; -import com.google.gson.annotations.SerializedName; - -public class Stream__1 { - - @SerializedName("udp") - @Expose - public Stream udp; - -} diff --git a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/Sum.java b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/Sum.java deleted file mode 100644 index 07ef6675..00000000 --- a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/Sum.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2023 Peter Hasse - * SPDX-FileCopyrightText: 2023 Johann Hackler - * SPDX-FileCopyrightText: 2023 Fraunhofer FOKUS - * - * SPDX-License-Identifier: BSD-3-Clause-Clear - */ - -package de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.JSON; - -import com.google.gson.annotations.Expose; -import com.google.gson.annotations.SerializedName; - -public class Sum { - - @SerializedName("start") - @Expose - public float start; - @SerializedName("end") - @Expose - public float end; - @SerializedName("seconds") - @Expose - public float seconds; - @SerializedName("bytes") - @Expose - public double bytes; - @SerializedName("bits_per_second") - @Expose - public float bitsPerSecond; - @SerializedName("retransmits") - @Expose - public int retransmits; - @SerializedName("omitted") - @Expose - public boolean omitted; - @SerializedName("sender") - @Expose - public boolean sender; - - @SerializedName("packets") - @Expose - public int packets; - @SerializedName("jitter_ms") - @Expose - public float jitterMs; - @SerializedName("lost_packets") - @Expose - public int lostPackets; - @SerializedName("lost_percent") - @Expose - public float lostPercent; - -} diff --git a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/SumReceived.java b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/SumReceived.java deleted file mode 100644 index e8c8372b..00000000 --- a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/SumReceived.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2023 Peter Hasse - * SPDX-FileCopyrightText: 2023 Johann Hackler - * SPDX-FileCopyrightText: 2023 Fraunhofer FOKUS - * - * SPDX-License-Identifier: BSD-3-Clause-Clear - */ - -package de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.JSON; - - -import com.google.gson.annotations.Expose; -import com.google.gson.annotations.SerializedName; - -public class SumReceived { - - @SerializedName("start") - @Expose - public int start; - @SerializedName("end") - @Expose - public float end; - @SerializedName("seconds") - @Expose - public float seconds; - @SerializedName("bytes") - @Expose - public long bytes; - @SerializedName("bits_per_second") - @Expose - public float bitsPerSecond; - @SerializedName("sender") - @Expose - public boolean sender; - @SerializedName("packets") - @Expose - public int packets; - @SerializedName("jitter_ms") - @Expose - public float jitterMs; - @SerializedName("lost_packets") - @Expose - public int lostPackets; - @SerializedName("lost_percent") - @Expose - public float lostPercent; -} diff --git a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/SumSent.java b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/SumSent.java deleted file mode 100644 index a83c7641..00000000 --- a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/SumSent.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2023 Peter Hasse - * SPDX-FileCopyrightText: 2023 Johann Hackler - * SPDX-FileCopyrightText: 2023 Fraunhofer FOKUS - * - * SPDX-License-Identifier: BSD-3-Clause-Clear - */ - -package de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.JSON; - - -import com.google.gson.annotations.Expose; -import com.google.gson.annotations.SerializedName; - -public class SumSent { - - @SerializedName("start") - @Expose - public int start; - @SerializedName("end") - @Expose - public float end; - @SerializedName("seconds") - @Expose - public float seconds; - @SerializedName("bytes") - @Expose - public long bytes; - @SerializedName("bits_per_second") - @Expose - public float bitsPerSecond; - @SerializedName("retransmits") - @Expose - public int retransmits; - @SerializedName("sender") - @Expose - public boolean sender; - @SerializedName("packets") - @Expose - public int packets; - @SerializedName("jitter_ms") - @Expose - public float jitterMs; - @SerializedName("lost_packets") - @Expose - public int lostPackets; - @SerializedName("lost_percent") - @Expose - public float lostPercent; -} diff --git a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/TestStart.java b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/TestStart.java deleted file mode 100644 index 99fecc99..00000000 --- a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/TestStart.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2023 Peter Hasse - * SPDX-FileCopyrightText: 2023 Johann Hackler - * SPDX-FileCopyrightText: 2023 Fraunhofer FOKUS - * - * SPDX-License-Identifier: BSD-3-Clause-Clear - */ - -package de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.JSON; - - -import com.google.gson.annotations.Expose; -import com.google.gson.annotations.SerializedName; - -public class TestStart { - - @SerializedName("protocol") - @Expose - public String protocol; - @SerializedName("num_streams") - @Expose - public int numStreams; - @SerializedName("blksize") - @Expose - public int blksize; - @SerializedName("omit") - @Expose - public int omit; - @SerializedName("duration") - @Expose - public int duration; - @SerializedName("bytes") - @Expose - public int bytes; - @SerializedName("blocks") - @Expose - public int blocks; - @SerializedName("reverse") - @Expose - public int reverse; - @SerializedName("tos") - @Expose - public int tos; - @SerializedName("target_bitrate") - @Expose - public int targetBitrate; - -} diff --git a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/Timestamp.java b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/Timestamp.java deleted file mode 100644 index bdebf702..00000000 --- a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/Timestamp.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2023 Peter Hasse - * SPDX-FileCopyrightText: 2023 Johann Hackler - * SPDX-FileCopyrightText: 2023 Fraunhofer FOKUS - * - * SPDX-License-Identifier: BSD-3-Clause-Clear - */ - -package de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.JSON; - - -import com.google.gson.annotations.Expose; -import com.google.gson.annotations.SerializedName; - -public class Timestamp { - - @SerializedName("time") - @Expose - public String time; - @SerializedName("timesecs") - @Expose - public long timesecs; - -} diff --git a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/Udp.java b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/Udp.java deleted file mode 100644 index e2ab4a90..00000000 --- a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/Udp.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2023 Peter Hasse - * SPDX-FileCopyrightText: 2023 Johann Hackler - * SPDX-FileCopyrightText: 2023 Fraunhofer FOKUS - * - * SPDX-License-Identifier: BSD-3-Clause-Clear - */ - -package de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.JSON; - -import com.google.gson.annotations.Expose; -import com.google.gson.annotations.SerializedName; - -public class Udp { - @SerializedName("socket") - @Expose - public int socket; - @SerializedName("start") - @Expose - public int start; - @SerializedName("end") - @Expose - public float end; - @SerializedName("seconds") - @Expose - public float seconds; - @SerializedName("bytes") - @Expose - public long bytes; - @SerializedName("bits_per_second") - @Expose - public float bitsPerSecond; - @SerializedName("packets") - @Expose - public int packets; - @SerializedName("jitter_ms") - @Expose - public float jitterMs; - @SerializedName("lost_packets") - @Expose - public int lostPackets; - @SerializedName("lost_percent") - @Expose - public float lostPercent; - @SerializedName("out_of_order") - @Expose - public int outOfOrder; - @SerializedName("sender") - @Expose - public boolean sender; -} \ No newline at end of file diff --git a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/start/Connected.java b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/start/Connected.java new file mode 100644 index 00000000..33f29b15 --- /dev/null +++ b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/start/Connected.java @@ -0,0 +1,21 @@ +package de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.JSON.start; + +import org.json.JSONException; +import org.json.JSONObject; + +public class Connected { + public int socket; + public String local_host; + public int local_port; + public String remote_host; + public int remote_port; + + public void parse(JSONObject data) throws JSONException { + this.socket = data.getInt("socket"); + this.local_host = data.getString("local_host"); + this.local_port = data.getInt("local_port"); + this.remote_host = data.getString("remote_host"); + this.remote_port = data.getInt("remote_port"); + + } +} diff --git a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/start/ConnectingTo.java b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/start/ConnectingTo.java new file mode 100644 index 00000000..b2c1ecf1 --- /dev/null +++ b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/start/ConnectingTo.java @@ -0,0 +1,14 @@ +package de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.JSON.start; + +import org.json.JSONException; +import org.json.JSONObject; + +public class ConnectingTo{ + public String host; + public int port; + + public void parse(JSONObject data) throws JSONException { + this.host = data.getString("host"); + this.port = data.getInt("port"); + } +} diff --git a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/start/Start.java b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/start/Start.java new file mode 100644 index 00000000..7fbc9d0e --- /dev/null +++ b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/start/Start.java @@ -0,0 +1,48 @@ +package de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.JSON.start; + +import java.util.ArrayList; +import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; + +public class Start{ + public ArrayList connected = new ArrayList(); + public String version; + public String system_info; + public Timestamp timestamp; + public ConnectingTo connecting_to; + public String cookie; + public int tcp_mss_default; + public int target_bitrate; + public int fq_rate; + public int sock_bufsize; + public int sndbuf_actual; + public int rcvbuf_actual; + public TestStart test_start; + + public Start(){ + } + public void parseStart(JSONObject data) throws JSONException { + JSONArray connected = data.getJSONArray("connected"); + for (int i = 0; i < connected.length(); i++) { + Connected connectedObj = new Connected(); + connectedObj.parse(connected.getJSONObject(i)); + this.connected.add(connectedObj); + } + this.version = data.getString("version"); + this.system_info = data.getString("system_info"); + this.timestamp = new Timestamp(); + this.timestamp.parse(data.getJSONObject("timestamp")); + this.connecting_to = new ConnectingTo(); + this.connecting_to.parse(data.getJSONObject("connecting_to")); + this.cookie = data.getString("cookie"); + this.tcp_mss_default = data.getInt("tcp_mss_default"); + this.target_bitrate = data.getInt("target_bitrate"); + this.fq_rate = data.getInt("fq_rate"); + this.sock_bufsize = data.getInt("sock_bufsize"); + this.sndbuf_actual = data.getInt("sndbuf_actual"); + this.rcvbuf_actual = data.getInt("rcvbuf_actual"); + this.test_start = new TestStart(); + this.test_start.parse(data.getJSONObject("test_start")); + } +} diff --git a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/start/TestStart.java b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/start/TestStart.java new file mode 100644 index 00000000..f65ee9b8 --- /dev/null +++ b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/start/TestStart.java @@ -0,0 +1,36 @@ +package de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.JSON.start; + +import org.json.JSONException; +import org.json.JSONObject; + +public class TestStart{ + public String protocol; + public int num_streams; + public int blksize; + public int omit; + public int duration; + public int bytes; + public int blocks; + public int reverse; + public int tos; + public int target_bitrate; + public boolean bidir; + public int fqrate; + public int interval; + + public void parse(JSONObject data) throws JSONException { + this.protocol = data.getString("protocol"); + this.num_streams = data.getInt("num_streams"); + this.blksize = data.getInt("blksize"); + this.omit = data.getInt("omit"); + this.duration = data.getInt("duration"); + this.bytes = data.getInt("bytes"); + this.blocks = data.getInt("blocks"); + this.reverse = data.getInt("reverse"); + this.tos = data.getInt("tos"); + this.target_bitrate = data.getInt("target_bitrate"); + this.bidir = data.getBoolean("bidir"); + this.fqrate = data.getInt("fqrate"); + this.interval = data.getInt("interval"); + } +} diff --git a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/start/Timestamp.java b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/start/Timestamp.java new file mode 100644 index 00000000..ddb003e0 --- /dev/null +++ b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/start/Timestamp.java @@ -0,0 +1,14 @@ +package de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.JSON.start; + +import org.json.JSONException; +import org.json.JSONObject; + +public class Timestamp{ + public String time; + public int timesecs; + + public void parse(JSONObject data) throws JSONException { + this.time = data.getString("time"); + this.timesecs = data.getInt("timesecs"); + } +} diff --git a/docs/iperf3.md b/docs/iperf3.md index 6274d219..bfdad654 100644 --- a/docs/iperf3.md +++ b/docs/iperf3.md @@ -4,4 +4,57 @@ To see how to integrate iPerf3 into your app, look at [iPerf3 Repo](https://gith ![iPerf3](images/iperf3.png) +Possible iPerf3 run Configurations are: + +| **Protocol** | **Single Stream** | **Multiple Streams** | +|--------------|--------------------|----------------------| +| **UDP** | | | +| | UL | UL | +| | DL | DL | +| | BIDIR | BIDIR | +| **TCP** | | | +| | UL | UL | +| | DL | DL | +| | BIDIR | BIDIR | + + +| **Protocol** | **Single Stream** | **Multiple Streams** | +|--------------|-------------------|----------------------| +| **UDP** | | | +| | ``` ```` | UL | +| | DL | DL | +| | BIDIR | BIDIR | +| **TCP** | | | +| | UL | UL | +| | DL | DL | +| | BIDIR | BIDIR | + + +TCP UL Single Stream +```json +{"event":"interval","data":{"streams":[{"socket":5,"start":0,"end":1.001069,"seconds":1.0010689496994019,"bytes":3994157056,"bits_per_second":31919136496.636753,"retransmits":0,"snd_cwnd":1506109,"snd_wnd":6192128,"rtt":59,"rttvar":14,"pmtu":65535,"omitted":false,"sender":true}],"sum":{"start":0,"end":1.001069,"seconds":1.0010689496994019,"bytes":3994157056,"bits_per_second":31919136496.636753,"retransmits":0,"omitted":false,"sender":true}}} +``` +TCP DL Single Stream +```JSON +{"event":"interval","data":{"streams":[{"socket":5,"start":0,"end":1.000363,"seconds":1.0003629922866821,"bytes":3878158336,"bits_per_second":31014008842.011257,"omitted":false,"sender":false}],"sum":{"start":0,"end":1.000363,"seconds":1.0003629922866821,"bytes":3878158336,"bits_per_second":31014008842.011257,"omitted":false,"sender":false}}} +``` +TCP BIDIR Single Stream +```json +{"event":"interval","data":{"streams":[{"socket":5,"start":0,"end":1.000228,"seconds":1.0002280473709106,"bytes":3935043584,"bits_per_second":31473171298.031265,"retransmits":0,"snd_cwnd":1309660,"snd_wnd":6192128,"rtt":34,"rttvar":2,"pmtu":65535,"omitted":false,"sender":true},{"socket":7,"start":0,"end":1.025515,"seconds":1.0255149602890015,"bytes":3690070016,"bits_per_second":28786084329.458031,"omitted":false,"sender":false}],"sum":{"start":0,"end":1.000228,"seconds":1.0002280473709106,"bytes":3935043584,"bits_per_second":31473171298.031265,"retransmits":0,"omitted":false,"sender":true},"sum_bidir_reverse":{"start":0,"end":1.000228,"seconds":1.0002280473709106,"bytes":3690070016,"bits_per_second":29513829576.759514,"omitted":false,"sender":false}}} +``` + +UDP UL Single Stream +```json +{"event":"interval","data":{"streams":[{"socket":5,"start":0,"end":1.000097,"seconds":1.0000970363616943,"bytes":135168,"bits_per_second":1081239.0804935072,"packets":8,"omitted":false,"sender":true}],"sum":{"start":0,"end":1.000097,"seconds":1.0000970363616943,"bytes":135168,"bits_per_second":1081239.0804935072,"packets":8,"omitted":false,"sender":true}}} +``` + +UDP DL Single Stream +```json +{"event":"interval","data":{"streams":[{"socket":5,"start":1.00107,"end":2.001073,"seconds":1.0000029802322388,"bytes":135168,"bits_per_second":1081340.7773533543,"jitter_ms":0.023491129322622144,"lost_packets":0,"packets":8,"lost_percent":0,"omitted":false,"sender":false}],"sum":{"start":1.00107,"end":2.001073,"seconds":1.0000029802322388,"bytes":135168,"bits_per_second":1081340.7773533543,"jitter_ms":0.023491129322622144,"lost_packets":0,"packets":8,"lost_percent":0,"omitted":false,"sender":false}}} +``` + +UDP BIDIR Single Stream +```json +{"event":"interval","data":{"streams":[{"socket":5,"start":0,"end":1.000089,"seconds":1.0000890493392944,"bytes":135168,"bits_per_second":1081247.7156053118,"packets":8,"omitted":false,"sender":true},{"socket":7,"start":0,"end":1.000093,"seconds":1.0000929832458496,"bytes":135168,"bits_per_second":1081243.4624733056,"jitter_ms":0.021732455059885976,"lost_packets":0,"packets":8,"lost_percent":0,"omitted":false,"sender":false}],"sum":{"start":0,"end":1.000089,"seconds":1.0000890493392944,"bytes":135168,"bits_per_second":1081247.7156053118,"packets":8,"omitted":false,"sender":true},"sum_bidir_reverse":{"start":0,"end":1.000089,"seconds":1.0000890493392944,"bytes":135168,"bits_per_second":1081247.7156053118,"jitter_ms":0.021732455059885976,"lost_packets":0,"packets":8,"lost_percent":0,"omitted":false,"sender":false}}} +``` [Home](OpenMobileNetworkToolkit.md) \ No newline at end of file From a66cf02696ffbf0ec0fdc5c893996cd428320aaf Mon Sep 17 00:00:00 2001 From: Johann Date: Thu, 6 Jun 2024 17:39:13 +0200 Subject: [PATCH 2/6] fix parsing --- .../Iperf3/Interval/Interval.java | 23 ++++- .../Iperf3/Interval/Streams/STREAM_TYPE.java | 9 ++ .../Iperf3/Interval/Streams/Stream.java | 34 +++++++ .../Iperf3/Interval/Streams/Streams.java | 55 ++++++++++- .../Interval/Streams/TCP/TCP_DL_STREAM.java | 5 +- .../Interval/Streams/TCP/TCP_UL_STREAM.java | 27 ++++++ .../Interval/Streams/UDP/UDP_DL_STREAM.java | 23 ++++- .../Interval/Streams/UDP/UDP_UL_STREAM.java | 2 + .../Iperf3/Interval/Sum/Sum.java | 49 ++++++++++ .../Interval/Sum/TCP/TCP_BIDIR_SUM.java | 18 ++++ .../Iperf3/Interval/Sum/TCP/TCP_DL_SUM.java | 15 +++ .../Iperf3/Interval/Sum/TCP/TCP_SUM.java | 15 +++ .../Iperf3/Interval/Sum/TCP/TCP_UL_SUM.java | 15 +++ .../Interval/Sum/UDP/UDP_BIDIR_SUM.java | 20 ++++ .../Iperf3/Interval/Sum/UDP/UDP_DL_SUM.java | 21 +++++ .../Iperf3/Interval/Sum/UDP/UDP_SUM.java | 6 ++ .../Iperf3/Interval/Sum/UDP/UDP_UL_SUM.java | 15 +++ .../Iperf3/Intervals.java | 6 ++ .../Iperf3/Iperf3LogFragment.java | 34 +------ .../Iperf3/Iperf3Parser.java | 17 ++-- .../Iperf3/Iperf3ToLineProtocolWorker.java | 91 ++++++++++++------- .../Iperf3/JSON/start/ConnectingTo.java | 11 ++- .../Iperf3/JSON/start/Start.java | 66 +++++++++++--- .../Iperf3/JSON/start/Timestamp.java | 10 +- 24 files changed, 483 insertions(+), 104 deletions(-) create mode 100644 app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Streams/STREAM_TYPE.java create mode 100644 app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Sum/Sum.java create mode 100644 app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Sum/TCP/TCP_BIDIR_SUM.java create mode 100644 app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Sum/TCP/TCP_DL_SUM.java create mode 100644 app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Sum/TCP/TCP_SUM.java create mode 100644 app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Sum/TCP/TCP_UL_SUM.java create mode 100644 app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Sum/UDP/UDP_BIDIR_SUM.java create mode 100644 app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Sum/UDP/UDP_DL_SUM.java create mode 100644 app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Sum/UDP/UDP_SUM.java create mode 100644 app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Sum/UDP/UDP_UL_SUM.java diff --git a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Interval.java b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Interval.java index 5f55a747..bd183fca 100644 --- a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Interval.java +++ b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Interval.java @@ -1,15 +1,32 @@ package de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.Interval; -import com.influxdb.client.JSON; import de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.Interval.Streams.Streams; +import de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.Interval.Sum.Sum; +import org.json.JSONException; import org.json.JSONObject; public class Interval { private Streams streams; + private Sum sum; + public Sum sum_bidir_reverse; + public Interval(){ streams = new Streams(); } - public void parse(JSONObject data){ - streams.parse(data); + public void parse(JSONObject data) throws JSONException { + streams.parse(data.getJSONObject("streams")); + sum = new Sum(); + sum.parse(data.getJSONObject("sum")); + if(data.has("sum_bidir_reverse")){ + sum_bidir_reverse = new Sum(); + sum_bidir_reverse.parse(data.getJSONObject("sum_bidir_reverse")); + } + } + + public Streams getStreams() { + return streams; + } + public Sum getSum() { + return sum; } } diff --git a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Streams/STREAM_TYPE.java b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Streams/STREAM_TYPE.java new file mode 100644 index 00000000..378fae95 --- /dev/null +++ b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Streams/STREAM_TYPE.java @@ -0,0 +1,9 @@ +package de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.Interval.Streams; + +public enum STREAM_TYPE { + TCP_UL, + TCP_DL, + UDP_UL, + UDP_DL, + UNKNOWN +} diff --git a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Streams/Stream.java b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Streams/Stream.java index 92371da1..1ba17956 100644 --- a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Streams/Stream.java +++ b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Streams/Stream.java @@ -13,6 +13,8 @@ public class Stream { private boolean omitted; private boolean sender; + private STREAM_TYPE streamType; + public Stream(){ } public void parse(JSONObject data) throws JSONException { @@ -24,7 +26,39 @@ public void parse(JSONObject data) throws JSONException { this.bits_per_second = data.getDouble("bits_per_second"); this.omitted = data.getBoolean("omitted"); this.sender = data.getBoolean("sender"); + } + + public int getSocket() { + return socket; + } + public int getStart() { + return start; + } + public double getEnd() { + return end; + } + public double getSeconds() { + return seconds; + } + public long getBytes() { + return bytes; + } + public double getBits_per_second() { + return bits_per_second; + } + public boolean getOmitted() { + return omitted; + } + public boolean getSender() { + return sender; + } + public STREAM_TYPE getStreamType() { + return streamType; } + public void setStreamType( + STREAM_TYPE streamType) { + this.streamType = streamType; + } } diff --git a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Streams/Streams.java b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Streams/Streams.java index 607e3955..d8cf94b6 100644 --- a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Streams/Streams.java +++ b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Streams/Streams.java @@ -1,5 +1,9 @@ package de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.Interval.Streams; +import de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.Interval.Streams.TCP.TCP_DL_STREAM; +import de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.Interval.Streams.TCP.TCP_UL_STREAM; +import de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.Interval.Streams.UDP.UDP_DL_STREAM; +import de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.Interval.Streams.UDP.UDP_UL_STREAM; import java.util.ArrayList; import org.json.JSONArray; import org.json.JSONException; @@ -11,16 +15,57 @@ public Streams(){ this.streams = new ArrayList<>(); } + private STREAM_TYPE identifyStream(JSONObject data) throws JSONException { + boolean sender = data.getBoolean("sender"); + if(sender){ + if(data.has("retransmits")) return STREAM_TYPE.TCP_UL; + if(data.has("packets")) return STREAM_TYPE.UDP_UL; + } + if(data.has("jitter_ms")) return STREAM_TYPE.UDP_DL; + return STREAM_TYPE.TCP_DL; + } + + private Stream parseStream(JSONObject data) throws JSONException{ + STREAM_TYPE type = identifyStream(data); + Stream stream = null; + switch (type) { + case TCP_UL: + stream = new TCP_UL_STREAM(); + break; + case TCP_DL: + stream = new TCP_DL_STREAM(); + break; + case UDP_UL: + stream = new UDP_UL_STREAM(); + break; + case UDP_DL: + stream = new UDP_DL_STREAM(); + break; + case UNKNOWN: + return stream; + } + stream.parse(data); + return stream; + } + public void parse(JSONObject data) throws JSONException { JSONArray streams = data.getJSONArray("streams"); for (int i = 0; i < streams.length(); i++) { - JSONObject stream = streams.getJSONObject(i); - Stream s = new Stream(); - s.parse(stream); - addStream(s); + JSONObject streamJSONObject = streams.getJSONObject(i); + Stream stream = parseStream(streamJSONObject); + if(stream == null){ + System.out.println("Stream is null!"); + continue; + } + addStream(stream); } } - + public int size(){ + return streams.size(); + } + public ArrayList getStreamArrayList() { + return streams; + } public void addStream(Stream stream){ streams.add(stream); } diff --git a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Streams/TCP/TCP_DL_STREAM.java b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Streams/TCP/TCP_DL_STREAM.java index 73fe9b90..81213eec 100644 --- a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Streams/TCP/TCP_DL_STREAM.java +++ b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Streams/TCP/TCP_DL_STREAM.java @@ -1,14 +1,17 @@ package de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.Interval.Streams.TCP; -import de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.Interval.Streams.Stream; +import de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.Interval.Streams.STREAM_TYPE; + import org.json.JSONException; import org.json.JSONObject; public class TCP_DL_STREAM extends TCP_STREAM { public TCP_DL_STREAM(){ super(); + super } public void parse(JSONObject data) throws JSONException { super.parse(data); + this.setStreamType(STREAM_TYPE.TCP_DL); } } diff --git a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Streams/TCP/TCP_UL_STREAM.java b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Streams/TCP/TCP_UL_STREAM.java index d9e85aec..ee53a38e 100644 --- a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Streams/TCP/TCP_UL_STREAM.java +++ b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Streams/TCP/TCP_UL_STREAM.java @@ -1,5 +1,6 @@ package de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.Interval.Streams.TCP; +import de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.Interval.Streams.STREAM_TYPE; import de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.Interval.Streams.Stream; import org.json.JSONException; import org.json.JSONObject; @@ -23,5 +24,31 @@ public void parse(JSONObject data) throws JSONException { this.rtt = data.getInt("rtt"); this.rttvar = data.getInt("rttvar"); this.pmtu = data.getInt("pmtu"); + this.setStreamType(STREAM_TYPE.TCP_UL); } + + public int getRetransmits() { + return retransmits; + } + + public int getSnd_cwnd() { + return snd_cwnd; + } + + public int getSnd_wnd() { + return snd_wnd; + } + + public int getRtt() { + return rtt; + } + + public int getRttvar() { + return rttvar; + } + + public int getPmtu() { + return pmtu; + } + } diff --git a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Streams/UDP/UDP_DL_STREAM.java b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Streams/UDP/UDP_DL_STREAM.java index 7e6a9bdc..6f4e24f3 100644 --- a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Streams/UDP/UDP_DL_STREAM.java +++ b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Streams/UDP/UDP_DL_STREAM.java @@ -1,14 +1,15 @@ package de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.Interval.Streams.UDP; +import de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.Interval.Streams.STREAM_TYPE; import de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.Interval.Streams.Stream; import org.json.JSONException; import org.json.JSONObject; public class UDP_DL_STREAM extends UDP_STREAM { - public double jitter_ms; - public int lost_packets; - public int packets; - public int lost_percent; + private double jitter_ms; + private int lost_packets; + private int packets; + private int lost_percent; public UDP_DL_STREAM(){ super(); } @@ -18,5 +19,19 @@ public void parse(JSONObject data) throws JSONException { this.lost_packets = data.getInt("lost_packets"); this.packets = data.getInt("packets"); this.lost_percent = data.getInt("lost_percent"); + this.setStreamType(STREAM_TYPE.UDP_DL); } + public double getJitter_ms() { + return jitter_ms; + } + public int getLost_packets() { + return lost_packets; + } + public int getPackets() { + return packets; + } + public int getLost_percent() { + return lost_percent; + } + } diff --git a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Streams/UDP/UDP_UL_STREAM.java b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Streams/UDP/UDP_UL_STREAM.java index a86021e2..6f4d867e 100644 --- a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Streams/UDP/UDP_UL_STREAM.java +++ b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Streams/UDP/UDP_UL_STREAM.java @@ -1,5 +1,6 @@ package de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.Interval.Streams.UDP; +import de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.Interval.Streams.STREAM_TYPE; import de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.Interval.Streams.Stream; import org.json.JSONException; import org.json.JSONObject; @@ -10,5 +11,6 @@ public UDP_UL_STREAM(){ } public void parse(JSONObject data) throws JSONException { super.parse(data); + this.setStreamType(STREAM_TYPE.UDP_UL); } } diff --git a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Sum/Sum.java b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Sum/Sum.java new file mode 100644 index 00000000..34a7b310 --- /dev/null +++ b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Sum/Sum.java @@ -0,0 +1,49 @@ +package de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.Interval.Sum; + +import org.json.JSONException; +import org.json.JSONObject; + +public class Sum { + private int start; + private float end; + private float seconds; + private long bytes; + private double bits_per_second; + private boolean omitted; + private boolean sender; + + public Sum(){ + } + public void parse(JSONObject data) throws JSONException { + this.start = data.getInt("start"); + this.end = (float) data.getDouble("end"); + this.seconds = (float) data.getDouble("seconds"); + this.bytes = data.getLong("bytes"); + this.bits_per_second = data.getDouble("bits_per_second"); + this.omitted = data.getBoolean("omitted"); + this.sender = data.getBoolean("sender"); + } + + public int getStart() { + return start; + } + public float getEnd() { + return end; + } + public float getSeconds() { + return seconds; + } + public long getBytes() { + return bytes; + } + public double getBits_per_second() { + return bits_per_second; + } + public boolean getOmitted() { + return omitted; + } + public boolean getSender() { + return sender; + } + +} diff --git a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Sum/TCP/TCP_BIDIR_SUM.java b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Sum/TCP/TCP_BIDIR_SUM.java new file mode 100644 index 00000000..1a73b02c --- /dev/null +++ b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Sum/TCP/TCP_BIDIR_SUM.java @@ -0,0 +1,18 @@ +package de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.Interval.Sum.TCP; + +import org.json.JSONException; +import org.json.JSONObject; + +public class TCP_BIDIR_SUM extends TCP_SUM{ + TCP_UL_SUM ul; + TCP_DL_SUM dl; + public TCP_BIDIR_SUM() { + super(); + } + public void parse(JSONObject data) throws JSONException { + this.ul = new TCP_UL_SUM(); + this.dl = new TCP_DL_SUM(); + this.ul.parse(data.getJSONObject("sum")); + this.dl.parse(data.getJSONObject("sum_bidir_reverse")); + } +} diff --git a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Sum/TCP/TCP_DL_SUM.java b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Sum/TCP/TCP_DL_SUM.java new file mode 100644 index 00000000..c6ddb385 --- /dev/null +++ b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Sum/TCP/TCP_DL_SUM.java @@ -0,0 +1,15 @@ +package de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.Interval.Sum.TCP; + +import org.json.JSONException; +import org.json.JSONObject; + +public class TCP_DL_SUM extends TCP_SUM{ + public TCP_DL_SUM() { + super(); + } + + @Override + public void parse(JSONObject data) throws JSONException { + super.parse(data); + } +} diff --git a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Sum/TCP/TCP_SUM.java b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Sum/TCP/TCP_SUM.java new file mode 100644 index 00000000..12bbd623 --- /dev/null +++ b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Sum/TCP/TCP_SUM.java @@ -0,0 +1,15 @@ +package de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.Interval.Sum.TCP; + +import de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.Interval.Sum.Sum; +import org.json.JSONException; +import org.json.JSONObject; + +public class TCP_SUM extends Sum { + public TCP_SUM() { + super(); + } + public void parse(JSONObject data) throws JSONException { + super.parse(data); + + } +} diff --git a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Sum/TCP/TCP_UL_SUM.java b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Sum/TCP/TCP_UL_SUM.java new file mode 100644 index 00000000..490e655e --- /dev/null +++ b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Sum/TCP/TCP_UL_SUM.java @@ -0,0 +1,15 @@ +package de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.Interval.Sum.TCP; + +import org.json.JSONException; +import org.json.JSONObject; + +public class TCP_UL_SUM extends TCP_SUM{ + public int retransmits; + public TCP_UL_SUM() { + super(); + } + public void parse(JSONObject data) throws JSONException { + super.parse(data); + this.retransmits = data.getInt("retransmits"); + } +} diff --git a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Sum/UDP/UDP_BIDIR_SUM.java b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Sum/UDP/UDP_BIDIR_SUM.java new file mode 100644 index 00000000..5c1b5b6c --- /dev/null +++ b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Sum/UDP/UDP_BIDIR_SUM.java @@ -0,0 +1,20 @@ +package de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.Interval.Sum.UDP; + +import org.json.JSONException; +import org.json.JSONObject; + +public class UDP_BIDIR_SUM { + + UDP_UL_SUM ul; + UDP_DL_SUM dl; + public UDP_BIDIR_SUM() { + super(); + } + public void parse(JSONObject data) throws JSONException { + this.ul = new UDP_UL_SUM(); + this.dl = new UDP_DL_SUM(); + this.ul.parse(data.getJSONObject("sum")); + this.dl.parse(data.getJSONObject("sum_bidir_reverse")); + } + +} diff --git a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Sum/UDP/UDP_DL_SUM.java b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Sum/UDP/UDP_DL_SUM.java new file mode 100644 index 00000000..26551239 --- /dev/null +++ b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Sum/UDP/UDP_DL_SUM.java @@ -0,0 +1,21 @@ +package de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.Interval.Sum.UDP; + +import org.json.JSONException; +import org.json.JSONObject; + +public class UDP_DL_SUM extends UDP_SUM{ + private double jitter_ms; + private int lost_packets; + private int lost_percent; + public UDP_DL_SUM() { + super(); + } + + @Override + public void parse(JSONObject data) throws JSONException { + super.parse(data); + this.jitter_ms = data.getDouble("jitter_ms"); + this.lost_packets = data.getInt("lost_packets"); + this.lost_percent = data.getInt("lost_percent"); + } +} diff --git a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Sum/UDP/UDP_SUM.java b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Sum/UDP/UDP_SUM.java new file mode 100644 index 00000000..f316b392 --- /dev/null +++ b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Sum/UDP/UDP_SUM.java @@ -0,0 +1,6 @@ +package de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.Interval.Sum.UDP; + +import de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.Interval.Sum.Sum; + +public class UDP_SUM extends Sum { +} diff --git a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Sum/UDP/UDP_UL_SUM.java b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Sum/UDP/UDP_UL_SUM.java new file mode 100644 index 00000000..e46250a9 --- /dev/null +++ b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Sum/UDP/UDP_UL_SUM.java @@ -0,0 +1,15 @@ +package de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.Interval.Sum.UDP; + +import org.json.JSONException; +import org.json.JSONObject; + +public class UDP_UL_SUM extends UDP_SUM{ + private int packets; + public UDP_UL_SUM() { + super(); + } + public void parse(JSONObject data) throws JSONException { + super.parse(data); + this.packets = data.getInt("packets"); + } +} diff --git a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Intervals.java b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Intervals.java index ccefc7a6..6f0638cd 100644 --- a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Intervals.java +++ b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Intervals.java @@ -1,7 +1,10 @@ package de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3; +import com.influxdb.client.JSON; import de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.Interval.Interval; import java.util.ArrayList; +import org.json.JSONException; +import org.json.JSONObject; public class Intervals { private ArrayList intervals;; @@ -12,5 +15,8 @@ public Intervals(){ public void addInterval(Interval interval){ intervals.add(interval); } + public ArrayList getIntervalArrayList(){ + return intervals; + } } diff --git a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Iperf3LogFragment.java b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Iperf3LogFragment.java index 1a6a1dbf..8c474f7c 100644 --- a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Iperf3LogFragment.java +++ b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Iperf3LogFragment.java @@ -103,38 +103,8 @@ public void run() { return; } String line; - try { - double max_value = Double.MIN_VALUE; - double min_value = Double.MAX_VALUE; - while ((line = br.readLine()) != null) { - JSONObject obj = new JSONObject(line); - String pageName = obj.getString("event"); - if(pageName.equals("interval")) { - double last_value = obj.getJSONObject("data").getJSONObject("sum").getDouble("bits_per_second"); - meanList.add(last_value); - mean.setText(String.format(" %s", getSpeedString(meanList.stream().mapToDouble(a -> a).sum()/meanList.size()))); - median.setText(String.format(" %s", getSpeedString(meanList.get(meanList.size()/2)))); - max_value = Math.max(max_value, last_value); - min_value = Math.min(min_value, last_value); - last.setText(String.format(" %s", getSpeedString(last_value))); - max.setText(String.format(" %s", getSpeedString(max_value))); - min.setText(String.format(" %s", getSpeedString(min_value))); - } - text.append('\n'); - } - br.close(); - iperf3OutputViewer.setText(text.toString()); - - } catch (IOException e) { - logHandler.removeCallbacks(logUpdate); - Log.d(TAG, "onCreateView: failed"); - return; - } catch (JSONException e) { - logHandler.removeCallbacks(logUpdate); - Log.d(TAG, "onCreateView: json failed"); - } - - + Iperf3Parser iperf3Parser = new Iperf3Parser(iperf3RunResult.input.iperf3rawIperf3file); + iperf3Parser.parse(); if (iperf3RunResult.result != -100) { logHandler.removeCallbacks(logUpdate); return; diff --git a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Iperf3Parser.java b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Iperf3Parser.java index 3afe715d..64a74b83 100644 --- a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Iperf3Parser.java +++ b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Iperf3Parser.java @@ -19,15 +19,15 @@ public class Iperf3Parser { private Intervals intervals = new Intervals(); Iperf3Parser(String pathToFile) { this.pathToFile = pathToFile; - this.file = new File(pathToFile); + this.file = new File(this.pathToFile); try { br = new BufferedReader(new FileReader(file)); } catch (FileNotFoundException ex) { System.out.println("File not found"); return; } - } + public void parse(){ String line; try { @@ -52,18 +52,17 @@ public void parse(){ System.out.println("Unknown event"); break; } - - - - - } } catch (Exception e) { System.out.println("Error reading file"); } } - - + public Intervals getIntervals() { + return intervals; + } + public Start getStart() { + return start; + } } diff --git a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Iperf3ToLineProtocolWorker.java b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Iperf3ToLineProtocolWorker.java index a102ad7e..07afcc57 100644 --- a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Iperf3ToLineProtocolWorker.java +++ b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Iperf3ToLineProtocolWorker.java @@ -25,6 +25,12 @@ import com.influxdb.client.domain.WritePrecision; import com.influxdb.client.write.Point; +import de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.Interval.Interval; +import de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.Interval.Streams.Stream; +import de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.Interval.Streams.TCP.TCP_DL_STREAM; +import de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.Interval.Streams.TCP.TCP_UL_STREAM; +import de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.Interval.Streams.UDP.UDP_DL_STREAM; +import de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.Interval.Streams.UDP.UDP_UL_STREAM; import java.io.BufferedReader; import java.io.FileNotFoundException; import java.io.FileOutputStream; @@ -143,61 +149,80 @@ public Map getTagsMap() { public Result doWork() { setup(); Data output = new Data.Builder().putBoolean("iperf3_upload", false).build(); - BufferedReader br = null; - try { - br = new BufferedReader(new FileReader(rawIperf3file)); - } catch (FileNotFoundException | NullPointerException e) { - e.printStackTrace(); - return Result.failure(output); - } - Root iperf3AsJson = new Gson().fromJson(br, Root.class); - long timestamp = iperf3AsJson.start.timestamp.timesecs*1000; + + Iperf3Parser iperf3Parser = new Iperf3Parser(rawIperf3file); + iperf3Parser.parse(); + + + long timestamp = Integer.toUnsignedLong( iperf3Parser.getStart().getTimestamp().getTimesecs())*1000; Log.d(TAG, "doWork: "+timestamp); String role = "server"; - if(iperf3AsJson.start.connectingTo != null){ + if(iperf3Parser.getStart().getConnecting_to() != null){ role = "client"; } LinkedList points = new LinkedList(); - for (Interval interval: iperf3AsJson.intervals) { - long tmpTimestamp = timestamp + (long) (interval.sum.end * 1000); - int intervalIdx = iperf3AsJson.intervals.indexOf(interval); - for (Stream stream: interval.streams){ + for (Interval interval: iperf3Parser.getIntervals().getIntervalArrayList()) { + long tmpTimestamp = timestamp + (long) (interval.getSum().getEnd() * 1000); + int intervalIdx = iperf3Parser.getIntervals().getIntervalArrayList().indexOf(interval); + for (Stream stream: interval.getStreams().getStreamArrayList()){ Point point = new Point("Iperf3"); point.addTag("run_uid", runID); point.addTag("bidir", String.valueOf(biDir)); - point.addTag("sender", String.valueOf(stream.sender)); + point.addTag("sender", String.valueOf(stream.getSender())); point.addTag("role", role); - point.addTag("socket", String.valueOf(stream.socket)); + point.addTag("socket", String.valueOf(stream.getSocket())); point.addTag("protocol", protocol); point.addTag("interval", intervalIperf); - point.addTag("version", iperf3AsJson.start.version); + point.addTag("version", iperf3Parser.getStart().getVersion()); point.addTag("reversed", String.valueOf(rev)); point.addTag("oneOff", String.valueOf(oneOff)); - point.addTag("connectingToHost", iperf3AsJson.start.connectingTo.host); - point.addTag("connectingToPort", String.valueOf(iperf3AsJson.start.connectingTo.port)); + point.addTag("connectingToHost", iperf3Parser + .getStart() + .getConnecting_to() + .getHost()); + point.addTag("connectingToPort", String.valueOf(iperf3Parser + .getStart() + .getConnecting_to() + .getPort())); point.addTag("bandwidth", bandwidth); point.addTag("duration", duration); point.addTag("bytesToTransmit", bytes); - point.addTag("streams", String.valueOf(interval.streams.size())); - point.addTag("streamIdx", String.valueOf(interval.streams.indexOf(stream))); + point.addTag("streams", String.valueOf(interval.getStreams().size())); + point.addTag("streamIdx", String.valueOf(interval.getStreams().getStreamArrayList().indexOf(stream))); point.addTag("intervalIdx", String.valueOf(intervalIdx)); - point.addField("bits_per_second", stream.bitsPerSecond); - point.addField("seconds", stream.seconds); - point.addField("bytes", stream.bytes); - - if(stream.rtt != 0) point.addField("rtt", stream.rtt); - if(stream.rttvar != 0) point.addField("rttvar", stream.rttvar); - if(stream.jitterMs != 0) point.addField("jitter_ms", stream.jitterMs); - if(protocol.equals("UDP") && rev){ - point.addField("lost_packets", stream.lostPackets); - point.addField("lost_percent", stream.lostPercent); + point.addField("bits_per_second", stream.getBits_per_second()); + point.addField("seconds", stream.getSeconds()); + point.addField("bytes", stream.getBytes()); + + + switch (stream.getStreamType()){ + case TCP_DL: + break; + case TCP_UL: + TCP_UL_STREAM tcp_ul_stream = (TCP_UL_STREAM) stream; + point.addField("snd_cwnd", tcp_ul_stream.getSnd_cwnd()); + point.addField("retransmits", tcp_ul_stream.getRetransmits()); + point.addField("snd_wnd", tcp_ul_stream.getSnd_wnd()); + point.addField("rtt", tcp_ul_stream.getRtt()); + point.addField("rttvar", tcp_ul_stream.getRttvar()); + point.addField("pmtu", tcp_ul_stream.getPmtu()); + break; + case UDP_DL: + UDP_DL_STREAM udp_dl_stream = (UDP_DL_STREAM) stream; + point.addField("jitter_ms", udp_dl_stream.getJitter_ms()); + point.addField("lost_packets", udp_dl_stream.getLost_packets()); + point.addField("packets", udp_dl_stream.getPackets()); + point.addField("lost_percent", udp_dl_stream.getLost_percent()); + break; + case UDP_UL: + break; + case UNKNOWN: + break; } - point.addField("retransmits", stream.retransmits); - point.time(tmpTimestamp, WritePrecision.MS); points.add(point); diff --git a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/start/ConnectingTo.java b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/start/ConnectingTo.java index b2c1ecf1..6ffdb23d 100644 --- a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/start/ConnectingTo.java +++ b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/start/ConnectingTo.java @@ -4,11 +4,18 @@ import org.json.JSONObject; public class ConnectingTo{ - public String host; - public int port; + private String host; + private int port; public void parse(JSONObject data) throws JSONException { this.host = data.getString("host"); this.port = data.getInt("port"); } + + public String getHost() { + return host; + } + public int getPort() { + return port; + } } diff --git a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/start/Start.java b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/start/Start.java index 7fbc9d0e..0d42a59d 100644 --- a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/start/Start.java +++ b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/start/Start.java @@ -6,19 +6,19 @@ import org.json.JSONObject; public class Start{ - public ArrayList connected = new ArrayList(); - public String version; - public String system_info; - public Timestamp timestamp; - public ConnectingTo connecting_to; - public String cookie; - public int tcp_mss_default; - public int target_bitrate; - public int fq_rate; - public int sock_bufsize; - public int sndbuf_actual; - public int rcvbuf_actual; - public TestStart test_start; + private ArrayList connected = new ArrayList(); + private String version; + private String system_info; + private Timestamp timestamp; + private ConnectingTo connecting_to; + private String cookie; + private int tcp_mss_default; + private int target_bitrate; + private int fq_rate; + private int sock_bufsize; + private int sndbuf_actual; + private int rcvbuf_actual; + private TestStart test_start; public Start(){ } @@ -45,4 +45,44 @@ public void parseStart(JSONObject data) throws JSONException { this.test_start = new TestStart(); this.test_start.parse(data.getJSONObject("test_start")); } + public ArrayList getConnected() { + return connected; + } + public String getVersion() { + return version; + } + public String getSystem_info() { + return system_info; + } + public Timestamp getTimestamp() { + return timestamp; + } + public ConnectingTo getConnecting_to() { + return connecting_to; + } + public String getCookie() { + return cookie; + } + public int getTcp_mss_default() { + return tcp_mss_default; + } + public int getTarget_bitrate() { + return target_bitrate; + } + public int getFq_rate() { + return fq_rate; + } + public int getSock_bufsize() { + return sock_bufsize; + } + public int getSndbuf_actual() { + return sndbuf_actual; + } + public int getRcvbuf_actual() { + return rcvbuf_actual; + } + public TestStart getTest_start() { + return test_start; + } + } diff --git a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/start/Timestamp.java b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/start/Timestamp.java index ddb003e0..27d25598 100644 --- a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/start/Timestamp.java +++ b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/start/Timestamp.java @@ -4,11 +4,17 @@ import org.json.JSONObject; public class Timestamp{ - public String time; - public int timesecs; + private String time; + private int timesecs; public void parse(JSONObject data) throws JSONException { this.time = data.getString("time"); this.timesecs = data.getInt("timesecs"); } + public String getTime() { + return time; + } + public int getTimesecs() { + return timesecs; + } } From 0e47e7a6f8bff766f1603655ca057da88ea55f27 Mon Sep 17 00:00:00 2001 From: Johann Date: Fri, 7 Jun 2024 10:53:07 +0200 Subject: [PATCH 3/6] update JSON parsing --- .../Iperf3/Interval/Sum/UDP/UDP_SUM.java | 6 ----- .../Iperf3/Intervals.java | 5 +--- .../Iperf3/Iperf3LogFragment.java | 20 ++++++++++++++++ .../Iperf3/Iperf3Parser.java | 18 ++++++++++++-- .../Iperf3/Iperf3ToLineProtocolWorker.java | 13 ++++------ .../Iperf3/JSON/Error.java | 24 +++++++++++++++++++ .../Iperf3/{ => JSON}/Interval/Interval.java | 8 +++---- .../Interval/Streams/STREAM_TYPE.java | 2 +- .../{ => JSON}/Interval/Streams/Stream.java | 2 +- .../{ => JSON}/Interval/Streams/Streams.java | 13 +++++----- .../Interval/Streams/TCP/TCP_DL_STREAM.java | 5 ++-- .../Interval/Streams/TCP/TCP_STREAM.java | 4 ++-- .../Interval/Streams/TCP/TCP_UL_STREAM.java | 5 ++-- .../Interval/Streams/UDP/UDP_DL_STREAM.java | 5 ++-- .../Interval/Streams/UDP/UDP_STREAM.java | 4 ++-- .../Interval/Streams/UDP/UDP_UL_STREAM.java | 5 ++-- .../Iperf3/{ => JSON}/Interval/Sum/Sum.java | 2 +- .../Interval/Sum/TCP/TCP_BIDIR_SUM.java | 2 +- .../Interval/Sum/TCP/TCP_DL_SUM.java | 2 +- .../{ => JSON}/Interval/Sum/TCP/TCP_SUM.java | 4 ++-- .../Interval/Sum/TCP/TCP_UL_SUM.java | 2 +- .../Interval/Sum/UDP/UDP_BIDIR_SUM.java | 2 +- .../Interval/Sum/UDP/UDP_DL_SUM.java | 2 +- .../Iperf3/JSON/Interval/Sum/UDP/UDP_SUM.java | 6 +++++ .../Interval/Sum/UDP/UDP_UL_SUM.java | 2 +- .../Iperf3/JSON/start/TestStart.java | 2 +- 26 files changed, 105 insertions(+), 60 deletions(-) delete mode 100644 app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Sum/UDP/UDP_SUM.java create mode 100644 app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/Error.java rename app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/{ => JSON}/Interval/Interval.java (68%) rename app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/{ => JSON}/Interval/Streams/STREAM_TYPE.java (51%) rename app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/{ => JSON}/Interval/Streams/Stream.java (94%) rename app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/{ => JSON}/Interval/Streams/Streams.java (77%) rename app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/{ => JSON}/Interval/Streams/TCP/TCP_DL_STREAM.java (62%) rename app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/{ => JSON}/Interval/Streams/TCP/TCP_STREAM.java (58%) rename app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/{ => JSON}/Interval/Streams/TCP/TCP_UL_STREAM.java (81%) rename app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/{ => JSON}/Interval/Streams/UDP/UDP_DL_STREAM.java (77%) rename app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/{ => JSON}/Interval/Streams/UDP/UDP_STREAM.java (60%) rename app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/{ => JSON}/Interval/Streams/UDP/UDP_UL_STREAM.java (54%) rename app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/{ => JSON}/Interval/Sum/Sum.java (93%) rename app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/{ => JSON}/Interval/Sum/TCP/TCP_BIDIR_SUM.java (84%) rename app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/{ => JSON}/Interval/Sum/TCP/TCP_DL_SUM.java (76%) rename app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/{ => JSON}/Interval/Sum/TCP/TCP_SUM.java (59%) rename app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/{ => JSON}/Interval/Sum/TCP/TCP_UL_SUM.java (79%) rename app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/{ => JSON}/Interval/Sum/UDP/UDP_BIDIR_SUM.java (84%) rename app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/{ => JSON}/Interval/Sum/UDP/UDP_DL_SUM.java (86%) create mode 100644 app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/Interval/Sum/UDP/UDP_SUM.java rename app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/{ => JSON}/Interval/Sum/UDP/UDP_UL_SUM.java (79%) diff --git a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Sum/UDP/UDP_SUM.java b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Sum/UDP/UDP_SUM.java deleted file mode 100644 index f316b392..00000000 --- a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Sum/UDP/UDP_SUM.java +++ /dev/null @@ -1,6 +0,0 @@ -package de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.Interval.Sum.UDP; - -import de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.Interval.Sum.Sum; - -public class UDP_SUM extends Sum { -} diff --git a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Intervals.java b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Intervals.java index 6f0638cd..b5402cd5 100644 --- a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Intervals.java +++ b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Intervals.java @@ -1,10 +1,7 @@ package de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3; -import com.influxdb.client.JSON; -import de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.Interval.Interval; +import de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.JSON.Interval.Interval; import java.util.ArrayList; -import org.json.JSONException; -import org.json.JSONObject; public class Intervals { private ArrayList intervals;; diff --git a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Iperf3LogFragment.java b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Iperf3LogFragment.java index 8c474f7c..6c19f150 100644 --- a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Iperf3LogFragment.java +++ b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Iperf3LogFragment.java @@ -30,6 +30,9 @@ import androidx.fragment.app.Fragment; import com.github.anastr.speedviewlib.SpeedView; +import de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.JSON.Interval.Interval; +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; import java.io.BufferedReader; import java.io.File; import java.io.FileNotFoundException; @@ -103,7 +106,24 @@ public void run() { return; } String line; + Iperf3Parser iperf3Parser = new Iperf3Parser(iperf3RunResult.input.iperf3rawIperf3file); + iperf3Parser.addPropertyChangeListener(new PropertyChangeListener() { + private double max_value = Double.MIN_VALUE; + private double min_value = Double.MAX_VALUE; + @Override + public void propertyChange(PropertyChangeEvent evt) { + Interval interval = (Interval) evt.getNewValue(); + meanList.add(interval.getSum().getBits_per_second()); + mean.setText(String.format(" %s", getSpeedString(meanList.stream().mapToDouble(a -> a).sum()/meanList.size()))); + median.setText(String.format(" %s", getSpeedString(meanList.get(meanList.size()/2)))); + max_value = Math.max(max_value, interval.getSum().getBits_per_second()); + min_value = Math.min(min_value, interval.getSum().getBits_per_second()); + last.setText(String.format(" %s", getSpeedString(interval.getSum().getBits_per_second()))); + max.setText(String.format(" %s", getSpeedString(max_value))); + min.setText(String.format(" %s", getSpeedString(min_value))); + } + }); iperf3Parser.parse(); if (iperf3RunResult.result != -100) { logHandler.removeCallbacks(logUpdate); diff --git a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Iperf3Parser.java b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Iperf3Parser.java index 64a74b83..41e79255 100644 --- a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Iperf3Parser.java +++ b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Iperf3Parser.java @@ -1,11 +1,15 @@ package de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3; -import de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.Interval.Interval; +import de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.JSON.Interval.Interval; import de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.JSON.start.Start; +import java.beans.PropertyChangeListener; +import java.beans.PropertyChangeSupport; import java.io.BufferedReader; import java.io.File; import java.io.FileNotFoundException; import java.io.FileReader; +import java.util.Observable; +import java.util.Observer; import org.json.JSONObject; @@ -14,7 +18,7 @@ public class Iperf3Parser { private String pathToFile; private File file; private BufferedReader br = null; - + private PropertyChangeSupport support; private Start start; private Intervals intervals = new Intervals(); Iperf3Parser(String pathToFile) { @@ -26,6 +30,7 @@ public class Iperf3Parser { System.out.println("File not found"); return; } + this.support = new PropertyChangeSupport(this); } public void parse(){ @@ -43,6 +48,7 @@ public void parse(){ case "interval": Interval interval = new Interval(); interval.parse(data); + support.firePropertyChange("interval", null, interval); intervals.addInterval(interval); break; case "end": @@ -64,5 +70,13 @@ public Intervals getIntervals() { public Start getStart() { return start; } + public void addPropertyChangeListener(PropertyChangeListener pcl) { + support.addPropertyChangeListener(pcl); + } + + public void removePropertyChangeListener(PropertyChangeListener pcl) { + support.removePropertyChangeListener(pcl); + } + } diff --git a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Iperf3ToLineProtocolWorker.java b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Iperf3ToLineProtocolWorker.java index 07afcc57..3056c8da 100644 --- a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Iperf3ToLineProtocolWorker.java +++ b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Iperf3ToLineProtocolWorker.java @@ -21,20 +21,15 @@ import androidx.work.WorkerParameters; import com.google.common.base.Splitter; -import com.google.gson.Gson; import com.influxdb.client.domain.WritePrecision; import com.influxdb.client.write.Point; -import de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.Interval.Interval; -import de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.Interval.Streams.Stream; -import de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.Interval.Streams.TCP.TCP_DL_STREAM; -import de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.Interval.Streams.TCP.TCP_UL_STREAM; -import de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.Interval.Streams.UDP.UDP_DL_STREAM; -import de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.Interval.Streams.UDP.UDP_UL_STREAM; -import java.io.BufferedReader; +import de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.JSON.Interval.Interval; +import de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.JSON.Interval.Streams.Stream; +import de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.JSON.Interval.Streams.TCP.TCP_UL_STREAM; +import de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.JSON.Interval.Streams.UDP.UDP_DL_STREAM; import java.io.FileNotFoundException; import java.io.FileOutputStream; -import java.io.FileReader; import java.io.IOException; import java.util.Collections; import java.util.HashMap; diff --git a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/Error.java b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/Error.java new file mode 100644 index 00000000..75f885ec --- /dev/null +++ b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/Error.java @@ -0,0 +1,24 @@ +package de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.JSON; + +import org.json.JSONException; +import org.json.JSONObject; + +public class Error { + private String error; + + public Error() { + } + + public String getError() { + return error; + } + + public void setError(String error) { + this.error = error; + } + + public void parse(JSONObject data) throws JSONException { + this.error = data.getString("error"); + } + +} diff --git a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Interval.java b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/Interval/Interval.java similarity index 68% rename from app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Interval.java rename to app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/Interval/Interval.java index bd183fca..4b64c6fa 100644 --- a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Interval.java +++ b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/Interval/Interval.java @@ -1,7 +1,7 @@ -package de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.Interval; +package de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.JSON.Interval; -import de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.Interval.Streams.Streams; -import de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.Interval.Sum.Sum; +import de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.JSON.Interval.Sum.Sum; +import de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.JSON.Interval.Streams.Streams; import org.json.JSONException; import org.json.JSONObject; @@ -14,7 +14,7 @@ public Interval(){ streams = new Streams(); } public void parse(JSONObject data) throws JSONException { - streams.parse(data.getJSONObject("streams")); + streams.parse(data.getJSONArray("streams")); sum = new Sum(); sum.parse(data.getJSONObject("sum")); if(data.has("sum_bidir_reverse")){ diff --git a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Streams/STREAM_TYPE.java b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/Interval/Streams/STREAM_TYPE.java similarity index 51% rename from app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Streams/STREAM_TYPE.java rename to app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/Interval/Streams/STREAM_TYPE.java index 378fae95..f5a50a29 100644 --- a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Streams/STREAM_TYPE.java +++ b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/Interval/Streams/STREAM_TYPE.java @@ -1,4 +1,4 @@ -package de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.Interval.Streams; +package de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.JSON.Interval.Streams; public enum STREAM_TYPE { TCP_UL, diff --git a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Streams/Stream.java b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/Interval/Streams/Stream.java similarity index 94% rename from app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Streams/Stream.java rename to app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/Interval/Streams/Stream.java index 1ba17956..9ec8dba1 100644 --- a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Streams/Stream.java +++ b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/Interval/Streams/Stream.java @@ -1,4 +1,4 @@ -package de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.Interval.Streams; +package de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.JSON.Interval.Streams; import org.json.JSONException; import org.json.JSONObject; diff --git a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Streams/Streams.java b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/Interval/Streams/Streams.java similarity index 77% rename from app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Streams/Streams.java rename to app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/Interval/Streams/Streams.java index d8cf94b6..b00cbc4c 100644 --- a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Streams/Streams.java +++ b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/Interval/Streams/Streams.java @@ -1,9 +1,9 @@ -package de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.Interval.Streams; +package de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.JSON.Interval.Streams; -import de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.Interval.Streams.TCP.TCP_DL_STREAM; -import de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.Interval.Streams.TCP.TCP_UL_STREAM; -import de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.Interval.Streams.UDP.UDP_DL_STREAM; -import de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.Interval.Streams.UDP.UDP_UL_STREAM; +import de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.JSON.Interval.Streams.TCP.TCP_DL_STREAM; +import de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.JSON.Interval.Streams.TCP.TCP_UL_STREAM; +import de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.JSON.Interval.Streams.UDP.UDP_DL_STREAM; +import de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.JSON.Interval.Streams.UDP.UDP_UL_STREAM; import java.util.ArrayList; import org.json.JSONArray; import org.json.JSONException; @@ -48,8 +48,7 @@ private Stream parseStream(JSONObject data) throws JSONException{ return stream; } - public void parse(JSONObject data) throws JSONException { - JSONArray streams = data.getJSONArray("streams"); + public void parse(JSONArray streams) throws JSONException { for (int i = 0; i < streams.length(); i++) { JSONObject streamJSONObject = streams.getJSONObject(i); Stream stream = parseStream(streamJSONObject); diff --git a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Streams/TCP/TCP_DL_STREAM.java b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/Interval/Streams/TCP/TCP_DL_STREAM.java similarity index 62% rename from app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Streams/TCP/TCP_DL_STREAM.java rename to app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/Interval/Streams/TCP/TCP_DL_STREAM.java index 81213eec..93e27705 100644 --- a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Streams/TCP/TCP_DL_STREAM.java +++ b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/Interval/Streams/TCP/TCP_DL_STREAM.java @@ -1,6 +1,6 @@ -package de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.Interval.Streams.TCP; +package de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.JSON.Interval.Streams.TCP; -import de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.Interval.Streams.STREAM_TYPE; +import de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.JSON.Interval.Streams.STREAM_TYPE; import org.json.JSONException; import org.json.JSONObject; @@ -8,7 +8,6 @@ public class TCP_DL_STREAM extends TCP_STREAM { public TCP_DL_STREAM(){ super(); - super } public void parse(JSONObject data) throws JSONException { super.parse(data); diff --git a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Streams/TCP/TCP_STREAM.java b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/Interval/Streams/TCP/TCP_STREAM.java similarity index 58% rename from app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Streams/TCP/TCP_STREAM.java rename to app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/Interval/Streams/TCP/TCP_STREAM.java index 784d0ab3..3b3e663b 100644 --- a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Streams/TCP/TCP_STREAM.java +++ b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/Interval/Streams/TCP/TCP_STREAM.java @@ -1,6 +1,6 @@ -package de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.Interval.Streams.TCP; +package de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.JSON.Interval.Streams.TCP; -import de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.Interval.Streams.Stream; +import de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.JSON.Interval.Streams.Stream; import org.json.JSONException; import org.json.JSONObject; diff --git a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Streams/TCP/TCP_UL_STREAM.java b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/Interval/Streams/TCP/TCP_UL_STREAM.java similarity index 81% rename from app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Streams/TCP/TCP_UL_STREAM.java rename to app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/Interval/Streams/TCP/TCP_UL_STREAM.java index ee53a38e..a305776d 100644 --- a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Streams/TCP/TCP_UL_STREAM.java +++ b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/Interval/Streams/TCP/TCP_UL_STREAM.java @@ -1,7 +1,6 @@ -package de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.Interval.Streams.TCP; +package de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.JSON.Interval.Streams.TCP; -import de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.Interval.Streams.STREAM_TYPE; -import de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.Interval.Streams.Stream; +import de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.JSON.Interval.Streams.STREAM_TYPE; import org.json.JSONException; import org.json.JSONObject; diff --git a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Streams/UDP/UDP_DL_STREAM.java b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/Interval/Streams/UDP/UDP_DL_STREAM.java similarity index 77% rename from app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Streams/UDP/UDP_DL_STREAM.java rename to app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/Interval/Streams/UDP/UDP_DL_STREAM.java index 6f4e24f3..c6a1f4d8 100644 --- a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Streams/UDP/UDP_DL_STREAM.java +++ b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/Interval/Streams/UDP/UDP_DL_STREAM.java @@ -1,7 +1,6 @@ -package de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.Interval.Streams.UDP; +package de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.JSON.Interval.Streams.UDP; -import de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.Interval.Streams.STREAM_TYPE; -import de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.Interval.Streams.Stream; +import de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.JSON.Interval.Streams.STREAM_TYPE; import org.json.JSONException; import org.json.JSONObject; diff --git a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Streams/UDP/UDP_STREAM.java b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/Interval/Streams/UDP/UDP_STREAM.java similarity index 60% rename from app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Streams/UDP/UDP_STREAM.java rename to app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/Interval/Streams/UDP/UDP_STREAM.java index 4fe5eca3..acf8e17f 100644 --- a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Streams/UDP/UDP_STREAM.java +++ b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/Interval/Streams/UDP/UDP_STREAM.java @@ -1,6 +1,6 @@ -package de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.Interval.Streams.UDP; +package de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.JSON.Interval.Streams.UDP; -import de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.Interval.Streams.Stream; +import de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.JSON.Interval.Streams.Stream; import org.json.JSONException; import org.json.JSONObject; diff --git a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Streams/UDP/UDP_UL_STREAM.java b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/Interval/Streams/UDP/UDP_UL_STREAM.java similarity index 54% rename from app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Streams/UDP/UDP_UL_STREAM.java rename to app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/Interval/Streams/UDP/UDP_UL_STREAM.java index 6f4d867e..99fdda02 100644 --- a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Streams/UDP/UDP_UL_STREAM.java +++ b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/Interval/Streams/UDP/UDP_UL_STREAM.java @@ -1,7 +1,6 @@ -package de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.Interval.Streams.UDP; +package de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.JSON.Interval.Streams.UDP; -import de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.Interval.Streams.STREAM_TYPE; -import de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.Interval.Streams.Stream; +import de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.JSON.Interval.Streams.STREAM_TYPE; import org.json.JSONException; import org.json.JSONObject; diff --git a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Sum/Sum.java b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/Interval/Sum/Sum.java similarity index 93% rename from app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Sum/Sum.java rename to app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/Interval/Sum/Sum.java index 34a7b310..ce084a13 100644 --- a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Sum/Sum.java +++ b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/Interval/Sum/Sum.java @@ -1,4 +1,4 @@ -package de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.Interval.Sum; +package de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.JSON.Interval.Sum; import org.json.JSONException; import org.json.JSONObject; diff --git a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Sum/TCP/TCP_BIDIR_SUM.java b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/Interval/Sum/TCP/TCP_BIDIR_SUM.java similarity index 84% rename from app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Sum/TCP/TCP_BIDIR_SUM.java rename to app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/Interval/Sum/TCP/TCP_BIDIR_SUM.java index 1a73b02c..b54c6360 100644 --- a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Sum/TCP/TCP_BIDIR_SUM.java +++ b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/Interval/Sum/TCP/TCP_BIDIR_SUM.java @@ -1,4 +1,4 @@ -package de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.Interval.Sum.TCP; +package de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.JSON.Interval.Sum.TCP; import org.json.JSONException; import org.json.JSONObject; diff --git a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Sum/TCP/TCP_DL_SUM.java b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/Interval/Sum/TCP/TCP_DL_SUM.java similarity index 76% rename from app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Sum/TCP/TCP_DL_SUM.java rename to app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/Interval/Sum/TCP/TCP_DL_SUM.java index c6ddb385..62b3a47d 100644 --- a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Sum/TCP/TCP_DL_SUM.java +++ b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/Interval/Sum/TCP/TCP_DL_SUM.java @@ -1,4 +1,4 @@ -package de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.Interval.Sum.TCP; +package de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.JSON.Interval.Sum.TCP; import org.json.JSONException; import org.json.JSONObject; diff --git a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Sum/TCP/TCP_SUM.java b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/Interval/Sum/TCP/TCP_SUM.java similarity index 59% rename from app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Sum/TCP/TCP_SUM.java rename to app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/Interval/Sum/TCP/TCP_SUM.java index 12bbd623..27833aea 100644 --- a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Sum/TCP/TCP_SUM.java +++ b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/Interval/Sum/TCP/TCP_SUM.java @@ -1,6 +1,6 @@ -package de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.Interval.Sum.TCP; +package de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.JSON.Interval.Sum.TCP; -import de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.Interval.Sum.Sum; +import de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.JSON.Interval.Sum.Sum; import org.json.JSONException; import org.json.JSONObject; diff --git a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Sum/TCP/TCP_UL_SUM.java b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/Interval/Sum/TCP/TCP_UL_SUM.java similarity index 79% rename from app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Sum/TCP/TCP_UL_SUM.java rename to app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/Interval/Sum/TCP/TCP_UL_SUM.java index 490e655e..e80458d1 100644 --- a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Sum/TCP/TCP_UL_SUM.java +++ b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/Interval/Sum/TCP/TCP_UL_SUM.java @@ -1,4 +1,4 @@ -package de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.Interval.Sum.TCP; +package de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.JSON.Interval.Sum.TCP; import org.json.JSONException; import org.json.JSONObject; diff --git a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Sum/UDP/UDP_BIDIR_SUM.java b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/Interval/Sum/UDP/UDP_BIDIR_SUM.java similarity index 84% rename from app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Sum/UDP/UDP_BIDIR_SUM.java rename to app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/Interval/Sum/UDP/UDP_BIDIR_SUM.java index 5c1b5b6c..38566036 100644 --- a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Sum/UDP/UDP_BIDIR_SUM.java +++ b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/Interval/Sum/UDP/UDP_BIDIR_SUM.java @@ -1,4 +1,4 @@ -package de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.Interval.Sum.UDP; +package de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.JSON.Interval.Sum.UDP; import org.json.JSONException; import org.json.JSONObject; diff --git a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Sum/UDP/UDP_DL_SUM.java b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/Interval/Sum/UDP/UDP_DL_SUM.java similarity index 86% rename from app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Sum/UDP/UDP_DL_SUM.java rename to app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/Interval/Sum/UDP/UDP_DL_SUM.java index 26551239..c4bdf365 100644 --- a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Sum/UDP/UDP_DL_SUM.java +++ b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/Interval/Sum/UDP/UDP_DL_SUM.java @@ -1,4 +1,4 @@ -package de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.Interval.Sum.UDP; +package de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.JSON.Interval.Sum.UDP; import org.json.JSONException; import org.json.JSONObject; diff --git a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/Interval/Sum/UDP/UDP_SUM.java b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/Interval/Sum/UDP/UDP_SUM.java new file mode 100644 index 00000000..02a4abe0 --- /dev/null +++ b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/Interval/Sum/UDP/UDP_SUM.java @@ -0,0 +1,6 @@ +package de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.JSON.Interval.Sum.UDP; + +import de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.JSON.Interval.Sum.Sum; + +public class UDP_SUM extends Sum { +} diff --git a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Sum/UDP/UDP_UL_SUM.java b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/Interval/Sum/UDP/UDP_UL_SUM.java similarity index 79% rename from app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Sum/UDP/UDP_UL_SUM.java rename to app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/Interval/Sum/UDP/UDP_UL_SUM.java index e46250a9..0ece1357 100644 --- a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Interval/Sum/UDP/UDP_UL_SUM.java +++ b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/Interval/Sum/UDP/UDP_UL_SUM.java @@ -1,4 +1,4 @@ -package de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.Interval.Sum.UDP; +package de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.JSON.Interval.Sum.UDP; import org.json.JSONException; import org.json.JSONObject; diff --git a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/start/TestStart.java b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/start/TestStart.java index f65ee9b8..d6d190b9 100644 --- a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/start/TestStart.java +++ b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/start/TestStart.java @@ -29,7 +29,7 @@ public void parse(JSONObject data) throws JSONException { this.reverse = data.getInt("reverse"); this.tos = data.getInt("tos"); this.target_bitrate = data.getInt("target_bitrate"); - this.bidir = data.getBoolean("bidir"); + this.bidir = 1 == data.getInt("bidir"); this.fqrate = data.getInt("fqrate"); this.interval = data.getInt("interval"); } From 658ace033cefc54f99c6d07080301727542017bc Mon Sep 17 00:00:00 2001 From: Johann Date: Fri, 7 Jun 2024 17:27:04 +0200 Subject: [PATCH 4/6] add JITTER MS and Packet Loss live view --- .../Iperf3/Iperf3LogFragment.java | 352 ++++++++++++++---- .../Iperf3/JSON/Interval/Interval.java | 57 ++- .../Iperf3/JSON/Interval/Sum/SUM_TYPE.java | 11 + .../Iperf3/JSON/Interval/Sum/Sum.java | 9 +- .../JSON/Interval/Sum/TCP/TCP_BIDIR_SUM.java | 18 +- .../JSON/Interval/Sum/TCP/TCP_DL_SUM.java | 2 + .../JSON/Interval/Sum/TCP/TCP_UL_SUM.java | 3 + .../JSON/Interval/Sum/UDP/UDP_BIDIR_SUM.java | 19 +- .../JSON/Interval/Sum/UDP/UDP_DL_SUM.java | 20 +- .../JSON/Interval/Sum/UDP/UDP_UL_SUM.java | 2 + .../Iperf3/JSON/start/Start.java | 2 +- .../Iperf3/METRIC_TYPE.java | 8 + 12 files changed, 411 insertions(+), 92 deletions(-) create mode 100644 app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/Interval/Sum/SUM_TYPE.java create mode 100644 app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/METRIC_TYPE.java diff --git a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Iperf3LogFragment.java b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Iperf3LogFragment.java index 6c19f150..793d9664 100644 --- a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Iperf3LogFragment.java +++ b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Iperf3LogFragment.java @@ -9,7 +9,9 @@ package de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3; import android.content.Context; +import android.graphics.Typeface; import android.graphics.drawable.Drawable; +import android.graphics.drawable.GradientDrawable; import android.os.Bundle; import android.os.Handler; import android.os.Looper; @@ -31,19 +33,21 @@ import com.github.anastr.speedviewlib.SpeedView; import de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.JSON.Interval.Interval; +import de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.JSON.Interval.Sum.SUM_TYPE; +import de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.JSON.Interval.Sum.Sum; +import de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.JSON.Interval.Sum.TCP.TCP_UL_SUM; +import de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.JSON.Interval.Sum.UDP.UDP_DL_SUM; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.io.BufferedReader; import java.io.File; import java.io.FileNotFoundException; import java.io.FileReader; -import java.io.IOException; import de.fraunhofer.fokus.OpenMobileNetworkToolkit.R; import java.util.ArrayList; import java.util.Locale; -import org.json.JSONException; -import org.json.JSONObject; +import java.util.function.Function; public class Iperf3LogFragment extends Fragment { @@ -62,14 +66,223 @@ public class Iperf3LogFragment extends Fragment { private SpeedView speedView; private LinearLayout parameterLL; private Context ct; - private TextView mean; - private TextView median; - private TextView max; - private TextView min; - private TextView last; - private ArrayList meanList = new ArrayList<>(); + private Metric defaultReverseThroughput; + private Metric defaultThroughput; + private Metric defaultRTT; + private Metric defaultJITTER; + private Metric PACKET_LOSS; + public class Metric { + private LinearLayout mean; + private LinearLayout median; + private LinearLayout max; + private LinearLayout min; + private LinearLayout last; + private TextView directionName; + private ArrayList meanList = new ArrayList<>(); + private double maxValueSum = Double.MIN_VALUE; + private double minValueSum = Double.MAX_VALUE; + private METRIC_TYPE metricType; + public Metric(METRIC_TYPE metricType){ + this.metricType = metricType; + } + + private LinearLayout createTile(String key) { + LinearLayout ll = new LinearLayout(ct); + + GradientDrawable gd = new GradientDrawable(); + gd.setColor(ct.getColor(R.color.cardview_dark_background)); + gd.setCornerRadius(10); + gd.setStroke(2, 0xFF000000); + ll.setBackground(gd); + ll.setMinimumHeight(ll.getWidth()); + ll.setGravity(Gravity.CENTER); + + ll.setOrientation(LinearLayout.VERTICAL); + LinearLayout.LayoutParams foo = new LinearLayout.LayoutParams(200, 150); + foo.weight = 1; + foo.setMargins(10, 10, 10, 10); + ll.setLayoutParams(foo); + TextView keyView = new TextView(ct); + keyView.setGravity(Gravity.CENTER); + LinearLayout.LayoutParams keyViewLayoutParams = new LinearLayout.LayoutParams(200, 50); + keyViewLayoutParams.setMargins(0, 0, 0, 10); + keyView.setLayoutParams(keyViewLayoutParams); + keyView.setTypeface(null, Typeface.BOLD); + + keyView.setText(key); + ll.addView(keyView); + TextView valueView = new TextView(ct); + valueView.setGravity(Gravity.CENTER); + LinearLayout.LayoutParams valueViewLayoutParams = new LinearLayout.LayoutParams(200, 50); + valueViewLayoutParams.setMargins(0, 0, 0, 0); + valueView.setLayoutParams(valueViewLayoutParams); + ll.addView(valueView); + return ll; + } + + private LinearLayout createLL(String key) { + LinearLayout ll = null; + switch (key) { + case "mean": + mean = createTile(key); + ll = mean; + break; + case "median": + median = createTile(key); + ll = median; + break; + case "max": + max = createTile(key); + ll = max; + break; + case "min": + min = createTile(key); + ll = min; + break; + case "last": + last = createTile(key); + ll = last; + break; + } + return ll; + } + private String getFormatedString(double value){ + switch (this.metricType){ + case THROUGHPUT: + return String.format(Locale.getDefault(), "%.2f", value/1e+6); + case RTT: + case PACKET_LOSS: + case JITTER: + return String.format(Locale.getDefault(), "%.2f", value); + } + return Double.toString(value); + } + private LinearLayout createOneDirection(String direction) { + LinearLayout oneDirection = new LinearLayout(ct); + LinearLayout.LayoutParams foo1 = new LinearLayout.LayoutParams( + LinearLayout.LayoutParams.MATCH_PARENT, + LinearLayout.LayoutParams.WRAP_CONTENT + ); + oneDirection.setOrientation(LinearLayout.VERTICAL); + oneDirection.setLayoutParams(foo1); + + directionName = new TextView(ct); + directionName.setText(direction); + oneDirection.addView(directionName); + + LinearLayout cardViewResult = new LinearLayout(ct); + LinearLayout.LayoutParams cardParams = new LinearLayout.LayoutParams( + LinearLayout.LayoutParams.MATCH_PARENT, + LinearLayout.LayoutParams.WRAP_CONTENT + ); + cardViewResult.setOrientation(LinearLayout.HORIZONTAL); + cardViewResult.setLayoutParams(cardParams); + + cardViewResult.addView(createLL("mean")); + cardViewResult.addView(createLL("median")); + cardViewResult.addView(createLL("max")); + cardViewResult.addView(createLL("min")); + cardViewResult.addView(createLL("last")); + oneDirection.addView(cardViewResult); + return oneDirection; + } + + public double calcMean(){ + return meanList.stream().mapToDouble(a -> a).sum()/meanList.size(); + } + + public double calcMedian(){ + this.getMeanList().sort(Double::compareTo); + return meanList.get(Math.round(meanList.size()/2)); + } + + public double calcMax(){ + return meanList.stream().mapToDouble(a -> a).max().getAsDouble(); + } + + public double calcMin(){ + return meanList.stream().mapToDouble(a -> a).min().getAsDouble(); + } + public void update(Double value){ + this.meanList.add(value); + + ((TextView)mean.getChildAt(1)).setText(String.format(" %s", getFormatedString(calcMean()))); + ((TextView)median.getChildAt(1)).setText(String.format(" %s", getFormatedString(calcMedian()))); + ((TextView)max.getChildAt(1)).setText(String.format(" %s", getFormatedString(calcMax()))); + ((TextView)min.getChildAt(1)).setText(String.format(" %s", getFormatedString(calcMin()))); + ((TextView)last.getChildAt(1)).setText(String.format(" %s", getFormatedString(meanList.get(meanList.size()-1)))); + } + + public ArrayList getMeanList() { + return meanList; + } + public void setMaxValueSum(double maxValueSum) { + this.maxValueSum = maxValueSum; + } + public void setMinValueSum(double minValueSum) { + this.minValueSum = minValueSum; + } + public double getMaxValueSum() { + return maxValueSum; + } + public double getMinValueSum() { + return minValueSum; + } + + public void setMeanList(ArrayList meanList) { + this.meanList = meanList; + } + + public LinearLayout getMean() { + return mean; + } + + public void setMean(LinearLayout mean) { + this.mean = mean; + } + + public LinearLayout getMedian() { + return median; + } + + public void setMedian(LinearLayout median) { + this.median = median; + } + + public LinearLayout getMax() { + return max; + } + + public void setMax(LinearLayout max) { + this.max = max; + } + + public LinearLayout getMin() { + return min; + } + + public void setMin(LinearLayout min) { + this.min = min; + } + + public LinearLayout getLast() { + return last; + } + + public void setLast(LinearLayout last) { + this.last = last; + } + + public TextView getDirectionName() { + return directionName; + } + + public void setDirectionName(TextView directionName) { + this.directionName = directionName; + } + } + public Iperf3LogFragment() { - // Required empty public constructor } @@ -81,9 +294,6 @@ public void onCreate(Bundle savedInstanceState) { private void setFields(Iperf3RunResult iperf3RunResult) { - } - private String getSpeedString(double speed) { - return String.format(Locale.getDefault(), "%.2f Mbit/s", speed/1e+6); } private final Runnable logUpdate = new Runnable() { @Override @@ -109,19 +319,34 @@ public void run() { Iperf3Parser iperf3Parser = new Iperf3Parser(iperf3RunResult.input.iperf3rawIperf3file); iperf3Parser.addPropertyChangeListener(new PropertyChangeListener() { - private double max_value = Double.MIN_VALUE; - private double min_value = Double.MAX_VALUE; + + private void parseSum(Sum sum, Metric throughput){ + SUM_TYPE sumType = sum.getSumType(); + throughput.update(sum.getBits_per_second()); + switch (sumType){ + case UDP_DL: + defaultJITTER.update(((UDP_DL_SUM)sum).getJitter_ms()); + PACKET_LOSS.update((double) ((UDP_DL_SUM) sum).getLost_percent()); + case TCP_DL: + if(throughput.directionName.getText().equals("Throughput")){ + throughput.directionName.setText("Downlink Mbit/s"); + } + break; + case UDP_UL: + case TCP_UL: + if(throughput.directionName.getText().equals("Throughput")){ + throughput.directionName.setText("Uplink Mbit/s"); + } + break; + } + + } @Override public void propertyChange(PropertyChangeEvent evt) { Interval interval = (Interval) evt.getNewValue(); - meanList.add(interval.getSum().getBits_per_second()); - mean.setText(String.format(" %s", getSpeedString(meanList.stream().mapToDouble(a -> a).sum()/meanList.size()))); - median.setText(String.format(" %s", getSpeedString(meanList.get(meanList.size()/2)))); - max_value = Math.max(max_value, interval.getSum().getBits_per_second()); - min_value = Math.min(min_value, interval.getSum().getBits_per_second()); - last.setText(String.format(" %s", getSpeedString(interval.getSum().getBits_per_second()))); - max.setText(String.format(" %s", getSpeedString(max_value))); - min.setText(String.format(" %s", getSpeedString(min_value))); + parseSum(interval.getSum(), defaultThroughput); + if(interval.getSumBidirReverse() != null) parseSum(interval.getSumBidirReverse(), + defaultReverseThroughput); } }); iperf3Parser.parse(); @@ -137,36 +362,6 @@ public void propertyChange(PropertyChangeEvent evt) { - private LinearLayout createLL(String key) { - LinearLayout ll = new LinearLayout(ct); - ll.setOrientation(LinearLayout.HORIZONTAL); - TextView keyView = new TextView(ct); - keyView.setText(key); - ll.addView(keyView); - switch (key){ - case "mean": - mean = new TextView(ct); - ll.addView(mean); - break; - case "median": - median = new TextView(ct); - ll.addView(median); - break; - case "max": - max = new TextView(ct); - ll.addView(max); - break; - case "min": - min = new TextView(ct); - ll.addView(min); - break; - case "last": - last = new TextView(ct); - ll.addView(last); - break; - } - return ll; - } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, @@ -302,22 +497,41 @@ public void onClick(View v) { 1, 10, 1, TypedValue.COMPLEX_UNIT_SP); iperf3OutputViewer.setTextIsSelectable(true); - LinearLayout cardViewResult = new LinearLayout(ct); - LinearLayout.LayoutParams cardParams = new LinearLayout.LayoutParams( - LinearLayout.LayoutParams.MATCH_PARENT, - LinearLayout.LayoutParams.WRAP_CONTENT - ); - cardViewResult.setOrientation(LinearLayout.VERTICAL); - cardViewResult.setLayoutParams(cardParams); - - cardViewResult.addView(createLL("mean")); - cardViewResult.addView(createLL("median")); - cardViewResult.addView(createLL("max")); - cardViewResult.addView(createLL("min")); - cardViewResult.addView(createLL("last")); - - - secondRow.addView(cardViewResult); + + defaultThroughput = new Metric(METRIC_TYPE.THROUGHPUT); + defaultReverseThroughput = new Metric(METRIC_TYPE.THROUGHPUT); + mainLL.addView(defaultThroughput.createOneDirection("Throughput")); + + if(iperf3RunResult.input.iperf3BiDir) { + mainLL.addView(defaultReverseThroughput.createOneDirection("Throughput")); + if(iperf3RunResult.input.iperf3IdxProtocol == 0) { + defaultRTT = new Metric(METRIC_TYPE.RTT); + mainLL.addView(defaultRTT.createOneDirection("RTT")); + }; + if(iperf3RunResult.input.iperf3IdxProtocol == 1) { + defaultJITTER = new Metric(METRIC_TYPE.JITTER); + mainLL.addView(defaultJITTER.createOneDirection("Jitter ms")); + PACKET_LOSS = new Metric(METRIC_TYPE.PACKET_LOSS); + mainLL.addView(PACKET_LOSS.createOneDirection("Packet Loss %")); + }; + }; + if(iperf3RunResult.input.iperf3Reverse) { + if(iperf3RunResult.input.iperf3IdxProtocol == 1) { + defaultJITTER = new Metric(METRIC_TYPE.JITTER); + mainLL.addView(defaultJITTER.createOneDirection("Jitter ms")); + PACKET_LOSS = new Metric(METRIC_TYPE.JITTER); + mainLL.addView(PACKET_LOSS.createOneDirection("Packet Loss %")); + }; + } else if(!iperf3RunResult.input.iperf3BiDir) { + if(iperf3RunResult.input.iperf3IdxProtocol == 0) { + defaultRTT = new Metric(METRIC_TYPE.RTT); + mainLL.addView(defaultRTT.createOneDirection("RTT ms")); + }; + } + + + + mainLL.addView(secondRow); if(iperf3RunResult.input.iperf3rawIperf3file == null){ diff --git a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/Interval/Interval.java b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/Interval/Interval.java index 4b64c6fa..4d1caf6b 100644 --- a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/Interval/Interval.java +++ b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/Interval/Interval.java @@ -1,25 +1,69 @@ package de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.JSON.Interval; +import static de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.JSON.Interval.Sum.SUM_TYPE.*; + +import de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.JSON.Interval.Streams.STREAM_TYPE; +import de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.JSON.Interval.Sum.SUM_TYPE; import de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.JSON.Interval.Sum.Sum; import de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.JSON.Interval.Streams.Streams; +import de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.JSON.Interval.Sum.TCP.TCP_BIDIR_SUM; +import de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.JSON.Interval.Sum.TCP.TCP_DL_SUM; +import de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.JSON.Interval.Sum.TCP.TCP_SUM; +import de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.JSON.Interval.Sum.TCP.TCP_UL_SUM; +import de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.JSON.Interval.Sum.UDP.UDP_BIDIR_SUM; +import de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.JSON.Interval.Sum.UDP.UDP_DL_SUM; +import de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.JSON.Interval.Sum.UDP.UDP_SUM; +import de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.JSON.Interval.Sum.UDP.UDP_UL_SUM; import org.json.JSONException; import org.json.JSONObject; public class Interval { private Streams streams; private Sum sum; - public Sum sum_bidir_reverse; + public Sum sumBidirReverse; public Interval(){ streams = new Streams(); } + + private SUM_TYPE getSumType(JSONObject data) throws JSONException { + boolean sender = data.getBoolean("sender"); + if(sender){ + if(data.has("retransmits")) return SUM_TYPE.TCP_UL; + if(data.has("packets")) return SUM_TYPE.UDP_UL; + } + if(data.has("jitter_ms")) return SUM_TYPE.UDP_DL; + return SUM_TYPE.TCP_DL; + } + + public Sum identifySum(JSONObject data) throws JSONException { + Sum identifiedSum = null; + switch (getSumType(data)){ + case TCP_DL: + identifiedSum = new TCP_DL_SUM(); + ((TCP_DL_SUM) identifiedSum).parse(data); + break; + case TCP_UL: + identifiedSum = new TCP_UL_SUM(); + ((TCP_UL_SUM) identifiedSum).parse(data); + break; + case UDP_DL: + identifiedSum = new UDP_DL_SUM(); + ((UDP_DL_SUM) identifiedSum).parse(data); + break; + case UDP_UL: + identifiedSum = new UDP_UL_SUM(); + ((UDP_UL_SUM) identifiedSum).parse(data); + break; + } + return identifiedSum; + } + public void parse(JSONObject data) throws JSONException { streams.parse(data.getJSONArray("streams")); - sum = new Sum(); - sum.parse(data.getJSONObject("sum")); + sum = identifySum(data.getJSONObject("sum")); if(data.has("sum_bidir_reverse")){ - sum_bidir_reverse = new Sum(); - sum_bidir_reverse.parse(data.getJSONObject("sum_bidir_reverse")); + sumBidirReverse = identifySum(data.getJSONObject("sum_bidir_reverse")); } } @@ -29,4 +73,7 @@ public Streams getStreams() { public Sum getSum() { return sum; } + public Sum getSumBidirReverse() { + return sumBidirReverse; + } } diff --git a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/Interval/Sum/SUM_TYPE.java b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/Interval/Sum/SUM_TYPE.java new file mode 100644 index 00000000..538bbd08 --- /dev/null +++ b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/Interval/Sum/SUM_TYPE.java @@ -0,0 +1,11 @@ +package de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.JSON.Interval.Sum; + +public enum SUM_TYPE { + TCP_UL, + TCP_DL, + TCP_BIDIR, + UDP_UL, + UDP_DL, + UDP_BIDIR, + UNKNOWN +} diff --git a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/Interval/Sum/Sum.java b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/Interval/Sum/Sum.java index ce084a13..c8f56f68 100644 --- a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/Interval/Sum/Sum.java +++ b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/Interval/Sum/Sum.java @@ -11,7 +11,7 @@ public class Sum { private double bits_per_second; private boolean omitted; private boolean sender; - + private SUM_TYPE sumType; public Sum(){ } public void parse(JSONObject data) throws JSONException { @@ -23,7 +23,6 @@ public void parse(JSONObject data) throws JSONException { this.omitted = data.getBoolean("omitted"); this.sender = data.getBoolean("sender"); } - public int getStart() { return start; } @@ -45,5 +44,11 @@ public boolean getOmitted() { public boolean getSender() { return sender; } + public SUM_TYPE getSumType() { + return sumType; + } + public void setSumType(SUM_TYPE sumType) { + this.sumType = sumType; + } } diff --git a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/Interval/Sum/TCP/TCP_BIDIR_SUM.java b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/Interval/Sum/TCP/TCP_BIDIR_SUM.java index b54c6360..2165f579 100644 --- a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/Interval/Sum/TCP/TCP_BIDIR_SUM.java +++ b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/Interval/Sum/TCP/TCP_BIDIR_SUM.java @@ -1,18 +1,24 @@ package de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.JSON.Interval.Sum.TCP; +import de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.JSON.Interval.Sum.SUM_TYPE; +import de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.JSON.Interval.Sum.Sum; import org.json.JSONException; import org.json.JSONObject; public class TCP_BIDIR_SUM extends TCP_SUM{ - TCP_UL_SUM ul; - TCP_DL_SUM dl; + Sum bidirReverse; + SUM_TYPE sumType; public TCP_BIDIR_SUM() { super(); + this.sumType = SUM_TYPE.TCP_BIDIR; } public void parse(JSONObject data) throws JSONException { - this.ul = new TCP_UL_SUM(); - this.dl = new TCP_DL_SUM(); - this.ul.parse(data.getJSONObject("sum")); - this.dl.parse(data.getJSONObject("sum_bidir_reverse")); + super.parse(data.getJSONObject("sum")); + this.bidirReverse.parse(data.getJSONObject("sum_bidir_reverse")); + + } + + public SUM_TYPE getSumType() { + return sumType; } } diff --git a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/Interval/Sum/TCP/TCP_DL_SUM.java b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/Interval/Sum/TCP/TCP_DL_SUM.java index 62b3a47d..d664ea55 100644 --- a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/Interval/Sum/TCP/TCP_DL_SUM.java +++ b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/Interval/Sum/TCP/TCP_DL_SUM.java @@ -1,11 +1,13 @@ package de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.JSON.Interval.Sum.TCP; +import de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.JSON.Interval.Sum.SUM_TYPE; import org.json.JSONException; import org.json.JSONObject; public class TCP_DL_SUM extends TCP_SUM{ public TCP_DL_SUM() { super(); + this.setSumType(SUM_TYPE.TCP_DL); } @Override diff --git a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/Interval/Sum/TCP/TCP_UL_SUM.java b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/Interval/Sum/TCP/TCP_UL_SUM.java index e80458d1..e8f84261 100644 --- a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/Interval/Sum/TCP/TCP_UL_SUM.java +++ b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/Interval/Sum/TCP/TCP_UL_SUM.java @@ -1,5 +1,6 @@ package de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.JSON.Interval.Sum.TCP; +import de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.JSON.Interval.Sum.SUM_TYPE; import org.json.JSONException; import org.json.JSONObject; @@ -7,9 +8,11 @@ public class TCP_UL_SUM extends TCP_SUM{ public int retransmits; public TCP_UL_SUM() { super(); + this.setSumType(SUM_TYPE.TCP_UL); } public void parse(JSONObject data) throws JSONException { super.parse(data); this.retransmits = data.getInt("retransmits"); + } } diff --git a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/Interval/Sum/UDP/UDP_BIDIR_SUM.java b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/Interval/Sum/UDP/UDP_BIDIR_SUM.java index 38566036..284a35aa 100644 --- a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/Interval/Sum/UDP/UDP_BIDIR_SUM.java +++ b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/Interval/Sum/UDP/UDP_BIDIR_SUM.java @@ -1,20 +1,25 @@ package de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.JSON.Interval.Sum.UDP; +import de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.JSON.Interval.Sum.SUM_TYPE; +import de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.JSON.Interval.Sum.Sum; import org.json.JSONException; import org.json.JSONObject; -public class UDP_BIDIR_SUM { +public class UDP_BIDIR_SUM extends UDP_SUM{ - UDP_UL_SUM ul; - UDP_DL_SUM dl; + Sum bidirReverse; + SUM_TYPE sumType; public UDP_BIDIR_SUM() { super(); + sumType = SUM_TYPE.UDP_BIDIR; } public void parse(JSONObject data) throws JSONException { - this.ul = new UDP_UL_SUM(); - this.dl = new UDP_DL_SUM(); - this.ul.parse(data.getJSONObject("sum")); - this.dl.parse(data.getJSONObject("sum_bidir_reverse")); + super.parse(data.getJSONObject("sum")); + this.bidirReverse.parse(data.getJSONObject("sum_bidir_reverse")); + } + public SUM_TYPE getSumType() { + return sumType; + } } diff --git a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/Interval/Sum/UDP/UDP_DL_SUM.java b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/Interval/Sum/UDP/UDP_DL_SUM.java index c4bdf365..041a39e1 100644 --- a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/Interval/Sum/UDP/UDP_DL_SUM.java +++ b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/Interval/Sum/UDP/UDP_DL_SUM.java @@ -1,14 +1,16 @@ package de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.JSON.Interval.Sum.UDP; +import de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.JSON.Interval.Sum.SUM_TYPE; import org.json.JSONException; import org.json.JSONObject; public class UDP_DL_SUM extends UDP_SUM{ private double jitter_ms; private int lost_packets; - private int lost_percent; + private double lost_percent; public UDP_DL_SUM() { super(); + this.setSumType(SUM_TYPE.UDP_DL); } @Override @@ -16,6 +18,20 @@ public void parse(JSONObject data) throws JSONException { super.parse(data); this.jitter_ms = data.getDouble("jitter_ms"); this.lost_packets = data.getInt("lost_packets"); - this.lost_percent = data.getInt("lost_percent"); + this.lost_percent = data.getDouble("lost_percent"); + + } + + public double getJitter_ms() { + return jitter_ms; + } + + public int getLost_packets() { + return lost_packets; + } + + public double getLost_percent() { + return lost_percent; } + } diff --git a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/Interval/Sum/UDP/UDP_UL_SUM.java b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/Interval/Sum/UDP/UDP_UL_SUM.java index 0ece1357..a73bab2c 100644 --- a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/Interval/Sum/UDP/UDP_UL_SUM.java +++ b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/Interval/Sum/UDP/UDP_UL_SUM.java @@ -1,5 +1,6 @@ package de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.JSON.Interval.Sum.UDP; +import de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.JSON.Interval.Sum.SUM_TYPE; import org.json.JSONException; import org.json.JSONObject; @@ -7,6 +8,7 @@ public class UDP_UL_SUM extends UDP_SUM{ private int packets; public UDP_UL_SUM() { super(); + this.setSumType(SUM_TYPE.UDP_UL); } public void parse(JSONObject data) throws JSONException { super.parse(data); diff --git a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/start/Start.java b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/start/Start.java index 0d42a59d..30cea994 100644 --- a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/start/Start.java +++ b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/start/Start.java @@ -36,7 +36,7 @@ public void parseStart(JSONObject data) throws JSONException { this.connecting_to = new ConnectingTo(); this.connecting_to.parse(data.getJSONObject("connecting_to")); this.cookie = data.getString("cookie"); - this.tcp_mss_default = data.getInt("tcp_mss_default"); + if(data.has("tcp_mss_default")) this.tcp_mss_default = data.getInt("tcp_mss_default"); this.target_bitrate = data.getInt("target_bitrate"); this.fq_rate = data.getInt("fq_rate"); this.sock_bufsize = data.getInt("sock_bufsize"); diff --git a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/METRIC_TYPE.java b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/METRIC_TYPE.java new file mode 100644 index 00000000..8521c4a1 --- /dev/null +++ b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/METRIC_TYPE.java @@ -0,0 +1,8 @@ +package de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3; + +public enum METRIC_TYPE { + THROUGHPUT, + RTT, + JITTER, + PACKET_LOSS + } From 2b34573ec588d67735a416c12ef6c0c23b19070f Mon Sep 17 00:00:00 2001 From: Johann Date: Mon, 10 Jun 2024 12:28:53 +0200 Subject: [PATCH 5/6] update JSON parsing --- .../Iperf3/Iperf3Fragment.java | 17 ++---- .../Iperf3/Iperf3LogFragment.java | 58 ++++++++++++++----- .../Iperf3/Iperf3Parser.java | 14 ++++- .../Iperf3/JSON/Error.java | 8 ++- .../main/res/layout/fragment_iperf3_input.xml | 14 ----- app/src/main/res/values/strings.xml | 2 +- 6 files changed, 65 insertions(+), 48 deletions(-) diff --git a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Iperf3Fragment.java b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Iperf3Fragment.java index 80d4c28f..ae6cae77 100644 --- a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Iperf3Fragment.java +++ b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Iperf3Fragment.java @@ -83,7 +83,7 @@ public class Iperf3Fragment extends Fragment { private final String IPERF3CPORT = "iperf3cport"; private CheckBox iperf3BiDir; private CheckBox iperf3Reverse; - private CheckBox iperf3Json; + private CheckBox iperf3OneOff; private EditText iperf3EtIp; private EditText iperf3EtPort; @@ -169,7 +169,6 @@ public void onChanged(String s) { iperf3Reverse.setChecked(iperf3RunResult.input.iperf3Reverse); iperf3BiDir.setChecked(iperf3RunResult.input.iperf3BiDir); - iperf3Json.setChecked(iperf3RunResult.input.iperf3Json); iperf3OneOff.setChecked(iperf3RunResult.input.iperf3OneOff); protocolSpinner.setSelection(iperf3RunResult.input.iperf3IdxProtocol); iperf3ModeSpinner.setSelection(iperf3RunResult.input.iperf3IdxMode); @@ -304,12 +303,10 @@ public void afterTextChanged(Editable s) { iperf3BiDir = v.findViewById(R.id.iperf_bidir); iperf3Reverse = v.findViewById(R.id.iperf3_reverse); - iperf3Json = v.findViewById(R.id.iperf3_json); iperf3OneOff = v.findViewById(R.id.iperf3_one_off); saveCheckboxInputToSharedPreferences(iperf3BiDir, IPERF3BIDIR); saveCheckboxInputToSharedPreferences(iperf3Reverse, IPERF3REVERSE); - saveCheckboxInputToSharedPreferences(iperf3Json, IPERF3JSON); saveCheckboxInputToSharedPreferences(iperf3OneOff, IPERF3ONEOFF); protocolSpinner = v.findViewById(R.id.iperf3_protocol_spinner); @@ -352,7 +349,6 @@ public void onFragmentResult(@NonNull String requestKey, iperf3Reverse.setChecked(iperf3RunResult.input.iperf3Reverse); iperf3BiDir.setChecked(iperf3RunResult.input.iperf3BiDir); - iperf3Json.setChecked(iperf3RunResult.input.iperf3Json); iperf3OneOff.setChecked(iperf3RunResult.input.iperf3OneOff); protocolSpinner.setSelection(iperf3RunResult.input.iperf3IdxProtocol); iperf3ModeSpinner.setSelection(iperf3RunResult.input.iperf3IdxMode); @@ -375,7 +371,6 @@ public void onFragmentResult(@NonNull String requestKey, iperf3BiDir.setChecked(savedInstanceState.getBoolean(IPERF3BIDIR)); iperf3Reverse.setChecked(savedInstanceState.getBoolean(IPERF3REVERSE)); - iperf3Json.setChecked(savedInstanceState.getBoolean(IPERF3JSON)); iperf3OneOff.setChecked(savedInstanceState.getBoolean(IPERF3ONEOFF)); protocolSpinner.setSelection(savedInstanceState.getInt(IPERF3IDXPROTOCOL)); iperf3ModeSpinner.setSelection(savedInstanceState.getInt(IPERF3IDXMODE)); @@ -391,7 +386,6 @@ public void onFragmentResult(@NonNull String requestKey, iperf3BiDir.setChecked(preferences.getBoolean(IPERF3BIDIR, false)); iperf3Reverse.setChecked(preferences.getBoolean(IPERF3REVERSE, false)); - iperf3Json.setChecked(preferences.getBoolean(IPERF3JSON, false)); iperf3OneOff.setChecked(preferences.getBoolean(IPERF3ONEOFF, false)); protocolSpinner.setSelection(preferences.getInt(IPERF3IDXPROTOCOL, 0)); iperf3ModeSpinner.setSelection(preferences.getInt(IPERF3IDXMODE, 0)); @@ -630,7 +624,7 @@ private String parseInput() { input.iperf3BiDir = false; input.iperf3Reverse = false; input.iperf3OneOff = false; - input.iperf3Json = false; + input.iperf3Json = true; if (!isModeSpinnerClient()) { stb.add("-s"); @@ -648,10 +642,8 @@ private String parseInput() { stb.add("--one-off"); input.iperf3OneOff = true; } - if (iperf3Json.isChecked()) { - stb.add("--json-stream"); - input.iperf3Json = true; - } + stb.add("--json-stream"); + String joined = String.join(" ", stb); @@ -682,7 +674,6 @@ private void writeToSP() { editor.putBoolean(IPERF3BIDIR, iperf3BiDir.isChecked()); editor.putBoolean(IPERF3REVERSE, iperf3Reverse.isChecked()); - editor.putBoolean(IPERF3JSON, iperf3Json.isChecked()); editor.putBoolean(IPERF3ONEOFF, iperf3OneOff.isChecked()); editor.apply(); } diff --git a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Iperf3LogFragment.java b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Iperf3LogFragment.java index 793d9664..74d40e8a 100644 --- a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Iperf3LogFragment.java +++ b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Iperf3LogFragment.java @@ -32,6 +32,7 @@ import androidx.fragment.app.Fragment; import com.github.anastr.speedviewlib.SpeedView; +import de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.JSON.Error; import de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.JSON.Interval.Interval; import de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.JSON.Interval.Sum.SUM_TYPE; import de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.JSON.Interval.Sum.Sum; @@ -66,6 +67,7 @@ public class Iperf3LogFragment extends Fragment { private SpeedView speedView; private LinearLayout parameterLL; private Context ct; + private LinearLayout metricLL; private Metric defaultReverseThroughput; private Metric defaultThroughput; private Metric defaultRTT; @@ -341,14 +343,32 @@ private void parseSum(Sum sum, Metric throughput){ } } - @Override public void propertyChange(PropertyChangeEvent evt) { - Interval interval = (Interval) evt.getNewValue(); - parseSum(interval.getSum(), defaultThroughput); - if(interval.getSumBidirReverse() != null) parseSum(interval.getSumBidirReverse(), - defaultReverseThroughput); + + switch (evt.getPropertyName()){ + case "interval": + Interval interval = (Interval) evt.getNewValue(); + parseSum(interval.getSum(), defaultThroughput); + if(interval.getSumBidirReverse() != null) parseSum(interval.getSumBidirReverse(), + defaultReverseThroughput); + break; + case "start": + break; + case "end": + break; + case "error": + Error error = (Error) evt.getNewValue(); + TextView errorView = new TextView(ct); + errorView.setText(error.getError()); + errorView.setTextColor(ct.getColor(R.color.crimson)); + errorView.setPadding(10, 10, 10, 10); + errorView.setTextSize(20); + metricLL.addView(errorView); + break; + } } }); + iperf3Parser.parse(); if (iperf3RunResult.result != -100) { logHandler.removeCallbacks(logUpdate); @@ -498,37 +518,45 @@ public void onClick(View v) { TypedValue.COMPLEX_UNIT_SP); iperf3OutputViewer.setTextIsSelectable(true); + metricLL = new LinearLayout(ct); + metricLL.setOrientation(LinearLayout.VERTICAL); + metricLL.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); + + + defaultThroughput = new Metric(METRIC_TYPE.THROUGHPUT); defaultReverseThroughput = new Metric(METRIC_TYPE.THROUGHPUT); - mainLL.addView(defaultThroughput.createOneDirection("Throughput")); + + metricLL.addView(defaultThroughput.createOneDirection("Throughput")); if(iperf3RunResult.input.iperf3BiDir) { - mainLL.addView(defaultReverseThroughput.createOneDirection("Throughput")); + metricLL.addView(defaultReverseThroughput.createOneDirection("Throughput")); if(iperf3RunResult.input.iperf3IdxProtocol == 0) { - defaultRTT = new Metric(METRIC_TYPE.RTT); - mainLL.addView(defaultRTT.createOneDirection("RTT")); + //defaultRTT = new Metric(METRIC_TYPE.RTT); + //metricLL.addView(defaultRTT.createOneDirection("RTT")); }; if(iperf3RunResult.input.iperf3IdxProtocol == 1) { defaultJITTER = new Metric(METRIC_TYPE.JITTER); - mainLL.addView(defaultJITTER.createOneDirection("Jitter ms")); + metricLL.addView(defaultJITTER.createOneDirection("Jitter ms")); PACKET_LOSS = new Metric(METRIC_TYPE.PACKET_LOSS); - mainLL.addView(PACKET_LOSS.createOneDirection("Packet Loss %")); + metricLL.addView(PACKET_LOSS.createOneDirection("Packet Loss %")); }; }; if(iperf3RunResult.input.iperf3Reverse) { if(iperf3RunResult.input.iperf3IdxProtocol == 1) { defaultJITTER = new Metric(METRIC_TYPE.JITTER); - mainLL.addView(defaultJITTER.createOneDirection("Jitter ms")); + metricLL.addView(defaultJITTER.createOneDirection("Jitter ms")); PACKET_LOSS = new Metric(METRIC_TYPE.JITTER); - mainLL.addView(PACKET_LOSS.createOneDirection("Packet Loss %")); + metricLL.addView(PACKET_LOSS.createOneDirection("Packet Loss %")); }; } else if(!iperf3RunResult.input.iperf3BiDir) { if(iperf3RunResult.input.iperf3IdxProtocol == 0) { - defaultRTT = new Metric(METRIC_TYPE.RTT); - mainLL.addView(defaultRTT.createOneDirection("RTT ms")); + //defaultRTT = new Metric(METRIC_TYPE.RTT); + //metricLL.addView(defaultRTT.createOneDirection("RTT ms")); }; } + mainLL.addView(metricLL); diff --git a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Iperf3Parser.java b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Iperf3Parser.java index 41e79255..f3499a34 100644 --- a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Iperf3Parser.java +++ b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/Iperf3Parser.java @@ -1,5 +1,6 @@ package de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3; +import de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.JSON.Error; import de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.JSON.Interval.Interval; import de.fraunhofer.fokus.OpenMobileNetworkToolkit.Iperf3.JSON.start.Start; import java.beans.PropertyChangeListener; @@ -39,21 +40,28 @@ public void parse(){ while ((line = br.readLine()) != null) { JSONObject obj = new JSONObject(line); String event = obj.getString("event"); - JSONObject data = obj.getJSONObject("data"); switch (event) { case "start": start = new Start(); - start.parseStart(data); + JSONObject startData = obj.getJSONObject("data"); + start.parseStart(startData); break; case "interval": Interval interval = new Interval(); - interval.parse(data); + JSONObject intervalData = obj.getJSONObject("data"); + interval.parse(intervalData); support.firePropertyChange("interval", null, interval); intervals.addInterval(interval); break; case "end": System.out.println("End"); break; + case "error": + Error error = new Error(); + String errorString = obj.getString("data"); + error.parse(errorString); + support.firePropertyChange("error", null, error); + break; default: System.out.println("Unknown event"); break; diff --git a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/Error.java b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/Error.java index 75f885ec..e1444cab 100644 --- a/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/Error.java +++ b/app/src/main/java/de/fraunhofer/fokus/OpenMobileNetworkToolkit/Iperf3/JSON/Error.java @@ -17,8 +17,12 @@ public void setError(String error) { this.error = error; } - public void parse(JSONObject data) throws JSONException { - this.error = data.getString("error"); + public void parse(String data) throws JSONException { + this.error = data; + } + + public String toString() { + return "Error: " + error; } } diff --git a/app/src/main/res/layout/fragment_iperf3_input.xml b/app/src/main/res/layout/fragment_iperf3_input.xml index bd98c3c9..61fa0ff7 100644 --- a/app/src/main/res/layout/fragment_iperf3_input.xml +++ b/app/src/main/res/layout/fragment_iperf3_input.xml @@ -150,20 +150,6 @@ app:layout_constraintStart_toStartOf="@+id/guideline210" app:layout_constraintTop_toTopOf="parent" /> - - Huawei Project Mediatek IMS iPerf3 - Send! + Send -c 172.17.0.1 OpenMobileNetworkToolkit logging This app is provided by NGNI a department of Fraunhofer FOKUS. \n\nhttps://www.fokus.fraunhofer.de/go/ngni \n\nThis software is licensed under BSD 3-Clause Clear License https://spdx.org/licenses/BSD-3-Clause-Clear.html \n\nAuthors: \n\nPeter Hasse \nMohsin Nisar \nJohann Hackler From d6f1354dd323dd630569e5be29edeb064623fc6e Mon Sep 17 00:00:00 2001 From: Johann Date: Mon, 10 Jun 2024 13:35:22 +0200 Subject: [PATCH 6/6] remove run config --- docs/iperf3.md | 52 -------------------------------------------------- 1 file changed, 52 deletions(-) diff --git a/docs/iperf3.md b/docs/iperf3.md index bfdad654..2f9a018a 100644 --- a/docs/iperf3.md +++ b/docs/iperf3.md @@ -4,57 +4,5 @@ To see how to integrate iPerf3 into your app, look at [iPerf3 Repo](https://gith ![iPerf3](images/iperf3.png) -Possible iPerf3 run Configurations are: -| **Protocol** | **Single Stream** | **Multiple Streams** | -|--------------|--------------------|----------------------| -| **UDP** | | | -| | UL | UL | -| | DL | DL | -| | BIDIR | BIDIR | -| **TCP** | | | -| | UL | UL | -| | DL | DL | -| | BIDIR | BIDIR | - - -| **Protocol** | **Single Stream** | **Multiple Streams** | -|--------------|-------------------|----------------------| -| **UDP** | | | -| | ``` ```` | UL | -| | DL | DL | -| | BIDIR | BIDIR | -| **TCP** | | | -| | UL | UL | -| | DL | DL | -| | BIDIR | BIDIR | - - -TCP UL Single Stream -```json -{"event":"interval","data":{"streams":[{"socket":5,"start":0,"end":1.001069,"seconds":1.0010689496994019,"bytes":3994157056,"bits_per_second":31919136496.636753,"retransmits":0,"snd_cwnd":1506109,"snd_wnd":6192128,"rtt":59,"rttvar":14,"pmtu":65535,"omitted":false,"sender":true}],"sum":{"start":0,"end":1.001069,"seconds":1.0010689496994019,"bytes":3994157056,"bits_per_second":31919136496.636753,"retransmits":0,"omitted":false,"sender":true}}} -``` -TCP DL Single Stream -```JSON -{"event":"interval","data":{"streams":[{"socket":5,"start":0,"end":1.000363,"seconds":1.0003629922866821,"bytes":3878158336,"bits_per_second":31014008842.011257,"omitted":false,"sender":false}],"sum":{"start":0,"end":1.000363,"seconds":1.0003629922866821,"bytes":3878158336,"bits_per_second":31014008842.011257,"omitted":false,"sender":false}}} -``` -TCP BIDIR Single Stream -```json -{"event":"interval","data":{"streams":[{"socket":5,"start":0,"end":1.000228,"seconds":1.0002280473709106,"bytes":3935043584,"bits_per_second":31473171298.031265,"retransmits":0,"snd_cwnd":1309660,"snd_wnd":6192128,"rtt":34,"rttvar":2,"pmtu":65535,"omitted":false,"sender":true},{"socket":7,"start":0,"end":1.025515,"seconds":1.0255149602890015,"bytes":3690070016,"bits_per_second":28786084329.458031,"omitted":false,"sender":false}],"sum":{"start":0,"end":1.000228,"seconds":1.0002280473709106,"bytes":3935043584,"bits_per_second":31473171298.031265,"retransmits":0,"omitted":false,"sender":true},"sum_bidir_reverse":{"start":0,"end":1.000228,"seconds":1.0002280473709106,"bytes":3690070016,"bits_per_second":29513829576.759514,"omitted":false,"sender":false}}} -``` - -UDP UL Single Stream -```json -{"event":"interval","data":{"streams":[{"socket":5,"start":0,"end":1.000097,"seconds":1.0000970363616943,"bytes":135168,"bits_per_second":1081239.0804935072,"packets":8,"omitted":false,"sender":true}],"sum":{"start":0,"end":1.000097,"seconds":1.0000970363616943,"bytes":135168,"bits_per_second":1081239.0804935072,"packets":8,"omitted":false,"sender":true}}} -``` - -UDP DL Single Stream -```json -{"event":"interval","data":{"streams":[{"socket":5,"start":1.00107,"end":2.001073,"seconds":1.0000029802322388,"bytes":135168,"bits_per_second":1081340.7773533543,"jitter_ms":0.023491129322622144,"lost_packets":0,"packets":8,"lost_percent":0,"omitted":false,"sender":false}],"sum":{"start":1.00107,"end":2.001073,"seconds":1.0000029802322388,"bytes":135168,"bits_per_second":1081340.7773533543,"jitter_ms":0.023491129322622144,"lost_packets":0,"packets":8,"lost_percent":0,"omitted":false,"sender":false}}} -``` - -UDP BIDIR Single Stream -```json -{"event":"interval","data":{"streams":[{"socket":5,"start":0,"end":1.000089,"seconds":1.0000890493392944,"bytes":135168,"bits_per_second":1081247.7156053118,"packets":8,"omitted":false,"sender":true},{"socket":7,"start":0,"end":1.000093,"seconds":1.0000929832458496,"bytes":135168,"bits_per_second":1081243.4624733056,"jitter_ms":0.021732455059885976,"lost_packets":0,"packets":8,"lost_percent":0,"omitted":false,"sender":false}],"sum":{"start":0,"end":1.000089,"seconds":1.0000890493392944,"bytes":135168,"bits_per_second":1081247.7156053118,"packets":8,"omitted":false,"sender":true},"sum_bidir_reverse":{"start":0,"end":1.000089,"seconds":1.0000890493392944,"bytes":135168,"bits_per_second":1081247.7156053118,"jitter_ms":0.021732455059885976,"lost_packets":0,"packets":8,"lost_percent":0,"omitted":false,"sender":false}}} -``` [Home](OpenMobileNetworkToolkit.md) \ No newline at end of file