summaryrefslogtreecommitdiff
path: root/TAO/performance-tests/Protocols/toggle_link.pl
blob: 0f46435c7707b79724274249fb6705ae3b43d84f (plain)
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
eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}'
    & eval 'exec perl -S $0 $argv:q'
    if 0;

# $Id$
# -*- perl -*-

use Time::localtime;
use Time::Local;

# amount of delay between running the servers
$sleeptime = 2;
$phasetime = 3;

$project = "pces/sctp";

$L1_DOWN = "tevc -e $project now link1 down &";
$L1_UP =   "tevc -e $project now link1 up &";
$L2_DOWN = "tevc -e $project now link2 down &";
$L2_UP =   "tevc -e $project now link2 up &";

$now = localtime;
$start_seconds = timelocal ($now->sec, $now->min, $now->hour, $now->mday, $now->mon, $now->year);

print_with_time ("L1 UP");
system ($L1_UP);

print_with_time ("L2 DOWN");
system ($L2_DOWN);

select undef, undef, undef, $phasetime;

for (;;)
{
    print_with_time ("L2 UP");

    system ($L2_UP);

    select undef, undef, undef, $sleeptime / 2;

    print_with_time ("L1 DOWN");

    system ($L1_DOWN);

    select undef, undef, undef, $sleeptime;

    print_with_time ("L1 UP");

    system ($L1_UP);

    select undef, undef, undef, $sleeptime / 2;

    print_with_time ("L2 Down");

    system ($L2_DOWN);

    select undef, undef, undef, $sleeptime;
}

sub print_with_time
{
    $now = localtime;
    $now_seconds = timelocal ($now->sec, $now->min, $now->hour, $now->mday, $now->mon, $now->year);

    print "@_ at ", $now_seconds - $start_seconds, "\n";
}