ramzez wrote:
> In my C app, How do I can know the MTU (Maximum Transfer Unit) of my
> net?
You can obtain the MTU of an interface with ioctl(SIOCGIFMTU), e.g.
const char if_name[] = "eth0";
struct ifreq ifr;
int fd;
fd = socket(PF_INET, SOCK_DGRAM, IPPROTO_IP);
strcpy(ifr.ifr_name, if_name);
ioctl(fd, SIOCGIFMTU, &ifr);
printf("MTU of %s is %d\n", if_name, ifr.ifr_mtu);
Assuming that path MTU discovery is enabled, you can obtain the path
MTU of an individual connection using getsockopt(SOL_IP, IP_MTU), e.g.
int mtu;
int mtulen = sizeof(mtu);
getsockopt(skt, SOL_IP, IP_MTU, &mtu, &mtulen);
--
Glynn Clements <[EMAIL PROTECTED]>
-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs