correct threads for all TX java
This commit is contained in:
parent
d18c91e2db
commit
b9744e8caa
|
|
@ -31,6 +31,7 @@ import java.util.Date;
|
||||||
public class MainActivity extends Activity {
|
public class MainActivity extends Activity {
|
||||||
// unchanged stuff
|
// unchanged stuff
|
||||||
protected static final String remoteIP = "128.111.68.220";
|
protected static final String remoteIP = "128.111.68.220";
|
||||||
|
protected static final String remoteMAC = "18:03:73:c8:86:52";
|
||||||
protected static final String sshlinklab = "ssh linklab@hotcrp.cs.ucsb.edu"
|
protected static final String sshlinklab = "ssh linklab@hotcrp.cs.ucsb.edu"
|
||||||
+ " -i /data/.ssh/id_rsa -o StrictHostKeyChecking=no";
|
+ " -i /data/.ssh/id_rsa -o StrictHostKeyChecking=no";
|
||||||
protected static final String sshlinklablocal = "ssh linklab@" + remoteIP
|
protected static final String sshlinklablocal = "ssh linklab@" + remoteIP
|
||||||
|
|
@ -69,6 +70,7 @@ public class MainActivity extends Activity {
|
||||||
protected static TextView txt_results;
|
protected static TextView txt_results;
|
||||||
protected static Handler myHandler;
|
protected static Handler myHandler;
|
||||||
protected static String myInetIP = "";
|
protected static String myInetIP = "";
|
||||||
|
protected static String myMAC = "";
|
||||||
protected static String RXportNum = "4444";
|
protected static String RXportNum = "4444";
|
||||||
protected static String outFolderPath;
|
protected static String outFolderPath;
|
||||||
protected static String btn_click_time;
|
protected static String btn_click_time;
|
||||||
|
|
@ -469,7 +471,7 @@ public class MainActivity extends Activity {
|
||||||
commd[2] = "cd " + outFolderPath + " && mv *" + btn_click_time
|
commd[2] = "cd " + outFolderPath + " && mv *" + btn_click_time
|
||||||
+ "* " + existedItems[selectedItems.get(j)] + "/";
|
+ "* " + existedItems[selectedItems.get(j)] + "/";
|
||||||
Runtime.getRuntime().exec(commd).waitFor();
|
Runtime.getRuntime().exec(commd).waitFor();
|
||||||
Log.d(TAG, "Finished " + (currentBandwidth / 1000000.0) + "MBps, "
|
Log.d(TAG, "Finished " + (currentBandwidth / 1000000.0) + "Mbps, "
|
||||||
+ i + "th repeat on " + existedItems[selectedItems.get(j)]
|
+ i + "th repeat on " + existedItems[selectedItems.get(j)]
|
||||||
+ ", t="+reportedFinishTime+"ms");
|
+ ", t="+reportedFinishTime+"ms");
|
||||||
Thread.sleep(5000);
|
Thread.sleep(5000);
|
||||||
|
|
@ -569,23 +571,22 @@ public class MainActivity extends Activity {
|
||||||
// grab WiFi service and check if wifi is enabled
|
// grab WiFi service and check if wifi is enabled
|
||||||
wm = (WifiManager) this.getSystemService(WIFI_SERVICE);
|
wm = (WifiManager) this.getSystemService(WIFI_SERVICE);
|
||||||
isUsingWifi = (wm.isWifiEnabled()) ? true : false;
|
isUsingWifi = (wm.isWifiEnabled()) ? true : false;
|
||||||
if (isUsingWifi) {
|
Utilities.getSelfIdentity(tcpdumpInterface, true);
|
||||||
myInetIP = Utilities.getInetIP(true);
|
|
||||||
}
|
|
||||||
// predefined selections
|
// predefined selections
|
||||||
existedItems = new CharSequence[] {
|
existedItems = new CharSequence[] {
|
||||||
"Socket_Normal", "Socket_NormalUDP", "Socket_Sendfile",
|
"Socket_Normal", "Socket_NormalUDP", "Socket_Sendfile",
|
||||||
"Socket_Splice", "RawSocket_Normal"
|
"Socket_Splice", "RawSocket_Normal"
|
||||||
};
|
};
|
||||||
existedItemsThrpt = new CharSequence[]{
|
existedItemsThrpt = new CharSequence[]{
|
||||||
"50KB", "100KB", "250KB", "0.5MB", "0.75MB", "1MB", "1.5MB", "2MB", // 0-7
|
"800Mbps", "760Mbps", "720Mbps", "680Mbps", "640Mbps", "600Mbps", "560Mbps",// 0-6
|
||||||
"2.5MB", "3MB", "3.5MB", "4MB", "4.5MB", "5MB", "5.5MB", "6MB", // 8-15
|
"520Mbps", "480Mbps", "440Mbps", "400Mbps", "360Mbps", "320Mbps", "280Mbps",// 7-13
|
||||||
"6.5MB", "7MB", "7.5MB", "8MB", "8.5MB", "9MB", "9.5MB", "10MB", // 16-23
|
"240Mbps", "200Mbps", "160Mbps", "120Mbps", "80Mbps", // 14-18
|
||||||
"Unlimited", // 24
|
"76Mbps", "72Mbps", "68Mbps", "64Mbps", "60Mbps", "56Mbps", "52Mbps", // 19-25
|
||||||
"15MB", "20MB", "25MB", "30MB", "35MB", "40MB", "45MB", "50MB", // 25-32
|
"48Mbps", "44Mbps", "40Mbps", "36Mbps", "32Mbps", "28Mbps", "24Mbps", // 26-32
|
||||||
"55MB", "60MB", "65MB", "70MB", "75MB", "80MB", "85MB", "90MB", // 33-40
|
"20Mbps", "16Mbps", "12Mbps", "8Mbps", // 33-36
|
||||||
"95MB", "100MB", // 41-42
|
"6Mbps", "5Mbps", "4Mbps", "3Mbps", "2Mbps", "1Mbps", // 37-42
|
||||||
"11MB", "13MB" // 43-44
|
"800Kbps", "600Kbps", "400Kbps", "200Kbps", // 43-46
|
||||||
|
"Unlimited", // 47
|
||||||
};
|
};
|
||||||
// binary executables to run
|
// binary executables to run
|
||||||
binary_TX_Normal = "client_send_normaltcp";
|
binary_TX_Normal = "client_send_normaltcp";
|
||||||
|
|
@ -750,6 +751,8 @@ public class MainActivity extends Activity {
|
||||||
if (isVerbose) {
|
if (isVerbose) {
|
||||||
Log.d(TAG, "TCPDump interface is set to " + tcpdumpInterface);
|
Log.d(TAG, "TCPDump interface is set to " + tcpdumpInterface);
|
||||||
}
|
}
|
||||||
|
// based on the selected interface, get corresponding IP and MAC address
|
||||||
|
Utilities.getSelfIdentity(tcpdumpInterface, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -779,21 +782,10 @@ public class MainActivity extends Activity {
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
isLocal = isChecked;
|
isLocal = isChecked;
|
||||||
// binary_TX_Normal = isLocal ? "normal_lo" : "normal";
|
|
||||||
// binary_TX_NormalUDP = isLocal ? "normal_udp_lo" : "normal_udp";
|
|
||||||
// binary_TX_Sendfile = isLocal ? "sendfile_lo" : "sendfile";
|
|
||||||
// binary_TX_Splice = isLocal ? "splice_lo" : "splice";
|
|
||||||
// binary_TX_RawNormal = isLocal ? "bypassl3_lo" : "bypassl3";
|
|
||||||
// binary_RX_Normal = isLocal ? "normal_recv_lo" : "normal_recv";
|
|
||||||
// binary_RX_NormalUDP =
|
|
||||||
// isLocal ? "normal_udp_recv_lo" : "normal_udp_recv";
|
|
||||||
// binary_RX_Splice = isLocal ? "splice_recv_lo" : "splice_recv";
|
|
||||||
// binary_RX_RawNormal =
|
|
||||||
// isLocal ? "bypassl3_recv_lo" : "bypassl3_recv";
|
|
||||||
if (isLocal) {
|
if (isLocal) {
|
||||||
isUsingTCPDump = false;
|
isUsingTCPDump = false;
|
||||||
Toast.makeText(MainActivity.this,
|
Toast.makeText(MainActivity.this, ""
|
||||||
"Remember to set IP to 192.168.1.15\n"
|
// "Remember to set IP to 192.168.1.15\n"
|
||||||
+ "Will start locally\n"
|
+ "Will start locally\n"
|
||||||
+ "tcpdump disabled", Toast.LENGTH_LONG).show();
|
+ "tcpdump disabled", Toast.LENGTH_LONG).show();
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,8 @@ public class SSLogger extends Service {
|
||||||
for (int i = 0; i < MainActivity.coreNum - 1; ++i) {
|
for (int i = 0; i < MainActivity.coreNum - 1; ++i) {
|
||||||
myTmp += raws[i+1] + " " + cpuFrequency(i) + " ";
|
myTmp += raws[i+1] + " " + cpuFrequency(i) + " ";
|
||||||
}
|
}
|
||||||
myTmp += raws[MainActivity.coreNum] + " " + cpuFrequency(MainActivity.coreNum-1) + "\n";
|
myTmp += raws[MainActivity.coreNum] + " "
|
||||||
|
+ cpuFrequency(MainActivity.coreNum - 1) + "\n";
|
||||||
// // cpuTotal
|
// // cpuTotal
|
||||||
// String[] cpuTotal = raws[0].split("\\s+");
|
// String[] cpuTotal = raws[0].split("\\s+");
|
||||||
// String cpuTotalsum = parseProcStat(cpuTotal);
|
// String cpuTotalsum = parseProcStat(cpuTotal);
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ import java.io.InputStreamReader;
|
||||||
* Created by yanzi on 9/18/15.
|
* Created by yanzi on 9/18/15.
|
||||||
* Updated on 01/25/17
|
* Updated on 01/25/17
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class Thread_TX_CNormal implements Runnable {
|
public class Thread_TX_CNormal implements Runnable {
|
||||||
private double sentBytes = 0.0;
|
private double sentBytes = 0.0;
|
||||||
private double duration = 0.0;
|
private double duration = 0.0;
|
||||||
|
|
|
||||||
|
|
@ -2,13 +2,21 @@ package edu.ucsb.cs.sandlab.offloadingdemo;
|
||||||
|
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
|
import java.io.BufferedReader;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by yanzi on 9/18/15.
|
* Created by yanzi on 9/18/15.
|
||||||
|
* Updated on 01/25/17
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class Thread_TX_CNormalUDP implements Runnable {
|
public class Thread_TX_CNormalUDP implements Runnable {
|
||||||
|
private double sentBytes = 0.0;
|
||||||
|
private double duration = 0.0;
|
||||||
|
private double throughput = 0.0;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (MainActivity.isRunning_TX_NormalUDP)
|
if (MainActivity.isRunning_TX_NormalUDP)
|
||||||
|
|
@ -18,48 +26,103 @@ public class Thread_TX_CNormalUDP implements Runnable {
|
||||||
MainActivity.isRunning_TX_NormalUDP = true;
|
MainActivity.isRunning_TX_NormalUDP = true;
|
||||||
Process proc;
|
Process proc;
|
||||||
String[] commd = new String[3];
|
String[] commd = new String[3];
|
||||||
|
|
||||||
|
// get the right command
|
||||||
commd[0] = "su";
|
commd[0] = "su";
|
||||||
commd[1] = "-c";
|
commd[1] = "-c";
|
||||||
|
// ./client_send_normaludp <bytes2send/file2send> <ip> <port>
|
||||||
|
// <[optional] bandwidth (bps)> <[optional] sendsize (bytes)>
|
||||||
commd[2] = (MainActivity.isForcingCPU0?"taskset 1 ":"")
|
commd[2] = (MainActivity.isForcingCPU0?"taskset 1 ":"")
|
||||||
+ MainActivity.binaryFolderPath + MainActivity.binary_TX_NormalUDP + " "
|
+ MainActivity.binaryFolderPath + MainActivity.binary_TX_NormalUDP + " "
|
||||||
+ MainActivity.bytes2send + " " + String.valueOf(MainActivity.currentBandwidth);
|
+ MainActivity.bytes2send + " "
|
||||||
|
+ (MainActivity.isLocal ? MainActivity.myInetIP : MainActivity.remoteIP) + " "
|
||||||
|
+ MainActivity.RXportNum + " "
|
||||||
|
+ ((MainActivity.currentBandwidth < 0) ? "" : String.valueOf(
|
||||||
|
MainActivity.currentBandwidth));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
// run process
|
||||||
proc = Runtime.getRuntime().exec(commd);
|
proc = Runtime.getRuntime().exec(commd);
|
||||||
|
|
||||||
|
// if config to log per process
|
||||||
while (MainActivity.isLoggingPerProcPID && MainActivity.perProcPID == -1) {
|
while (MainActivity.isLoggingPerProcPID && MainActivity.perProcPID == -1) {
|
||||||
// Log.d("Thread_TX_CNormalUDP", "per proc: " + MainActivity.perProcPID);
|
|
||||||
MainActivity.perProcPID = Utilities.getMyPID(MainActivity.binary_TX_NormalUDP, false);
|
MainActivity.perProcPID = Utilities.getMyPID(MainActivity.binary_TX_NormalUDP, false);
|
||||||
}
|
}
|
||||||
proc.waitFor();
|
proc.waitFor();
|
||||||
InputStream stdout = proc.getInputStream();
|
|
||||||
byte[] buffer = new byte[20];
|
|
||||||
int read;
|
// read error
|
||||||
StringBuilder out = new StringBuilder();
|
BufferedReader error_buf = new BufferedReader(new InputStreamReader(
|
||||||
while(true){
|
proc.getErrorStream()));
|
||||||
read = stdout.read(buffer);
|
final String error = error_buf.readLine(); // only one line error
|
||||||
if(read<0){
|
|
||||||
|
// read std out
|
||||||
|
BufferedReader stdout_buf = new BufferedReader(new InputStreamReader(
|
||||||
|
proc.getInputStream()));
|
||||||
|
String stdout;
|
||||||
|
|
||||||
|
// get sent bytes
|
||||||
|
stdout = stdout_buf.readLine();
|
||||||
|
if (stdout == null) {
|
||||||
|
// error happens
|
||||||
MainActivity.myHandler.post(new Runnable() {
|
MainActivity.myHandler.post(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
MainActivity.txt_results.append("Failed in TX_NormalUDP\n");
|
MainActivity.txt_results.append("Err in TX_NormalUDP: " + error + "\n");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
break;
|
} else {
|
||||||
}
|
// sent bytes
|
||||||
out.append(new String(buffer, 0, read));
|
sentBytes = Utilities.parseBinOutput(stdout);
|
||||||
if(read<20){
|
|
||||||
break;
|
// duration
|
||||||
}
|
stdout = stdout_buf.readLine();
|
||||||
}
|
duration = Utilities.parseBinOutput(stdout);
|
||||||
final String mOut = out.toString().trim();
|
MainActivity.reportedFinishTime = duration;
|
||||||
MainActivity.reportedFinishTime = Double.parseDouble(mOut);
|
|
||||||
if (MainActivity.isVerbose) {
|
if (MainActivity.isVerbose) {
|
||||||
MainActivity.myHandler.post(new Runnable() {
|
MainActivity.myHandler.post(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
MainActivity.txt_results.append("Time: " + mOut + "ms\n");
|
MainActivity.txt_results.append("Time: " + duration + "ms\n");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// throughput
|
||||||
|
stdout = stdout_buf.readLine();
|
||||||
|
throughput = Utilities.parseBinOutput(stdout);
|
||||||
|
}
|
||||||
|
//
|
||||||
|
// InputStream stdout = proc.getInputStream();
|
||||||
|
// byte[] buffer = new byte[20];
|
||||||
|
// int read;
|
||||||
|
// StringBuilder out = new StringBuilder();
|
||||||
|
// while(true){
|
||||||
|
// read = stdout.read(buffer);
|
||||||
|
// if(read<0){
|
||||||
|
// MainActivity.myHandler.post(new Runnable() {
|
||||||
|
// @Override
|
||||||
|
// public void run() {
|
||||||
|
// MainActivity.txt_results.append("Failed in TX_NormalUDP\n");
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
// out.append(new String(buffer, 0, read));
|
||||||
|
// if(read<20){
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// final String mOut = out.toString().trim();
|
||||||
|
// MainActivity.reportedFinishTime = Double.parseDouble(mOut);
|
||||||
|
// if (MainActivity.isVerbose) {
|
||||||
|
// MainActivity.myHandler.post(new Runnable() {
|
||||||
|
// @Override
|
||||||
|
// public void run() {
|
||||||
|
// MainActivity.txt_results.append("Time: " + mOut + "ms\n");
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
// }
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
|
|
|
||||||
|
|
@ -2,13 +2,20 @@ package edu.ucsb.cs.sandlab.offloadingdemo;
|
||||||
|
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
|
import java.io.BufferedReader;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by yanzi on 9/19/15.
|
* Created by yanzi on 9/19/15.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class Thread_TX_CRawNormal implements Runnable {
|
public class Thread_TX_CRawNormal implements Runnable {
|
||||||
|
private double sentBytes = 0.0;
|
||||||
|
private double duration = 0.0;
|
||||||
|
private double throughput = 0.0;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (MainActivity.isRunning_TX_RawNormal)
|
if (MainActivity.isRunning_TX_RawNormal)
|
||||||
|
|
@ -18,47 +25,101 @@ public class Thread_TX_CRawNormal implements Runnable {
|
||||||
MainActivity.isRunning_TX_RawNormal = true;
|
MainActivity.isRunning_TX_RawNormal = true;
|
||||||
Process proc;
|
Process proc;
|
||||||
String[] commd = new String[3];
|
String[] commd = new String[3];
|
||||||
|
|
||||||
|
// get the right command
|
||||||
commd[0] = "su";
|
commd[0] = "su";
|
||||||
commd[1] = "-c";
|
commd[1] = "-c";
|
||||||
|
// ./client_send_bypassl3 <bytes2send/file2send> <dest MAC address>
|
||||||
|
// <[optional] bandwidth (bps)> <[optional] sendsize (bytes)> <[optional] interface>
|
||||||
commd[2] = (MainActivity.isForcingCPU0?"taskset 1 ":"")
|
commd[2] = (MainActivity.isForcingCPU0?"taskset 1 ":"")
|
||||||
+ MainActivity.binaryFolderPath + MainActivity.binary_TX_RawNormal + " "
|
+ MainActivity.binaryFolderPath + MainActivity.binary_TX_RawNormal + " "
|
||||||
+ MainActivity.bytes2send + " " + String.valueOf(MainActivity.currentBandwidth);
|
+ MainActivity.bytes2send + " "
|
||||||
|
+ (MainActivity.isLocal ? MainActivity.myMAC : MainActivity.remoteMAC) + " "
|
||||||
|
+ ((MainActivity.currentBandwidth < 0) ? "" : String.valueOf(
|
||||||
|
MainActivity.currentBandwidth));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
// run process
|
||||||
proc = Runtime.getRuntime().exec(commd);
|
proc = Runtime.getRuntime().exec(commd);
|
||||||
|
|
||||||
|
// if config to log per process
|
||||||
while (MainActivity.isLoggingPerProcPID && MainActivity.perProcPID == -1) {
|
while (MainActivity.isLoggingPerProcPID && MainActivity.perProcPID == -1) {
|
||||||
MainActivity.perProcPID = Utilities.getMyPID(MainActivity.binary_TX_RawNormal, false);
|
MainActivity.perProcPID = Utilities.getMyPID(MainActivity.binary_TX_RawNormal, false);
|
||||||
}
|
}
|
||||||
proc.waitFor();
|
proc.waitFor();
|
||||||
InputStream stdout = proc.getInputStream();
|
|
||||||
byte[] buffer = new byte[20];
|
// read error
|
||||||
int read;
|
BufferedReader error_buf = new BufferedReader(new InputStreamReader(
|
||||||
StringBuilder out = new StringBuilder();
|
proc.getErrorStream()));
|
||||||
while(true){
|
final String error = error_buf.readLine(); // only one line error
|
||||||
read = stdout.read(buffer);
|
|
||||||
if(read<0){
|
// read std out
|
||||||
|
BufferedReader stdout_buf = new BufferedReader(new InputStreamReader(
|
||||||
|
proc.getInputStream()));
|
||||||
|
String stdout;
|
||||||
|
|
||||||
|
// get sent bytes
|
||||||
|
stdout = stdout_buf.readLine();
|
||||||
|
if (stdout == null) {
|
||||||
|
// error happens
|
||||||
MainActivity.myHandler.post(new Runnable() {
|
MainActivity.myHandler.post(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
MainActivity.txt_results.append("Failed in TX_RawNormal\n");
|
MainActivity.txt_results.append("Err in TX_RawNormal: " + error + "\n");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
break;
|
} else {
|
||||||
}
|
// sent bytes
|
||||||
out.append(new String(buffer, 0, read));
|
sentBytes = Utilities.parseBinOutput(stdout);
|
||||||
if(read<20){
|
|
||||||
break;
|
// duration
|
||||||
}
|
stdout = stdout_buf.readLine();
|
||||||
}
|
duration = Utilities.parseBinOutput(stdout);
|
||||||
final String mOut = out.toString().trim();
|
MainActivity.reportedFinishTime = duration;
|
||||||
MainActivity.reportedFinishTime = Double.parseDouble(mOut);
|
|
||||||
if (MainActivity.isVerbose) {
|
if (MainActivity.isVerbose) {
|
||||||
MainActivity.myHandler.post(new Runnable() {
|
MainActivity.myHandler.post(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
MainActivity.txt_results.append("Time: " + mOut + "ms\n");
|
MainActivity.txt_results.append("Time: " + duration + "ms\n");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// throughput
|
||||||
|
stdout = stdout_buf.readLine();
|
||||||
|
throughput = Utilities.parseBinOutput(stdout);
|
||||||
|
}
|
||||||
|
|
||||||
|
// InputStream stdout = proc.getInputStream();
|
||||||
|
// byte[] buffer = new byte[20];
|
||||||
|
// int read;
|
||||||
|
// StringBuilder out = new StringBuilder();
|
||||||
|
// while(true){
|
||||||
|
// read = stdout.read(buffer);
|
||||||
|
// if(read<0){
|
||||||
|
// MainActivity.myHandler.post(new Runnable() {
|
||||||
|
// @Override
|
||||||
|
// public void run() {
|
||||||
|
// MainActivity.txt_results.append("Failed in TX_RawNormal\n");
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
// out.append(new String(buffer, 0, read));
|
||||||
|
// if(read<20){
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// final String mOut = out.toString().trim();
|
||||||
|
// MainActivity.reportedFinishTime = Double.parseDouble(mOut);
|
||||||
|
// if (MainActivity.isVerbose) {
|
||||||
|
// MainActivity.myHandler.post(new Runnable() {
|
||||||
|
// @Override
|
||||||
|
// public void run() {
|
||||||
|
// MainActivity.txt_results.append("Time: " + mOut + "ms\n");
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
// }
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
|
|
|
||||||
|
|
@ -2,13 +2,21 @@ package edu.ucsb.cs.sandlab.offloadingdemo;
|
||||||
|
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
|
import java.io.BufferedReader;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by yanzi on 9/18/15.
|
* Created by yanzi on 9/18/15.
|
||||||
|
* Updated on 01/25/17
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class Thread_TX_CRawSplice implements Runnable {
|
public class Thread_TX_CRawSplice implements Runnable {
|
||||||
|
private double sentBytes = 0.0;
|
||||||
|
private double duration = 0.0;
|
||||||
|
private double throughput = 0.0;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (MainActivity.isRunning_TX_RawSplice)
|
if (MainActivity.isRunning_TX_RawSplice)
|
||||||
|
|
@ -18,47 +26,107 @@ public class Thread_TX_CRawSplice implements Runnable {
|
||||||
MainActivity.isRunning_TX_RawSplice = true;
|
MainActivity.isRunning_TX_RawSplice = true;
|
||||||
Process proc;
|
Process proc;
|
||||||
String[] commd = new String[3];
|
String[] commd = new String[3];
|
||||||
|
|
||||||
|
// get the right command
|
||||||
commd[0] = "su";
|
commd[0] = "su";
|
||||||
commd[1] = "-c";
|
commd[1] = "-c";
|
||||||
|
// ./client_send_bypassl3_splice <bytes2send/file2send> <ip> <port>
|
||||||
|
// <[optional] bandwidth (bps)> <[optional] sendsize (bytes)>
|
||||||
commd[2] = (MainActivity.isForcingCPU0?"taskset 1 ":"")
|
commd[2] = (MainActivity.isForcingCPU0?"taskset 1 ":"")
|
||||||
+ MainActivity.binaryFolderPath + MainActivity.binary_TX_RawSplice + " "
|
+ MainActivity.binaryFolderPath + MainActivity.binary_TX_RawSplice + " "
|
||||||
+ MainActivity.bytes2send + " " + String.valueOf(MainActivity.currentBandwidth);
|
+ MainActivity.bytes2send + " "
|
||||||
|
+ (MainActivity.isLocal ? MainActivity.myInetIP : MainActivity.remoteIP) + " "
|
||||||
|
+ MainActivity.RXportNum + " "
|
||||||
|
+ ((MainActivity.currentBandwidth < 0) ? "" : String.valueOf(
|
||||||
|
MainActivity.currentBandwidth));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
// run process
|
||||||
proc = Runtime.getRuntime().exec(commd);
|
proc = Runtime.getRuntime().exec(commd);
|
||||||
|
|
||||||
|
// if config to log per process
|
||||||
while (MainActivity.isLoggingPerProcPID && MainActivity.perProcPID == -1) {
|
while (MainActivity.isLoggingPerProcPID && MainActivity.perProcPID == -1) {
|
||||||
MainActivity.perProcPID = Utilities.getMyPID(MainActivity.binary_TX_RawSplice, false);
|
MainActivity.perProcPID = Utilities.getMyPID(MainActivity.binary_TX_RawSplice, false);
|
||||||
}
|
}
|
||||||
proc.waitFor();
|
proc.waitFor();
|
||||||
InputStream stdout = proc.getInputStream();
|
|
||||||
byte[] buffer = new byte[20];
|
// read error
|
||||||
int read;
|
BufferedReader error_buf = new BufferedReader(new InputStreamReader(
|
||||||
StringBuilder out = new StringBuilder();
|
proc.getErrorStream()));
|
||||||
while(true){
|
final String error = error_buf.readLine(); // only one line error
|
||||||
read = stdout.read(buffer);
|
|
||||||
if(read<0){
|
// read std out
|
||||||
|
BufferedReader stdout_buf = new BufferedReader(new InputStreamReader(
|
||||||
|
proc.getInputStream()));
|
||||||
|
String stdout;
|
||||||
|
|
||||||
|
// get sent bytes
|
||||||
|
stdout = stdout_buf.readLine();
|
||||||
|
if (stdout == null) {
|
||||||
|
// error happens
|
||||||
MainActivity.myHandler.post(new Runnable() {
|
MainActivity.myHandler.post(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
MainActivity.txt_results.append("Failed in TX_RawSplice\n");
|
MainActivity.txt_results.append("Err in TX_Raw_Splice: " + error + "\n");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
break;
|
} else {
|
||||||
}
|
// sent bytes
|
||||||
out.append(new String(buffer, 0, read));
|
sentBytes = Utilities.parseBinOutput(stdout);
|
||||||
if(read<20){
|
|
||||||
break;
|
// duration
|
||||||
}
|
stdout = stdout_buf.readLine();
|
||||||
}
|
duration = Utilities.parseBinOutput(stdout);
|
||||||
final String mOut = out.toString().trim();
|
MainActivity.reportedFinishTime = duration;
|
||||||
MainActivity.reportedFinishTime = Double.parseDouble(mOut);
|
|
||||||
if (MainActivity.isVerbose) {
|
if (MainActivity.isVerbose) {
|
||||||
MainActivity.myHandler.post(new Runnable() {
|
MainActivity.myHandler.post(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
MainActivity.txt_results.append("Time: " + mOut + "ms\n");
|
MainActivity.txt_results.append("Time: " + duration + "ms\n");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// throughput
|
||||||
|
stdout = stdout_buf.readLine();
|
||||||
|
throughput = Utilities.parseBinOutput(stdout);
|
||||||
|
}
|
||||||
|
|
||||||
|
// proc = Runtime.getRuntime().exec(commd);
|
||||||
|
// while (MainActivity.isLoggingPerProcPID && MainActivity.perProcPID == -1) {
|
||||||
|
// MainActivity.perProcPID = Utilities.getMyPID(MainActivity.binary_TX_RawSplice, false);
|
||||||
|
// }
|
||||||
|
// proc.waitFor();
|
||||||
|
// InputStream stdout = proc.getInputStream();
|
||||||
|
// byte[] buffer = new byte[20];
|
||||||
|
// int read;
|
||||||
|
// StringBuilder out = new StringBuilder();
|
||||||
|
// while(true){
|
||||||
|
// read = stdout.read(buffer);
|
||||||
|
// if(read<0){
|
||||||
|
// MainActivity.myHandler.post(new Runnable() {
|
||||||
|
// @Override
|
||||||
|
// public void run() {
|
||||||
|
// MainActivity.txt_results.append("Failed in TX_RawSplice\n");
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
// out.append(new String(buffer, 0, read));
|
||||||
|
// if(read<20){
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// final String mOut = out.toString().trim();
|
||||||
|
// MainActivity.reportedFinishTime = Double.parseDouble(mOut);
|
||||||
|
// if (MainActivity.isVerbose) {
|
||||||
|
// MainActivity.myHandler.post(new Runnable() {
|
||||||
|
// @Override
|
||||||
|
// public void run() {
|
||||||
|
// MainActivity.txt_results.append("Time: " + mOut + "ms\n");
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
// }
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
|
|
|
||||||
|
|
@ -2,13 +2,20 @@ package edu.ucsb.cs.sandlab.offloadingdemo;
|
||||||
|
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
|
import java.io.BufferedReader;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by yanzi on 9/19/15.
|
* Created by yanzi on 9/19/15.
|
||||||
|
* Updated on 01/25/17
|
||||||
*/
|
*/
|
||||||
public class Thread_TX_CSendfile implements Runnable {
|
public class Thread_TX_CSendfile implements Runnable {
|
||||||
|
private double sentBytes = 0.0;
|
||||||
|
private double duration = 0.0;
|
||||||
|
private double throughput = 0.0;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (MainActivity.isRunning_TX_Sendfile)
|
if (MainActivity.isRunning_TX_Sendfile)
|
||||||
|
|
@ -18,47 +25,114 @@ public class Thread_TX_CSendfile implements Runnable {
|
||||||
MainActivity.isRunning_TX_Sendfile = true;
|
MainActivity.isRunning_TX_Sendfile = true;
|
||||||
Process proc;
|
Process proc;
|
||||||
String[] commd = new String[3];
|
String[] commd = new String[3];
|
||||||
|
|
||||||
|
// get the right command
|
||||||
commd[0] = "su";
|
commd[0] = "su";
|
||||||
commd[1] = "-c";
|
commd[1] = "-c";
|
||||||
|
// ./client_send_normaltcp_sendfile <bytes2send/file2send> <ip> <port>
|
||||||
|
// <[optional] bandwidth (bps)> <[optional] sendsize (bytes)>
|
||||||
commd[2] = (MainActivity.isForcingCPU0?"taskset 1 ":"")
|
commd[2] = (MainActivity.isForcingCPU0?"taskset 1 ":"")
|
||||||
+ MainActivity.binaryFolderPath + MainActivity.binary_TX_Sendfile + " "
|
+ MainActivity.binaryFolderPath + MainActivity.binary_TX_Sendfile + " "
|
||||||
+ MainActivity.bytes2send + " " + String.valueOf(MainActivity.currentBandwidth);
|
+ MainActivity.bytes2send + " "
|
||||||
|
+ (MainActivity.isLocal ? MainActivity.myInetIP : MainActivity.remoteIP) + " "
|
||||||
|
+ MainActivity.RXportNum + " "
|
||||||
|
+ ((MainActivity.currentBandwidth < 0) ? "" : String.valueOf(
|
||||||
|
MainActivity.currentBandwidth));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
// run process
|
||||||
proc = Runtime.getRuntime().exec(commd);
|
proc = Runtime.getRuntime().exec(commd);
|
||||||
|
|
||||||
|
// if config to log per process
|
||||||
while (MainActivity.isLoggingPerProcPID && MainActivity.perProcPID == -1) {
|
while (MainActivity.isLoggingPerProcPID && MainActivity.perProcPID == -1) {
|
||||||
MainActivity.perProcPID = Utilities.getMyPID(MainActivity.binary_TX_Sendfile, false);
|
MainActivity.perProcPID = Utilities.getMyPID(
|
||||||
|
MainActivity.binary_TX_Sendfile, false);
|
||||||
}
|
}
|
||||||
proc.waitFor();
|
proc.waitFor();
|
||||||
InputStream stdout = proc.getInputStream();
|
|
||||||
byte[] buffer = new byte[20];
|
// read error
|
||||||
int read;
|
BufferedReader error_buf = new BufferedReader(new InputStreamReader(
|
||||||
StringBuilder out = new StringBuilder();
|
proc.getErrorStream()));
|
||||||
while(true){
|
final String error = error_buf.readLine(); // only one line error
|
||||||
read = stdout.read(buffer);
|
|
||||||
if(read<0){
|
// read std out
|
||||||
|
BufferedReader stdout_buf = new BufferedReader(new InputStreamReader(
|
||||||
|
proc.getInputStream()));
|
||||||
|
String stdout;
|
||||||
|
|
||||||
|
// get sent bytes
|
||||||
|
stdout = stdout_buf.readLine();
|
||||||
|
if (stdout == null) {
|
||||||
|
// error happens
|
||||||
MainActivity.myHandler.post(new Runnable() {
|
MainActivity.myHandler.post(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
MainActivity.txt_results.append("Failed in TX_Sendfile\n");
|
MainActivity.txt_results.append("Err in TX_Normal_Splice: " + error + "\n");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
break;
|
} else {
|
||||||
}
|
// sent bytes
|
||||||
out.append(new String(buffer, 0, read));
|
sentBytes = Utilities.parseBinOutput(stdout);
|
||||||
if(read<20){
|
|
||||||
break;
|
// duration
|
||||||
}
|
stdout = stdout_buf.readLine();
|
||||||
}
|
duration = Utilities.parseBinOutput(stdout);
|
||||||
final String mOut = out.toString().trim();
|
MainActivity.reportedFinishTime = duration;
|
||||||
MainActivity.reportedFinishTime = Double.parseDouble(mOut);
|
|
||||||
if (MainActivity.isVerbose) {
|
if (MainActivity.isVerbose) {
|
||||||
MainActivity.myHandler.post(new Runnable() {
|
MainActivity.myHandler.post(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
MainActivity.txt_results.append("Time: " + mOut + "ms\n");
|
MainActivity.txt_results.append("Time: " + duration + "ms\n");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// throughput
|
||||||
|
stdout = stdout_buf.readLine();
|
||||||
|
throughput = Utilities.parseBinOutput(stdout);
|
||||||
|
}
|
||||||
|
|
||||||
|
// commd[0] = "su";
|
||||||
|
// commd[1] = "-c";
|
||||||
|
// commd[2] = (MainActivity.isForcingCPU0?"taskset 1 ":"")
|
||||||
|
// + MainActivity.binaryFolderPath + MainActivity.binary_TX_Sendfile + " "
|
||||||
|
// + MainActivity.bytes2send + " " + String.valueOf(MainActivity.currentBandwidth);
|
||||||
|
// try {
|
||||||
|
// proc = Runtime.getRuntime().exec(commd);
|
||||||
|
// while (MainActivity.isLoggingPerProcPID && MainActivity.perProcPID == -1) {
|
||||||
|
// MainActivity.perProcPID = Utilities.getMyPID(MainActivity.binary_TX_Sendfile, false);
|
||||||
|
// }
|
||||||
|
// proc.waitFor();
|
||||||
|
// InputStream stdout = proc.getInputStream();
|
||||||
|
// byte[] buffer = new byte[20];
|
||||||
|
// int read;
|
||||||
|
// StringBuilder out = new StringBuilder();
|
||||||
|
// while(true){
|
||||||
|
// read = stdout.read(buffer);
|
||||||
|
// if(read<0){
|
||||||
|
// MainActivity.myHandler.post(new Runnable() {
|
||||||
|
// @Override
|
||||||
|
// public void run() {
|
||||||
|
// MainActivity.txt_results.append("Failed in TX_Sendfile\n");
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
// out.append(new String(buffer, 0, read));
|
||||||
|
// if(read<20){
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// final String mOut = out.toString().trim();
|
||||||
|
// MainActivity.reportedFinishTime = Double.parseDouble(mOut);
|
||||||
|
// if (MainActivity.isVerbose) {
|
||||||
|
// MainActivity.myHandler.post(new Runnable() {
|
||||||
|
// @Override
|
||||||
|
// public void run() {
|
||||||
|
// MainActivity.txt_results.append("Time: " + mOut + "ms\n");
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
// }
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
|
|
|
||||||
|
|
@ -2,13 +2,20 @@ package edu.ucsb.cs.sandlab.offloadingdemo;
|
||||||
|
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
|
import java.io.BufferedReader;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by yanzi on 9/18/15.
|
* Created by yanzi on 9/18/15.
|
||||||
|
* Updated on 01/25/17
|
||||||
*/
|
*/
|
||||||
public class Thread_TX_CSplice implements Runnable {
|
public class Thread_TX_CSplice implements Runnable {
|
||||||
|
private double sentBytes = 0.0;
|
||||||
|
private double duration = 0.0;
|
||||||
|
private double throughput = 0.0;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (MainActivity.isRunning_TX_Splice)
|
if (MainActivity.isRunning_TX_Splice)
|
||||||
|
|
@ -18,47 +25,113 @@ public class Thread_TX_CSplice implements Runnable {
|
||||||
MainActivity.isRunning_TX_Splice = true;
|
MainActivity.isRunning_TX_Splice = true;
|
||||||
Process proc;
|
Process proc;
|
||||||
String[] commd = new String[3];
|
String[] commd = new String[3];
|
||||||
|
|
||||||
|
// get the right command
|
||||||
commd[0] = "su";
|
commd[0] = "su";
|
||||||
commd[1] = "-c";
|
commd[1] = "-c";
|
||||||
|
// ./client_send_normaltcp_splice <bytes2send/file2send> <ip> <port>
|
||||||
|
// <[optional] bandwidth (bps)> <[optional] sendsize (bytes)>
|
||||||
commd[2] = (MainActivity.isForcingCPU0?"taskset 1 ":"")
|
commd[2] = (MainActivity.isForcingCPU0?"taskset 1 ":"")
|
||||||
+ MainActivity.binaryFolderPath + MainActivity.binary_TX_Splice + " "
|
+ MainActivity.binaryFolderPath + MainActivity.binary_TX_Splice + " "
|
||||||
+ MainActivity.bytes2send + " " + String.valueOf(MainActivity.currentBandwidth);
|
+ MainActivity.bytes2send + " "
|
||||||
|
+ (MainActivity.isLocal ? MainActivity.myInetIP : MainActivity.remoteIP) + " "
|
||||||
|
+ MainActivity.RXportNum + " "
|
||||||
|
+ ((MainActivity.currentBandwidth < 0) ? "" : String.valueOf(
|
||||||
|
MainActivity.currentBandwidth));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
// run process
|
||||||
proc = Runtime.getRuntime().exec(commd);
|
proc = Runtime.getRuntime().exec(commd);
|
||||||
|
|
||||||
|
// if config to log per process
|
||||||
while (MainActivity.isLoggingPerProcPID && MainActivity.perProcPID == -1) {
|
while (MainActivity.isLoggingPerProcPID && MainActivity.perProcPID == -1) {
|
||||||
MainActivity.perProcPID = Utilities.getMyPID(MainActivity.binary_TX_Splice, false);
|
MainActivity.perProcPID = Utilities.getMyPID(MainActivity.binary_TX_Splice, false);
|
||||||
}
|
}
|
||||||
proc.waitFor();
|
proc.waitFor();
|
||||||
InputStream stdout = proc.getInputStream();
|
|
||||||
byte[] buffer = new byte[20];
|
// read error
|
||||||
int read;
|
BufferedReader error_buf = new BufferedReader(new InputStreamReader(
|
||||||
StringBuilder out = new StringBuilder();
|
proc.getErrorStream()));
|
||||||
while(true){
|
final String error = error_buf.readLine(); // only one line error
|
||||||
read = stdout.read(buffer);
|
|
||||||
if(read<0){
|
// read std out
|
||||||
|
BufferedReader stdout_buf = new BufferedReader(new InputStreamReader(
|
||||||
|
proc.getInputStream()));
|
||||||
|
String stdout;
|
||||||
|
|
||||||
|
// get sent bytes
|
||||||
|
stdout = stdout_buf.readLine();
|
||||||
|
if (stdout == null) {
|
||||||
|
// error happens
|
||||||
MainActivity.myHandler.post(new Runnable() {
|
MainActivity.myHandler.post(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
MainActivity.txt_results.append("Failed in TX_Splice\n");
|
MainActivity.txt_results.append("Err in TX_Normal_Splice: " + error + "\n");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
break;
|
} else {
|
||||||
}
|
// sent bytes
|
||||||
out.append(new String(buffer, 0, read));
|
sentBytes = Utilities.parseBinOutput(stdout);
|
||||||
if(read<20){
|
|
||||||
break;
|
// duration
|
||||||
}
|
stdout = stdout_buf.readLine();
|
||||||
}
|
duration = Utilities.parseBinOutput(stdout);
|
||||||
final String mOut = out.toString().trim();
|
MainActivity.reportedFinishTime = duration;
|
||||||
MainActivity.reportedFinishTime = Double.parseDouble(mOut);
|
|
||||||
if (MainActivity.isVerbose) {
|
if (MainActivity.isVerbose) {
|
||||||
MainActivity.myHandler.post(new Runnable() {
|
MainActivity.myHandler.post(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
MainActivity.txt_results.append("Time: " + mOut + "ms\n");
|
MainActivity.txt_results.append("Time: " + duration + "ms\n");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// throughput
|
||||||
|
stdout = stdout_buf.readLine();
|
||||||
|
throughput = Utilities.parseBinOutput(stdout);
|
||||||
|
}
|
||||||
|
|
||||||
|
// commd[0] = "su";
|
||||||
|
// commd[1] = "-c";
|
||||||
|
// commd[2] = (MainActivity.isForcingCPU0?"taskset 1 ":"")
|
||||||
|
// + MainActivity.binaryFolderPath + MainActivity.binary_TX_Splice + " "
|
||||||
|
// + MainActivity.bytes2send + " " + String.valueOf(MainActivity.currentBandwidth);
|
||||||
|
// try {
|
||||||
|
// proc = Runtime.getRuntime().exec(commd);
|
||||||
|
// while (MainActivity.isLoggingPerProcPID && MainActivity.perProcPID == -1) {
|
||||||
|
// MainActivity.perProcPID = Utilities.getMyPID(MainActivity.binary_TX_Splice, false);
|
||||||
|
// }
|
||||||
|
// proc.waitFor();
|
||||||
|
// InputStream stdout = proc.getInputStream();
|
||||||
|
// byte[] buffer = new byte[20];
|
||||||
|
// int read;
|
||||||
|
// StringBuilder out = new StringBuilder();
|
||||||
|
// while(true){
|
||||||
|
// read = stdout.read(buffer);
|
||||||
|
// if(read<0){
|
||||||
|
// MainActivity.myHandler.post(new Runnable() {
|
||||||
|
// @Override
|
||||||
|
// public void run() {
|
||||||
|
// MainActivity.txt_results.append("Failed in TX_Splice\n");
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
// out.append(new String(buffer, 0, read));
|
||||||
|
// if(read<20){
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// final String mOut = out.toString().trim();
|
||||||
|
// MainActivity.reportedFinishTime = Double.parseDouble(mOut);
|
||||||
|
// if (MainActivity.isVerbose) {
|
||||||
|
// MainActivity.myHandler.post(new Runnable() {
|
||||||
|
// @Override
|
||||||
|
// public void run() {
|
||||||
|
// MainActivity.txt_results.append("Time: " + mOut + "ms\n");
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
// }
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
|
|
|
||||||
|
|
@ -16,11 +16,13 @@ import java.io.InputStream;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
import java.net.NetworkInterface;
|
import java.net.NetworkInterface;
|
||||||
|
import java.net.SocketException;
|
||||||
import java.net.UnknownHostException;
|
import java.net.UnknownHostException;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.Enumeration;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -36,10 +38,9 @@ public class Utilities {
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Android 6.0 + required
|
||||||
* Checks if the app has permission to write to device storage
|
* Checks if the app has permission to write to device storage
|
||||||
*
|
|
||||||
* If the app does not has permission then the user will be prompted to grant permissions
|
* If the app does not has permission then the user will be prompted to grant permissions
|
||||||
*
|
|
||||||
* @param activity
|
* @param activity
|
||||||
*/
|
*/
|
||||||
public static void verifyStoragePermissions(Activity activity) {
|
public static void verifyStoragePermissions(Activity activity) {
|
||||||
|
|
@ -47,8 +48,8 @@ public class Utilities {
|
||||||
int permission = ActivityCompat.checkSelfPermission(
|
int permission = ActivityCompat.checkSelfPermission(
|
||||||
activity, Manifest.permission.WRITE_EXTERNAL_STORAGE);
|
activity, Manifest.permission.WRITE_EXTERNAL_STORAGE);
|
||||||
|
|
||||||
if (permission != PackageManager.PERMISSION_GRANTED) {
|
|
||||||
// We don't have permission so prompt the user
|
// We don't have permission so prompt the user
|
||||||
|
if (permission != PackageManager.PERMISSION_GRANTED) {
|
||||||
ActivityCompat.requestPermissions(
|
ActivityCompat.requestPermissions(
|
||||||
activity,
|
activity,
|
||||||
PERMISSIONS_STORAGE,
|
PERMISSIONS_STORAGE,
|
||||||
|
|
@ -71,35 +72,58 @@ public class Utilities {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get the ip address
|
* get the ip and mac addresses
|
||||||
* @return str
|
|
||||||
*/
|
*/
|
||||||
protected static String getInetIP(boolean useIPv4) {
|
protected static void getSelfIdentity(String interface_name, boolean useIPv4) {
|
||||||
try {
|
try {
|
||||||
List<NetworkInterface> interfaces = Collections.list(
|
Enumeration<NetworkInterface> networks =
|
||||||
NetworkInterface.getNetworkInterfaces());
|
NetworkInterface.getNetworkInterfaces();
|
||||||
for (NetworkInterface intf : interfaces) {
|
|
||||||
List<InetAddress> addrs = Collections.list(intf.getInetAddresses());
|
|
||||||
for (InetAddress addr : addrs) {
|
|
||||||
if (!addr.isLoopbackAddress()) {
|
|
||||||
String sAddr = addr.getHostAddress();
|
|
||||||
//boolean isIPv4 = InetAddressUtils.isIPv4Address(sAddr);
|
|
||||||
boolean isIPv4 = sAddr.indexOf(':')<0;
|
|
||||||
|
|
||||||
|
while (networks.hasMoreElements()) {
|
||||||
|
NetworkInterface network = networks.nextElement();
|
||||||
|
|
||||||
|
// check if the interface matches the desired one
|
||||||
|
String name = network.getDisplayName();
|
||||||
|
if (!name.equals(interface_name))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
// get the ip address
|
||||||
|
Enumeration<InetAddress> inetAddresses = network.getInetAddresses();
|
||||||
|
while (inetAddresses.hasMoreElements()) {
|
||||||
|
InetAddress inetAddress = inetAddresses.nextElement();
|
||||||
|
if (!inetAddress.isLoopbackAddress()) {
|
||||||
|
String sAddr = inetAddress.getHostAddress();
|
||||||
|
boolean isIPv4 = sAddr.indexOf(':') < 0;
|
||||||
|
// check if we only want ipv4
|
||||||
if (useIPv4) {
|
if (useIPv4) {
|
||||||
if (isIPv4)
|
if (isIPv4)
|
||||||
return sAddr;
|
MainActivity.myInetIP = sAddr;
|
||||||
} else {
|
} else {
|
||||||
if (!isIPv4) {
|
if (!isIPv4) {
|
||||||
int delim = sAddr.indexOf('%'); // drop ip6 zone suffix
|
int delim = sAddr.indexOf('%'); // drop ip6 zone suffix
|
||||||
return delim<0 ? sAddr.toUpperCase() : sAddr.substring(0, delim).toUpperCase();
|
MainActivity.myInetIP =
|
||||||
|
(delim < 0) ? sAddr.toUpperCase() : sAddr.substring(
|
||||||
|
0, delim).toUpperCase();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// get the mac address
|
||||||
|
byte[] mac = network.getHardwareAddress();
|
||||||
|
|
||||||
|
if (mac != null) {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
for (int i = 0; i < mac.length; i++) {
|
||||||
|
sb.append(String.format("%02X%s", mac[i],
|
||||||
|
(i < mac.length - 1) ? ":" : ""));
|
||||||
|
}
|
||||||
|
MainActivity.myMAC = sb.toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (SocketException e) {
|
||||||
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
} catch (Exception ex) { } // for now eat exceptions
|
|
||||||
return "";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -332,21 +356,20 @@ public class Utilities {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Translate the selection index into throughput setup
|
||||||
|
* @param myI
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
protected static int findCorrespondingThrpt(int myI) {
|
protected static int findCorrespondingThrpt(int myI) {
|
||||||
if (myI == 0) {
|
if (myI < 19) {
|
||||||
return 8 * 50000;
|
return (800 - (myI * 40)) * 1000000;
|
||||||
} else if (myI == 1) {
|
} else if (myI < 37) {
|
||||||
return 8 * 100000;
|
return (76 - ((myI - 19) * 4)) * 1000000;
|
||||||
} else if (myI < 6) {
|
} else if (myI < 43) {
|
||||||
return 8 * 250000 * (myI - 1);
|
return (6 - ((myI - 37))) * 1000000;
|
||||||
} else if (myI < 24) {
|
} else if (myI < 47) {
|
||||||
return 8 * (1500000 + 500000 * (myI - 6));
|
return (800 - ((myI - 43) * 200)) * 1000;
|
||||||
} else if (myI > 24 && myI < 43) {
|
|
||||||
return 8 * (15000000 + 5000000 * (myI - 25));
|
|
||||||
} else if (myI == 43) {
|
|
||||||
return 8 * 11000000;
|
|
||||||
} else if (myI == 44){
|
|
||||||
return 8 * 13000000;
|
|
||||||
} else { // default unlimited
|
} else { // default unlimited
|
||||||
if (MainActivity.isLocal)
|
if (MainActivity.isLocal)
|
||||||
return 8 * 100000000; // for loopback, the unlimited shouldn't be really unlimited..
|
return 8 * 100000000; // for loopback, the unlimited shouldn't be really unlimited..
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue