[Winpcap-users] problem with sending raw packets with pcap_sendqueue_transmit/PacketSendPackets

Nicolai Hansen nic at hsautomatic.com
Mon Jul 17 12:56:06 GMT 2006

Hi List,

I'm new on here - I checked the archives as I thought someone would've had a
problem like this before but I couldn't find anything. Maybe I'm just doing
something wrong but I can't figure out what. I'm using pcap 3.1 for windows
and this is my problem:

I am creating a raw packet of 1038 bytes (1024+IP header), I place this same
packet in the sendqueue 8192 times (here I can check that the queue's
datapointers and length are correct). It's just some junk data: the IP
header is 00 01 02 03 04 05 06 07 08 09 0A 0B 0C and the packet is full of
When I call pcap_sendqueue_transmit, it sends out all 8192 packets. I sniff
them with ethereal and at a first glance it looks fine... BUT! A few of the
packets suddenly has a header of 00 XX XX XX 04 05 06 ... - 3 bytes changed
into something that looks completely random. In the beginning of the
transmission its pretty rare, but for the last 500 packets almost every
packet has this error.
I inspect the buffer at the positions where I detect the problems, but the
buffer is in perfect order.
I also tried to sort the buffer part out myself and use PacketSendPackets to
send the data - with the excact same result.

Has anyone got any comments? The code is below:

void SendRawData(pcap_if_t *device)
	pcap_t *fp;
	pcap_send_queue *queue;
	char error[PCAP_ERRBUF_SIZE];
	u_char data[1038];
	eth_header *packet;
	pcap_pkthdr pkth;
	char *pktdata;

	int i;

	packet=(eth_header *) &data[0];

	if ((fp=pcap_open_live(device->name, 1038, 1, 1000, error))==NULL)
		fprintf(stderr, "Cannot send packet: %s\n\r", error);


	for (i=0; i<14; i++)

	for (i=14; i<1024; i++)


	pktdata=(char *) &data[0];

	printf("Sending 8 MByte of data\n\r");

	for (i=0; i<1024; i++)
		pcap_sendqueue_queue(queue, &pkth, data);

	pcap_sendqueue_transmit(fp, queue, 0);



More information about the Winpcap-users mailing list