I'm creating a kind of access point.
I capture all packets, of all the types, from my machine, in order to prioritize them before forwarding them, according to the default Quality of Service (QoS) classes.
By calling socket
with the ETH_P_ALL
parameter , I can get all incoming packets of any protocol type:
if ((sockfd = socket(AF_PACKET, SOCK_RAW, htons(ETH_P_ALL))) == ERROR) {
perror("socket");
exit(1);
}
By using ethhdr
, iphdr
, tcphdr
and udphdr
structs I can't retrieve information on which application sent each packet.
However, both Voip and SNMP use UDP, and I don't know which of the two sent me UDP package.
I'd like to know which applications are sending the UDP packets, so I may follow the QoS classes and forward some packets (e.g. conversational voice) before others (e.g. e-mail).
In order to recognize the protocol, should I use the list of TCP and UDP port numbers?