When developing the network program, we can visually see the data, which is very convenient for development. Here are a few ways to do this:
One, virtual network card 1. Create an RVI (remote virtual Interface) virtual network card on iphone or ipad
Connect the device to your Mac with USB, open the command line tool, and enter the command:
rvictl -s abcdef01234563e91f1f2f8a8cb0841d2dafeebbc
The long list of things here is the udid of the equipment. Use itunes to find this thing. (The default is to display the serial number, click the serial number three words, will switch the display). Click menu Edit-Copy Udid.
Under normal circumstances, it will prompt starting device ********************* [succedded] with interface rival success.
Test with the ifconfig-l command:
2. Use the tcpdump command to save the packet to the. pcap file
In the terminal input command:
sudo tcpdump -i rv0 -n -s 0 -w dumpFile.pcap tcp
Parameter description:
- -I rv0 intercept virtual network card data
- -N Do not use DNS
- -S 0 intercepts the entire packet, not just the first byte
- -W DUMPFILE.PCP output file, is the Libpcap file format
- TCP only intercepts TCP packets
Now run the app on the device, and at the end, exit tcpdump. This time, if you no longer need to intercept the data, you can also remove the virtual network card.
rvictl -x abcdef01234563e91f1f2f8a8cb0841d2dafeebbc
But now this data file is not easy to use, using VIM to open will see all garbled.
Now install a Tcpreplay tool
brew install tcpreplay
I encountered this error when I was working on it:
Error: Cannot write To/usr/local/cellar
Execute First:
sudo chown-r $USER/usr/local
After installation, execute the command:
tcprewrite --dlt=enet --enet-dmac=00:11:22:33:44:55 --enet-smac=66:77:88:99:AA:BB --infile=dumpFile.pcap --outfile=dumpFileFinal.pcap
3. Install Wireshark View data
Download the installation to Wireshark.
Wireshark needs X11 support. If it is not installed, booting the Wireshark will boot the installation. You can also download the installation here:
http://xquartz.macosforge.org/landing/
Start Wireshark, you may be prompted choose application. Click Browser to "/application/utilities/xquartz.app". If you are installing the latest wireshark, you may not need to specify it and it will be recognized automatically.
Note that starting open may be slow and be patient.
When you open the converted Dumpfilefinal.pcap, you can see the data content.
Second, HTTP Data monitoring View Httparchive website: http://www.softwareishard.com/blog/har-12-spec/
The pcap obtained using tcpdump can also be converted to Httparchive view, using the Pcap2har Python scripting tool.
This is introduced in addition later.
Third, use instruments network profiling
The use of virtual machines when testing is not able to monitor the data, the need to connect physical machine testing.
Here is an example of the result:
It is not easy to see the real data here, only to see the approximate communication situation.
Original:
Http://blog.manbolo.com/2013/02/22/analysing-ios-app-network-performances-on-cellularwifi
Data monitoring during development of IOS network programs