My network consists of the GL-MT300N-V2 router running this code:
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <fcntl.h>
#include <netdb.h>
#include <sys/time.h>
#include <arpa/inet.h>
#include <time.h>
#include <errno.h>
int main(int argc, char *argv[])
{
int sock;
if( (sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) == -1)
{
perror("socket : ");
return -1;
}
int broadcast = 1;
if( setsockopt(sock, SOL_SOCKET, SO_BROADCAST, &broadcast, sizeof(broadcast)) != 0 )
{
perror("setsockopt BROADCAST: ");
close(sock);
return -1;
}
char netif[] = "eth0";
if( setsockopt(sock, SOL_SOCKET, SO_BINDTODEVICE, netif, sizeof(netif) )
{
perror("setsockopt BIND : ");
close(sock);
return -1;
};
char *ip = "255.255.255.255";
char * msg = "OOO"; //Actual code has 250 'O's to be visible in the dump
struct sockaddr_in si;
si.sin_family = AF_INET;
si.sin_port = htons( 4444 );
inet_aton( ip, &si.sin_addr.s_addr );
/* send data */
for(int i = 0; i < 10000; i ++) //Used to spam for tcpdump
{
size_t nBytes = sendto(sock, msg, strlen(msg), 0,
(struct sockaddr*) &si, sizeof(si));
if(i % 1000 == 0)
{
printf("Sent msg: %s, %d bytes with socket %d to %s\n", msg, nBytes, sock, ip);
}
}
return 0;
}
The code successfully continually and rapidly sends packets. Said packets are easily visible in TCPdump. However, when I connect the router to a Windows 10 PC or laptop using ethernet, the computers are unable to detect the packets with Wireshark.
The sheer amount of packets is likely not the problem, as other code I have run sends similar amounts of packets, all of which are received.
Windows firewall has also been disabled, so the packet isn't being dropped there either.