Lab 1
Lab 1
Details
Aim: To provide a foundation for using the WinPcap packet capture library, for reading
data packets from a network interface card (NIC). The lab will use the C# high level
programming language, from the MS Visual Studio IDE, to access the WinPcap
library.
Outline
In this lab Visual Studio will be used to create a basic C# .NET application, to harness the
WinPcap packet capture library, to interrogate the NICs on the local machine.
WinPcap is an open source code library which can be used for packet capture and network
analysis. It can give direct access to the raw network traffic, without having to use high level
OS methods. WinPcap is used by network and network security tools such as packet
sniffers, IDS, network scanners, and network monitors.
Activities
Microsoft Visual Studio is required to complete the practical elements of the lab. It can be
downloaded from the Napier Software Portal.
If Visual Studio is installed on your machine, download the following solution to your
desktop:
Open the zip file, and extract the WinPcap1 folder to the Desktop using the Extract All
button and extract to the Windows Desktop, as shown below.
As Visual Studio starts, you may need to select the default environment. Select C#
environment if requested, as shown below.
Depending on the version of Visual Studio, you may be required to convert the code to
the latest version of C#.NET.
The C# application for this lab is a Windows Console Application, with input and
output from the user via a Console Window.
The code can be viewed by opening the C# code file (.cs file). The code panel should
contain the following code. The code uses the SharpPcap wrapper code (Gal, 2010),
which provides access to the WinPcap packet capture library.
using System;
using Tamir.IPLib;
namespace NapierCapture
{
public class ListNICs
{
public static void Main(string[] args)
{
int count=0;
The project is a Windows Console application, which when run, should create a
console window and display a list of the Network Interfaces on the local machine.
Run the application (F5 or the green run button), and verify that it produces a list of
the available network interfaces, such as the following:
Questions
Q: List the network interfaces in your machine, including index no. and Name:
Q: Look at the back of your PC, and identify the physical network cards.
The output should show the details of the network connections, as shown below:
Questions
Q: List some of the details of some of the network interfaces on your machine