Click here to Skip to main content
15,880,891 members
Articles / Programming Languages / C#
Article

RawSocket Class-Create Network Monitoring (Packet Sniffing) Apps

Rate me:
Please Sign up or sign in to vote.
4.83/5 (17 votes)
11 Apr 2002 252.9K   3.2K   71   50
A class for creating Network Monitoring Programs

Introduction

This program illustrates the use of the RawSocket class which is written in C#. The class RawSocket is a packet sniffing class that fires notification events when an IP packet is received. This makes using the class simple. Just declare your RawSocket object, instantiate it, and register to be notified when the event fires.

When the event fires, you are sent event arguments which give your program access to everything in the IP packet including things like IP addresses, port numbers, protocols, message lengths, and of course the message contents.

The included Windows form is a simplified example which basically just shows the origination and destination IP addresses for all incoming packets on a listbox control. The Rawsocket class makes creating more sophisticated network monitoring applications easy.

This program relies on Winsock 2 and runs only on Win2000 or WinXP.

Please email comments and improvements to:

Kember Brown
kbrown@internetcds.com

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
United States United States
Lyle is a computer programmer in Vancouver, Washington.

Comments and Discussions

 
GeneralSender Pin
Gary Brewer2-Apr-03 4:09
Gary Brewer2-Apr-03 4:09 
GeneralRe: Sender Pin
Anonymous18-Apr-03 5:12
Anonymous18-Apr-03 5:12 
GeneralRe: Sender Pin
Gary Brewer22-Apr-03 4:54
Gary Brewer22-Apr-03 4:54 
GeneralVB.net version Pin
Calamitous2-Sep-02 23:00
Calamitous2-Sep-02 23:00 
GeneralPackets length Pin
Pyt15-Aug-02 4:25
Pyt15-Aug-02 4:25 
GeneralRe: Packets length Pin
Lyle Smith15-Aug-02 6:39
Lyle Smith15-Aug-02 6:39 
GeneralRe: Packets length Pin
Pyt15-Aug-02 14:55
Pyt15-Aug-02 14:55 
GeneralRe: Packets length Pin
Lul Brown19-Aug-02 5:33
Lul Brown19-Aug-02 5:33 
The packet length on my machine was the same (1480.) I assumed that was normal (the packet sniffer doesn't control that.) I would have to check out a tcpip book to see what controls the packet length.

Lyle.
GeneralRe: Packets length Pin
Carver18-Sep-02 4:25
Carver18-Sep-02 4:25 
GeneralBug SIO_RCVALL Pin
17-Jun-02 9:45
suss17-Jun-02 9:45 
GeneralRe: Bug SIO_RCVALL Pin
Lyle Brown18-Jun-02 10:56
Lyle Brown18-Jun-02 10:56 
GeneralRe: Bug SIO_RCVALL Pin
summo17-Jan-03 5:19
summo17-Jan-03 5:19 
GeneralRe: Bug SIO_RCVALL Pin
Anonymous30-Jan-03 19:42
Anonymous30-Jan-03 19:42 
GeneralRe: Bug SIO_RCVALL Pin
SpaceQ18-Nov-03 21:55
SpaceQ18-Nov-03 21:55 
QuestionHow about a C++ version? Pin
McGarrah15-Apr-02 3:14
McGarrah15-Apr-02 3:14 
AnswerRe: How about a C++ version? Pin
Amit Dey15-Apr-02 6:03
Amit Dey15-Apr-02 6:03 
AnswerRe: How about a C++ version? Pin
Lyle Brown15-Apr-02 8:42
Lyle Brown15-Apr-02 8:42 
AnswerRe: How about a C++ version? Pin
5.5 cents25-Nov-03 21:28
suss5.5 cents25-Nov-03 21:28 
GeneralUnexplained Pin
Nick Parker13-Apr-02 1:55
protectorNick Parker13-Apr-02 1:55 
GeneralRe: Unexplained Pin
Lyle Brown13-Apr-02 13:30
Lyle Brown13-Apr-02 13:30 
GeneralSomething's missing Pin
Jason Douglas12-Apr-02 9:29
professionalJason Douglas12-Apr-02 9:29 
GeneralRe: Something's missing Pin
Nish Nishant12-Apr-02 17:50
sitebuilderNish Nishant12-Apr-02 17:50 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.