iOS Development tools--Network packet analysis tools Charles

Source: Internet
Author: User

Charles

Charles is a common tool for intercepting network packets under Mac. When doing iOS development, we often need to intercept network packets for debugging and server-side network communication protocols. By setting himself up as a network Access Proxy for the system, Charles enables all network access requests to be done through it, enabling the interception and analysis of network packets.

Charles ' main features include:

    1. Support SSL Proxy. You can intercept requests that analyze SSL.
    2. Supports flow control. You can simulate slow networks and long wait times (latency) of requests.
    3. Supports Ajax debugging. JSON or XML data can be automatically formatted for easy viewing.
    4. Supports AMF debugging. The flash Remoting or Flex Remoting information can be formatted for easy viewing.
    5. Support to re-send network requests, convenient back-end debugging.
    6. Support for modifying network request parameters.
    7. Supports interception and dynamic modification of network requests.
    8. Check whether Html,css and RSS content meet the standards.
1. Install Charles

Online to find a cracked version of the download installation. such as: Http://crcfj.onlinedown.net/down/charles-proxy-3.10.2.zip

2. Configure Charles

When Charles is started, Charles will ask you to set permissions on the System agent for the first time. You can enter the login password to grant Charles this permission. You can also ignore the request, and then, when you need to set up Charles as a system agent, choose "Proxy", "Mac OS X Proxy" in the menu to set up Charles as a system agent. As shown below:

After that, you can see a steady stream of Web requests appearing in Charles's interface.

3.Charles Main Interface Introduction

Charles provides 2 views of the package, named "Structure" and "Sequence", respectively.

    1. The structure view classifies network requests by the domain name that is accessed.
    2. The sequence view sorts network requests by the time they are accessed.

You can switch back and forth between the two views according to your specific needs.

For a specific network request, you can view its detailed request content and response content. If the response is in JSON format, Charles can automatically format the JSON content for you to see.

4. Filtering Network Requests

Typically, we need to filter the network requests and only monitor requests sent to the specified directory server. We have 2 ways to do this.

    1. Fill in the filter bar in the middle of the main interface with keywords that need to be filtered out. For example, our server's address is: http://yuantiku.com, then only need to fill in the filter bar Yuantiku.

    2. In Charles's menu bar, select "Proxy", "Recording Settings", then select the Include column, select Add an item, and then fill in the protocol, host address, port number you want to monitor. This allows you to intercept only the packets of the target Web site. As shown in the following:

Typically, we use Method 1 to do some temporary packet filtering, using method 2 to do some frequent packet filtering.

5. Intercept the network packets on your iphone (iOS common)

Charles is often used to intercept local network packets, but we can also use them to intercept network requests on other devices when we need them. I'll take the iphone as an example to explain how to do it.

The settings on Charles

To intercept the network request on the iphone, we first need to turn on Charles's proxy function. In Charles's menu bar, select "Proxy", "Proxy Settings", fill in the agent port 8888, and check "Enable transparent HTTP proxying" to complete the setup on Charles. As shown in the following:

Settings on the iphone

First we need to get the IP address of the computer where Charles is running, open terminal, enter ifconfig en0 , and get the IP of that computer, as shown in:

In the iphone's "Settings", "Wireless LAN", you can see the current connected WiFi name, by clicking on the right of the details key, you can see the current connection of WiFi details, including IP address, subnet mask and other information. At the bottom of it is an "HTTP proxy", which we'll switch to manual, then fill in the IP of the computer where Charles is running and the port number 8888, as shown in:

After setting up, we open any program that needs network communication on the iphone, we can see Charles Pop-up iphone request connection Confirmation menu (as shown), click "Allow" to complete the setup.

Intercepting SSL Information

Charles does not intercept SSL by default, and if you want to intercept all SSL network requests on a Web site, you can right-click on the request and select SSL Proxy, as shown in:

In this way, all SSL requests for the host can be intercepted.

6. Analog Network Slow speed

When it comes to iphone development, we often need to simulate a slow network or a high-latency network to test whether the application behaves properly under the mobile network. Charles has provided a good support for this requirement.

On the Charles menu, select "Proxy", "throttle Setting", in the dialog box that pops up, we can tick "Enable throttling" and set the type of throttle preset. As shown in the following:

If we only want to simulate the slow network of the specified site, you can tick the "only for selected hosts" item and then add the specified hosts to the lower half of the dialog box.

7. Modify Network Request Content

Sometimes in order to debug the server interface, we need to repeatedly try different parameters of the network request. Charles makes it easy to provide modification and re-sending of network requests. Simply right-click on a previous network request and select "Edit" to create an editable network request. As shown below:

8. Summary

Charles is very powerful and very convenient for us to develop and debug apps with Web requests.

iOS Development tools--Network packet analysis tools Charles

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.