forked from maratishe/e2eprobe
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtx.php
More file actions
126 lines (116 loc) · 4.88 KB
/
tx.php
File metadata and controls
126 lines (116 loc) · 4.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
<?php
set_time_limit( 0);
ob_implicit_flush( 1);
//ini_set( 'memory_limit', '4000M');
for ( $prefix = is_dir( 'ajaxkit') ? 'ajaxkit/' : ''; ! is_dir( $prefix) && count( explode( '/', $prefix)) < 4; $prefix .= '../'); if ( ! is_file( $prefix . "env.php")) $prefix = '/web/ajaxkit/'; if ( ! is_file( $prefix . "env.php")) die( "\nERROR! Cannot find env.php in [$prefix], check your environment! (maybe you need to go to ajaxkit first?)\n\n");
foreach ( array( 'functions', 'env') as $k) require_once( $prefix . "$k.php"); clinit();
clhelp( "PURPOSE: to run a TCP socket sender -- make tasks and send them to server");
clhelp( "[tag] tag for all records");
htg( clgetq( 'rip,rport,tag,timeout,run'));
$port2 = $rport + 1;
$C = new NTCPClient();
$C->init( $rip, $rport);
echo "sleep 500ms..."; usleep( 500000); echo " OK\n";
// global setup
$psize = 1200; // bytes
$probesize = 60; // packets
echo "[START]\n";
$msg = "action=restart"; $C->send( $msg); echo "> $msg\n";
sleep( 1);
@socket_close( $C->sock); unset( $C);
$C = new NTCPClient();
$C->init( $rip, $rport);
echo "sleep 500ms..."; usleep( 500000); echo " OK\n";
// PROPOSED method bypassed - use fixed thru for PathChirp/IGI
// echo "[PROPOSED]\n";
// $lastime = tsystem(); $before = tsystem(); $thru = null;
// $msg = "tag=$tag,run=$run,method=proposed,psize=$psize,probesize=$probesize"; $C->send( $msg);
// echo "> $msg\n"; unset( $status);
// while ( tsystem() - $lastime < $timeout) {
// $msg = $C->recv(); if ( ! $msg) { usleep( 300000); continue; }
// echo '< ' . json_encode( $msg) . "\n";
// extract( $msg); break;
// }
// if ( ! isset( $status)) die( "\n");
// $c = "$CDIR/probe.udp.proposed.tx $rip $port2 $psize $probesize";
// echo "c[$c]\n"; procat( $c);
// $lastime = tsystem(); unset( $status);
// while ( tsystem() - $lastime < $timeout) {
// $msg = $C->recv(); if ( ! $msg) { usleep( 300000); continue; }
// echo '< ' . json_encode( $msg) . "\n";
// extract( $msg); break;
// }
// if ( ! isset( $status)) die( "\n");
// echo "OK, took " . tshinterval( $before, tsystem()) . "\n";
// if ( $thru == 0 || !isset($thru)) {
// echo "WARNING: Using default throughput\n";
// $thru = 5000; // 5 Mbps
// }
$thru = 5000; // Kbps (5 Mbps) - bypass PROPOSED, use fixed value for PathChirp/IGI
// pathchirp method
echo "[PATHCHIRP]\n";
$smallest = 0.5 * $thru;
$biggest = 5 * $thru;
echo "picking alpha (smallest=$smallest,biggest=$biggest):";
for ( $alpha = 1.05; $alpha < 2.5; $alpha += 0.05) {
$L = array(); $pspace = round( 1000000 * ( ( $psize * 8) / ( 1000 * $smallest)));
$iter = 0;
while ( count( $L) < $probesize && $iter < 200) {
lpush( $L, $pspace);
$pspace = round( $pspace / $alpha);
$iter++;
}
$thru2 = round( 0.001 * ( ( $psize * 8) / ( llast( $L) * 0.000001)));
echo " $alpha/$pspace/$thru2";
if ( $thru2 > $biggest) break;
}
echo "\nSelected alpha = $alpha\n";
$pspace = round( 1000000 * ( ( $psize * 8) / ( 1000 * $smallest)));
$lastime = tsystem(); $before = tsystem();
$msg = "tag=$tag,run=$run,method=pathchirp,psize=$psize,probesize=$probesize,pspace=$pspace,alpha=$alpha"; $C->send( $msg);
echo "> $msg\n"; unset( $status);
while ( tsystem() - $lastime < $timeout) {
$msg = $C->recv(); if ( ! $msg) { usleep( 300000); continue; }
echo '< ' . json_encode( $msg) . "\n";
extract( $msg); break;
}
if ( ! isset( $status)) die( "\n");
$c = "$CDIR/probe.udp.pathchirp.tx $rip $port2 $psize $probesize $pspace $alpha";
echo "Running command: $c\n";
exec( $c . ' > /dev/null 2>&1 &');
sleep( 5);
$lastime = tsystem(); unset( $status);
while ( tsystem() - $lastime < $timeout) {
$msg = $C->recv(); if ( ! $msg) { usleep( 300000); continue; }
echo '< ' . json_encode( $msg) . "\n";
extract( $msg); break;
}
if ( ! isset( $status)) die( "\n");
echo "OK, took " . tshinterval( $before, tsystem()) . "\n";
// igi method
echo "[IGI]\n";
$smallest = 0.5 * $thru; $pspace1 = round( 1000000 * ( ( $psize * 8) / ( 1000 * $smallest)));
$biggest = 1.5 * $thru; $pspace2 = round( 1000000 * ( ( $psize * 8) / ( 1000 * $biggest)));
$step = round( ( $pspace1 - $pspace2) / 5);
$lastime = tsystem(); $before = tsystem();
$msg = "tag=$tag,run=$run,method=igi,psize=$psize,probesize=$probesize,pspacestart=$pspace1,pspacestep=$step,pspaceend=$pspace2"; $C->send( $msg);
echo "> $msg\n"; unset( $status);
while ( tsystem() - $lastime < $timeout) {
$msg = $C->recv(); if ( ! $msg) { usleep( 300000); continue; }
echo '< ' . json_encode( $msg) . "\n";
extract( $msg); break;
}
if ( ! isset( $status)) die( "\n");
$c = "$CDIR/probe.udp.igi.tx $rip $port2 $psize $probesize $pspace1 $step $pspace2 > igi.log";
echo "Running command: $c\n";
exec( $c . ' > /dev/null 2>&1 &');
sleep( 5);
$lastime = tsystem(); unset( $status);
while ( tsystem() - $lastime < $timeout) {
$msg = $C->recv(); if ( ! $msg) { usleep( 300000); continue; }
echo '< ' . json_encode( $msg) . "\n";
extract( $msg); break;
}
if ( ! isset( $status)) die( "\n");
echo "OK, took " . tshinterval( $before, tsystem()) . "\n";
?>