AN3406 Application note Using an STM32W108-based board and Wireshark for IEEE 802.15.4 packet analysis 1 Introduction This document describes a PC software application that interfaces STM32W108-based boards with Wireshark for capturing and displaying IEEE 802.15.4 traffic at 2.4 GHz. This application requires the use of a compatible IEEE 802.15.4 board to interface with Wireshark as an over-the-air protocol analyzer or packet sniffer. Wireshark is a complete open-source network protocol analyzer, widely used for troubleshooting, analysis, development and education. It enables you to inspect hundreds of protocols, including IEEE 802.15.4 and most related upper-layer protocols, such as Zigbee and 6LoWPAN. May 2011 Doc ID 018855 Rev 1 1/10 www.st.com Contents AN3406 Contents 1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 2 Prerequisites . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 3 Application block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 4 Installing software . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 5 6 4.1 Installing Wireshark . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 4.2 Installing the STM32W108 Wireshark server . . . . . . . . . . . . . . . . . . . . . . . 5 Installing sniffing boards . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 5.1 Plugging in the board . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 5.2 Programming the board as a sniffer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 Virtual sniffer server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 6.1 7 2/10 Packet capturing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 Revision history . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 Doc ID 018855 Rev 1 AN3406 2 Prerequisites Prerequisites ● PC with at least one USB 1.1 port ● Windows XP™ or more recent. ● Any of the compatible boards equipped with STM32W108 microcontroller: – MB851 – MB950 – MB951 – MB954 These are provided in the following kits: – STM32W108xx starter kit (part number: STM32W-SK) – STM32W108xx extension kit (part number: STM32W-EXT) – STM32W108xx low-cost RF control kit (part number: STM32W-RFCKIT) Make sure also you have appropriate FTDI drivers installed if your board is equipped with FTDI device. The FTDI drivers can be downloaded from http://www.ftdichip.com/Drivers/D2XX.htm. ● Wireshark 1.4.3 or later. The latest release can be downloaded from www.wireshark.org. ● Installer file: STM32W108-WiresharkServer-1.0.0-Setup.exe, which can be downloaded from http://www.st.com. Doc ID 018855 Rev 1 3/10 Application block diagram 3 AN3406 Application block diagram The following diagram shows the relationship between the hardware and software components required to capture and analyze packets. Relationship between the hardware and software components 34-7 "OARD 3%2)!, 0/24 Figure 1. 34-7 7IRESHARK 3ERVER 7IRESHARK 7INDOWS0# -36 A board equipped with the STM32W108 microcontroller is connected with the user's PC via a USB cable. The board enumerates itself as a virtual serial COM port. The STM32W108 Wireshark virtual server is a sort of glue between this sniffing board and Wireshark. Its primary task is to send commands to the sniffing hardware and read captured packets from it. It also delivers these packets to Wireshark through a named pipe. The STM32W108 Wireshark server can also flash STM32W108-based boards with the appropriate firmware for capturing packets. 4/10 Doc ID 018855 Rev 1 AN3406 Installing software 4 Installing software 4.1 Installing Wireshark Download and install Wireshark if it is not already installed on your system. You can also install it later, but you will not be able to view captured packets until it is installed. The setup can be downloaded from www.wireshark.org. Use at least version 1.4.3. We recommend using the most recent release, with the most recent bug fixes and protocol updates. 4.2 Installing the STM32W108 Wireshark server Launch STM32W108-WiresharkServer-1.0.0-Setup.exe to install the virtual server used to interface between the STM32W108-based board and the Wireshark packet analysis utility. Doc ID 018855 Rev 1 5/10 Installing sniffing boards 5 AN3406 Installing sniffing boards This application requires the use of an IEEE 802.15.4 transceiver, such as the STM32W108-based boards, to capture packets sent over-the-air. 5.1 Plugging in the board Plug the board into one of the USB ports of your PC. When LED D1 blinks every second, this indicates that correct firmware has been programmed in the board. If not, make sure that the board is powered on and is programmed with the correct firmware (see Section 5.2 for how to upload the binary onto the board). Install the appropriate drivers for the board you are using in order to communicate with the PC (see Section 2: Prerequisites). 5.2 Programming the board as a sniffer 1. If the board is not preprogrammed, flash the correct firmware into the device. To do this, use the built-in device programmer: launch the STM32W108 Wireshark server utility and select Tools > Flasher. Figure 2. 2. STM32W108 Wireshark server utility Choose the COM port that identifies the device you want to flash with the sniffer firmware and press the Flash button. Figure 3. A blinking LED indicates that the device is flashed successfully. 6/10 Doc ID 018855 Rev 1 AN3406 6 Virtual sniffer server Virtual sniffer server A sniffing server is needed to capture data with the boards and show them in Wireshark. Figure 4 shows the main window of the program. Figure 4. Wireshark main window Toolbar icons let you control the capturing process. START Start a new live capture, reading from the selected device and listening on the selected channel. Wireshark is opened. If the process is paused, it will be resumed. PAUSE Suspend the current capture process. Press START to resume. STOP Stop the running live capture. Press START to start a new live capture and a new instance of Wireshark. REFRESH Detect compatible devices attached to your PC. ● Serial port box shows you all compatible devices found in your system. If you plug a board when the software is already started, click Refresh icon in the toolbar to update its content. ● Channel box lets you change the IEEE 802.15.4 channel from which you want to capture packets. Doc ID 018855 Rev 1 7/10 Virtual sniffer server 6.1 Note: AN3406 Packet capturing 1. Launch the sniffer server by double-clicking the shortcut on your desktop, or from the Start menu. The main window of the program displays (see Figure 4)(a). 2. Choose one of the devices from the serial port combo box, and your desired IEEE 802.15.4 channel from the Channel box. 3. Click START. Wireshark opens and packets are shown inside its live capture window (see Figure 5). 4. You can change the channel before starting the capture, or while it is already running. You can also: – suspend the capture by clicking PAUSE – resume the capture by clicking START – terminate the capture by clicking STOP If capturing is stopped from Wireshark, you cannot restart a new capture from Wireshark itself. You have to stop and launch a new capture process from the server. Figure 5. Packet capturing a. The program tries to detect if Wireshark is installed during startup. If Wireshark cannot be detected the correct path can be specified under Settings > Preferences 8/10 Doc ID 018855 Rev 1 AN3406 7 Revision history Revision history Table 1. Document revision history Date Revision 26-May-2011 1 Changes Initial release. Doc ID 018855 Rev 1 9/10 AN3406 Please Read Carefully: Information in this document is provided solely in connection with ST products. STMicroelectronics NV and its subsidiaries (“ST”) reserve the right to make changes, corrections, modifications or improvements, to this document, and the products and services described herein at any time, without notice. All ST products are sold pursuant to ST’s terms and conditions of sale. Purchasers are solely responsible for the choice, selection and use of the ST products and services described herein, and ST assumes no liability whatsoever relating to the choice, selection or use of the ST products and services described herein. No license, express or implied, by estoppel or otherwise, to any intellectual property rights is granted under this document. If any part of this document refers to any third party products or services it shall not be deemed a license grant by ST for the use of such third party products or services, or any intellectual property contained therein or considered as a warranty covering the use in any manner whatsoever of such third party products or services or any intellectual property contained therein. UNLESS OTHERWISE SET FORTH IN ST’S TERMS AND CONDITIONS OF SALE ST DISCLAIMS ANY EXPRESS OR IMPLIED WARRANTY WITH RESPECT TO THE USE AND/OR SALE OF ST PRODUCTS INCLUDING WITHOUT LIMITATION IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE (AND THEIR EQUIVALENTS UNDER THE LAWS OF ANY JURISDICTION), OR INFRINGEMENT OF ANY PATENT, COPYRIGHT OR OTHER INTELLECTUAL PROPERTY RIGHT. UNLESS EXPRESSLY APPROVED IN WRITING BY AN AUTHORIZED ST REPRESENTATIVE, ST PRODUCTS ARE NOT RECOMMENDED, AUTHORIZED OR WARRANTED FOR USE IN MILITARY, AIR CRAFT, SPACE, LIFE SAVING, OR LIFE SUSTAINING APPLICATIONS, NOR IN PRODUCTS OR SYSTEMS WHERE FAILURE OR MALFUNCTION MAY RESULT IN PERSONAL INJURY, DEATH, OR SEVERE PROPERTY OR ENVIRONMENTAL DAMAGE. ST PRODUCTS WHICH ARE NOT SPECIFIED AS "AUTOMOTIVE GRADE" MAY ONLY BE USED IN AUTOMOTIVE APPLICATIONS AT USER’S OWN RISK. Resale of ST products with provisions different from the statements and/or technical features set forth in this document shall immediately void any warranty granted by ST for the ST product or service described herein and shall not create or extend in any manner whatsoever, any liability of ST. ST and the ST logo are trademarks or registered trademarks of ST in various countries. Information in this document supersedes and replaces all information previously supplied. The ST logo is a registered trademark of STMicroelectronics. All other names are the property of their respective owners. © 2011 STMicroelectronics - All rights reserved STMicroelectronics group of companies Australia - Belgium - Brazil - Canada - China - Czech Republic - Finland - France - Germany - Hong Kong - India - Israel - Italy - Japan Malaysia - Malta - Morocco - Philippines - Singapore - Spain - Sweden - Switzerland - United Kingdom - United States of America www.st.com 10/10 Doc ID 018855 Rev 1