#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <unistd.h>
#define UDP_DEST_PORT 30000
#define UDP_LOCAL_PORT 30000
#define MAX_LINE 1024
//#define SEND_NUM 10
unsigned match_udp(FILE*, int, unsigned char*, long*);
int dataSend(unsigned char*, long, const char*, int);
const char* ipDst = "239.100.0.100";
typedef struct pcap_pkt_header_t
{
// struct time_val ts; /* time stamp */
int wSecond; /* seconds ????? time_t ?????? */
int wMicroseconds; /* and microseconds */
unsigned int uwcaplen; /* length of portion present */
unsigned int uwlen; /* length this packet (off wire) */
} __attribute__((packed)) pcap_pkt_header_t;
// MAC_HEAD_STRUCT
typedef struct mac_header_t
{
unsigned char ucaDstMAC[6]; //
unsigned char ucaSrcMAC[6]; //
unsigned short usFrameType; //
} __attribute__((packed)) mac_header_t;
// IP_PACKET_HEAD
typedef struct ip_header_t
{
unsigned char ucVer_HLen; //
unsigned char ucTOS; //
unsigned short usTotalLen; //
unsigned short usID; //
unsigned short usFlag_Segment; //
unsigned char ucTTL; //
unsigned char ucProtocol; //
unsigned short usChecksum; //
unsigned int uwSrcIP; //
unsigned int uwDstIP; //
} __attribute__((packed)) ip_header_t;
// UDP HEADER
typedef struct udp_header_t
{
// UDP
unsigned short usSrcPort; //
unsigned short usDstPort; //
unsigned short usDataLen; //
unsigned short usChecksum; //
} __attribute__
从pcap文件中读数据并组播
于 2021-09-03 09:49:22 首次发布
本文介绍如何从pcap文件中提取数据,并详细阐述了如何利用这些数据进行UDP组播操作,参考了https://www.tenouk.com/Module41c.html的相关教程。
摘要由CSDN通过智能技术生成