First, the network traffic is observed.
The behavior of observing network traffic is called sniffing or packet analysis.
1, sniff hardware.
Capturing packets from the iOS emulator does not require special hardware or network configuration. If you need to capture these packets, you can use sniffer software to listen for loopback devices or interfaces for connecting to the network.
2, Sniff software.
OS X comes with a command-line packet sniffer topdump, which is the foundation of most other sniffers in OS X.
1) capture using tcpdump.
2) capture using Wireshark.
Second, operating network traffic
1, configure Charles
2,http Breakpoint.
3, rewrite the rule.
Third, simulate the network condition.
Network packet capture and HTTP proxy tools are ideal for visualizing network traffic in a visual manner. Another tool that should be adapted and familiar to all iOS developers ' toolboxes is the network traffic modifier. It is used to simulate low-speed or unreliable networks.
1,os X Line offers an excellent flow modifier called network Link Conditioner (NLC).
Reference: "iOS network advanced programming-iphone and ipad Enterprise application Development"
"Reading notes" iOS network-testing and manipulating network traffic