在IP头中,有一Type-of-Service字段,该字段描述了IP包的
优先级和QoS选项,使用IP_TOS可以来设定该字段的值:
使用setsockopt设置IP_TOS代码如下:
unsigned char service_type = 0xe0 | IPTOS_LOWDELAY | IPTOS_RELIABILITY;
if(setsockopt(sock, SOL_IP/*IPPROTO_IP*/, IP_TOS, (void *)&service_type, sizeof(service_type)) < 0)
perror("setsockopt(IP_TOS) failed:");
使用getsockopt读取IP_TOS代码如下:
int optval = 0;
int optlen = sizeof(optval);
if(getsockopt(sock, SOL_IP, IP_TOS, (v......
阅读全文