Expressions and Buttons

Throughout the process of capturing and, especially, filtering traffic in Wireshark, you’ll encounter various expressions (for defining filter rules) and interactive buttons within the interface that aid in constructing and applying these rules. Understanding these elements is key to effectively leveraging Wireshark’s filtering capabilities.

Expressions (Filter Syntax)

As discussed in the sections on Capture Filters and Display Filters, these filters are defined using specific syntax and expressions.

  • Capture Filter Expressions: Follow the BPF syntax, using primitives like host, port, proto, net, src, dst, and logical operators (and, or, not). These expressions are entered directly into the “Capture Filter” field in the “Capture Options” dialog.
  • Display Filter Expressions: Use Wireshark’s own field-based syntax, referencing dissected protocol fields (e.g., ip.src, tcp.flags.syn, http.request.method) and employing comparison operators (==, >, <) and logical operators (and, or, not). These expressions are entered into the Filter Toolbar.

Key Aspects of Filter Expressions:

  • Case Sensitivity: Generally, display filter field names are case-sensitive (e.g., http.request.method is different from HTTP.request.method). Capture filter keywords are usually case-insensitive.
  • Auto-Completion and Syntax Highlighting: Wireshark often provides auto-completion suggestions as you type filter expressions in the Filter Toolbar, helping you remember field names and syntax. It also uses syntax highlighting to visually indicate valid and invalid parts of your filter.
  • Validation: When you apply a display filter, Wireshark typically validates the syntax and will provide an error message if there is an issue with your expression. Capture filters are validated when you start the capture.

Buttons and Interface Elements for Filtering:

Wireshark provides several buttons and interactive elements within the interface to assist you in creating and applying filters:

  • “Apply” Button (Filter Toolbar): After typing a display filter expression in the Filter Toolbar, clicking the “Apply” button (usually a right arrow) activates the filter, showing only the matching packets.
  • “Clear” Button (Filter Toolbar): Clicking the “Clear” button (often an “X”) in the Filter Toolbar removes the currently active display filter, displaying all captured packets.
  • “Save” Button (Filter Toolbar): Clicking the “Save” button (often a bookmark icon) allows you to save the currently entered display filter for later reuse. This opens the “Display Filter Expressions” dialog.
  • “Display Filter Expressions” Dialog (Analyze > Display Filters…): This dialog allows you to manage your saved display filters. You can add new filters, edit existing ones, delete filters, and apply them directly.
  • “Apply as Filter” (Right-Click Context Menu and Main Toolbar): When you select a packet or a specific field in the Packet Details Pane, right-clicking often provides an “Apply as Filter” submenu. This allows you to automatically create a display filter based on the selected packet or field value (e.g., filter by source IP, destination port, protocol). The Main Toolbar also sometimes has an “Apply as Filter” dropdown for quick filter creation.
  • “Prepare a Filter” (Right-Click Context Menu): Similar to “Apply as Filter,” the “Prepare a Filter” option in the right-click context menu allows you to build a filter based on the selected packet or field, but instead of immediately applying it, it populates the Filter Toolbar with the expression, allowing you to further refine it before applying.
  • Coloring Rules Editor (View > Coloring Rules…): While primarily for visual highlighting, coloring rules are based on filter expressions. The Coloring Rules editor provides a way to create and manage rules that automatically color-code packets based on specific filter criteria.

By understanding the syntax of both capture and display filter expressions and effectively utilizing the buttons and interface elements provided by Wireshark, you can significantly enhance your ability to isolate and analyze the network traffic that is most relevant to your investigations.

Finding and Marking Packets
OSI Model Introduction

Get industry recognized certification – Contact us

keyboard_arrow_up
Open chat
Need help?
Hello 👋
Can we help you?