云题海 - 专业文章范例文档资料分享平台

当前位置:首页 > 《网络编程与协议分析》课程设计报告

《网络编程与协议分析》课程设计报告

  • 62 次阅读
  • 3 次下载
  • 2025/5/1 16:45:07

unsigned short int ip_Sum; //首部校验和 unsigned int ip_SoIp; //源ip unsigned int ip_DeIp; //目的ip };

struct tcphead { unsigned short tcp_SoPort; //16位的源端口 unsigned short tcp_DePort; //16位的目的端口 unsigned int tcp_Seq; //32位的序列号 unsigned int tcp_Ack; //32位的确认号 unsigned char tcp_LenAndRes; //4位的首部长度和4位的保留字 unsigned char tcp_Flag; //2位的保留字和6位的标志位 unsigned short tcp_Win; //16位的窗口大小 unsigned short tcp_Wum; //16位校验和 unsigned short tcp_Mov; //16位的紧急数据偏移量 };

struct udphead { unsigned short udp_SoPort; //源端口 unsigned short udp_DePort; //目的端口 unsigned short udp_Len; //总长度 unsigned short udp_Sum; //校验和 };

struct icmphead {

unsigned char icmp_Type; //类型 unsigned char icmp_Code; //代码 unsigned short icmp_Sum; //16位检验和 };

4)“开始”按钮事件

void CTestDlg::OnStart() { // TODO: Add your control notification handler code here DWORD code;

}

if (!GetExitCodeThread(m_thr,&code) || (code != STILL_ACTIVE)) { alldata * recvdata=new alldata; recvdata->lis=&m_List; recvdata->sock=m_sock; m_thr=CreateThread(NULL,0,RecvProc,(LPVOID)recvdata,0,NULL); CloseHandle(m_thr); } else { m_List.DeleteAllItems(); ResumeThread(m_thr); }

GetDlgItem(IDC_STOP)->EnableWindow(TRUE); GetDlgItem(IDC_START)->EnableWindow(FALSE); GetDlgItem(IDC_STOP)->SetFocus();

5)数据包抓取与初步处理

DWORD WINAPI CTestDlg::RecvProc(LPVOID lpParameter) { SOCKET sock=((alldata*)lpParameter)->sock; CListCtrl * lis=(CListCtrl *)(((alldata*)lpParameter)->lis); struct iphead *ih; SOCKADDR_IN tem; char RecvBuf[65535] = {0}; char soip[16]; char deip[16]; char buf[100];

int i=0;

while(1) { if(int a=recv(sock,ddat[++count].buff,sizeof(ddat[count].buff),0)<=0) continue; ih=(struct iphead *)(ddat[count].buff); tem.sin_addr.s_addr=ih->ip_SoIp; strncpy(soip,inet_ntoa(tem.sin_addr),16); tem.sin_addr.s_addr=ih->ip_DeIp; strncpy(deip,inet_ntoa(tem.sin_addr),16);

lis->InsertItem(i, \

sprintf(buf,\lis->SetItemText(i,0,buf);

sprintf(buf,\lis->SetItemText(i,1,buf); sprintf(buf,\lis->SetItemText(i,2,buf); sprintf(buf,\lis->SetItemText(i,3,buf); sprintf(buf,\lis->SetItemText(i,4,buf);

sprintf(buf,\lis->SetItemText(i,5,buf);

sprintf(buf,\lis->SetItemText(i,6,buf); sprintf(buf,\lis->SetItemText(i,7,buf);

switch((int)ih->ip_Protocol) { case 1:sprintf(buf,\ case 2:sprintf(buf,\

}

case 6:sprintf(buf,\ case 8:sprintf(buf,\ case 9:sprintf(buf,\ case 17:sprintf(buf,\ case 41:sprintf(buf,\ case 89:sprintf(buf,\ default:sprintf(buf,\}

lis->SetItemText(i,8,buf); sprintf(buf,\lis->SetItemText(i,9,buf); sprintf(buf,\lis->SetItemText(i,10,buf); sprintf(buf,\lis->SetItemText(i,11,buf); i++;

Sleep(100); }

return true;

6)表格单击事件

void CTestDlg::OnClickList1(NMHDR* pNMHDR, LRESULT* pResult) { // TODO: Add your control notification handler code here NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR; CString buf; char tem[100]; int i; if(pNMListView->iItem != -1) { i=pNMListView->iItem; CString strtemp; CNewDlg newdlg;

  • 收藏
  • 违规举报
  • 版权认领
下载文档10.00 元 加入VIP免费下载
推荐下载
本文作者:...

共分享92篇相关文档

文档简介:

unsigned short int ip_Sum; //首部校验和 unsigned int ip_SoIp; //源ip unsigned int ip_DeIp; //目的ip }; struct tcphead { unsigned short tcp_SoPort; //16位的源端口 unsigned short tcp_DePort; //16位的目的端口 unsigned int tcp_Seq; //32位的序列号 unsigned int tcp_Ack; //32位的确认号 unsigned char tcp_LenAndRes; //4位的首部长度和4位的保留字 unsigned char tcp_Flag; /

× 游客快捷下载通道(下载后可以自由复制和排版)
单篇付费下载
限时特价:10 元/份 原价:20元
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信:fanwen365 QQ:370150219
Copyright © 云题海 All Rights Reserved. 苏ICP备16052595号-3 网站地图 客服QQ:370150219 邮箱:370150219@qq.com