IOS Get Communication Speed ​​(Router Speed ​​Test)

I want to check the speed of a connected router (Wi-Fi modem) from an iOS application.

I found something here Get link speed programmatically? but could not find sockios.h and ethtool.h

Is it possible to port this code to Objective-C or is there another way?

-

Sorry for the missing information and my poor english.

I want to check the connection speed (tx rate) between an ios device and a connected Wi-Fi modem.

The CWInterface class had a txRate property. I want to get this data in 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); 
+4
source share
2 answers

Finally, I found a solution.

 #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; } 
+4
source

You can use NSURLConnection to connect to your test server and download a predefined file of approximately 1 MB. Use the NSURLConnection delegate -connection -connection:didReceiveData: and -connectionDidFinishLoading: to track the download so far and calculate the download speed.

+2
source

Source: https://habr.com/ru/post/1483994/


All Articles