Reputation: 1
I am using the following code snippet,
/* Open PF_PACKET socket, listening for EtherType ETHER_TYPE */
if ((sockfd = socket(PF_PACKET, SOCK_RAW, htons(ETHER_TYPE))) == -1) {
perror("listener: socket");
return -1;
}
/* Set interface to promiscuous mode - do we need to do this every time? */
strncpy(ifopts.ifr_name, ifName, IFNAMSIZ-1);
ioctl(sockfd, SIOCGIFFLAGS, &ifopts);
ifopts.ifr_flags |= IFF_PROMISC;
ioctl(sockfd, SIOCSIFFLAGS, &ifopts);
/* Allow the socket to be reused - incase connection is closed prematurely */
if (setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, &sockopt, sizeof sockopt) == -1) {
perror("setsockopt");
close(sockfd);
return ERR_GENERIC;
}
/* Bind to device */
if (setsockopt(sockfd, SOL_SOCKET, SO_BINDTODEVICE, ifName, IFNAMSIZ-1) == -1) {
perror("SO_BINDTODEVICE");
close(sockfd);
return ERR_GENERIC;
}
/* Open RAW socket to send on */
if ((sendfd = socket(AF_PACKET, SOCK_RAW, IPPROTO_IP)) == -1) {
//if ((sendfd = socket(PF_PACKET, SOCK_RAW, htons (ETHER_TYPE))) == -1) {
perror("socket");
}
I am receiving more than MTU size of 1500. Please share your inputs for getting packet more than size of MTU.
Upvotes: 0
Views: 541
Reputation: 123320
The MTU is the maximum number of bytes the physical layer can transport in a single frame. The packet size is the logical size of the IP packet. If an IP packet does not fit in a single physical frame for transport it will be fragmented for transport (i.e. split into multiple physical frames) and reassembled at the receiver. See wikipedia: IPv4 Fragmentation and reassembly for more details.
What you see in your code is the logical size of the packet which if fragmentation is used can well be larger than the MTU constraint of the physical layer.
Upvotes: 1