-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathEndpoint_controller.m
110 lines (79 loc) · 2.01 KB
/
Endpoint_controller.m
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
//
// Endpoint_controller.m
// data_m
//
// Created by Mike Fluff on 17.02.11.
// Copyright 2011 Altell ltd. All rights reserved.
//
#import "Endpoint_controller.h"
#import "NSStringArgs.h"
#import "configBuilder.h"
#import "DeviceConfigurator.h"
@implementation Endpoint_controller
@synthesize isStarted;
-(void)startEndpointPerfServer
{
NSAutoreleasePool * pool;
pool = [[NSAutoreleasePool alloc] init];
while(true)
{
if([lock tryLock])
{
[iface startProcess:@"iperf"];
isStarted = YES;
[delegate threadFinished];
[lock unlock];
break;
}
}
[pool drain];
}
-(void)startEndpointPerfClient:(NSNumber *)pairs;
{
NSArray *PairsIps = [configBuilder ipList:[pairs intValue] side:@"Right" oktet:10];
NSMutableString *action = [[NSMutableString alloc] init];
for(NSString *ip in PairsIps)
{
[action appendFormat:@"iperf -c %@ -t 100 -i 1 -y C& ",ip];
}
while(true)
{
if([TAC isConfigured])
{
self.delegate = TAC;
[iface setDelegate:self];
NSLog(@"%@",action);
[iface setAction:action];
[iface runAction];
break;
}
}
}
- (void)processActiveResult:(NSString *)result
{
// NSLog(@"%@",result);
NSArray *results = [result componentsSeparatedByString:@","];
[delegate processActiveResult:results];
}
- (void)processFinished:(id)sender;
{
NSArray *result = [sender csvRows];
NSMutableArray *perf = [[NSMutableArray alloc] initWithCapacity:([result count] - 1)];
NSInteger i=1;
int median;
for (NSArray *arr in result)
{
if (i < [result count])
{
[perf addObject:[NSNumber numberWithInt:[[arr objectAtIndex:8] intValue]]];
i++;
}
else {
median = [[arr objectAtIndex:8] intValue];
}
}
int min = [[perf valueForKeyPath:@"@min.intValue"] intValue];
int max = [[perf valueForKeyPath:@"@max.intValue"] intValue];
NSLog(@"%d %d %d", min, median, max);
}
@end