-
大小: 1.06MB文件類型: .rar金幣: 2下載: 0 次發布日期: 2023-11-05
- 語言: 其他
- 標簽:
資源簡介
這個程序利用Winpcap庫來捕獲IP數據包。在調試時注意:
1:務必將“Include”文件夾下的所有頭文件拷貝到VC安裝目錄下的庫文件夾中,如"D:\Program Files\Microsoft Visual Studio\VC98\Include"。
2:將“Lib”文件夾下面的所以庫拷貝到VC安裝目錄下的Lib文件夾下,比如"D:\Program Files\Microsoft Visual Studio\VC98\Lib"。
以上1、2兩個步驟其實是為了讓程序能夠利用winpcap這個開發包。這時程序能夠正確編譯連接了。要讓程序能夠運行,還必須安裝winpcap驅動程序WinPcap_3_1.exe。

代碼片段和文件信息
//?AnayDlg.cpp?:?implementation?file
//
#include?“stdafx.h“
#include?“IPControl.h“
#include?“AnayDlg.h“
#ifdef?_DEBUG
#define?new?DEBUG_NEW
#undef?THIS_FILE
static?char?THIS_FILE[]?=?__FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
//?CAnayDlg?dialog
CAnayDlg::CAnayDlg(CWnd*?pParent?/*=NULL*/)
:?CDialog(CAnayDlg::IDD?pParent)
{
//{{AFX_DATA_INIT(CAnayDlg)
//?NOTE:?the?ClassWizard?will?add?member?initialization?here
//}}AFX_DATA_INIT
for(int?i=0;i<=59;i++)
{
m_data[i]=0;
}
m_brushBlack.CreateSolidBrush(RGB(000));
m_penRed.CreatePen(PS_SOLID2RGB(25500));
m_Pengreen.CreatePen(PS_SOLID1RGB(02550));
}
void?CAnayDlg::DoDataExchange(CDataExchange*?pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAnayDlg)
//?NOTE:?the?ClassWizard?will?add?DDX?and?DDV?calls?here
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CAnayDlg?CDialog)
//{{AFX_MSG_MAP(CAnayDlg)
ON_WM_PAINT()
ON_WM_CLOSE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
//?CAnayDlg?message?handlers
BOOL?CAnayDlg::OnInitDialog()?
{
CDialog::OnInitDialog();
//?TODO:?Add?extra?initialization?here
return?TRUE;??//?return?TRUE?unless?you?set?the?focus?to?a?control
??????????????//?EXCEPTION:?OCX?Property?Pages?should?return?FALSE
}
void?CAnayDlg::OnPaint()?
{
CPaintDC?dc(this);?//?device?context?for?painting
//?TODO:?Add?your?message?handler?code?here
CRect?rect;
GetClientRect(&rect);
rect.left+=30;
rect.top+=30;
rect.right-=30;
rect.bottom-=30;
CDC*?pdc=GetDC();
SetBkMode(pdc->GetSafeHdc()TRANSPARENT);
//繪制黑色背景
CBrush*?pOldBrush=pdc->Selectobject(&m_brushBlack);
pdc->Rectangle(&rect);
pdc->Selectobject(pOldBrush);
CPen*?pOldPen=pdc->Selectobject(&m_Pengreen);
pdc->MoveTo(rect.left-1rect.bottom+1);
pdc->LineTo(rect.right+20rect.bottom+1);
pdc->MoveTo(rect.left-1rect.bottom+1);
pdc->LineTo(rect.left-1rect.top-20);
pdc->TextOut(rect.right+10rect.bottom+3“秒“);
pdc->TextOut(rect.left-20rect.top-20“流量(IP個數/秒)“);
//繪制水平線
double?hori=rect.Height()/16;?//水平間距?
for(int?i=0;i<=16;i++)
{
float?y=rect.bottom-hori*i;
if(i%2==0)
{
char?data[3];
sprintf(data“%d“i*5);
pdc->TextOut(rect.left-15y-8data);
pdc->MoveTo(rect.left-10y);
}
else
pdc->MoveTo(rect.lefty);
pdc->LineTo(rect.righty);
}
//繪制垂直線
double?perLen=rect.Height()/80;
double?verti=rect.Width()/60.00;?//垂直間距
for(i=0;i<=60;i++)
{
xs[i]=rect.left+verti*i;
if(i%10==0)
{
char?data[3];
sprintf(data“%d“i-60);
pdc->TextOut(xs[i]-5rect.bottom+3data);
pdc->MoveTo(xs[i]rect.bottom+6);
}
else
pdc->MoveTo(xs[i]rect.bottom);
pdc->LineTo(xs[i]rect.top);
// //繪制數據
pdc->Selectobject(&m_penRed);//選擇紅色筆
pdc->MoveTo(xs[i]rect.bottom);
/*
if(rect.bottom-perLen*m_data[i]?>?
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄??????????0??2006-01-11?10:40??IPtrafficmonitor
????..AD...?????????0??2006-01-09?17:32??IPtrafficmonitor\Include
?????文件???????2901??2002-08-01?10:33??IPtrafficmonitor\Include\bittypes.h
?????文件???????1620??2002-05-18?12:30??IPtrafficmonitor\Include\bucket_lookup.h
?????文件???????1600??2002-05-18?12:30??IPtrafficmonitor\Include\count_packets.h
?????文件???????3963??2002-04-10?13:45??IPtrafficmonitor\Include\DEVIOCTL.H
?????文件????????829??2002-08-01?10:33??IPtrafficmonitor\Include\Gnuc.h
?????文件???????5685??2002-08-02?15:25??IPtrafficmonitor\Include\ip6_misc.h
?????文件???????1784??2002-07-11?08:41??IPtrafficmonitor\Include\key_parser.h
?????文件???????3218??2002-05-31?20:48??IPtrafficmonitor\Include\memory_t.h
????..AD...?????????0??2006-01-09?17:32??IPtrafficmonitor\Include\NET
?????文件??????17173??2003-01-23?08:24??IPtrafficmonitor\Include\NET\bpf.h
?????文件???????1672??2002-05-18?12:30??IPtrafficmonitor\Include\normal_lookup.h
?????文件??????48556??2002-04-10?13:45??IPtrafficmonitor\Include\Ntddndis.h
?????文件???????1293??2002-05-08?09:04??IPtrafficmonitor\Include\Ntddpack.h
?????文件??????14467??2002-07-12?15:58??IPtrafficmonitor\Include\Packet32.h
?????文件??????11052??2003-02-03?15:11??IPtrafficmonitor\Include\PCAP-INT.H
?????文件???????1593??2002-08-05?09:45??IPtrafficmonitor\Include\pcap-stdinc.h
?????文件??????15387??2003-02-04?16:54??IPtrafficmonitor\Include\PCAP.H
?????文件??????34536??2002-03-02?03:04??IPtrafficmonitor\Include\pthread.h
?????文件???????4692??2002-03-02?03:04??IPtrafficmonitor\Include\sched.h
?????文件???????4123??2002-03-02?03:04??IPtrafficmonitor\Include\semaphore.h
?????文件???????2456??2002-05-18?12:30??IPtrafficmonitor\Include\tcp_session.h
?????文件???????6347??2002-09-19?08:28??IPtrafficmonitor\Include\time_calls.h
?????文件???????5730??2002-05-31?20:48??IPtrafficmonitor\Include\tme.h
?????文件???????2810??2003-02-03?15:52??IPtrafficmonitor\Include\Win32-Extensions.h
?????目錄??????????0??2006-01-11?10:34??IPtrafficmonitor\IPControl
?????文件???????4442??2005-11-01?20:13??IPtrafficmonitor\IPControl\AnayDlg.cpp
?????文件???????1436??2005-11-01?19:21??IPtrafficmonitor\IPControl\AnayDlg.h
?????文件???????4263??2005-10-26?13:16??IPtrafficmonitor\IPControl\IPControl.cpp
............此處省略106個文件信息
- 上一篇:數據庫系統概論第四版實驗報告
- 下一篇:基于SIP協議的抓包工具
評論
共有 條評論