ios平台网络诊断SDK,支持对ip和域名的ping,traceroute(udp,icmp协议),支持tcp ping, 端口扫描,nslookup,局域网活跃ip扫描等功能-----------Ios platform network diagnostic SDK, support ip and domain name ping, traceroute (udp, icmp protocol), support tcp ping, port scan, nslookup, LAN active ip scan and other functions
By ingegrating iOS network diagnostics sdk
you can easily do ping/traceroute/mobile public network information/port scanning on IPhone.
Take a screenshot of the network diagnostic app developed with this sdk:
Enable Bitcode
to NO
Add the following dependencies to your project’s Podfile
:
pod 'PhoneNetSDK'
Import the SDK header file to the project:
#import <PhoneNetSDK/PhoneNetSDK.h>
In addition, you need to add -lc++
,-ObjC
,$(inherited)
to the project’s Build Setting
->other link flags
. As shown below:
[[PhoneNetManager shareInstance] netStartPing:@"www.baidu.com" packetCount:10 pingResultHandler:^(NSString * _Nullable pingres) {
// your processing logic
}];
_tcpPing = [PNTcpPing start:hostDomain port:portNum.integerValue count:3 complete:^(NSMutableString *pingres) {
// your processing logic
}];
The default traceroute command on the command line sends a UDP packet (referred to as udp traceroute):
_udpTraceroute = [PNUdpTraceroute start:ip complete:^(NSMutableString *res) {
// your processinig logic
}];
In the terminal of mac, enter traceroute -I baidu.com
to use the ICMP protocol to do traceroute. This function is provided in sdk:
[[PhoneNetManager shareInstance] netStartTraceroute:@"www.baidu.com" tracerouteResultHandler:^(NSString * _Nullable tracertRes, NSString * _Nullable destIp) {
// your processing logic
}];
[[PhoneNetManager shareInstance] netLookupDomain:@"www.google.com" completeHandler:^(NSMutableArray<DomainLookUpRes *> * _Nullable lookupRes, PNError * _Nullable sdkError) {
// your processing logic
}];
[[PhoneNetManager shareInstance] netPortScan:@"www.baidu.com" beginPort:8000 endPort:9000 completeHandler:^(NSString * _Nullable port, BOOL isOpen, PNError * _Nullable sdkError) {
// your processing logic
}];
If you want to do the LAN active ip scanning function, then you can quickly monitor every active ip with the SDK, and the SDK will return to you the scanning progress.
Specific steps are as follows:
PNetMLanScannerDelegate
PNetMLanScanner *lanScanner = [PNetMLanScanner shareInstance];
lanScanner.delegate = self;
[lanScanner scan];
Ios platform network diagnostic APP (using the SDK), support ping and domain name ping, traceroute (udp, icmp protocol), support tcp ping, port scan, nslookup and other functions.
Simply go to the directory where the Podfile
file is located and install the SDK to run successfully.
macdeiMac:NetPinger ethan$ pod install
Analyzing dependencies
Downloading dependencies
Installing PhoneNetSDK (1.0.7)
Generating Pods project
Integrating client project
[!] Please close any current Xcode sessions and use `NetPinger.xcworkspace` for this project from now on.
Sending stats
Pod installation complete! There is 1 dependency from the Podfile and 1 total pod installed.
In development, you often encounter problems with the interface (DNS resolution error, etc.), so you need to detect whether the mobile terminal to the server’s network is not connected, so you need to interrupt ping
on the mobile phone, but the free network detection tool on the market. Most have pop-up ads affecting the experience (eg: iNetTools), so it is necessary to develop a web drama detection app.
All functions are implemented using the functions provided by the SDK. The pages and icons are mainly imitating the NetWork Utility
on the MAC, and hope to provide a valuable reference for your application.
star
& fork