fixed rx end for new binaries
This commit is contained in:
parent
99d73ad3ea
commit
62b08e13c2
|
|
@ -30,7 +30,7 @@ import java.util.Date;
|
|||
import java.util.Locale;
|
||||
|
||||
public class MainActivity extends Activity {
|
||||
// unchanged stuff
|
||||
// tmp fixed
|
||||
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"
|
||||
|
|
@ -38,6 +38,7 @@ public class MainActivity extends Activity {
|
|||
protected static final String sshlinklablocal = "ssh linklab@" + remoteIP
|
||||
+ " -i /data/.ssh/id_rsa -o StrictHostKeyChecking=no";
|
||||
protected static final String udpserver_pathport = "~/mobileRDMABeach/UDPServer 32000 ";
|
||||
// unchanged stuff
|
||||
protected static final String binaryFolderPath = "/data/local/tmp/";
|
||||
protected static final String binary_tcpdump = "tcpdump";
|
||||
private static final String TAG = "MainActivity";
|
||||
|
|
@ -135,9 +136,7 @@ public class MainActivity extends Activity {
|
|||
Runtime.getRuntime().exec("su -c killall -9 " + binary_RX_NormalUDP).waitFor();
|
||||
Runtime.getRuntime().exec("su -c killall -9 " + binary_RX_Splice).waitFor();
|
||||
Runtime.getRuntime().exec("su -c killall -9 " + binary_RX_RawNormal).waitFor();
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
} catch (InterruptedException | IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
|
@ -196,7 +195,7 @@ public class MainActivity extends Activity {
|
|||
|
||||
/**
|
||||
* start the record
|
||||
* @param myflag
|
||||
* @param myflag:
|
||||
*/
|
||||
protected void startRecording(boolean myflag) {
|
||||
final boolean flagRecv = myflag;
|
||||
|
|
@ -275,9 +274,7 @@ public class MainActivity extends Activity {
|
|||
Runtime.getRuntime().exec(
|
||||
"su -c echo 0 > /sys/class/lcd/panel/lcd_power")
|
||||
.waitFor();
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
} catch (InterruptedException | IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
myHandler.post(new Runnable() {
|
||||
|
|
@ -311,9 +308,7 @@ public class MainActivity extends Activity {
|
|||
// }
|
||||
// });
|
||||
// }
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
} catch (InterruptedException | IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
// start iteration
|
||||
|
|
|
|||
|
|
@ -2,71 +2,105 @@ package edu.ucsb.cs.sandlab.offloadingdemo;
|
|||
|
||||
import android.util.Log;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
|
||||
/**
|
||||
* Created by yanzi on 9/18/15.
|
||||
* Updated on 01/31/17
|
||||
*/
|
||||
public class Thread_RX_CNormal implements Runnable {
|
||||
|
||||
class Thread_RX_CNormal implements Runnable {
|
||||
private double recvBytes = 0.0;
|
||||
private double duration = 0.0;
|
||||
private double throughput = 0.0;
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
// prevent multiple runs
|
||||
if (MainActivity.isRunning_RX_Normal)
|
||||
return;
|
||||
if (MainActivity.isVerbose)
|
||||
Log.d("RX_Normal", "Start RX Normal");
|
||||
MainActivity.isRunning_RX_Normal = true;
|
||||
|
||||
// variables
|
||||
Process proc;
|
||||
String stdout;
|
||||
BufferedReader stdout_buf, error_buf;
|
||||
String[] commd = new String[3];
|
||||
|
||||
// get the right command
|
||||
commd[0] = "su";
|
||||
commd[1] = "-c";
|
||||
// ./client_recv_normaltcp <ip> <port>
|
||||
// <[optional] recvsize (bytes)> <[optional] filepath>
|
||||
commd[2] = (MainActivity.isForcingCPU0?"taskset 1 ":"")
|
||||
+ MainActivity.binaryFolderPath + MainActivity.binary_RX_Normal + " "
|
||||
+ MainActivity.bytes2send + " " + MainActivity.RXportNum;
|
||||
+ MainActivity.binaryFolderPath + MainActivity.binary_RX_Normal
|
||||
+ " " + (MainActivity.isLocal ? Utilities.myInetIP : MainActivity.remoteIP)
|
||||
+ " " + MainActivity.RXportNum
|
||||
+ " " + MainActivity.bytes2send;
|
||||
|
||||
Log.d("RX_Normal", "Start RX Normal");
|
||||
|
||||
try {
|
||||
// run process
|
||||
proc = Runtime.getRuntime().exec(commd);
|
||||
|
||||
// if config to log per process
|
||||
while (MainActivity.isLoggingPerProcPID && MainActivity.perProcPID == -1) {
|
||||
MainActivity.perProcPID = Utilities.getMyPID(MainActivity.binary_RX_Normal, false);
|
||||
MainActivity.perProcPID = Utilities.getMyPID(MainActivity.binary_RX_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){
|
||||
|
||||
// read error
|
||||
error_buf = new BufferedReader(new InputStreamReader(
|
||||
proc.getErrorStream()));
|
||||
final String error = error_buf.readLine(); // only one line error
|
||||
|
||||
// read std out
|
||||
stdout_buf = new BufferedReader(new InputStreamReader(
|
||||
proc.getInputStream()));
|
||||
|
||||
// get received bytes
|
||||
stdout = stdout_buf.readLine();
|
||||
if (stdout == null) {
|
||||
// error happens
|
||||
MainActivity.myHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
MainActivity.txt_results.append("Failed in RX_Normal at port " + MainActivity.RXportNum + "\n");
|
||||
MainActivity.txt_results.append("Err in RX_Normal: " + error + "\n");
|
||||
}
|
||||
});
|
||||
break;
|
||||
}
|
||||
out.append(new String(buffer, 0, read));
|
||||
if(read<20){
|
||||
break;
|
||||
}
|
||||
}
|
||||
final String mOut = out.toString().trim();
|
||||
MainActivity.reportedFinishTime = Double.parseDouble(mOut);
|
||||
} else {
|
||||
// sent bytes
|
||||
recvBytes = Utilities.parseBinOutput(stdout);
|
||||
|
||||
// duration
|
||||
stdout = stdout_buf.readLine();
|
||||
duration = Utilities.parseBinOutput(stdout);
|
||||
MainActivity.reportedFinishTime = duration;
|
||||
if (MainActivity.isVerbose) {
|
||||
Log.d("Thread_RX_CNormal", mOut + "ms");
|
||||
MainActivity.myHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
MainActivity.txt_results.append("Time: " + mOut + "ms\n");
|
||||
MainActivity.txt_results.append("Time: " + duration + "ms\n");
|
||||
}
|
||||
});
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} catch (InterruptedException e) {
|
||||
|
||||
// throughput
|
||||
stdout = stdout_buf.readLine();
|
||||
throughput = Utilities.parseBinOutput(stdout);
|
||||
}
|
||||
|
||||
} catch (IOException | InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (MainActivity.isVerbose)
|
||||
|
||||
Log.d("RX_Normal", "Stop RX Normal");
|
||||
|
||||
MainActivity.isRunning_RX_Normal = false;
|
||||
MainActivity.perProcPID = -1;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,74 +2,105 @@ package edu.ucsb.cs.sandlab.offloadingdemo;
|
|||
|
||||
import android.util.Log;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
|
||||
/**
|
||||
* Created by yanzi on 9/18/15.
|
||||
* Updated on 01/31/17
|
||||
*/
|
||||
public class Thread_RX_CNormalUDP implements Runnable {
|
||||
|
||||
class Thread_RX_CNormalUDP implements Runnable {
|
||||
private double recvBytes = 0.0;
|
||||
private double duration = 0.0;
|
||||
private double throughput = 0.0;
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
// prevent multiple runs
|
||||
if (MainActivity.isRunning_RX_NormalUDP)
|
||||
return;
|
||||
if (MainActivity.isVerbose)
|
||||
Log.d("RX_NormalUDP", "Start RX NormalUDP");
|
||||
MainActivity.isRunning_RX_NormalUDP = true;
|
||||
|
||||
// variables
|
||||
Process proc;
|
||||
String stdout;
|
||||
BufferedReader stdout_buf, error_buf;
|
||||
String[] commd = new String[3];
|
||||
|
||||
// get the right command
|
||||
commd[0] = "su";
|
||||
commd[1] = "-c";
|
||||
// ./client_recv_normaludp <ip> <port>
|
||||
// <[optional] recvsize (bytes)> <[optional] filepath>
|
||||
commd[2] = (MainActivity.isForcingCPU0?"taskset 1 ":"")
|
||||
+ MainActivity.binaryFolderPath + MainActivity.binary_RX_NormalUDP + " "
|
||||
+ MainActivity.bytes2send + " 32000";
|
||||
+ MainActivity.binaryFolderPath + MainActivity.binary_RX_Normal
|
||||
+ " " + (MainActivity.isLocal ? Utilities.myInetIP : MainActivity.remoteIP)
|
||||
+ " " + MainActivity.RXportNum
|
||||
+ " " + MainActivity.bytes2send;
|
||||
|
||||
Log.d("RX_NormalUDP", "Start RX NormalUDP");
|
||||
|
||||
try {
|
||||
// run process
|
||||
proc = Runtime.getRuntime().exec(commd);
|
||||
|
||||
// if config to log per process
|
||||
while (MainActivity.isLoggingPerProcPID && MainActivity.perProcPID == -1) {
|
||||
MainActivity.perProcPID = Utilities.getMyPID(MainActivity.binary_RX_NormalUDP, false);
|
||||
MainActivity.perProcPID = Utilities.getMyPID(MainActivity.binary_RX_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){
|
||||
|
||||
// read error
|
||||
error_buf = new BufferedReader(new InputStreamReader(
|
||||
proc.getErrorStream()));
|
||||
final String error = error_buf.readLine(); // only one line error
|
||||
|
||||
// read std out
|
||||
stdout_buf = new BufferedReader(new InputStreamReader(
|
||||
proc.getInputStream()));
|
||||
|
||||
// get received bytes
|
||||
stdout = stdout_buf.readLine();
|
||||
if (stdout == null) {
|
||||
// error happens
|
||||
MainActivity.myHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
MainActivity.txt_results.append("Failed in RX_NormalUDP at port 32000\n");
|
||||
MainActivity.txt_results.append("Err in RX_NormalUDP: " + error + "\n");
|
||||
}
|
||||
});
|
||||
break;
|
||||
}
|
||||
out.append(new String(buffer, 0, read));
|
||||
if(read<20){
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (out.length() > 0) {
|
||||
MainActivity.UDPfinishTime = (int)Float.parseFloat(out.toString().trim());
|
||||
}
|
||||
final String mOut = out.toString().trim();
|
||||
MainActivity.reportedFinishTime = Double.parseDouble(mOut);
|
||||
} else {
|
||||
// sent bytes
|
||||
recvBytes = Utilities.parseBinOutput(stdout);
|
||||
|
||||
// duration
|
||||
stdout = stdout_buf.readLine();
|
||||
duration = Utilities.parseBinOutput(stdout);
|
||||
MainActivity.reportedFinishTime = duration;
|
||||
if (MainActivity.isVerbose) {
|
||||
Log.d("Thread_RX_CNormalUDP", mOut + "ms");
|
||||
MainActivity.myHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
MainActivity.txt_results.append("Time: " + mOut + "ms\n");
|
||||
MainActivity.txt_results.append("Time: " + duration + "ms\n");
|
||||
}
|
||||
});
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} catch (InterruptedException e) {
|
||||
|
||||
// throughput
|
||||
stdout = stdout_buf.readLine();
|
||||
throughput = Utilities.parseBinOutput(stdout);
|
||||
}
|
||||
|
||||
} catch (IOException | InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (MainActivity.isVerbose)
|
||||
|
||||
Log.d("RX_NormalUDP", "Stop RX NormalUDP");
|
||||
|
||||
MainActivity.isRunning_RX_NormalUDP = false;
|
||||
MainActivity.perProcPID = -1;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,74 +2,105 @@ package edu.ucsb.cs.sandlab.offloadingdemo;
|
|||
|
||||
import android.util.Log;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
|
||||
/**
|
||||
* Created by yanzi on 9/18/15.
|
||||
* Updated on 01/31/17
|
||||
*/
|
||||
public class Thread_RX_CRawNormal implements Runnable {
|
||||
|
||||
class Thread_RX_CRawNormal implements Runnable {
|
||||
private double recvBytes = 0.0;
|
||||
private double duration = 0.0;
|
||||
private double throughput = 0.0;
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
// prevent multiple runs
|
||||
if (MainActivity.isRunning_RX_RawNormal)
|
||||
return;
|
||||
if (MainActivity.isVerbose)
|
||||
Log.d("RX_RawNormal", "Start RX RawNormal");
|
||||
MainActivity.isRunning_RX_RawNormal = true;
|
||||
|
||||
// variables
|
||||
Process proc;
|
||||
String stdout;
|
||||
BufferedReader stdout_buf, error_buf;
|
||||
String[] commd = new String[3];
|
||||
|
||||
// get the right command
|
||||
commd[0] = "su";
|
||||
commd[1] = "-c";
|
||||
// ./client_recv_bypassl3 <ip> <port>
|
||||
// <[optional] recvsize (bytes)> <[optional] interface> <[optional] filepath>
|
||||
commd[2] = (MainActivity.isForcingCPU0?"taskset 1 ":"")
|
||||
+ MainActivity.binaryFolderPath + MainActivity.binary_RX_RawNormal + " "
|
||||
+ MainActivity.bytes2send;
|
||||
+ MainActivity.binaryFolderPath + MainActivity.binary_RX_RawNormal
|
||||
+ " " + (MainActivity.isLocal ? Utilities.myInetIP : MainActivity.remoteIP)
|
||||
+ " " + MainActivity.RXportNum
|
||||
+ " " + MainActivity.bytes2send;
|
||||
|
||||
Log.d("RX_RawNormal", "Start RX RawNormal");
|
||||
|
||||
try {
|
||||
// run process
|
||||
proc = Runtime.getRuntime().exec(commd);
|
||||
|
||||
// if config to log per process
|
||||
while (MainActivity.isLoggingPerProcPID && MainActivity.perProcPID == -1) {
|
||||
MainActivity.perProcPID = Utilities.getMyPID(MainActivity.binary_RX_RawNormal, false);
|
||||
MainActivity.perProcPID = Utilities.getMyPID(MainActivity.binary_RX_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){
|
||||
|
||||
// read error
|
||||
error_buf = new BufferedReader(new InputStreamReader(
|
||||
proc.getErrorStream()));
|
||||
final String error = error_buf.readLine(); // only one line error
|
||||
|
||||
// read std out
|
||||
stdout_buf = new BufferedReader(new InputStreamReader(
|
||||
proc.getInputStream()));
|
||||
|
||||
// get received bytes
|
||||
stdout = stdout_buf.readLine();
|
||||
if (stdout == null) {
|
||||
// error happens
|
||||
MainActivity.myHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
MainActivity.txt_results.append("Failed in RX_RawNormal at port " + MainActivity.RXportNum + "\n");
|
||||
MainActivity.txt_results.append("Err in RX_RawNormal: " + error + "\n");
|
||||
}
|
||||
});
|
||||
break;
|
||||
}
|
||||
out.append(new String(buffer, 0, read));
|
||||
if(read<20){
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (out.length() > 0) {
|
||||
MainActivity.UDPfinishTime = (int)Float.parseFloat(out.toString().trim());
|
||||
}
|
||||
final String mOut = out.toString().trim();
|
||||
MainActivity.reportedFinishTime = Double.parseDouble(mOut);
|
||||
} else {
|
||||
// sent bytes
|
||||
recvBytes = Utilities.parseBinOutput(stdout);
|
||||
|
||||
// duration
|
||||
stdout = stdout_buf.readLine();
|
||||
duration = Utilities.parseBinOutput(stdout);
|
||||
MainActivity.reportedFinishTime = duration;
|
||||
if (MainActivity.isVerbose) {
|
||||
Log.d("Thread_RX_CRawNormal", mOut + "ms");
|
||||
MainActivity.myHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
MainActivity.txt_results.append("Time: " + mOut + "ms\n");
|
||||
MainActivity.txt_results.append("Time: " + duration + "ms\n");
|
||||
}
|
||||
});
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} catch (InterruptedException e) {
|
||||
|
||||
// throughput
|
||||
stdout = stdout_buf.readLine();
|
||||
throughput = Utilities.parseBinOutput(stdout);
|
||||
}
|
||||
|
||||
} catch (IOException | InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (MainActivity.isVerbose)
|
||||
|
||||
Log.d("RX_RawNormal", "Stop RX RawNormal");
|
||||
|
||||
MainActivity.isRunning_RX_RawNormal = false;
|
||||
MainActivity.perProcPID = -1;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,71 +2,106 @@ package edu.ucsb.cs.sandlab.offloadingdemo;
|
|||
|
||||
import android.util.Log;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
|
||||
/**
|
||||
* Created by yanzi on 9/18/15.
|
||||
* Updated on 01/31/17
|
||||
*/
|
||||
public class Thread_RX_CSendfile implements Runnable {
|
||||
|
||||
class Thread_RX_CSendfile implements Runnable {
|
||||
private double recvBytes = 0.0;
|
||||
private double duration = 0.0;
|
||||
private double throughput = 0.0;
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
// prevent multiple runs
|
||||
if (MainActivity.isRunning_RX_Sendfile)
|
||||
return;
|
||||
if (MainActivity.isVerbose)
|
||||
Log.d("RX_Sendfile", "Start RX Sendfile");
|
||||
MainActivity.isRunning_RX_Sendfile = true;
|
||||
|
||||
// variables
|
||||
Process proc;
|
||||
String stdout;
|
||||
BufferedReader stdout_buf, error_buf;
|
||||
String[] commd = new String[3];
|
||||
|
||||
// get the right command
|
||||
commd[0] = "su";
|
||||
commd[1] = "-c";
|
||||
// ./client_recv_normaltcp_sendfile <ip> <port>
|
||||
// <[optional] recvsize (bytes)> <[optional] filepath>
|
||||
commd[2] = (MainActivity.isForcingCPU0?"taskset 1 ":"")
|
||||
+ MainActivity.binaryFolderPath + MainActivity.binary_RX_Sendfile + " "
|
||||
+ MainActivity.bytes2send + " " + MainActivity.RXportNum;
|
||||
+ MainActivity.binaryFolderPath + MainActivity.binary_RX_Sendfile
|
||||
+ " " + (MainActivity.isLocal ? Utilities.myInetIP : MainActivity.remoteIP)
|
||||
+ " " + MainActivity.RXportNum
|
||||
+ " " + MainActivity.bytes2send;
|
||||
|
||||
|
||||
Log.d("RX_Sendfile", "Start RX Sendfile");
|
||||
try {
|
||||
// run process
|
||||
proc = Runtime.getRuntime().exec(commd);
|
||||
|
||||
// if config to log per process
|
||||
while (MainActivity.isLoggingPerProcPID && MainActivity.perProcPID == -1) {
|
||||
MainActivity.perProcPID = Utilities.getMyPID(MainActivity.binary_RX_Sendfile, false);
|
||||
MainActivity.perProcPID = Utilities.getMyPID(MainActivity.binary_RX_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){
|
||||
|
||||
// read error
|
||||
error_buf = new BufferedReader(new InputStreamReader(
|
||||
proc.getErrorStream()));
|
||||
final String error = error_buf.readLine(); // only one line error
|
||||
|
||||
// read std out
|
||||
stdout_buf = new BufferedReader(new InputStreamReader(
|
||||
proc.getInputStream()));
|
||||
|
||||
// get received bytes
|
||||
stdout = stdout_buf.readLine();
|
||||
if (stdout == null) {
|
||||
// error happens
|
||||
MainActivity.myHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
MainActivity.txt_results.append("Failed in RX_Sendfile at port " + MainActivity.RXportNum + "\n");
|
||||
MainActivity.txt_results.append(
|
||||
"Err in RX_Normal_Sendfile: " + error + "\n");
|
||||
}
|
||||
});
|
||||
break;
|
||||
}
|
||||
out.append(new String(buffer, 0, read));
|
||||
if(read<20){
|
||||
break;
|
||||
}
|
||||
}
|
||||
final String mOut = out.toString().trim();
|
||||
MainActivity.reportedFinishTime = Double.parseDouble(mOut);
|
||||
} else {
|
||||
// sent bytes
|
||||
recvBytes = Utilities.parseBinOutput(stdout);
|
||||
|
||||
// duration
|
||||
stdout = stdout_buf.readLine();
|
||||
duration = Utilities.parseBinOutput(stdout);
|
||||
MainActivity.reportedFinishTime = duration;
|
||||
if (MainActivity.isVerbose) {
|
||||
Log.d("Thread_RX_CSendfile", mOut + "ms");
|
||||
MainActivity.myHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
MainActivity.txt_results.append("Time: " + mOut + "ms\n");
|
||||
MainActivity.txt_results.append("Time: " + duration + "ms\n");
|
||||
}
|
||||
});
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} catch (InterruptedException e) {
|
||||
|
||||
// throughput
|
||||
stdout = stdout_buf.readLine();
|
||||
throughput = Utilities.parseBinOutput(stdout);
|
||||
}
|
||||
|
||||
} catch (IOException | InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (MainActivity.isVerbose)
|
||||
|
||||
Log.d("RX_Sendfile", "Stop RX Sendfile");
|
||||
|
||||
MainActivity.isRunning_RX_Sendfile = false;
|
||||
MainActivity.perProcPID = -1;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,71 +2,104 @@ package edu.ucsb.cs.sandlab.offloadingdemo;
|
|||
|
||||
import android.util.Log;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
|
||||
/**
|
||||
* Created by yanzi on 9/18/15.
|
||||
* Updated on 01/31/17
|
||||
*/
|
||||
public class Thread_RX_CSplice implements Runnable {
|
||||
|
||||
class Thread_RX_CSplice implements Runnable {
|
||||
private double recvBytes = 0.0;
|
||||
private double duration = 0.0;
|
||||
private double throughput = 0.0;
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
// prevent multiple runs
|
||||
if (MainActivity.isRunning_RX_Splice)
|
||||
return;
|
||||
if (MainActivity.isVerbose)
|
||||
Log.d("RX_Splicee", "Start RX Splice");
|
||||
MainActivity.isRunning_RX_Splice = true;
|
||||
|
||||
// variables
|
||||
Process proc;
|
||||
String stdout;
|
||||
BufferedReader stdout_buf, error_buf;
|
||||
String[] commd = new String[3];
|
||||
|
||||
// get the right command
|
||||
commd[0] = "su";
|
||||
commd[1] = "-c";
|
||||
// ./client_recv_normaltcp_splice <ip> <port>
|
||||
// <[optional] recvsize (bytes)> <[optional] filepath>
|
||||
commd[2] = (MainActivity.isForcingCPU0?"taskset 1 ":"")
|
||||
+ MainActivity.binaryFolderPath + MainActivity.binary_RX_Splice + " "
|
||||
+ MainActivity.bytes2send + " " + MainActivity.RXportNum;
|
||||
+ MainActivity.binaryFolderPath + MainActivity.binary_RX_Splice
|
||||
+ " " + (MainActivity.isLocal ? Utilities.myInetIP : MainActivity.remoteIP)
|
||||
+ " " + MainActivity.RXportNum
|
||||
+ " " + MainActivity.bytes2send;
|
||||
|
||||
Log.d("RX_Splice", "Start RX Splice");
|
||||
try {
|
||||
// run process
|
||||
proc = Runtime.getRuntime().exec(commd);
|
||||
|
||||
// if config to log per process
|
||||
while (MainActivity.isLoggingPerProcPID && MainActivity.perProcPID == -1) {
|
||||
MainActivity.perProcPID = Utilities.getMyPID(MainActivity.binary_RX_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){
|
||||
|
||||
// read error
|
||||
error_buf = new BufferedReader(new InputStreamReader(
|
||||
proc.getErrorStream()));
|
||||
final String error = error_buf.readLine(); // only one line error
|
||||
|
||||
// read std out
|
||||
stdout_buf = new BufferedReader(new InputStreamReader(
|
||||
proc.getInputStream()));
|
||||
|
||||
// get received bytes
|
||||
stdout = stdout_buf.readLine();
|
||||
if (stdout == null) {
|
||||
// error happens
|
||||
MainActivity.myHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
MainActivity.txt_results.append("Failed in RX_Splice at port " + MainActivity.RXportNum + "\n");
|
||||
MainActivity.txt_results.append("Err in RX_Normal_Splice: " + error + "\n");
|
||||
}
|
||||
});
|
||||
break;
|
||||
}
|
||||
out.append(new String(buffer, 0, read));
|
||||
if(read<20){
|
||||
break;
|
||||
}
|
||||
}
|
||||
final String mOut = out.toString().trim();
|
||||
MainActivity.reportedFinishTime = Double.parseDouble(mOut);
|
||||
} else {
|
||||
// sent bytes
|
||||
recvBytes = Utilities.parseBinOutput(stdout);
|
||||
|
||||
// duration
|
||||
stdout = stdout_buf.readLine();
|
||||
duration = Utilities.parseBinOutput(stdout);
|
||||
MainActivity.reportedFinishTime = duration;
|
||||
if (MainActivity.isVerbose) {
|
||||
Log.d("Thread_RX_CSplice", mOut + "ms");
|
||||
MainActivity.myHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
MainActivity.txt_results.append("Time: " + mOut + "ms\n");
|
||||
MainActivity.txt_results.append("Time: " + duration + "ms\n");
|
||||
}
|
||||
});
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} catch (InterruptedException e) {
|
||||
|
||||
// throughput
|
||||
stdout = stdout_buf.readLine();
|
||||
throughput = Utilities.parseBinOutput(stdout);
|
||||
}
|
||||
|
||||
} catch (IOException | InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (MainActivity.isVerbose)
|
||||
|
||||
Log.d("RX_Splice", "Stop RX Splice");
|
||||
|
||||
MainActivity.isRunning_RX_Splice = false;
|
||||
MainActivity.perProcPID = -1;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ class Thread_TX_CRawNormal implements Runnable {
|
|||
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
// prevent multiple runs
|
||||
if (MainActivity.isRunning_TX_RawNormal)
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ class Thread_TX_CSplice implements Runnable {
|
|||
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
// prevent multiple runs
|
||||
if (MainActivity.isRunning_TX_Splice)
|
||||
return;
|
||||
|
|
@ -30,8 +31,6 @@ class Thread_TX_CSplice implements Runnable {
|
|||
BufferedReader stdout_buf, error_buf;
|
||||
String[] commd = new String[3];
|
||||
|
||||
MainActivity.isRunning_TX_Splice = true;
|
||||
|
||||
// get the right command
|
||||
commd[0] = "su";
|
||||
commd[1] = "-c";
|
||||
|
|
|
|||
Loading…
Reference in New Issue