Skip to content
Snippets Groups Projects
Commit c8193aa4 authored by Mohamed Alzayat's avatar Mohamed Alzayat
Browse files

Merged

parents 925884dd 2c59f070
No related branches found
No related tags found
No related merge requests found
......@@ -183,6 +183,7 @@ $wgSMEEnforcement = 1;
$wgSMEDebug = 0;
$wgSMEDummyIP = "139.19.168.173";
$wgSMEDummyPort = 2231;
$wgSMEMultiTier=0;
###TODO: disable before experiments
#$wgShowExceptionDetails = 1;
......
......@@ -158,7 +158,7 @@ $wgScribuntoEngineConf['luastandalone']['luaPath'] = '/usr/bin/lua';
#$wgScribuntoEngineConf['luastandalone']['errorFile'] = '/tmp/mwlua_error.log';
## lua debug log shows not enough memory
$wgScribuntoEngineConf['luastandalone']['memoryLimit'] = 524288000; # 500M in bytes
$wgScribuntoEngineConf['luastandalone']['cpuLimit'] = 150; # in seconds
$wgScribuntoEngineConf['luastandalone']['cpuLimit'] = 250; # in seconds
#$wgScribuntoDefaultEngine = 'luasandbox';
$wgMaxUploadSize = 32 * 1024 * 1024;
$wgMaxArticleSize = 32 * 1024 * 1024;
......@@ -166,22 +166,27 @@ $wgMaxArticleSize = 32 * 1024 * 1024;
## added by alzayat
#$wgEnableParserCache = false;
#$wgCachePages = false;
#$wgEnableSidebarCache=true;
$wgUseFileCache = true; /* default: false */
#$wgUseFileCache = false; /* default: false */
#$wgUseGzip = true;
$wgFileCacheDirectory = "/cache/new_cache/wiktionary_cache";
#$wgFileCacheDirectory = "$IP/cache";
$wgJobRunRate=0;
$wgInvalidateCacheOnLocalSettingsChange=0;
##added by alzayat -- 28/03/2017
$wgSMEEnabled = 1;
$wgSMEIOCTL = 1;
$wgSMEioctlDEV = "/dev/SMECTRL";
$wgSMEStats = 0;
$wgSMEProfiling = 1;
$wgSMEEnforcement = 1;
$wgSMEDebug = 0;
$wgSMEDummyIP = "139.19.168.173";
$wgSMEDummyPort = 2231;
$wgSMEMultiTier=0;
###TODO: disable before experiments
#$wgShowExceptionDetails = 1;
......
......@@ -158,7 +158,7 @@ $wgScribuntoEngineConf['luastandalone']['luaPath'] = '/usr/bin/lua';
#$wgScribuntoEngineConf['luastandalone']['errorFile'] = '/tmp/mwlua_error.log';
## lua debug log shows not enough memory
$wgScribuntoEngineConf['luastandalone']['memoryLimit'] = 524288000; # 500M in bytes
$wgScribuntoEngineConf['luastandalone']['cpuLimit'] = 150; # in seconds
$wgScribuntoEngineConf['luastandalone']['cpuLimit'] = 250; # in seconds
#$wgScribuntoDefaultEngine = 'luasandbox';
$wgMaxUploadSize = 32 * 1024 * 1024;
$wgMaxArticleSize = 32 * 1024 * 1024;
......@@ -166,22 +166,27 @@ $wgMaxArticleSize = 32 * 1024 * 1024;
## added by alzayat
#$wgEnableParserCache = false;
#$wgCachePages = false;
#$wgEnableSidebarCache=true;
$wgUseFileCache = true; /* default: false */
#$wgUseFileCache = false; /* default: false */
#$wgUseGzip = true;
$wgFileCacheDirectory = "/cache/new_cache/wiktionary_cache";
#$wgFileCacheDirectory = "$IP/cache";
$wgJobRunRate=0;
$wgInvalidateCacheOnLocalSettingsChange=0;
##added by alzayat -- 28/03/2017
$wgSMEEnabled = 0;
$wgSMEIOCTL = 0;
$wgSMEioctlDEV = "/dev/SMECTRL";
$wgSMEStats = 0;
$wgSMEProfiling = 0;
$wgSMEEnforcement = 0;
$wgSMEDebug = 0;
$wgSMEDummyIP = "139.19.168.173";
$wgSMEDummyPort = 2231;
$wgSMEMultiTier=0;
###TODO: disable before experiments
#$wgShowExceptionDetails = 1;
......
......@@ -92,7 +92,7 @@ class DatabaseMysqli extends DatabaseMysqlBase {
*/
protected function mysqlConnect( $realServer ) {
global $wgDBmysql5;
global $wgSMEMultiTier;
# Avoid suppressed fatal error, which is very hard to track down
if ( !function_exists( 'mysqli_init' ) ) {
throw new DBConnectionError( $this, "MySQLi functions missing,"
......@@ -145,8 +145,8 @@ class DatabaseMysqli extends DatabaseMysqlBase {
global $wgSMEEnabled, $wgSMEEnforcement;
global $public_input_hash;
global $private_input_hash;
if ( isset($wgSMEEnabled) && isset($wgSMEEnforcement)
&& $wgSMEEnabled == 1 && $wgSMEEnforcement == 1 ) {
if ( isset($wgSMEEnabled) && isset($wgSMEEnforcement) && isset($wgSMEMultiTier)
&& $wgSMEEnabled == 1 && $wgSMEEnforcement == 1 && $wgSMEMultiTier == 1) {
sendBackendProfileToKernel($public_input_hash, $private_input_hash,
$mysqli);
}
......
......@@ -477,6 +477,7 @@ function set_request_id($pubinput, $privinput)
for ($i = 0; $i < $num_pub; $i++) {
#$pubhash[] = "1234567890abcdef";
$public_input_hash[] = md5($pubinput[$i], True);
#$public_input_hash[] = md5($privinput[$i], True);
#$pubhash[] = md5($client_public_input, True);
}
......@@ -677,12 +678,16 @@ function sendBackendProfileToBackendMysql($pbuf_BE_FE, $plen_BE_FE, $mysqli,
$result = $mysqli->query($sql_str);
if (!is_null($result)) {
if (isset($wgSMEDebug) && $wgSMEDebug) {
$restr = print_r($result, true);
file_put_contents("/local/sme/msg_sent_to_kernel.txt", "RESULT: $restr",
$restr = print_r($result, true);
file_put_contents("/local/sme/msg_sent_to_kernel.txt", "UDPSOCK CALL: $sql_str",
FILE_APPEND | LOCK_EX);
file_put_contents("/local/sme/msg_sent_to_kernel.txt", "UDPSOCK RESULT: $restr",
FILE_APPEND | LOCK_EX);
}
$result->close();
if(!is_bool($result)){
$result->close();
}
} else {
if (isset($wgSMEDebug) && $wgSMEDebug) {
file_put_contents("/local/sme/msg_sent_to_kernel.txt", "RESULT EMPTY!\n",
......@@ -701,97 +706,103 @@ function sendBackendProfileToKernel($pubhash, $privhash, $mysqli)
global $wgSMEStats;
global $wgSMEIOCTL;
if (isset($wgSMEDummyIP))
$dummy_server_ip = $wgSMEDummyIP;
else
$dummy_server_ip = "139.19.168.173";
if (isset($wgSMEDummyPort))
$dummy_server_port = $wgSMEDummyPort;
else
$dummy_server_port = 2231;
try {
if (isset($wgSMEDummyIP))
$dummy_server_ip = $wgSMEDummyIP;
else
$dummy_server_ip = "139.19.168.173";
if (isset($wgSMEDummyPort))
$dummy_server_port = $wgSMEDummyPort;
else
$dummy_server_port = 2231;
get_local_ip_port($server_ip, $server_port);
get_remote_ip_port($client_ip, $client_port);
if (isset($wgSMEStats) && $wgSMEStats){
$time_start = microtime(true);
}
get_local_ip_port($server_ip, $server_port);
get_remote_ip_port($client_ip, $client_port);
if (isset($wgSMEStats) && $wgSMEStats){
$time_start = microtime(true);
}
identify_backend_connection($local_backend_ip, $local_backend_port,
$remote_backend_ip, $remote_backend_port);
identify_backend_connection($local_backend_ip, $local_backend_port,
$remote_backend_ip, $remote_backend_port);
if (isset($wgSMEStats) && $wgSMEStats){
$time_end = microtime(true);
$time = $time_end - $time_start;
file_put_contents("/local/sme/stats_5_tuple.txt",
"$time\n",
LOCK_EX|FILE_APPEND);
if (isset($wgSMEStats) && $wgSMEStats){
$time_end = microtime(true);
$time = $time_end - $time_start;
file_put_contents("/local/sme/stats_5_tuple.txt",
"$time\n",
LOCK_EX|FILE_APPEND);
}
}
/*
file_put_contents("/local/sme/besock.txt",
"src: $client_ip $client_port, in: $server_ip $server_port" .
", out: $local_backend_ip, $local_backend_port" .
", dst: $remote_backend_ip, $remote_backend_port\n", FILE_APPEND|LOCK_EX);
*/
/*
file_put_contents("/local/sme/besock.txt",
"src: $client_ip $client_port, in: $server_ip $server_port" .
", out: $local_backend_ip, $local_backend_port" .
", dst: $remote_backend_ip, $remote_backend_port\n", FILE_APPEND|LOCK_EX);
*/
$num_pub = count($pubhash);
$num_priv = count($privhash);
$num_pub = count($pubhash);
$num_priv = count($privhash);
// BE-FE profile, to be forwarded to the backend via SQL
create_tmp_profile_marker($pbuf_BE_FE, $plen_BE_FE,
$local_backend_ip, $local_backend_port,
$remote_backend_ip, $remote_backend_port,
$remote_backend_ip, $remote_backend_port,
$local_backend_ip, $local_backend_port,
$num_pub, $num_priv, $pubhash, $privhash);
// BE-FE profile, to be forwarded to the backend via SQL
create_tmp_profile_marker($pbuf_BE_FE, $plen_BE_FE,
$local_backend_ip, $local_backend_port,
$remote_backend_ip, $remote_backend_port,
$remote_backend_ip, $remote_backend_port,
$local_backend_ip, $local_backend_port,
$num_pub, $num_priv, $pubhash, $privhash);
sendBackendProfileToBackendMysql($pbuf_BE_FE, $plen_BE_FE, $mysqli,
$dummy_server_ip, $dummy_server_port);
sendBackendProfileToBackendMysql($pbuf_BE_FE, $plen_BE_FE, $mysqli,
$dummy_server_ip, $dummy_server_port);
// FE-BE profile
create_tmp_profile_marker($pbuf_FE_BE, $plen_FE_BE,
$client_ip, $client_port,
$server_ip, $server_port,
$local_backend_ip, $local_backend_port,
$remote_backend_ip, $remote_backend_port,
$num_pub, $num_priv, $pubhash, $privhash);
/*
$sock = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
*/
// Wait for ACK to the FE-Client marker on the frontend kernel,
// before sending the FE-BE marker
// Only in the case of UDP SOCKETS
if (isset($wgSMEIOCTL) && $wgSMEIOCTL==0 && isset($wgSMEDebug) && $wgSMEDebug == 0) {
waitForKernelACK($SME_MARKER_SOCK_OR_CTL, $dummy_server_ip, $dummy_server_port);
}
// FE-BE profile
create_tmp_profile_marker($pbuf_FE_BE, $plen_FE_BE,
$client_ip, $client_port,
$server_ip, $server_port,
$local_backend_ip, $local_backend_port,
$remote_backend_ip, $remote_backend_port,
$num_pub, $num_priv, $pubhash, $privhash);
// Send FE-BE profile marker to kernel
if (isset($wgSMEIOCTL) && $wgSMEIOCTL){
$ret = dev_ioctl($SME_MARKER_SOCK_OR_CTL, 0, $pbuf_FE_BE, $plen_FE_BE);
}else{
$ret = socket_sendto($SME_MARKER_SOCK_OR_CTL, $pbuf_FE_BE, $plen_FE_BE, 0,
$dummy_server_ip, $dummy_server_port);
}
/*
$sock = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
*/
// Wait for ACK to the FE-Client marker on the frontend kernel,
// before sending the FE-BE marker
// Only in the case of UDP SOCKETS
if (isset($wgSMEIOCTL) && $wgSMEIOCTL==0 && isset($wgSMEDebug) && $wgSMEDebug == 0) {
waitForKernelACK($SME_MARKER_SOCK_OR_CTL, $dummy_server_ip, $dummy_server_port);
}
// Send FE-BE profile marker to kernel
if (isset($wgSMEIOCTL) && $wgSMEIOCTL){
$ret = dev_ioctl($SME_MARKER_SOCK_OR_CTL, 0, $pbuf_FE_BE, $plen_FE_BE);
}else{
$ret = socket_sendto($SME_MARKER_SOCK_OR_CTL, $pbuf_FE_BE, $plen_FE_BE, 0,
$dummy_server_ip, $dummy_server_port);
if (isset($wgSMEIOCTL) && $wgSMEIOCTL==0 && isset($wgSMEDebug) && $wgSMEDebug == 0) {
waitForKernelACK($SME_MARKER_SOCK_OR_CTL, $dummy_server_ip, $dummy_server_port);
}
}
if (isset($wgSMEIOCTL) && $wgSMEIOCTL==0 && isset($wgSMEDebug) && $wgSMEDebug == 0) {
waitForKernelACK($SME_MARKER_SOCK_OR_CTL, $dummy_server_ip, $dummy_server_port);
catch (Exception $e) {
echo 'Caught exception: ', $e->getMessage(), "\n";
}
if (isset($wgSMEIOCTL) && $wgSMEIOCTL){
dev_close($SME_MARKER_SOCK_OR_CTL);
#echo "closing ioctl dev";
}else{
socket_close($SME_MARKER_SOCK_OR_CTL);
finally {
if (isset($wgSMEIOCTL) && $wgSMEIOCTL){
dev_close($SME_MARKER_SOCK_OR_CTL);
#echo "Sent BE, closing ioctl dev";
}else{
socket_close($SME_MARKER_SOCK_OR_CTL);
#echo "Sent BE, closing socket";
}
}
}
......@@ -839,6 +850,7 @@ function sendProfileToKernel($pubhash, $privhash)
{
global $SME_MARKER_SOCK_OR_CTL;
global $wgSMEMultiTier;
global $wgSMEioctlDEV;
global $wgSMEIOCTL;
global $wgSMEDebug;
......@@ -891,6 +903,15 @@ function sendProfileToKernel($pubhash, $privhash)
$dummy_server_ip, $dummy_server_port);
}
if(isset($wgSMEMultiTier) && $wgSMEMultiTier == 0){
if (isset($wgSMEIOCTL) && $wgSMEIOCTL){
dev_close($SME_MARKER_SOCK_OR_CTL);
#echo "closing ioctl dev";
}else{
#echo "closing socket";
socket_close($SME_MARKER_SOCK_OR_CTL);
}
}
/*
if (isset($wgSMEDebug) && $wgSMEDebug == 1){
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment