How to use tcpdump to capture packets on android phones

Source: Internet
Author: User
Two days ago, I made an android client and found that the reported data is not the same as the expected data. I can only view the client request data and server response data, and found the error. On the Internet, Baidu found that tcpdump can solve the problem. I will share with you the process. Test Machine root is required! The test machine without root must be root. otherwise

Two days ago, I made an android client and found that the reported data is not the same as the expected data. I can only view the client request data and server response data, and found the error.

Baidu discovery on the InternetTcpdumpThis can solve the problem and I will share with you the process.

Test Machine root is required! Root is required for a test machine without root. Otherwise, the tcpdump software must be downloaded ).

1. connect the test machine to your computer and open the windows Command Prompt window;

2. copy the tcpdump program to the android mobile phone.

In the command prompt window, enter adbpush c:/tcpdump/data/local/tcpdump ("c:/tcpdump" is the address of the local tcpdump software, "/data/local/tcpdump" for the destination mobile address)

Note: When executing this command, make sure that only one test machine is connected and the simulator is not enabled. Otherwise, an error "error: more than one device and emulator" will be reported.

3. modify tcpdump permissions

Enter adbshell chmod 6755/data/local/tcpdump in the command prompt window.

4. enter the root permission on the mobile phone.

Enter adbshell in the command prompt window.

$ Is displayed on the root phone.

Enter the "su" command again to access the root permission of the mobile phone, and change the cursor to "#".

5. run tcpdump software

Enter/data/local/tcpdump-p-vv-s 0-w/sdcard/capture. pcap in the command prompt window.

Note: The test machine must be connected to the network.

6. execute the operations on the mobile phone end that require packet capture analysis. after the execution is complete, execute Ctrl + C in the command prompt window to interrupt the packet capture process.

7. copy the packet capture result to the local device.

Enter adbpull/sdcard/capture. pcap c:/in the command prompt window :/

If you place it elsewhere, you can change "c:/" to what you need.

8. use relevant software to view the captured File capture. pcap. here I use Wireshark software to view the analysis (Wireshark download ).

The error is analyzed.

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.