Location:
Search - sock_raw
Search list
Description: Linux下SOCK_RAW原理和应用示例,比较有趣!建议大家看看玩-Linux SOCK_RAW principle and application examples, the more interesting! We look at the proposal to play
Platform: |
Size: 1524 |
Author: handsoft |
Hits:
Description: Linux下SOCK_RAW原理和应用,自己尝试编的,还请各位高手多多指点。-Linux SOCK_RAW principles and applications, try to compile, Members also requested the guidance of many experts.
Platform: |
Size: 1472 |
Author: 左俊 |
Hits:
Description: Sniffer using Sock_raw.
挺不错的。
Platform: |
Size: 22567 |
Author: 亡命 |
Hits:
Description: 为了方便网络编程,90年代初,由Microsoft联合了其他几家公司共同制定了一套WINDOWS下的网络编程接口,即Windows Sockets规范,它不是一种网络协议,而是一套开放的、支持多种协议的Windows下的网络编程接口。本篇论文主要是介绍了在TCP/IP基础上利用winsock2对网卡进行编程,以达到网络流量监测的目的。论文首先介绍了TCP/IP协议,旨在介绍IP,TCP,UDP等比较重要的协议。主要是介绍IP头,TCP头,UDP头的特点,以便从IP头中可以获取源地址,目的地址,协议类型等信息。在随后的章节中提出了Socket的概念,Socket实际上提供了一个通信端口使所有拥有Socket的端口的计算机之间能够相互通信,在本论文中主要说明了socket的建立,监听和撤销的过程。具体到程序实现中,对网卡混杂模式的设置是通过原始套接字(raw socket)来实现的。为了让原始套接字能接受所有的数据,还需要通过将SOCK_RAW设置成SIO_RCVALL。对数据包的获取通过recv()函数来完成。最后要完成的工作就是对所捕获的IP数据包进行分析以提取出我们所需要的信息。在论文的最后是旨在说明进一步工作的展开.
关键词:网络流量测量 TCP/IP协议 WINSOCK编程
-To facilitate network programming and the beginning of the 1990s, Microsoft jointly by several other companies to develop a set of Windows programming network access , that is, Windows Sockets norms, it is not a network protocol, but a liberal, Multi-protocol support for the Windows network programming interface. The main purpose of this paper is to introduce a TCP / IP based on the use of the card for winsock2 programming, to achieve network traffic monitoring purposes. Papers first introduced the TCP / IP protocol, aimed at introducing IP, TCP, UDP, and other more important agreements. IP is introduced first, the first TCP, UDP first features to the IP header from access to the source address, destination address, Agreement type, and other information. In the ensuing chapters of the Sock
Platform: |
Size: 10687 |
Author: wq57 |
Hits:
Description: 相信各位都玩过SOCKET编程,用CSocket进行网络通讯非常方便,但有时想搞点底层点东西却非常麻烦,用windows的API最低也只能SOCK_RAW,顶多能看到IP层数据,如果想处理数据链路层的数据就无从下手了,幸好某天发现了winpcap东西。用了它处理底层的东西就非常方便。
winpcap主要有两个dll供程序员直接调用,pcap.dll和packet.dll,本程序主要使用pcap.dll.详细请看代码,本人也是刚接触WinPcap,所以一不定有一些错漏的地方,请各位大蝦不要见笑。
如果程序有编译不过去的地方,请务必先按装winPcap库,更新VC6的PlatformSDK
Platform: |
Size: 48370 |
Author: iie9615 |
Hits:
Description: 用SOCK_RAW编写的ping程序 C++语言 只有简单的ping功能
Platform: |
Size: 14743 |
Author: 果汁红 |
Hits:
Description: 一个判断远程主机存活程序代码(ping)
#include
#include
#include
#include
#include "winsock.h"
#pragma comment(lib,"Ws2_32");
#define SEND_SIZE 32
#define PACKET_SIZE 4096
#define ICMP_ECHO 8
#define ICMP_ECHOREPLY 0
struct icmp
{
unsigned char icmp_type;
unsigned char icmp_code;
unsigned short icmp_cksum;
unsigned short icmp_id;
unsigned short icmp_seq;
unsigned long icmp_data;
};
struct ip
{
unsigned char ip_hl:4;
unsigned char ip_v:4;
unsigned char ip_tos;
unsigned short ip_len;
unsigned short ip_id;
unsigned short ip_off;
unsigned char ip_ttl;
unsigned char ip_p;
unsigned short ip_sum;
unsigned long ip_src;
unsigned long ip_dst;
};
unsigned char sendpacket[PACKET_SIZE];
unsigned char recvpacket[PACKET_SIZE];
struct sockaddr_in dest_addr;
struct sockaddr_in from_addr;
int sockfd;
int pid;
unsigned short cal_chksum(unsigned short *addr,int len);
int pack(int pack_no);
int unpack(unsigned char *buf,int len);
void send_packet(void);
void recv_packet(void);
void main(int argc,char *argv[])
{
struct hostent *host;
struct protoent *protocol;
WSADATA wsaData;
int timeout=1000;
int SEND_COUNT=4;
int i;
char *par_host;
par_host=argv[argc-1]; //IP赋值
switch(argc)
{
case 2: break;
case 3: if(strcmp(argv[1],"-t")==0)
{
SEND_COUNT=10000;
break;
}
//fall through
default:
printf("usage: %s [-t] Host name or IP address\n",argv[0]);
exit(1);
}
if(WSAStartup(0x1010,&wsaData)!=0)
{
printf("wsastartup error\n");
exit(1);
}
if( (protocol=getprotobyname("icmp") )==NULL)
{
printf("getprotobyname error\n");
exit(1);
}
/*
printf("%s\n",protocol->p_name);
printf("%s\n",protocol->p_aliases);
printf("%d\n",protocol->p_proto);
system("pause");
*/
if( (sockfd=socket(AF_INET,SOCK_RAW,protocol->p_proto) )<0)
{
printf("socket error\n");
exit(1);
}
if(setsockopt(sockfd,SOL_SOCKET,SO_RCVTIMEO,(char*)&timeout,sizeof(timeout))h_length);
//resolve address to hostname
if(host=gethostbyaddr(host->h_addr,4,PF_INET))
par_host=host->h_name;
//
//printf("%s\n",par_host);
//
}
else if( dest_addr.sin_addr.s_addr=inet_addr(par_host)==INADDR_NONE)
{
printf("Unkown host %s\n",par_host);
exit(1);
}
pid=getpid();
/*
printf("%d\n",pid);
system("pause");
*/
printf("Pinging %s [%s]: with %d bytes of data:\n\n",par_host,inet_ntoa(dest_addr.sin_addr),SEND_SIZE);
for(i=0;i1)
{ sum+=*w++;
nleft-=2;
}
if( nleft==1)
{ *(unsigned char *)(&answer)=*(unsigned char *)w;
sum+=answer;
}
sum=(sum>>16)+(sum&0xffff);
sum+=(sum>>16);
answer=~sum;
return answer;
}
//打包
int pack(int pack_no)
{
int packsize;
struct icmp *icmp;
packsize=8+SEND_SIZE;
icmp=(struct icmp*)sendpacket;
icmp->icmp_type=ICMP_ECHO;
icmp->icmp_code=0;
icmp->icmp_cksum=0;
icmp->icmp_seq=pack_no;
icmp->icmp_id=pid;
icmp->icmp_data=GetTickCount();
icmp->icmp_cksum=cal_chksum( (unsigned short *)icmp,packsize); /*校验算法*/
return packsize;
}
//解包
int unpack(unsigned char *buf,int len)
{
struct ip *ip;
struct icmp *icmp;
double rtt;
int iphdrlen;
ip=(struct ip *)buf;
iphdrlen=ip->ip_hl*4;
icmp=(struct icmp *)(buf+iphdrlen);
if( (icmp->icmp_type==ICMP_ECHOREPLY) && (icmp->icmp_id==pid) )
{
len=len-iphdrlen-8;
rtt=GetTickCount()-icmp->icmp_data;
printf("Reply from %s: bytes=%d time=%.0fms TTL=%d icmp_seq=%u\n",
inet_ntoa(from_addr.sin_addr),
len,
rtt,
ip->ip_ttl,
icmp->icmp_seq);
return 1;
}
return 0;
}
//发送
void send_packet()
{
int packetsize;
static int pack_no=0;
packetsize=pack(pack_no++);
if( sendto(sockfd,(char *)sendpacket,packetsize,0,(struct sockaddr *)&dest_addr,sizeof(dest_addr) )=0)
success=unpack(recvpacket,n);
else if (WSAGetLastError() == WSAETIMEDOUT)
{
printf("Request timed out.\n");
return;
}
}while(!success);
}
UID5380 帖子239 精华0 积分1289 阅读权限40 来自软件学院 在线时间81 小时 注册时间2006-5-22 最后登录2007-2-24 查看详细资料
TOP
Platform: |
Size: 5881 |
Author: shuiyuan313 |
Hits:
Description: 这是我课程设计的一个程序,程序实现echo request icmp 的发送和echo reply icmp 的接收,以发现网络中在线主机以及测量与其他主机的平均往返时间-This is my curriculum design a procedure, Program icmp echo request and send the reply icmp echo reception, to detect network and host online measurement and other hosts of the average journey time
Platform: |
Size: 4096 |
Author: 陈建锋 |
Hits:
Description: Linux下SOCK_RAW原理和应用示例,比较有趣!建议大家看看玩-Linux SOCK_RAW principle and application examples, the more interesting! We look at the proposal to play
Platform: |
Size: 1024 |
Author: handsoft |
Hits:
Description: Linux下SOCK_RAW原理和应用,自己尝试编的,还请各位高手多多指点。-Linux SOCK_RAW principles and applications, try to compile, Members also requested the guidance of many experts.
Platform: |
Size: 1024 |
Author: 左俊 |
Hits:
Description: Sniffer using Sock_raw.
挺不错的。-Sniffer using Sock_raw. Pretty good.
Platform: |
Size: 22528 |
Author: 亡命 |
Hits:
Description: 为了方便网络编程,90年代初,由Microsoft联合了其他几家公司共同制定了一套WINDOWS下的网络编程接口,即Windows Sockets规范,它不是一种网络协议,而是一套开放的、支持多种协议的Windows下的网络编程接口。本篇论文主要是介绍了在TCP/IP基础上利用winsock2对网卡进行编程,以达到网络流量监测的目的。论文首先介绍了TCP/IP协议,旨在介绍IP,TCP,UDP等比较重要的协议。主要是介绍IP头,TCP头,UDP头的特点,以便从IP头中可以获取源地址,目的地址,协议类型等信息。在随后的章节中提出了Socket的概念,Socket实际上提供了一个通信端口使所有拥有Socket的端口的计算机之间能够相互通信,在本论文中主要说明了socket的建立,监听和撤销的过程。具体到程序实现中,对网卡混杂模式的设置是通过原始套接字(raw socket)来实现的。为了让原始套接字能接受所有的数据,还需要通过将SOCK_RAW设置成SIO_RCVALL。对数据包的获取通过recv()函数来完成。最后要完成的工作就是对所捕获的IP数据包进行分析以提取出我们所需要的信息。在论文的最后是旨在说明进一步工作的展开.
关键词:网络流量测量 TCP/IP协议 WINSOCK编程
-To facilitate network programming and the beginning of the 1990s, Microsoft jointly by several other companies to develop a set of Windows programming network access , that is, Windows Sockets norms, it is not a network protocol, but a liberal, Multi-protocol support for the Windows network programming interface. The main purpose of this paper is to introduce a TCP/IP based on the use of the card for winsock2 programming, to achieve network traffic monitoring purposes. Papers first introduced the TCP/IP protocol, aimed at introducing IP, TCP, UDP, and other more important agreements. IP is introduced first, the first TCP, UDP first features to the IP header from access to the source address, destination address, Agreement type, and other information. In the ensuing chapters of the Sock
Platform: |
Size: 10240 |
Author: wq57 |
Hits:
Description: 相信各位都玩过SOCKET编程,用CSocket进行网络通讯非常方便,但有时想搞点底层点东西却非常麻烦,用windows的API最低也只能SOCK_RAW,顶多能看到IP层数据,如果想处理数据链路层的数据就无从下手了,幸好某天发现了winpcap东西。用了它处理底层的东西就非常方便。
winpcap主要有两个dll供程序员直接调用,pcap.dll和packet.dll,本程序主要使用pcap.dll.详细请看代码,本人也是刚接触WinPcap,所以一不定有一些错漏的地方,请各位大蝦不要见笑。
如果程序有编译不过去的地方,请务必先按装winPcap库,更新VC6的PlatformSDK
-I am sure we all played SOCKET programming, use CSocket for network communication is very convenient, but sometimes want to point at the bottom of things is very troublesome, with the lowest API of windows can only SOCK_RAW, at most able to see IP layer data, if you want to deal with data link layer data can never gain the upper hand, and fortunately found one day things WinPcap. Deal with it on the bottom of things very convenient. WinPcap has two main dll programmers for direct call, pcap.dll and packet.dll, the main use of this procedure pcap.dll. details please see the code, and I was a刚接触WinPcap, so one has some mistakes in the indeterminate place, please not a laughing stock of shrimp. If the program does not have to compile the last place, be sure to press installed Winpcap library updated VC6 the PlatformSDK
Platform: |
Size: 48128 |
Author: iie9615 |
Hits:
Description: 用SOCK_RAW编写的ping程序 C++语言 只有简单的ping功能-SOCK_RAW prepared using ping procedures C++ Language only simple ping function
Platform: |
Size: 1020928 |
Author: 果汁红 |
Hits:
Description: 用VC++6.0的Sockets API实现一个聊天室程序.txt
VC++对网络编程的支持有socket支持,WinInet支持,MAPI和ISAPI支持等。其中,Windows Sockets API是TCP/IP网络环境里,也是Internet上进行开发最为通用的API。最早美国加州大学Berkeley分校在UNIX下为TCP/IP协议开发了一个API,这个API就是著名的Berkeley Socket接口(套接字)。在桌面操作系统进入Windows时代后,仍然继承了Socket方法。在TCP/IP网络通信环境下,Socket数据传输是一种特殊的I/O,它也相当于一种文件描述符,具有一个类似于打开文件的函数调用-socket()。可以这样理解:Socket实际上是一个通信端点,通过它,用户的Socket程序可以通过网络和其他的Socket应用程序通信。Socket存在于一个"通信域"(为描述一般的线程如何通过Socket进行通信而引入的一种抽象概念)里,并且与另一个域的Socket交换数据。Socket有三类。第一种是SOCK_STREAM(流式),提供面向连接的可靠的通信服务,比如telnet,http。第二种是SOCK_DGRAM(数据报),提供无连接不可靠的通信,比如UDP。第三种是SOCK_RAW(原始),主要用于协议的开发和测试,支持通信底层操作,比如对IP和ICMP的直接访问。
-VC++6.0 using the Sockets API procedures for the realization of a chat room. Txt
VC++ on the support network programming socket support, WinInet support, MAPI and ISAPI support. One, Windows Sockets API is TCP/IP network environment, but also for the development of Internet, the most common API. The first University of California, Berkeley campus in UNIX for the TCP/IP protocol has developed an API, the API is well-known Berkeley Socket interface (socket). Into the Windows desktop operating system in the era after the Socket method inherited. In the TCP/IP network communication environment, Socket data transmission is a special kind of I/O, it is equivalent to a file descriptor, open the file with a similar function call in-socket (). Can interpret it this way: Socket is a communication endpoint, through which users can program the Socket and other network applications of Socket Communications. Socket exist in a "communication domain" (as described in the general thread o
Platform: |
Size: 3072 |
Author: 李涛 |
Hits:
Description: sockets(套接字)编程有三种,流式套接字(SOCK_STREAM),数据报套接字 (SOCK_DGRAM),原始套接字(SOCK_RAW);基于TCP的socket编程是采用的流式套接字(SOCK_STREAM)。基于UDP采 用的数据报套接字(SOCK_DGRAM).-sockets (socket) programming there are three kinds of stream sockets (SOCK_STREAM), datagram sockets (SOCK_DGRAM), raw sockets (SOCK_RAW) based on TCP-socket programming is used in streaming socket the word (SOCK_STREAM). Based on UDP datagram sockets used in (SOCK_DGRAM).
Platform: |
Size: 1024 |
Author: sun |
Hits:
Description: 编程实现ping操作,是一个一错的例子,我专门从配套光盘上挑选的-aaaaaaaaaaaaaaaaa
Platform: |
Size: 34816 |
Author: hufangbin |
Hits:
Description: 实现GUI界面的ping功能,与DOS下的ping命令一样-GUI interface to achieve the ping function, and the ping command under DOS as
Platform: |
Size: 195584 |
Author: 李明 |
Hits:
Description: ping命令看似小小的一个工具,但它带有许多参数,要完全掌握它的使用方法还真不容易,要达到熟练使用则更是难下加难,但不管怎样我们还得来看看它的源程序吧!-a tool may seem a little ping command, but it comes with a number of parameters, to fully grasp its really not easy to use, to achieve even more difficult under the skilled use of additional difficulties, but in any case we have to look at Its source code now!
Platform: |
Size: 2048 |
Author: chao |
Hits:
Description: windows raw socket编程实例-windows raw socket
Platform: |
Size: 2952192 |
Author: 冷雪刚 |
Hits: