Skip to content

Commit

Permalink
Hongyi: add progress bar, change PRR to loss rate, update UI so that …
Browse files Browse the repository at this point in the history
…the user can set more parameters
  • Loading branch information
laoyaosniper committed Sep 13, 2014
1 parent 63d8c69 commit e32e276
Show file tree
Hide file tree
Showing 7 changed files with 103 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,12 @@ public void TestPacketPackAndUnpack() throws UnknownHostException {
try {
packet = new MeasurementPacket(id1, rawData);
} catch (MeasurementError e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
byte[] newData = null;
try {
newData = packet.getByteArray();
} catch (MeasurementError e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
for ( int i = 0; i < newData.length; i++ ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ private void init()
}

@Test(expected = MeasurementError.class)
public void TestProcessPacket_Request_shortPacket()
public void TestProcessPacketRequestShortPacket()
throws Throwable {
init();

Expand All @@ -89,7 +89,7 @@ public void TestProcessPacket_Request_shortPacket()
}

@Test(expected = MeasurementError.class)
public void TestProcessPacket_Request_longPacket()
public void TestProcessPacketRequestLongPacket()
throws Throwable {
init();

Expand All @@ -108,7 +108,7 @@ public void TestProcessPacket_Request_longPacket()
}

@Test(expected = MeasurementError.class)
public void TestProcessPacket_Request_NegBurst()
public void TestProcessPacketRequestNegBurst()
throws Throwable {
init();

Expand All @@ -129,7 +129,7 @@ public void TestProcessPacket_Request_NegBurst()


@Test(expected = MeasurementError.class)
public void TestProcessPacket_Request_HugeBurst()
public void TestProcessPacketRequestHugeBurst()
throws Throwable {
init();

Expand All @@ -151,7 +151,7 @@ public void TestProcessPacket_Request_HugeBurst()


@Test(expected = MeasurementError.class)
public void TestProcessPacket_Data_SeqChange()
public void TestProcessPacketDataSeqChange()
throws Throwable {
init();

Expand Down
52 changes: 52 additions & 0 deletions android/res/layout/measurement_creation_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,58 @@
</RadioGroup>
</LinearLayout>
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/UDPBurstPacketSizeView"
android:paddingTop="@dimen/marginBetweenRows">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="right|center_vertical"
android:textSize="@dimen/regularTextSize"
android:text="@string/UDPBurstPacketSizeLabel"/>
<LinearLayout
android:paddingLeft="@dimen/marginBetweenColumns"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText android:id="@+id/UDPBurstPacketSizeText"
android:layout_height="@dimen/editTextBoxHeight"
android:layout_width="match_parent"
android:hint="@string/UDPBurstPacketSizeHint"
android:inputType="number"
android:lines="1"
android:textSize="@dimen/smallTextSize"
android:text="@string/UDPBurstPacketSizeHint"/>
</LinearLayout>
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/UDPBurstPacketCountView"
android:paddingTop="@dimen/marginBetweenRows">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="right|center_vertical"
android:textSize="@dimen/regularTextSize"
android:text="@string/UDPBurstPacketCountLabel"/>
<LinearLayout
android:paddingLeft="@dimen/marginBetweenColumns"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText android:id="@+id/UDPBurstPacketCountText"
android:layout_height="@dimen/editTextBoxHeight"
android:layout_width="match_parent"
android:hint="@string/UDPBurstPacketCountHint"
android:inputType="number"
android:lines="1"
android:textSize="@dimen/smallTextSize"
android:text="@string/UDPBurstPacketCountHint"/>
</LinearLayout>
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content"
Expand Down
8 changes: 6 additions & 2 deletions android/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
<string name="default_user_agent">"MobiPerf-2.0 (Linux; Android)"</string>
<string name="ping_executable">ping</string>
<string name="ping6_executable">ping6</string>
<string name="serverUrl">https://openmobiledata.appspot.com</string>
<string name="anonymousServerUrl">https://openmobiledata.appspot.com/anonymous</string>
<string name="serverUrl">http://mobiperf-udp.mobiperf-udp.appspot.com</string>
<string name="anonymousServerUrl">http://mobiperf-udp.mobiperf-udp.appspot.com</string>
<string name="testServerUrl"></string>
<string name="menuQuit">Quit</string>
<string name="menumPause">Pause</string>
Expand All @@ -26,6 +26,10 @@
<string name="UDPBurstIntervalLabel">Interval(ms): </string>
<string name="UDPBurstTargetHint">www.google.com</string>
<string name="UDPBurstIntervalHint">256</string>
<string name="UDPBurstPacketSizeLabel">Packet Size(byte): </string>
<string name="UDPBurstPacketSizeHint">100</string>
<string name="UDPBurstPacketCountLabel">Packet Number: </string>
<string name="UDPBurstPacketCountHint">16</string>
<string name="httpUrlHint">www.google.com</string>
<string name="httpUrlLabel">URL Address</string>
<string name="checkinIntervalPrefKey">KEY_CHECKEDIN_INTERVAL</string>
Expand Down
12 changes: 9 additions & 3 deletions android/src/com/mobiperf/MeasurementCreationActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,8 @@ private void populateMeasurementSpecificArea() {
this.findViewById(R.id.dnsTargetView).setVisibility(View.VISIBLE);
} else if (this.measurementTypeUnderEdit.compareTo(UDPBurstTask.TYPE) == 0) {
this.findViewById(R.id.UDPBurstDirView).setVisibility(View.VISIBLE);
this.findViewById(R.id.UDPBurstPacketSizeView).setVisibility(View.VISIBLE);
this.findViewById(R.id.UDPBurstPacketCountView).setVisibility(View.VISIBLE);
this.findViewById(R.id.UDPBurstIntervalView).setVisibility(View.VISIBLE);
} else if (this.measurementTypeUnderEdit.compareTo(TCPThroughputTask.TYPE) == 0) {
this.findViewById(R.id.TCPThroughputDirView).setVisibility(View.VISIBLE);
Expand Down Expand Up @@ -245,7 +247,12 @@ public void onClick(View v) {
// m-lab.
params.put("target", MLabNS.TARGET);
params.put("direction", udpDir);
params.put("packet_burst", "16");
// Get UDP Burst packet size
EditText UDPBurstPacketSizeText = (EditText) findViewById(R.id.UDPBurstPacketSizeText);
params.put("packet_size_byte", UDPBurstPacketSizeText.getText().toString());
// Get UDP Burst packet count
EditText UDPBurstPacketCountText = (EditText) findViewById(R.id.UDPBurstPacketCountText);
params.put("packet_burst", UDPBurstPacketCountText.getText().toString());
// Get UDP Burst interval
EditText UDPBurstIntervalText = (EditText) findViewById(R.id.UDPBurstIntervalText);
params.put("udp_interval", UDPBurstIntervalText.getText().toString());
Expand All @@ -256,8 +263,7 @@ public void onClick(View v) {
Config.DEFAULT_USER_MEASUREMENT_INTERVAL_SEC,
Config.DEFAULT_USER_MEASUREMENT_COUNT,
MeasurementTask.USER_PRIORITY,
params,
MeasurementCreationActivity.this.getApplicationContext());
params);
newTask =
new UDPBurstTask(desc, MeasurementCreationActivity.this.getApplicationContext());
} else if (measurementTypeUnderEdit.equals(TCPThroughputTask.TYPE)) {
Expand Down
4 changes: 2 additions & 2 deletions android/src/com/mobiperf/MeasurementResult.java
Original file line number Diff line number Diff line change
Expand Up @@ -249,8 +249,8 @@ private void getUDPBurstResult(StringBuilderPrinter printer, HashMap<String, Str
printer.println("Packets number: " + desc.udpBurstCount);
printer.println("Packets interval: " + desc.udpInterval);

printer.println("\nPRR: " + values.get("PRR"));
printer.println("Inversion Number: " + values.get("Inversion_Number"));
printer.println("\nLoss Rate: " + values.get("loss_rate"));
printer.println("Inversion Number: " + values.get("inversion_number"));
printer.println("Jitter: " + values.get("jitter"));
} else {
printer.println("Failed");
Expand Down
35 changes: 29 additions & 6 deletions android/src/com/mobiperf/measurements/UDPBurstTask.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
*/
package com.mobiperf.measurements;

import com.mobiperf.Config;
import com.mobiperf.Logger;
import com.mobiperf.MeasurementDesc;
import com.mobiperf.MeasurementError;
Expand Down Expand Up @@ -54,11 +55,12 @@ public class UDPBurstTask extends MeasurementTask {
public static final String DESCRIPTOR = "UDP Burst";

private static final int DEFAULT_UDP_PACKET_SIZE = 100;
private static final int DEFAULT_UDP_BURST = 16;
private static final int DEFAULT_UDP_INTERVAL = 256;
private static final int DEFAULT_UDP_BURST = 10;
private static final int DEFAULT_UDP_INTERVAL = 500;

// Min packet size = (int type) + (int burstCount) + (int packetNum) + (int intervalNum) +
// (long timestamp) + (int packetSize) + (int seq) + (int udpInterval)
// Min packet size = (int type) + (int burstCount) + (int packetNum)
// + (int intervalNum) + (long timestamp) + (int packetSize)
// + (int seq) + (int udpInterval)
// = 36
private static final int MIN_PACKETSIZE = 36;

Expand Down Expand Up @@ -401,6 +403,11 @@ private DatagramSocket sendUpBurst() throws MeasurementError {
Logger.i("Sent packet pnum:" + i + " to " + desc.target + ": "
+ targetIp);

// Update progress bar, leave the last grid for receiving response
this.progress = 100 * i / (desc.udpBurstCount + 1);
this.progress = Math.min(Config.MAX_PROGRESS_BAR_VALUE, progress);
broadcastProgressForUser(this.progress);

try {
Thread.sleep(desc.udpInterval);
Logger.i("UDP Burst sleep " + desc.udpInterval + "ms");
Expand Down Expand Up @@ -476,6 +483,10 @@ private UDPResult recvUpResponse(DatagramSocket sock)
+ " burst:" + burstsize + " pktnum:" + pktnum + " invnum: "
+ invnum + " jitter: " + jitter);

// Update the last grid in progress bar
this.progress = Config.MAX_PROGRESS_BAR_VALUE;
broadcastProgressForUser(this.progress);

udpResult.packetNumber = pktnum;
udpResult.InversionNumber = invnum;
udpResult.jitter = jitter;
Expand Down Expand Up @@ -546,6 +557,12 @@ private DatagramSocket sendDownRequest() throws MeasurementError {
+ desc.target);
}


// Update the first grid of progress bar for sending request
this.progress = 100 * 1 / (desc.udpBurstCount + 1);
this.progress = Math.min(Config.MAX_PROGRESS_BAR_VALUE, progress);
broadcastProgressForUser(this.progress);

return sock;
}

Expand Down Expand Up @@ -609,6 +626,11 @@ private UDPResult recvDownResponse(DatagramSocket sock)
+ " burst:" + burstsize + " pktnum:" + pktnum
+ " timestamp:" + timestamp);

// Update progress bar, the first grid is taken by client request
this.progress = 100 * (i + 1) / (desc.udpBurstCount + 1);
this.progress = Math.min(Config.MAX_PROGRESS_BAR_VALUE, progress);
broadcastProgressForUser(this.progress);

if (ptype == UDPBurstTask.PKT_DATA) {
pktrecv++;
metricCalculator.addPacket(pktnum, timestamp);
Expand Down Expand Up @@ -694,8 +716,9 @@ public MeasurementResult call() throws MeasurementError {
this.measurementDesc);

result.addResult("target_ip", targetIp);
result.addResult("PRR", response);
result.addResult("Inversion_Number", udpResult.InversionNumber);
// It is more reasonable to show loss rate othen then packet received rate
result.addResult("loss_rate", 1.0 - response);
result.addResult("inversion_number", udpResult.InversionNumber);
result.addResult("jitter", udpResult.jitter);
// Update the sequence number to be used by the next burst
seq++;
Expand Down

0 comments on commit e32e276

Please sign in to comment.