How to create an application that uses packet.dll
The creation of an application that uses packet.dll requires the following
steps:
- Include the file packet32.h at the beginning of every source file
that uses the functions exported by the dll. Packet32.h is
distributed both with the packet.dll source code and with the WinPcap
developer's pack. It is platform-independent.
- Include packet.lib in the project. Packet.lib is generated
compiling the packet driver and can be found in the developer's pack.
Remember that:
- To add a new library to the project with Microsoft Visual C++, you must
select Settings from the Project menu, then select Link
from the tab control, and then add the name of the new library in the Objcet/library
modules editbox.
- To add a new path where Microsoft Visual C++ will look for the libraries,
you must select Options from the Tools menu, then Link
from the tab control, library files from the show directories
for combobox, and the add the path in the directories box.
- To add a new path where Microsoft Visual C++ will look for the include
files, you must select Options from the Tools menu, then Link
from the tab control, include files from the show directories
for combobox, and the add the path in the directories box.
Sample programs
A couple of sample programs are provided to show how to use packet.dll. The
source code of the examples, along with all the files needed to compile and run
them, can be found in the Developer's
Pack.
Testapp
This is a very simple capture program that tests packet.dll. It is a console
application that once complied can be executed both under Win9x and under WinNTx.
When executed, testapp gives to the user the possibility to choose one of the
adapters installed on the machine, then it captures packets from the specified
network adapter until a key is pressed, dumping the content of each packet on
the screen.
Traffic Generator
This example shows how to use packet.dll to send packets to the network. It
receives three input parameters: the interface that will be used, the number of
packets to send and their size. The generated packets will have 1:1:1:1:1:1 as
source MAC address, and 2:2:2:2:2:2 as destination address. The 'multiple write'
feature of the driver is used to obtain a higher transmit rate.