KSYNetTracker.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. //
  2. // KSYNetTracker.h
  3. // KSYCommon
  4. //
  5. // Created by 施雪梅 on 2017/1/4.
  6. // Copyright © 2017年 施雪梅. All rights reserved.
  7. //
  8. #import <Foundation/Foundation.h>
  9. FOUNDATION_EXPORT NSString * _Nonnull const KSYNetTrackerOnceDoneNotification;
  10. FOUNDATION_EXPORT NSString * _Nonnull const KSYNetTrackerFinishedNotification;
  11. FOUNDATION_EXPORT NSString * _Nonnull const KSYNetTrackerErrorNotification;
  12. /**
  13. * 探测方式
  14. */
  15. typedef NS_ENUM(NSInteger, KSY_NETTRACKER_ACTION){
  16. ///mtr方式,探测链路上每个节点
  17. KSY_NETTRACKER_ACTION_MTR,
  18. ///ping方式,直接探测终点
  19. KSY_NETTRACKER_ACTION_PING,
  20. };
  21. /**
  22. * 网络链路上的路由节点信息类
  23. */
  24. @interface KSYNetRouterInfo : NSObject
  25. /**
  26. @abstract 链路上每个节点的ip地址
  27. @discussion 如果每个探测报文对应的路径不同,则每一跳上会存在多个不同ip
  28. */
  29. @property (nonatomic, readonly) NSMutableArray * _Nullable ips;
  30. /**
  31. @abstract 所有探测报文的rtt最大值
  32. */
  33. @property (nonatomic, readonly) float tmax;
  34. /**
  35. @abstract 所有探测报文的rtt最小值
  36. */
  37. @property (nonatomic, readonly) float tmin;
  38. /**
  39. @abstract 所有探测报文的rtt平均值
  40. */
  41. @property (nonatomic, readonly) float tavg;
  42. /**
  43. @abstract 所有探测报文的rtt均方差
  44. */
  45. @property (nonatomic, readonly) float tdev;
  46. /**
  47. @abstract 所有探测报文的丢包率
  48. */
  49. @property (nonatomic, readonly) float loss;
  50. /**
  51. @abstract 统计所使用的探测报文个数
  52. */
  53. @property (nonatomic, readonly) int number;
  54. @end
  55. /**
  56. * 网络链路探测器类
  57. */
  58. @interface KSYNetTracker : NSObject
  59. /**
  60. @abstract 开始探测
  61. @param domain 探测地址
  62. @return 成功开始返回0, 否则返回非0
  63. */
  64. - (int) start:(NSString * __nonnull)domain;
  65. /**
  66. @abstract 停止探测
  67. */
  68. - (void) stop;
  69. /**
  70. @abstract 探测方式
  71. @discussion 说明:
  72. * start开始前配置有效,探测过程中配置下一次探测生效
  73. */
  74. @property (nonatomic, assign) KSY_NETTRACKER_ACTION action;
  75. /**
  76. @abstract 探测超时时间,单位是ms,默认值是1000ms
  77. @discussion 说明:
  78. * start开始前配置有效,探测过程中配置下一次探测生效
  79. * 有效范围是100-2000ms,不在有效范围内的配置不生效
  80. */
  81. @property (nonatomic, assign) int timeout;
  82. /**
  83. @abstract 探测使用的最大ttl值,默认值是64
  84. @discussion 说明:
  85. * start开始前配置有效,探测过程中配置下一次探测生效
  86. * 有效范围是1-int最大值,不在有效范围内的配置不生效
  87. */
  88. @property (nonatomic, assign) int maxttl;
  89. /**
  90. @abstract 探测次数,默认值是10
  91. @discussion 说明:
  92. * start开始前配置有效,探测过程中配置下一次探测生效
  93. * 有效范围是1-20,不在有效范围内的配置不生效
  94. */
  95. @property (nonatomic, assign) int number;
  96. /**
  97. @abstract 链路状况
  98. */
  99. @property (nonatomic, readonly) NSMutableArray * _Nullable routerInfo;
  100. @end