© The Author(s), under exclusive license to APress Media, LLC, part of Springer Nature 2022
V. JainWireshark Fundamentalshttps://doi.org/10.1007/978-1-4842-8002-7_2

2. Getting Familiar with Wireshark

Vinit Jain1  
(1)
San Jose, CA, USA
 

Network administrators and security analysts often work packet captures to analyze the traffic and determine the cause of network events and attacks in the network. With Wireshark being the preferred tool to capture and analyze network traffic, it is important to have an understanding of how to use Wireshark’s features and know about its options. This chapter focuses on various features and options available in Wireshark.

This chapter covers the following topics:
  • Overview of Wireshark tool

  • Performing packet capture using Wireshark

  • Working with Wireshark capture files

  • Analyzing packets in Wireshark

Overview of Wireshark Tool

In the previous chapter we learned about what Wireshark is and how to install Wireshark on various OSs. In this chapter, we focus on how to use the Wireshark tool. After Wireshark is installed, you can open the Wireshark tool using the Wireshark shortcut from the installed applications list. Before diving into how to use Wireshark, let’s take a closer look at the user interface (UI) , which is shown in Figure 2-1.
Figure 2-1

Wireshark user interface

Wireshark Preferences

There are numerous settings that a user can customize when using Wireshark. All these settings can be changed from the Preferences window. To open the Preferences window, navigate through the following menu:
  • Mac: Wireshark | Preferences

  • Windows: Edit | Preferences

  • Linux: Edit | Preferences

From the Preferences window, users can change the settings for the following sections.

Appearance

The Appearance section of the Wireshark preferences allows you to change the UI settings of Wireshark. In this section, you can adjust the text for the window title, specify the columns that you want to see when using Wireshark, and set the font and colors and the layout of Wireshark UI. For instance, if you want to change the default layout of Wireshark to a layout that is more comfortable for you, you can change what information the different panes in the layout will display. Figure 2-2 displays the modified layout where Pane 1 displays the packet list, Pane 2 displays the packet details, and Pane 3 displays the packet bytes in the layout that you selected in the Preferences window.
Figure 2-2

Custom Wireshark layout

Capture

The Capture section allows you to select the default interface that Wireshark will use for capturing traffic. Users can also select other settings in this section:
  • Enable or disable the option to capture packets in promiscuous mode

  • Enable or disable the option to capture packets in pcapng format

  • Enable or disable the option to update the list of packets in real time

  • Enable or disable the option for automatic scrolling when capturing live packets

  • Enable or disable the option to not load interfaces on startup

  • Enable or disable the option to disable external capture interfaces

Expert

The Expert section of the Wireshark Preferences window allows you to define different field names and set the severity for those fields.

Note

The Expert section is covered later when covering Expert Information.

Filter Buttons

The Filter Buttons options allow the user to create custom shortcuts on the toolbar for various filter expressions. By using these buttons, users don’t have to repeatedly type the filter expressions; instead they can just click the button to apply the filter on the captured traffic. Figure 2-3 displays how to create a filter button for the HTTP GET method.
Figure 2-3

HTTP GET filter button

Name Resolution

The Name Resolution settings allow users to update the settings with regard to MAC address resolution and transport and network address resolution. These settings also allow users to use Domain Name System (DNS) packets for address resolution, use an external network name resolver, and also use the list of DNS servers for name resolution. The Name Resolution section also has options to list the DNS servers that can be used by Wireshark.

Protocols

The Protocols section of the Preferences window allows the user to configure settings for various lists of protocols supported by Wireshark. This is useful for analyzing traffic in network environments where the protocols are being used ports different than the default port numbers.

RSA Keys

The RSA Keys section allows user to configure the RSA private keys for decryption. In this section, use the Add New Keyfile button to select a file. The user will be prompted for a password if necessary. The Add New Token button can be used to add keys from a hardware security module (HSM), which might require using Add New Provider to add a vendor-specific configuration.

Statistics

This section allows you to customize the settings used by Wireshark to perform and display statistical analysis of the captured traffic. Settings such as burst rate resolution, burst rate window size, tab update interval, and so on, can be configured under this section.

Advanced

The Advanced section of the Preferences window allows user to view and edit all Wireshark preferences. If you are familiar with about:config in Firefox or chrom:flags in the Chrome web browser, then making changes using the Advanced pane will be a walk in the park. Users can search for a preference by typing text in the Search box on this window as shown in Figure 2-4.
Figure 2-4

Wireshark Advanced preferences

Performing Packet Capture Using Wireshark

When the Wireshark application is launched, a welcome screen displays options to either open old files or to start a new packet capture on the current device. In the Capture section, all the wired, wireless, and virtual network interfaces that can be selected to begin the packet capture immediately are listed. Alternatively, users can go to the Capture menu and then select the Option submenu. This will open the Wireshark – Capture Options window shown in Figure 2-5, which has three tabs:
  • Input: This tab displays all the interfaces. You can enable the listed network interfaces and select one of the interfaces on which you wish to capture incoming and outgoing packets.

  • Output: This tab allows the user to edit the output settings, such as the output format, permanent file name where the packet capture will be saved, and also options to save the captured traffic into a new file by limiting the number of packets, file size, duration, and so on.

  • Options: The Options tab gives you options to set the display settings of the captured packets, such as updating the list of packets in real time, automatic scrolling during live capture, and showing capture information during live capture. It also has options for name resolution such as resolving MAC addresses, network names, and transport names. Users can also define the settings for when they can stop the packet capture.

Figure 2-5

Wireshark - Capture Options window

Once all the capture options are set, users can click the Start button to begin the packet capture. It is important to note that you can capture traffic on interfaces that are in promiscuous mode. This mode allows you to see all the traffic coming into the NIC. In Figure 2-5, notice that all the listed interfaces have promiscuous mode enabled.

Note

To perform on Mac OS, users are required to install the ChmodBPF application. By default, users on Mac OS do not have privileges or permission to capture traffic on local interfaces. Once the ChmodBPF daemon is launched, it creates the access_bpf group and adds the user to that group. Similarly, on Windows, Wireshark requires either Npcap or WinPcap to capture live network traffic.

Dissectors

As most of you might already know, traffic enters the NIC in binary format. Wireshark uses the Enhanced Packet Analyzer (EPAN), which decodes the binary data into human-readable format. EPAN is the main core of the Wireshark tool. It is the packet analyzer engine that uses dissectors to re-create the protocol packets from the binary data. EPAN primarily consists of four components:
  • Protocol tree: Performs detailed analysis of a single packet.

  • Dissectors: Hold the information from the Request for Comment (RFC) and other specifications on how to decode and interpret fields of different protocol packets.

  • Dissector plug-ins: Allows the use of default dissectors that come with Wireshark and also allows the use of user-created dissector plug-ins.

  • Display filters: – Provide options to perform filtering on captured data.

Dissection of any packet can be broken down into a few simple steps:
  1. 1.

    Wireshark identifies the frame type of any incoming packet and hands it off to the correct frame dissector, for instance, Ethernet.

     
  2. 2.

    The dissector breaks down the contents of the frame header to understand which section to look up next. For instance, Ethernet type 0x0800 in the Type field of the Ethernet header indicates Internet Protocol version 4 (IPv4). Wireshark then hands off the packet to the IP dissector.

     
  3. 3.

    After the IP dissector decodes the IP header, it identifies the next protocol header by looking at the Protocol field in the IP header. If the value is 0x06 it hands off the packet to the TCP dissector. If the value is 0x11, it hands off the packet to the User Datagram Protocol (UDP) dissector.

     
  4. 4.

    This process is followed until there are no further dissections identified by the current dissector.

     
Although Wireshark is a very mature application and supports a wide range of protocol specifications and dissectors, there might still be scenarios where you are required to guide Wireshark on how to decode a protocol. For such scenarios, users can simply right-click the frame and select the Decode-As option. This option will open the window shown in Figure 2-6. Using this window, a user can select the field type from which the user can select any of the options such as a TCP port, a UDP port, and so on. Once that is selected, the user can then define the value and then map the field and value to a particular protocol from the drop-down list in the Current column. For example, let’s presume that Wireshark does not understand a Virtual Extensible Local Area Network (VXLAN) packet. When Wireshark receives such a packet, the user can select the packet and choose UDP port as the Field, set the Value to port 4789, and in the Current column, map the packet to the VXLAN protocol. This setup is shown in Figure 2-6.
Figure 2-6

Wireshark - Decode As

This feature comes in very handy when the network administrators are running the protocols on a port numbers other than their defaults.

Configuration Profiles

Wireshark allows users to define and maintain configurations and preferences in the form of configuration profiles. Wireshark comes with four predefined configuration profiles:
  • Default: Default profile

  • Bluetooth: Global profile

  • Classic: Global profile

  • No Reassembly: Global profile

The configuration profiles store the following set of information:
  • Preferences

  • Capture filters (cfilters)

  • Display filters (dfilters)

  • Coloring rules

  • Disabled drotocols

  • User accessible tables (e.g., custom HTTP headers, custom LDAP AttributeValue types, etc.)

  • Dissector assignments (decode_as_entries)

  • Recent settings such as pane sizes, column widths, and so on

Users can create custom profiles in few simple steps.
  1. 1.

    On the Edit menu, click Configuration Profiles. This opens the Configuration Profiles dialog box.

     
  2. 2.

    In the Configuration Profiles dialog box, click the + icon to add a new profile. For example, let’s create a configuration profile named Network Profile. This profile will be of type Personal. The newly created profile is created with the default settings that are part of the Default profile.

     
  3. 3.

    Select the Network Profile and click OK.

     

Once the custom profile is created and selected, all the preferences and other settings such as capture or display filters will be saved under the custom configuration profile.

Filtering with Wireshark

When packet capture is performed using Wireshark, all the incoming and outgoing traffic on the selected NIC is captured. This limits the user to capturing a huge amount of packets on high-speed as well as high-traffic links. Although capturing more data is never bad, it could also lead to other issues:
  • Crashing of Wireshark application due to large file size

  • Longer time needed to load and analyze the captured packets

  • Might not be able to capture problematic traffic during a short time span due to higher packet per second (pps) rate

Filtering in Wireshark can be of two types:
  • Capture filter: This is used to filter or restrict the packets that will be captured by Wireshark.

  • Display filter: This is used to filter the packets from the captured traffic.

We next discuss both these filtering capabilities in detail.

Capture Filters

As stated previously, the capture filter in Wireshark is used to limit the packets that can be captured during a live capture. This means that the capture filter cannot be applied on existing packet capture or pcap files. In scenarios where the network is busy with heavy traffic or during network troubleshooting when a user wants to capture a specific packet, capture filters are a very useful feature. Capture filters are applied on the packets after they are processed by WinPcap in a Windows installation or the libpcap library in a Linux installation. Once the packets are passed through the filter criteria, they are then passed to the Wireshark capture engine as shown in Figure 2-7. Note that once the packets are parsed through the capture filter, only the filtered packets are received by the capture engine. The remaining packets are dropped and discarded before being sent to the capture engine.
Figure 2-7

Wireshark capture filter

Capture filters follow the Berkeley Packet Filtering (BPF) syntax , which is also used by Tcpdump. Wireshark comes with default capture filters named cfilters that are stored in the Wireshark application or program file directory. Wireshark comes with the default capture filters shown in Table 2-1.
Table 2-1

Default Wireshark Capture Filters

Filter Name

Filter Config

Ethernet address 00:08:15:00:08:15

ether host 00:08:15:00:08:15

Ethernet type 0x0806 (ARP)

ether proto 0x0806

No Broadcast and no Multicast

not broadcast and not multicast

No ARP

not arp

IPv4 only

ip

IPv4 address 192.0.2.1

host 192.0.2.1

IPv6 only

ip6

IPv6 address 2001:db8::1

host 2001:db8::1

TCP only

tcp

UDP only

udp

Non-DNS

not port 53

TCP or UDP port 80 (HTTP)

port 80

HTTP TCP port 80

tcp port http

No ARP and no DNS

not arp and port not 53

Non-HTTP and non-SMTP to/from www.​wireshark.​org

not port 80 and not port 25 and host www.wireshark.org

Users can also create custom cfilters that can be part of the default profile or a custom profile. Let’s now create a custom capture filter for capturing only VXLAN traffic. To filter VXLAN encapsulated traffic, we can simply filter on UDP port 4789. This filter can be created in a few simple steps:
  1. 1.

    Go to the Capture menu and select Capture Filters to open the Capture Filters dialog box.

     
  2. 2.

    In the Capture Filters dialog box, click the + icon, which will add an entry at the end of the existing default list.

     
  3. 3.

    Edit the name of the filter and set it to VXLAN only and then edit the Filter Expression and set it to udp port 4789.

     
  4. 4.

    Click OK to save.

     
  5. 5.

    Once saved, go to the Capture menu and select Options. This will open the Wireshark Capture Options dialog box.

     
  6. 6.

    In this dialog box, click the green bookmark icon next to Capture Filter for Selected Interfaces. This displays the list of all capture filters that are available. Select the VXLAN Only option as shown in Figure 2-8.

     
  7. 7.

    Once the interface and capture filter are selected, click Start to start the capture.

     
Figure 2-8

Selecting a customdefined capture filter

You will now notice that only the VXLAN packets are being captured in Wireshark. This method of capturing packets has the benefit of capturing only specific traffic, but if the user is unsure about which traffic to capture, it might be a better option to use display filters.

Display Filters

Most traffic analysis is performed during live traffic or on precaptured packet captures. To analyze traffic in both these scenarios, display filters can help users easily narrow down the problematic traffic quickly by applying the filter criteria on the packets. Display filters enable users to focus on specific packets based on the filter expressions that are specified. There are several ways of creating display filters:
  • Typing the display filter criteria with the help of auto-complete

  • Applying saved display filters

  • Using expressions

  • Right-clicking the filter

  • Applying conversation or endpoint filters

Before moving on to checking different ways of implementing display filters, let’s talk about the syntax for display filters. Wireshark uses a proprietary Wireshark display filter that is different than the capture filter’s BPF format. Even though the syntax for both capture and display filters is different, there are a few examples where the syntax for both of them happens to be the same. For instance, the syntax for filtering TCP traffic on both filters is specifying the tcp keyword. Figure 2-9 illustrates how the packets are filtered after applying the display filter for TCP traffic. Notice that in this example, there are 76 packets that have been identified and filtered for TCP traffic out of 1,452 packets.
Figure 2-9

Filtering packets using a display filter

Display filters can be relatively simple or quite complex. It all depends on the display filter expression. Users can perform simple filtering by specifying the protocol traffic that they want to filter. For instance, Table 2-2 displays a sample list of packets that can be filtered with just a single filtering keyword.
Table 2-2

Simple Display Filters

Filter Config

Filter Description

tcp

Filtering only TCP packets

udp

Filtering only UDP packets

ip

Filtering only IPv4 traffic

ipv6

Filtering only IPv6 traffic

arp

Filtering only ARP broadcast packets

dns

Filtering only DNS packets

Display filters also allow users to filter packets based on packet characteristics. For instance, if a user wants to filter packets that have an invalid IP header checksum, they can simply set the display filter to ip.checksum_bad.expert. Note that by packet characteristics we do not mean an actual field in the headers. Some examples of display filters based on packet characteristics are listed in Table 2-3.
Table 2-3

Display Filters for Packet Characteristics

Filter Config

Filter Description

tcp.analysis.flags

Displays packets that contain one of the TCP analysis flags packets

tcp.bogus_header_length

Filters TCP packets that have bogus header length in the TCP header

ip.bogus_header_length

Filters packets that have bogus header length in the IP header

The display filters provide an option to filter more specific packets by the use of expressions. Expressions allow users to define filters based on the contents of a field and matching specific values that can be set using comparison operators. Display filters can also be a combination of two or more expressions that are evaluated based on the evaluation operators. The operators that can be used with display filters are listed in Table 2-4.
Table 2-4

Operators for Display Filters

Operators

Operator Description

==

Exactly matches the specified value

>

Matches when the value of the field is greater than the specified value

<

Matches when the value of the field is less than the specified value

>=

Matches when the value of the field is greater than or equal to the specified value

<=

Matches when the value of the field is less than or equal to the specified value

!

Filters all the values of the field that do not match the specified expression

!=

Filters all the values that do not match the specified value

&&

Allows AND operation between two different expressions; filters the packets that match all the specified expressions

||

Allows OR operation between two different expressions; filters the packets that match any of the two expressions

Let’s now examine how we can use these operators to create expressions for display filters. Table 2-5 displays a list of expressions for filtering various types of traffic.
Table 2-5

Expressions for Display Filters

Filter Expressions

Filter Description

http.request.method == "POST"

Filters traffic that includes the HTTP POST method in the HTTP headers

tcp.window_size < 1500

Matches packets that have TCP window size less than 1,500

dns.qry.name == "www.google.com"

Filters DNS queries for www.google.com

udp.port != 686

Filters out packets that do not match UDP port number 686

(arp.opcode == 0x0001) && (arp.src.hw_mac == 00:01:ab:cd:0e:02)

Displays ARP request only from MAC address 00:01:ab:cd:0e:02

(tcp.flags.syn == 1) && !(tcp.flags.ack == 1)

Displays packets that have the TCP SYN bit set but do not have the TCP ACK bit set.

(icmp.type == 3) && ((icmp.code = 0x01) || (ip.addr == 192.168.100.1))

Displays Internet Control Message Protocol (ICMP) unreachable packets where the host is unreachable or either the source or destination address is 192.168.100.1

Because there is a different set of fields within each header, it is nearly impossible to remember all the fields to create the display filters. Wireshark comes with an auto-complete feature that helps users to create filters. Users are only required to know the top-level header and the Wireshark Intellisense or auto-complete feature kicks in as soon as any character is typed. The Wireshark auto-complete feature displays all the available options within that header that can be used to create the filter. For example, if the user wants to check for any traffic with destination port 53 or DNS traffic, the user can just type in tcp and it will display all the available options. In this case, the option would be tcp.dstport, as shown in Figure 2-10. Once the user identifies the right filter option, he or she can then complete the expression by using the comparison operators. For this example, the display filter is tcp.dstport == 53.
Figure 2-10

Display filter using auto-complete

Users are also allowed to select display filters from previously used filters or save their display filter like a capture filter. To use the previously searched display filter, use the drop-down list seen at the end of the display filter bar. To save the current display filter, use the bookmark icon at the beginning of the display filter area, as shown in Figure 2-11. The drop-down list shows the default display filters available as well as other options to save or manage the display filters. Selecting the Save This Filter option opens the Display Filters dialog box. There you can click the + icon to add the current display filter.
Figure 2-11

Display filter bookmarks and options

Another quick method of filtering the packets is using the right-click filtering method. While navigating through the list of packets, if you come across a packet that looks suspicious or you are interested in checking out similar packets, you can simply right-click the packet or field of interest and select either the Apply as Filter | Selected or the Prepare as Filter | Selected option as shown in Figure 2-12. The Apply as Filter | Selected option directly places the filter on the live traffic or captured packets, whereas the Prepare as Filter | Selected option prepares the display filter and gives the user an option to edit the filter before it is applied on the live traffic or captured packets.
Figure 2-12

Right-click filtering

Within both Apply as Filter | Selected and Prepare as Filter | Selected, users can choose from one of the available filter options:
  • Selected: Creates a filter matching the selection

  • Not Selected: Creates an exclusion filter

  • And Selected: Must match both the existing filter and the selection

  • Or Selected: Must match either the existing filter or the selection

  • And Not Selected: Must match the existing filter with the exclusion of the selection

  • Or Not Selected: Must match either the existing filter or filter based on the exclusion of the selection

Users can also leverage the Copy | As Filter feature available in Wireshark as part of right-click filtering. This feature allows users to copy the filter expression without applying or listing the filter in the display filter pane. This feature can be very useful for creating complex display filters or for copying filters between different Wireshark instances where we want to trace the packets across multiple capture files.

Although there are many ways of creating display filters, one of the features that really stands out in Wireshark is its ability to catch errors or mistakes in display filters, which prevents users from applying the wrong display filters on the packet captures. The display filter pane turns red and disables the option to apply a filter if there is an incomplete or incorrect display filter expression typed in the pane.

Working with Wireshark Capture Files

As stated before, Wireshark captures network traffic and allows the user to save the packets with either .pcap or .pcapng extensions. The pcap file format is the initial version of the file format that was originally implemented in UNIX and Linux using the libcap library. This file format was implemented in Windows using the WinPcap library. The pcapng file format was the result of an Internet Engineering Task Force (IETF) draft that specifies the PCAP Next Generation (pcapng) Capture File Format. Through this IETF draft, the proponents defined standardized blocks and fields, thus making the pcapng format a more extensible and futureproof file format.

PCAP vs. PCAPng

There are several differences between the pcap and pcapng file formats, some of which are listed in the sections that follow.

Capture from Multiple Interfaces

The pcap format contains some information about the capture interface but does not have support for multiple interfaces. This is because the interface information is included as part of the common header and not stored on a per-packet basis, making it difficult to capture traffic from multiple interfaces in the same capture file. On the other hand, the pcapng file format supports multiple interfaces by using the interface description block defined in the PCAP Next Generation (pcapng) capture file format IETF draft. Using the interface description block, each packet can be associated with a specific interface. Figure 2-13 displays the interface description block as defined in the IETF draft. Note that the block type of the interface description block is 1 (0x00000001).
Figure 2-13

Interface description block

Note

A simple packet block, which is a smaller and simpler packet block that is easy to process and contains a minimal set of information, does not contain the Interface ID field and is thus set to a default value of 0. With a simple packet block, it is assumed that the packets have been captured on the interface that was previously specified in the first interface description block.

When a packet capture is initiated for multiple interfaces, a user can see the packet of each interface in the pcapng file using their interface_id field. Figure 2-14 displays the packets belonging to interface id 1, which in this case is a loopback interface (IP address 127.0.0.1) of the PC itself.
Figure 2-14

Packets with interface id 1

Timestamps

With pcap format, one of the major concerns for network analysts was its resolution on packet timestamps. Each packet in the pcap format has a time resolution accurate to the microsecond level (i.e., 10-6 seconds), which provides a resolution for 999,999 packets per second. On first look, this number looks reasonable, but with the modern-day networks evolving to 25 Gig, 40 Gig, and 100 Gig links, microsecond-level accuracy can create a huge gap. It is imperative to note that even a common 1 Gig link can easily exceed this link. The pcapng file format provides the capability to adjust the resolution using a flexible timestamp format, which is now expressed as a 64-bit time unit that can easily accommodate evolving network speeds. The default resolution value on packet timestamps is still given in microseconds, but this can be altered by setting the if_tsresol option in the interface description block.

Embedding Comments

Troubleshooting networks can be complex and time consuming and could be further delayed when information is shared across peers or customers. The pcapng format allows the user to embed both top-level and per-packet comments that can be helpful when traces are shared across multiple users for analysis. To add a comment to a packet, select a packet and right-click to choose the Packet Comment option. Once selected, this opens a window that will allow the user to add a comment on the packet, as shown in Figure 2-15.
Figure 2-15

Adding comments on a packet

Once the comment is added, the packet headers will also have a packet comments section added at the top, as shown in Figure 2-16.
Figure 2-16

Packet headers with comments

To add top-level comments or file-level comments, go to Statistics | Capture File Properties. This opens a window that includes a Capture File Comments section. Users can add the comments and then click Save Comments to save the top-level comments.

Metadata

Additional information is always useful when investigating network issues. Although adding top-level and per-packet comments can be extremely useful, additional information such as the source of the packet capture can be very useful. With pcapng, additional fields such as a description field, OS field, and filter field within the interface description block can provide additional information regarding the capture source.

Extendable Format

Because the pcapng format is standardized and deploys a generic block structure, it allows the format to evolve over time. In pcapng, specific blocks are defined for packets (enhanced packet block or simple packet block) and interfaces (interface description block). Additional information such as metadata can be stored in other optional blocks, such as a name resolution block or interface statistics block. With the options to define experimental blocks and metadata, pcapng allows organizations to develop their own customized yet compatible network analysis tools.

Splitting Packet Captures into Multiple Files

When capturing network traffic on high-speed links, the Wireshark file size can increase rapidly. This could increase the loading time when the packet capture file is opened for analysis. To overcome this challenge, network administrators or analysts can adjust the capture options in Wireshark to automatically split the packet captures into multiple files. Follow these simple steps to do that:
  1. 1.

    On the Capture menu, select Capture Options. This opens the Capture Options window in Wireshark.

     
  2. 2.
    In the Capture Options window, click the Output tab.
    • On the Output tab, set the capture file from under Capture to a Permanent File by clicking Browse and specifying the file name. Click Save.

    • Choose the output format. The default option is pcapng.

    • Select the Create a New File Automatically check box.

    • You can then select one or multiple options to decide which factors will trigger the creation of a new file. For instance, you can select an option to create a new file after the file has reached 100 packets, as shown in Figure 2-17.

     
  3. 3.

    Once these options are selected, click Start.

     
Once you have completed the capture and stopped the capture, you will notice that multiple files have been created.
Figure 2-17

Splitting packet capture into multiple files

Merging Multiple Capture Files

While splitting helps load the packet capture files quickly, merging is required to analyze the packets, especially in scenarios where captures are taken from multiple interfaces or when the packet stream is split across multiple capture files. The Wireshark merge option tries to merge the files based on one of the following selected options:
  • Prepend Packets: Prepends the packets from the selected file before the currently loaded packets.

  • Merge Chronologically: Merge packets from both opened and selected files in chronological order. This option is selected by default.

  • Append Packets: Appends the packets from the selected file after the currently loaded packets.

To merge multiple files, few simple steps can be followed:
  1. 1.

    Open or load a packet capture file on Wireshark.

     
  2. 2.

    On the File menu, select Merge to open the Merge dialog box.

     
  3. 3.

    Select the file that you want to merge with the opened file, as shown in Figure 2-18.

     
Figure 2-18

Merging multiple capture files

Once the packets are merged, the user can then save the merged file with the same or a different name.

Analyzing Packets in Wireshark

Now that we have learned about the basics of the Wireshark UI, how to perform a packet capture, and how to work with capture files, the next step is learning how to analyze the packets using Wireshark. Before we jump into analyzing the packets, there are few critical factors that must be kept in mind, and this goes back to the question of why we need to analyze the packets. Usually, network packet analysis is done when there is a problem in the network and we need to tackle get to the root of any network event. For instance, Company ABC is seeing some anomaly in their network behavior, and they want to investigate what is causing the problem. To get to the root cause of the anomaly, network administrators or security analysts might begin by asking few basic questions such as these:
  1. 1.

    When did the problem start?

     
  2. 2.

    What is or was the trigger for the problem?

     
  3. 3.

    Can we re-create the problem?

     
  4. 4.

    Does the problem happen at a particular time in the day?

     
  5. 5.

    How frequently does the problem occur in the network?

     
  6. 6.

    What kind of traffic is affected?

     
  7. 7.

    Is the issue currently occurring?

     
  8. 8.

    To which segment of the network is the problem isolated?

     
  9. 9.

    How many network users are affected due to the given problem?

     
All these questions, though, might or might not directly answer why we need to perform packet analysis, but these questions will always help get to the bottom of the problem or at least one or few steps closer to it. Out of these questions, the answers to questions 2, 3, 4, 5, 6, and 7 are required when performing network analysis by performing packet captures at different points in the network. If you do not know the answer to question 8, you will eventually find the answer to that question while investigating any network event. Even though, there can be several reasons for performing packet analysis, it is usually done for two primary reasons:
  • Baselining the network

  • Troubleshooting a network issue (e.g., packet loss, latency issue, network attack, etc.)

OSI Model

Before diving into the steps involved in performing packet analysis, it is important to understand the Open Systems Interconnection (OSI) model. The OSI model was developed by the International Organization for Standardization (ISO) in 1984 with the sole intent of standardizing the communication functions of a telecommunications or computing system irrespective of its underlying structure and technology. The OSI model helps with interoperability across different computers or network devices.

The OSI model outlines the data flow in a network device (or a communication system) through its seven abstraction layers, as shown in Figure 2-19.
Figure 2-19

OSI model

Each layer in the OSI model defines different functions, as listed in Table 2-6.
Table 2-6

OSI Model Layers and Their Functions

Layer

Functions

Physical layer

Transits and receives raw bit streams over a physical medium

Examples: 1000BaseTX, ISDN, etc.

Data Link layer

Provides reliable transmission of data frames between two devices connected via the physical layer

Examples: Ethernet, Frame Relay, ATM, etc.

Network layer

Provides mechanism for structuring and managing a multinode network. The network layer takes care of IP/IPv6 addressing, routing protocols, and traffic control.

Examples: IPv4, IPv6, ICMP, IPSEC

Transport layer

Provides reliable transmission of data segments between two points in a network through transport layer protocols.

Examples: TCP and UDP

Session layer

Manages communication sessions.

Examples: NetBIOS, SAP

Presentation layer

Also known as the Translation layer; Provides three primary functions:

Translation

Encryption/decryption

Compression

Examples: SSL, TLS, MPEG

Application layer

Provides high-level application programming interfaces (APIs) including resource sharing and remote file access.

Examples: FTP, SMTP

To enable communication across each layer, communication protocols enable the communication between two hosts on the same corresponding layer. We learn more about these communication protocols in the coming chapters.

Analyzing Packets

Wireshark organizes the captured packets in an incredibly easy-to-read packet list pane. Once the packets are captured, and if users want to identify the details of the packet, all they need to do is find the packet and click on it. On clicking any packet in the packet list pane, the details about the structure of the packet along with all its fields are visible in the packet details pane. The details displayed in the packet details pane make it incredibly easy to learn and understand more about the packet.

To start analyzing the packets, it is important to first understand the different columns available in the Wireshark UI. Figure 2-20 displays the Wireshark UI and information present across various columns in the packet list pane.
Figure 2-20

Wireshark user interface

Here are high-level details about the various columns available at the top of the packet list pane.
  • No.: This column displays the number order of the captured packet. If there is a bracket displayed along with the packet number, it indicates that the packet is part of the conversation.

  • Time: This column displays how long after the packet capture was started each packet got captured.

  • Source: This column displays the source address of the system from where the packet originated.

  • Destination: This column displays the address of the destination device or host for which the packet is destined.

  • Protocol: This column displays the type of each packet; for instance, TCP, ICMP, DNS, and so on.

  • Length: Displays the length of each packet in bytes.

  • Info: This column displays more information about the packet and could have varied information from packet to packet.

Out of these fields, the Time and Length fields require a bit more explanation, as the rest of the fields are self-explanatory.

Time

As packets are captured in Wireshark, each packet is timestamped. These timestamps are available for each packet in the packet list pane, which can be further used for analysis. It is important to note that the timestamps are created by the Npcap library, but the source of the timestamps is the system’s kernel. That is the primary reason timestamps can vary from file to file. Users can choose from one of the following time precision formats in which they wish the timestamps to be displayed:
  • Seconds

  • Tenths of a second

  • Hundredths of a second

  • Milliseconds

  • Microseconds

  • Nanoseconds

Apart from choosing the format of the timestamps, user can also change the display format of the Time column. Users can right-click the column and select the Edit Column option from the menu. That opens a column edit pane just below the display filter bar. In this pane, users can select one of the following time format options from the Type field:
  • Time (format as specified); this is the default option

  • Absolute date, as YYYY-MM-DD, and time

  • Absolute date, as YYYY/DOY, and time

  • Absolute time

  • Delta time

  • Delta time displayed

  • Relative time

  • UTC date, as YYYY-MM-DD, and time

  • UTC date, as YYYY/DOY, and time

  • UTC time

After selecting one of these options, click OK in the edit column pane. Figure 2-21 displays the packet list pane with Time column displayed in UTC date and time option.
Figure 2-21

Wireshark with UTC date and time timestamps

Length

In Wireshark, the length column displays the number of bytes captured for that packet. The number of bytes usually corresponds to the raw data bytes listed at the bottom of the Wireshark window. Now, you must be wondering what is so significant about these captured bytes of the packet. The significance is the statistics that can be gathered from these captured bytes. Based on the captured bytes of each packet, users can examine the distribution of lengths across the captured traffic. To do so, users can go to the Statistics menu and select Packet Length. This will open the Packet Lengths window, which displays the statistical information for varied packet lengths and includes the following columns, as shown in Figure 2-22:
  • Packet Lengths

  • Count

  • Average

  • Min Val

  • Max Val

  • Rate (ms)

  • Percent

  • Burst Rate

  • Burst Start

Figure 2-22

Packet Lengths statistics

Capture File Properties

Wireshark provides a summarized view of the captured packets in the Capture File Properties dialog box. Users can select Capture File Properties from the Statistics menu. This opens the Capture File Properties dialog box, which shows when the first and the last packets were captured, the device hardware on which the packet was captured, interfaces on which the packets were captured, and statistics from the captured packets as shown in Figure 2-23:
  • Packets (total packets captured)

  • Time span (total time span for which the capture was running)

  • Average pps

  • Average packet size in bytes

  • Bytes

  • Average bytes/second

  • Average bits/second

Figure 2-23

Capture File Properties dialog box

There is other statistical and deep packet analysis that can be done, but those topics are covered in the coming chapters once we have built a more foundational knowledge on troubleshooting issues with different packet types.

Summary

In this chapter we gained a basic understanding of how to use the Wireshark tool and became familiar with its UI. Initially, we learned about Wireshark preferences and how users can change the default settings and UI according to their requirements and oreferences. We then learned how to perform packet captures and how dissectors play a role in Wireshark to break down packets into a more consumable format. We also covered various filtering techniques, such as capture filters, display filters, and how users can save the filters based on their usage. This chapter also discussed in detail the differences between the pcap and the pcapng file formats and the information available across these file formats. Finally, we concluded this chapter by learning how to analyze the packet using the Wireshark UI and how various statistical information can be identified from the captured packets.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.129.70.185