

Note the third parameter: if nonzero, the send will be synchronized, i.e. To transmit a send queue, WinPcap provides the pcap_sendqueue_transmit() function. These parameters are the same as those received by pcap_next_ex() and pcap_handler(), therefore queuing a packet that was just captured or read from a file is a matter of passing these parameters to pcap_sendqueue_queue(). This function takes a pcap_pkthdr with the timestamp and the length and a buffer with the data of the packet.

Once the send queue is created, pcap_sendqueue_queue() can be used to add a packet to the send queue. It has a size, that represents the maximum amount of bytes it can store.Ī send queue is created calling the pcap_sendqueue_alloc() function, specifying the size of the new send queue. A send queue is a container for a variable number of packets that will be sent to the network. While pcap_sendpacket() offers a simple and immediate way to send a single packet, send queues provides an advanced, powerful and optimized mechanism to send a collection of packets. * Send down the packet */ if ( pcap_sendpacket(fp, packet, 100 /* size */) != 0)įprintf(stderr, "\nError sending the packet: %s\n", pcap_geterr(fp)) * Fill the rest of the packet */ for(i=12 i<100 i++)
#Packet sender pcap mac#
* Supposing to be on ethernet, set mac destination to 1:1:1:1:1:1 */ %s is not supported by WinPcap\n", argv) NULL, // authentication on the remote machineįprintf(stderr, "\nUnable to open the adapter. * Open the output device */ if ( (fp= pcap_open(argv, // name of the deviceġ00, // portion of the packet to capture (only the first 100 bytes) PCAP_OPENFLAG_PROMISCUOUS, // promiscuous mode * Check the validity of the command line */ if (argc != 2) #include #include #include void main( int argc, char **argv)
