diff --git a/LocalSettings.php b/LocalSettings.php index 2a1bd3085c7843910eb98bb4bf46b0588179a4d6..f3d1bd90bf8b416b8db8ffaf4806bdbcf6baff78 100755 --- a/LocalSettings.php +++ b/LocalSettings.php @@ -163,6 +163,7 @@ $wgInvalidateCacheOnLocalSettingsChange=0; ##added by alzayat -- 28/03/2017 $wgSMEEnabled = 1; +$wgSMEStats = 1; $wgSMEProfiling = 0; $wgSMEEnforcement = 1; $wgSMEDebug=0; diff --git a/sme_extn/sme_helper.php b/sme_extn/sme_helper.php index 043bbcf417bff6cc25bb30021a39ec2d70fe1923..34c753a67382a013da82289fb208eafea4b84dcd 100644 --- a/sme_extn/sme_helper.php +++ b/sme_extn/sme_helper.php @@ -696,6 +696,7 @@ function sendBackendProfileToKernel($pubhash, $privhash, $mysqli) global $wgSMEDebug; global $wgSMEDummyIP, $wgSMEDummyPort; global $SME_KERNEL_ENFORCEMENT_TIMESTAMP; + global $wgSMEStats; if (isset($wgSMEDummyIP)) $dummy_server_ip = $wgSMEDummyIP; @@ -709,9 +710,23 @@ function sendBackendProfileToKernel($pubhash, $privhash, $mysqli) 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); + + if (isset($wgSMEStats) && $wgSMEStats){ + $time_end = microtime(true); + $time = $time_end - $time_start; + file_put_contents("/local/sme/stats_5_tuple.txt", + "Time required for fetching the 5 tuple is: $time (seconds)\n", + LOCK_EX|FILE_APPEND); + + } + /* file_put_contents("/local/sme/besock.txt", "src: $client_ip $client_port, in: $server_ip $server_port" . @@ -720,11 +735,6 @@ function sendBackendProfileToKernel($pubhash, $privhash, $mysqli) */ - // Wait for ACK to the FE-Client marker on the frontend kernel, - // before sending the FE-BE marker - if (isset($wgSMEDebug) && $wgSMEDebug == 0) { - waitForKernelACK($SME_MARKER_SOCK, $dummy_server_ip, $dummy_server_port); - } $num_pub = count($pubhash); $num_priv = count($privhash); @@ -739,6 +749,12 @@ function sendBackendProfileToKernel($pubhash, $privhash, $mysqli) /* $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 + if (isset($wgSMEDebug) && $wgSMEDebug == 0) { + waitForKernelACK($SME_MARKER_SOCK, $dummy_server_ip, $dummy_server_port); + } // Send FE-BE profile marker to kernel $ret = socket_sendto($SME_MARKER_SOCK, $pbuf_FE_BE, $plen_FE_BE, 0, @@ -771,15 +787,28 @@ function sendBackendProfileToKernel($pubhash, $privhash, $mysqli) function waitForKernelACK($sock, $dummy_server_ip, $dummy_server_port){ global $SME_KERNEL_ENFORCEMENT_TIMESTAMP; global $wgSMEDebug; - + global $wgSMEStats; if ($sock == -1) { file_put_contents("/local/sme/msg_sent_to_kernel.txt", "sock: $sock\n", FILE_APPEND | LOCK_EX); return; } + if (isset($wgSMEStats) && $wgSMEStats){ + $time_start = microtime(true); + } + $ret = socket_recvfrom($sock, $ackbuf, 8, 0, $dummy_server_ip, $dummy_server_port); + + if (isset($wgSMEStats) && $wgSMEStats){ + $time_end = microtime(true); + $time = $time_end - $time_start; + file_put_contents("/local/sme/stats_marker_sync.txt", + "Marker sync additional delay: $time\n", + LOCK_EX|FILE_APPEND); + } + $SME_KERNEL_ENFORCEMENT_TIMESTAMP = int_helper::uInt64($ackbuf);