Tcpdump for Android Network Development

Source: Internet
Author: User

When network communication is involved in Android development, some fields need to be captured. I have not written the correct Header Format because of the SSDP device. After packet capture analysis and comparison with the standard header, I found this problem that has plagued me for a long time. In short, it is necessary to capture packets in Android phones.

Preparations: Android mobile phones, network environments, tcpdump, and cracking root permissions of mobile phones. We recommend that you install the RE File Manager on your mobile phone and grant root permissions. The procedure is as follows:

First, use the adb tool to push tcpdump to your mobile phone. The tcpdump tool is http://www.strazzere.com/android/tcpdump. The operation can be done with one command: adb push c:/tcpdump/data/local/tcpdump. You can also use other methods to send tcpdump to your mobile phone.

Then, you need to modify the tcpdump permission:

C: \ adb shell

$ Su
# Chmod 777/data/local/tcpdump

When entering the su command, you may need to click the OK button on your phone. In this way, adb can have the permission to modify the attributes of tcpdump.

Start packet capture:

Adb shell
$ Su
/Data/local/tcpdump-p-vv-s 0-w/sdcard/capture. pcap

After the packet capture ends, press ctrl + c. Note: On Windows, ctrl + c is directly interrupted. use ctrl + d or other commands to end the program (Mac OS is not affected ).

Pull out the packet capture file: adb pull/sdcard/capture. pcap c:/if you have not installed the RE File Manager, you may not see the capture. pcap file, but it does exist because of insufficient permissions (the File Created by root is in Android and cannot be viewed by normal permission programs ).

Next, you can use Wireshark to analyze your captured packages. An error may be reported when the file is opened, because if you stop packet capture in an interrupted way, the pcap file is not written at the end. ignore this.


If you have reprinted the results of your hard work, please indicate the source. Thank you!

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.