iOS获取链接速度(路由器速度测试)

iOS获取链接速度(路由器速度测试),第1张

概述我想从iOS应用程序测试连接路由器(wifi调制解调器)的速度. 我在这里找到了一些东西Get link speed programmatically?但找不到sockios.h和ethtool.h 是否可以将此代码移植到Objective-C或是否有其他方法? – 对不起缺少的信息和我可怜的英语. 我想测试ios设备和连接的wifi调制解调器之间的链接速度(tx速率). CWInterface类 我想从iOS应用程序测试连接路由器(wifi调制解调器)的速度.

我在这里找到了一些东西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:@"%s",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获取链接速度(路由器速度测试)所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1065147.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-26
下一篇 2022-05-26

发表评论

登录后才能评论

评论列表(0条)

保存