wireshark-user-guide.rst 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  1. ******************************
  2. Espressif Wireshark User Guide
  3. ******************************
  4. :link_to_translation:`zh_CN:[中文]`
  5. ===========
  6. 1. Overview
  7. ===========
  8. 1.1 What is Wireshark?
  9. ======================
  10. `Wireshark <https://www.wireshark.org>`_ (originally named "Ethereal") is a network packet analyzer that captures network packets and displays the packet data as detailed as possible. It uses WinPcap as its interface to directly capture network traffic going through a network interface controller (NIC).
  11. You could think of a network packet analyzer as a measuring device used to examine what is going on inside a network cable, just like a voltmeter is used by an electrician to examine what is going on inside an electric cable.
  12. In the past, such tools were either very expensive, proprietary, or both. However, with the advent of Wireshark, all that has changed.
  13. Wireshark is released under the terms of the GNU General Public License, which means you can use the software and the source code free of charge. It also allows you to modify and customize the source code.
  14. Wireshark is, perhaps, one of the best open source packet analyzers available today.
  15. 1.2 Some Intended Purposes
  16. ==========================
  17. Here are some examples of how Wireshark is typically used:
  18. * Network administrators use it to troubleshoot network problems.
  19. * Network security engineers use it to examine security problems.
  20. * Developers use it to debug protocol implementations.
  21. * People use it to learn more about network protocol internals.
  22. Beside these examples, Wireshark can be used for many other purposes.
  23. 1.3 Features
  24. ============
  25. The main features of Wireshark are as follows:
  26. * Available for UNIX and Windows
  27. * Captures live packet data from a network interface
  28. * Displays packets along with detailed protocol information
  29. * Opens/saves the captured packet data
  30. * Imports/exports packets into a number of file formats, supported by other capture programs
  31. * Advanced packet filtering
  32. * Searches for packets based on multiple criteria
  33. * Colorizes packets according to display filters
  34. * Calculates statistics
  35. * … and a lot more!
  36. 1.4 Wireshark Can or Can't Do
  37. ==============================
  38. * **Live capture from different network media**.
  39. Wireshark can capture traffic from different network media, including wireless LAN.
  40. * **Import files from many other capture programs**.
  41. Wireshark can import data from a large number of file formats, supported by other capture programs.
  42. * **Export files for many other capture programs**.
  43. Wireshark can export data into a large number of file formats, supported by other capture programs.
  44. * **Numerous protocol dissectors**.
  45. Wireshark can dissect, or decode, a large number of protocols.
  46. * **Wireshark is not an intrusion detection system**.
  47. It will not warn you if there are any suspicious activities on your network. However, if strange things happen, Wireshark might help you figure out what is really going on.
  48. * **Wireshark does not manipulate processes on the network, it can only perform "measurements" within it**.
  49. Wireshark does not send packets on the network or influence it in any other way, except for resolving names (converting numerical address values into a human readable format), but even that can be disabled.
  50. ==========================
  51. 2. Where to Get Wireshark
  52. ==========================
  53. You can get Wireshark from the official website: https://www.wireshark.org/download.html
  54. Wireshark can run on various operating systems. Please download the correct version according to the operating system you are using.
  55. ======================
  56. 3. Step-by-step Guide
  57. ======================
  58. **This demonstration uses Wireshark 2.2.6 on Linux.**
  59. **a) Start Wireshark**
  60. On Linux, you can run the shell script provided below. It starts Wireshark, then configures NIC and the channel for packet capture.
  61. ::
  62. ifconfig $1 down
  63. iwconfig $1 mode monitor
  64. iwconfig $1 channel $2
  65. ifconfig $1 up
  66. Wireshark&
  67. In the above script, the parameter ``$1`` represents NIC and ``$2`` represents channel. For example, ``wlan0`` in ``./xxx.sh wlan0 6``, specifies the NIC for packet capture, and ``6`` identifies the channel of an AP or Soft-AP.
  68. **b) Run the Shell Script to Open Wireshark and Display Capture Interface**
  69. .. figure:: ../../_static/ws-capture-interface.jpeg
  70. :align: center
  71. :alt: Wireshark Capture Interface
  72. :figclass: align-center
  73. :width: 60%
  74. Wireshark Capture Interface
  75. **c) Select the Interface to Start Packet Capture**
  76. As the red markup shows in the picture above, many interfaces are available. The first one is a local NIC and the second one is a wireless NIC.
  77. Please select the NIC according to your requirements. This document will use the wireless NIC to demonstrate packet capture.
  78. Double click *wlan0* to start packet capture.
  79. **d) Set up Filters**
  80. Since all packets in the channel will be captured, and many of them are not needed, you have to set up filters to get the packets that you need.
  81. Please find the picture below with the red markup, indicating where the filters should be set up.
  82. .. figure:: ../../_static/ws-setup-filters.png
  83. :align: center
  84. :alt: Setting up Filters in Wireshark
  85. :figclass: align-center
  86. Setting up Filters in Wireshark
  87. Click *Filter*, the top left blue button in the picture below. The *display filter* dialogue box will appear.
  88. .. figure:: ../../_static/ws-display-filter-dialogue-box.png
  89. :align: center
  90. :alt: *Display Filter* Dialogue Box
  91. :figclass: align-center
  92. :width: 60%
  93. *Display Filter* Dialogue Box
  94. Click the *Expression* button to bring up the *Filter Expression* dialogue box and set the filter according to your requirements.
  95. .. figure:: ../../_static/ws-filter-expression.png
  96. :align: center
  97. :alt: *Filter Expression* Dialogue Box
  98. :figclass: align-center
  99. :width: 80%
  100. *Filter Expression* Dialogue Box
  101. **The quickest way**: enter the filters directly in the toolbar.
  102. .. figure:: ../../_static/ws-filter-toolbar.png
  103. :align: center
  104. :alt: Filter Toolbar
  105. :figclass: align-center
  106. Filter Toolbar
  107. Click on this area to enter or modify the filters. If you enter a wrong or unfinished filter, the built-in syntax check turns the background red. As soon as the correct expression is entered, the background becomes green.
  108. The previously entered filters are automatically saved. You can access them anytime by opening the drop down list.
  109. For example, as shown in the picture below, enter two MAC addresses as the filters and click *Apply* (the blue arrow). In this case, only the packet data transmitted between these two MAC addresses will be captured.
  110. .. figure:: ../../_static/ws-filter-toolbar_green.png
  111. :align: center
  112. :alt: Example of MAC Addresses applied in the Filter Toolbar
  113. :figclass: align-center
  114. Example of MAC Addresses applied in the Filter Toolbar
  115. **e) Packet List**
  116. You can click any packet in the packet list and check the detailed information about it in the box below the list. For example, if you click the first packet, its details will appear in that box.
  117. .. figure:: ../../_static/ws-packet-list.png
  118. :align: center
  119. :alt: Example of Packet List Details
  120. :figclass: align-center
  121. Example of Packet List Details
  122. **f) Stop/Start Packet Capture**
  123. As shown in the picture below, click the red button to stop capturing the current packet.
  124. .. figure:: ../../_static/ws-stop-packet-capture.png
  125. :align: center
  126. :alt: Stopping Packets Capture
  127. :figclass: align-center
  128. Stopping Packet Capture
  129. Click the top left blue button to start or resume packet capture.
  130. .. figure:: ../../_static/ws-start-resume-packet-capture.png
  131. :align: center
  132. :alt: Starting or Resuming Packets Capture
  133. :figclass: align-center
  134. :width: 60%
  135. Starting or Resuming the Packets Capture
  136. **g) Save the Current Packet**
  137. On Linux, go to *File* -> *Export Packet Dissections* -> *As Plain Text File* to save the packet.
  138. .. figure:: ../../_static/ws-save-packets.png
  139. :align: center
  140. :alt: Saving Captured Packets
  141. :figclass: align-center
  142. :width: 60%
  143. Saving Captured Packets
  144. Please note that *All packets*, *Displayed* and *All expanded* must be selected.
  145. By default, Wireshark saves the captured packet in a libpcap file. You can also save the file in other formats, e.g. txt, to analyze it in other tools.