KSYNetTracker.h
2.87 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
127
//
// KSYNetTracker.h
// KSYCommon
//
// Created by 施雪梅 on 2017/1/4.
// Copyright © 2017年 施雪梅. All rights reserved.
//
#import <Foundation/Foundation.h>
FOUNDATION_EXPORT NSString * _Nonnull const KSYNetTrackerOnceDoneNotification;
FOUNDATION_EXPORT NSString * _Nonnull const KSYNetTrackerFinishedNotification;
FOUNDATION_EXPORT NSString * _Nonnull const KSYNetTrackerErrorNotification;
/**
* 探测方式
*/
typedef NS_ENUM(NSInteger, KSY_NETTRACKER_ACTION){
///mtr方式,探测链路上每个节点
KSY_NETTRACKER_ACTION_MTR,
///ping方式,直接探测终点
KSY_NETTRACKER_ACTION_PING,
};
/**
* 网络链路上的路由节点信息类
*/
@interface KSYNetRouterInfo : NSObject
/**
@abstract 链路上每个节点的ip地址
@discussion 如果每个探测报文对应的路径不同,则每一跳上会存在多个不同ip
*/
@property (nonatomic, readonly) NSMutableArray * _Nullable ips;
/**
@abstract 所有探测报文的rtt最大值
*/
@property (nonatomic, readonly) float tmax;
/**
@abstract 所有探测报文的rtt最小值
*/
@property (nonatomic, readonly) float tmin;
/**
@abstract 所有探测报文的rtt平均值
*/
@property (nonatomic, readonly) float tavg;
/**
@abstract 所有探测报文的rtt均方差
*/
@property (nonatomic, readonly) float tdev;
/**
@abstract 所有探测报文的丢包率
*/
@property (nonatomic, readonly) float loss;
/**
@abstract 统计所使用的探测报文个数
*/
@property (nonatomic, readonly) int number;
@end
/**
* 网络链路探测器类
*/
@interface KSYNetTracker : NSObject
/**
@abstract 开始探测
@param domain 探测地址
@return 成功开始返回0, 否则返回非0
*/
- (int) start:(NSString * __nonnull)domain;
/**
@abstract 停止探测
*/
- (void) stop;
/**
@abstract 探测方式
@discussion 说明:
* start开始前配置有效,探测过程中配置下一次探测生效
*/
@property (nonatomic, assign) KSY_NETTRACKER_ACTION action;
/**
@abstract 探测超时时间,单位是ms,默认值是1000ms
@discussion 说明:
* start开始前配置有效,探测过程中配置下一次探测生效
* 有效范围是100-2000ms,不在有效范围内的配置不生效
*/
@property (nonatomic, assign) int timeout;
/**
@abstract 探测使用的最大ttl值,默认值是64
@discussion 说明:
* start开始前配置有效,探测过程中配置下一次探测生效
* 有效范围是1-int最大值,不在有效范围内的配置不生效
*/
@property (nonatomic, assign) int maxttl;
/**
@abstract 探测次数,默认值是10
@discussion 说明:
* start开始前配置有效,探测过程中配置下一次探测生效
* 有效范围是1-20,不在有效范围内的配置不生效
*/
@property (nonatomic, assign) int number;
/**
@abstract 链路状况
*/
@property (nonatomic, readonly) NSMutableArray * _Nullable routerInfo;
@end