๐ŸŒ
B.TECH III YEAR โ€ข I SEMESTER โ€ข R22

Computer Networks - Lab Manual

Computer Networks Laboratory โ€ข Program Solution

๐Ÿ“˜ R22 Regulation ๐ŸŽ“ III Year ๐Ÿ“š I Semester ๐ŸŒ Computer Networks ๐Ÿงช Lab Program
Selected Program

Wireshark

โ† All Computer Networks Programs

Wireshark :


Introduction

Wireshark is a free and open-source packet analyzer. It captures the packets that pass through a network interface and displays the contents of every protocol layer (Ethernet, IP, TCP/UDP and application protocols such as HTTP, DNS, ARP and ICMP). It is used for network troubleshooting, protocol analysis and learning how the protocols work.

Note: capture packets only on networks that you own or are authorised to monitor.

i. Packet Capture Using Wireshark

A packet capture is a recording of the frames that arrive at (or leave) a network interface. Wireshark uses the libpcap / Npcap library to put the interface in capture mode.

Installation:

# Ubuntu / Debian
sudo apt update
sudo apt install wireshark

# allow a normal user to capture (log out and log in again afterwards)
sudo usermod -aG wireshark $USER

# Windows / macOS: download the installer from https://www.wireshark.org/download.html

ii. Starting Wireshark

Steps:

  1. Start Wireshark (from the applications menu, or type wireshark in a terminal).
  2. The Capture home screen lists all available interfaces (for example Wi-Fi, Ethernet, loopback). The small graph next to an interface shows its live traffic.
  3. Select the interface that carries your traffic (double-click it, or select it and click the blue shark fin button) to start the capture.
  4. Generate some traffic: open a web page, run ping 8.8.8.8 or run nslookup studyglance.in.
  5. Click the red Stop button to stop the capture.
  6. Save the capture with File → Save As (extension .pcapng).

To capture from a terminal (no GUI), the command-line tool tshark can be used:

# capture 20 packets on interface eth0
sudo tshark -i eth0 -c 20

# save the capture to a file
sudo tshark -i eth0 -c 100 -w capture.pcapng

iii. Viewing Captured Traffic

The main window is divided into three panes:

PaneWhat it shows
Packet List (top)One line per packet: No., Time, Source, Destination, Protocol, Length and Info.
Packet Details (middle)The selected packet as a tree of protocol layers: Frame, Ethernet II, Internet Protocol, TCP/UDP and the application protocol. Each layer can be expanded to see its header fields.
Packet Bytes (bottom)The raw bytes of the packet in hexadecimal and ASCII. Selecting a field in the details pane highlights its bytes.

Useful actions:

iv. Analysis and Statistics & Filters

Display filters

A display filter is typed in the filter bar (just below the toolbar) and hides all packets that do not match. It can be applied to a capture that has already been recorded.

Display filterMeaning
ip.addr == 192.168.1.10Packets to or from the host 192.168.1.10
ip.src == 192.168.1.10Packets whose source address is 192.168.1.10
tcp.port == 80TCP packets using port 80
udp.port == 53 or dnsDNS traffic
httpHTTP packets
icmpICMP packets (for example ping)
arpARP requests and replies
tcp.flags.syn == 1 && tcp.flags.ack == 0TCP connection requests (first packet of the three-way handshake)
http.request.method == "GET"HTTP GET requests
frame contains "student"Packets that contain the text "student"
!(arp or icmp)Everything except ARP and ICMP

The filter bar turns green when the filter is valid and red when it is not. Operators: ==, !=, >, <, && (and), || (or) and ! (not).

Capture filters

A capture filter (BPF syntax) is set before the capture starts (Capture → Options) and decides which packets are recorded at all.

host 192.168.1.10
port 80
tcp
udp port 53
net 192.168.1.0/24
tcp and port 443

Statistics

The Statistics menu summarises a capture:

Observation

Record the following in the lab record: the interface used, the display filters applied with a screenshot of the result, the Protocol Hierarchy of the capture, and the packets of one TCP three-way handshake (SYN, SYN-ACK, ACK) with their sequence numbers.

โ† Back to Computer Networks Lab Programs ๐Ÿ“š All Lab Manuals