【问题标题】:Test connection speed in objective-C在 Objective-C 中测试连接速度
【发布时间】:2017-04-07 19:40:42
【问题描述】:

我目前正在开展一个项目,该项目有一部分用于测试我的连接速度并检索结果。

结果应包含以下内容:

Downlink Data Throughput(Mbps)
Maximum Downlink Data Rate(Mbps)
Avg Downlink Data Rate(Mbps)
Session Duration(mSec)
Latency / Ping Test(mSec)

我找到了speedTest,我基本上可以用它来获取最大和平均数据速率以及会话持续时间(下载文件的时间)

但是我应该如何获得下行数据吞吐量和 Ping 呢? 谁能帮助我如何检索这些数据?

【问题讨论】:

  • 你必须自己做。创建一个连接,下载一些东西并测量你想要的任何东西。没有什么可以为你做的。
  • @Avi 我知道我应该自己做,但我问如何检索下行数据吞吐量和 ping?应该用什么方法来完成它?这两个的定义让我不清楚如何检索它。

标签: objective-c xcode download connection latency


【解决方案1】:

为了检查 ping 延迟,

@property (strong,nonatomic) NSDate *start;

- (void)simplePing:(SimplePing *)pinger didSendPacket:(NSData *)packet
{
    self.start=[NSDate date];
}

- (void)simplePing:(SimplePing *)pinger didReceivePingResponsePacket:(NSData *)packet
{
    NSDate *end=[NSDate date];
    double latency = [end timeIntervalSinceDate:self.start]*1000.0;

    //TODO - Do something with latency
}

2017 年 4 月 7 日编辑

你可能还想看看这个 github 项目:https://github.com/lmirosevic/GBPing

【讨论】:

  • 您的链接不可用
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-10-24
  • 2013-04-28
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多