大佬教程收集整理的这篇文章主要介绍了iOS获取链接速度(路由器速度测试),大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我在这里找到了一些东西Get link speed programmatically?但找不到sockios.h和ethtool.h
是否可以将此代码移植到Objective-C或是否有其他方法?
–
对不起缺少的信息和我可怜的英语.
我想测试ios设备和连接的wifi调制解调器之间的链接速度(tx速率).
CWInterface类中有一个名为txRate的属性.我想在Cocoa Touch中获取这些数据.
/*! * @property * @abstract Current transmit rate (Mbps) of the CoreWLAN interface. * @discussion Dynamically queries thE interface for the current transmit rate. */ @property(readonly) NSnumber *txRate NS_DEPRECATED_MAC(10_6,10_7);
#include <ifaddrs.h> #include <net/if.h> + (doublE)getRouterLinkSpeed { BOOL success; struct ifaddrs *addrs; const struct ifaddrs *cursor; const struct if_data *networkStatisc; double linkSpeed = 0; NSString *name = [[NSString alloc] init]; success = getifaddrs(&addrs) == 0; if (success) { cursor = addrs; while (cursor != NULL) { name=[NSString StringWithFormat:@"@L_489_11@",cursor->ifa_name]; if (cursor->ifa_addr->sa_family == AF_LINK) { if ([name hasPrefix:@"en"]) { networkStatisc = (const struct if_data *) cursor->ifa_data; linkSpeed = networkStatisc->ifi_baudrate; } } cursor = cursor->ifa_next; } freeifaddrs(addrs); } return linkSpeed; }
以上是大佬教程为你收集整理的iOS获取链接速度(路由器速度测试)全部内容,希望文章能够帮你解决iOS获取链接速度(路由器速度测试)所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。