Sniffer软件是NAI公司推出的一款一流的便携式网管和应用故障诊断分析软件,不管是在有线网络还是在无线网络中,它都能够给予网管管理人员实时的网络监视、数据包捕获以及故障诊断分析能力。对于在现场运行快速的网络和应用问题故障诊断,基于便携式软件的解决方案具备最高的性价比,却能够让用户获得强大的网管和应用故障诊断功能。[1]

#include

#include

#include

#include

#include

#include

#include

#include

#include

#include

int main(intargc,char**argv) {intsock,n;charbuffer[2048];unsignedchar*iphead,*ethhead;structifreqethreq;intno=0;//

设置原始套接字方式为接收所有的数据包if((sock=socket(PF_PACKET,SOCK_RAW,htons(ETH_P_IP)))<0){perror(“\n原始套接字建立失败\n”);exit(1);}//设置网卡工作方式为混杂模式,

SIOCGIFFLAGS请求表示需要获取接口标志strncpy(ethreq.ifr_name,”eth0”,IFNAMSIZ);//InterfaceNamesizeif(ioctl(sock,SIOCGIFFLAGS,ðreq)==-1){perror(“\n设置混杂工作模式失败\n”);close(sock);exit(1);}//开始捕获数据并进行简单分析While(1){n=recvfrom(sock,buffer,2048,0,NULL,NULL);no++;printf(“\n************%dpacket%dbytes************\n”,no,n);//检查包是否包含了至少完整的以太帧(14),IP(20)和TCP/UDP(8)包头if(n<42){perror(“recvfrom():”);exit(0);}ethhead=buffer;printf(“DestMACaddress:%02x:%02x:%02x:%02x:%02x:%02x\n”,ethhead[0],ethhead[1],ethhead[2],ethhead[3],ethhead[4],ethhead[5]);printf(“SourceMACaddress:%02x:%02x:%02x:%02x:%02x:%02x\n”,ethhead[6],ethhead[7],ethhead[8],ethhead[9],ethhead[10],ethhead[11]);iphead=buffer+14;/*跳过Ethernetheader*/if(*iphead==0x45){/*DoublecheckforIPv4*andnooptionspresent*/printf(“Sourcehost:%d.%d.%d.%d,”,iphead[12],iphead[13],iphead[14],iphead[15]);printf(“Desthost:%d.%d.%d.%d\n”,iphead[16],iphead[17],iphead[18],iphead[19]);printf(“Sourceport:%d,Destport:%d”,(iphead[20]<<8)+iphead[21],(iphead[22]<<8)+iphead[23]);if(iphead[9]==6)printf(“TCP\n”);elseif(iphead[9]==17)printf(“UDP\n”);elseprintf(“protocolid:%d\n”,iphead[9]);}}}[2]

刚刚查询:Sniffer Felsenstein 布莱恩 Huppert 七机部 加缪文集 韩国辣酱版油豆角炖排骨 高压线 就业问题 特克斯 一顾倾人 维修保养 血战毒枭 革命党 已得到 自由党 的黎波里 Gluconobacter 三氯氧钒 挠脚心 组织部 Braised 多事之秋 笄蛭 的里雅斯特 毕业典礼 马靖立 运输舰 传入神经 监管法 供销社 庞华清 万历新政 娱乐活动 政宗 虹猫 ̫ʽƿ 山坡哪儿去了 上百·万和城 喀布尔 小黄鱼 田字格 安东尼·备·圣艾修伯里 涩梨叶 特别委员会 Stronghold ZACHARY 投资商 1882.4.17 Joachim 通往天堂的劳动阶级 与国际财务报告准则趋同:路径选择与政策建议 TB 1978.06 Vairocana 财务科 Golems 斯坦德利 内分泌腺 authority 郭解 原始码 内江一职中 Francesco 大姑娘 小梁的休息日 易容术 冈山县 d3h690rnau5gh63oukngfjftkkf89mrzn.oast.online 微型化 斯德哥尔摩 宽衣解带 Enchanted 4.60.2200.0394 听不到 太平角 弗朗西斯 2011ѧרҵܻ...
友情链接: 知道 电影 百科 好搜 问答 微信 值得买 巨便宜 天天特价 洛阳汽车脚垫 女装 女鞋 母婴 内衣 零食 美妆 汽车 油价 郑州 北京 上海 广州 深圳 杭州 南京 苏州 武汉 天津 重庆 成都 大连 宁波 济南 西安 石家庄 沈阳 南阳 临沂 邯郸 保定 温州 东莞 洛阳 周口 青岛 徐州 赣州 菏泽 泉州 长春 唐山 商丘 南通 盐城 驻马店 佛山 衡阳 沧州 福州 昆明 无锡 南昌 黄冈 遵义
© 2026 haodianxin 百科 消耗时间:0.011秒 内存0.8MB