Problem with SO_PRIORITY when sending broadcast packets
up vote
0
down vote
favorite
I'm having some issues with SO_PRIORITY, when used with setsockopt().
My doubt is about the WME MAC layer queues and socket priority when sending packets (defing, among other things, the AIFS times, in place of DIFS). I'm able to set a certain priority with:
setsockopt(sFd,SOL_SOCKET,SO_PRIORITY,&up,sizeof(up))
where "up" is the desired user priority (for instance, up=4 to use the AC_VO queue).
This seems to work both with raw and IP datagram sockets.
The problem is that the MAC queues are correctly used only when sending unicast packets (which are actually acknowledged); when sending broadcast (or multicast) data, as I'm required to do, only the "AC_BE" (up=0) queue is used, no matter what I set with SO_PRIORITY.
Do you know why? I actually want to properly use these queues also for broadcast transmissions, as it may be very useful for a research work I'm doing.
This is part of the code I'm using to send the packets out (here a raw socket is used, but the same happens with non-raw sockets, as AF_INET datagram ones):
// Open socket
sFd=socket(AF_PACKET,SOCK_RAW,htons(ETH_P_ALL));
if(sFd==-1)
perror("socket() error");
exit(EXIT_FAILURE);
// Getting WLAN interface index using a custom library (wlanLookup() and macAddrTypeGet() functions
ret_wlanl_val=wlanLookup(devname,&ifindex,srcmacaddr,0);
if(ret_wlanl_val<=0)
fprintf(stderr,"wlanLookup() error.n");
rs_printerror(stderr,ret_wlanl_val);
close(sFd);
exit(EXIT_FAILURE);
if(macAddrTypeGet(srcmacaddr)==MAC_BROADCAST)
fprintf(stderr,"Could not retrieve source MAC address.n");
close(sFd);
exit(EXIT_FAILURE);
// Prepare sockaddr_ll structure
bzero(&addrll,sizeof(addrll));
addrll.sll_ifindex=ifindex;
addrll.sll_family=AF_PACKET;
addrll.sll_protocol=htons(ETH_P_ALL);
// Bind to the wireless interface
if(bind(sFd,(struct sockaddr *) &addrll,sizeof(addrll))<0)
perror("Cannot bind to interface: bind() error");
close(sFd);
exit(EXIT_FAILURE);
// Print AC corresponding to selected UP (and handle possible wrong UP)
up=atoi(argv[3]);
switch(up)
case 0:
case 3:
fprintf(stdout,"AC_BE is selected, with UP: %d.n",up);
break;
case 1:
case 2:
fprintf(stdout,"AC_BK is selected, with UP: %d.n",up);
break;
case 4:
case 5:
fprintf(stdout,"AC_VI is selected, with UP: %d.n",up);
break;
case 6:
case 7:
fprintf(stdout,"AC_VO is selected, with UP: %d.n",up);
break;
default:
fprintf(stderr,"Wrong UP specified. AC_BE will be used.n");
up=0;
break;
// Set user priority using socket layer options (does not work with broadcast?)
if(setsockopt(sFd,SOL_SOCKET,SO_PRIORITY,&up,sizeof(up))!=0)
perror("setsockopt() for SO_PRIORITY error");
close(sFd);
exit(EXIT_FAILURE);
// Set broadcast permission using socket layer options (is this really required?)
if(setsockopt(sFd,SOL_SOCKET,SO_BROADCAST,(void *) &broadPerm,sizeof(broadPerm))!=0)
perror("setsockopt() for SO_BROADCAST error");
close(sFd);
exit(EXIT_FAILURE);
//... Prepare payload, headers and timer to periodically send data...
while(1)
// poll waiting for events happening on the timer descriptor (i.e. wait for timer expiration)
if(poll(&timerMon,1,INDEFINITE_BLOCK)>0)
// "Clear the event" by performing a read() on a junk variable
read(clockFd,&junk,sizeof(junk));
// Send brodcast data (if verbose==1, print '.' for each sent datagram)
// Prepare datagram
// ... Prepare datagram to be sent (contained in "ethernetpacket", with size "finalpktsize")
if(sendto(sFd,ethernetpacket,finalpktsize,0,(struct sockaddr *)&addrll,sizeof(struct sockaddr_ll))!=finalpktsize)
perror("sendto() for sending broadcasted data failed");
fprintf(stderr,"The program will be terminated now");
break;
if(verbose)
fprintf(stdout,".");
fflush(stdout);
//... free variables, close socket, ...
Thank you very much in advance.
c sockets queue broadcast wireless
add a comment |
up vote
0
down vote
favorite
I'm having some issues with SO_PRIORITY, when used with setsockopt().
My doubt is about the WME MAC layer queues and socket priority when sending packets (defing, among other things, the AIFS times, in place of DIFS). I'm able to set a certain priority with:
setsockopt(sFd,SOL_SOCKET,SO_PRIORITY,&up,sizeof(up))
where "up" is the desired user priority (for instance, up=4 to use the AC_VO queue).
This seems to work both with raw and IP datagram sockets.
The problem is that the MAC queues are correctly used only when sending unicast packets (which are actually acknowledged); when sending broadcast (or multicast) data, as I'm required to do, only the "AC_BE" (up=0) queue is used, no matter what I set with SO_PRIORITY.
Do you know why? I actually want to properly use these queues also for broadcast transmissions, as it may be very useful for a research work I'm doing.
This is part of the code I'm using to send the packets out (here a raw socket is used, but the same happens with non-raw sockets, as AF_INET datagram ones):
// Open socket
sFd=socket(AF_PACKET,SOCK_RAW,htons(ETH_P_ALL));
if(sFd==-1)
perror("socket() error");
exit(EXIT_FAILURE);
// Getting WLAN interface index using a custom library (wlanLookup() and macAddrTypeGet() functions
ret_wlanl_val=wlanLookup(devname,&ifindex,srcmacaddr,0);
if(ret_wlanl_val<=0)
fprintf(stderr,"wlanLookup() error.n");
rs_printerror(stderr,ret_wlanl_val);
close(sFd);
exit(EXIT_FAILURE);
if(macAddrTypeGet(srcmacaddr)==MAC_BROADCAST)
fprintf(stderr,"Could not retrieve source MAC address.n");
close(sFd);
exit(EXIT_FAILURE);
// Prepare sockaddr_ll structure
bzero(&addrll,sizeof(addrll));
addrll.sll_ifindex=ifindex;
addrll.sll_family=AF_PACKET;
addrll.sll_protocol=htons(ETH_P_ALL);
// Bind to the wireless interface
if(bind(sFd,(struct sockaddr *) &addrll,sizeof(addrll))<0)
perror("Cannot bind to interface: bind() error");
close(sFd);
exit(EXIT_FAILURE);
// Print AC corresponding to selected UP (and handle possible wrong UP)
up=atoi(argv[3]);
switch(up)
case 0:
case 3:
fprintf(stdout,"AC_BE is selected, with UP: %d.n",up);
break;
case 1:
case 2:
fprintf(stdout,"AC_BK is selected, with UP: %d.n",up);
break;
case 4:
case 5:
fprintf(stdout,"AC_VI is selected, with UP: %d.n",up);
break;
case 6:
case 7:
fprintf(stdout,"AC_VO is selected, with UP: %d.n",up);
break;
default:
fprintf(stderr,"Wrong UP specified. AC_BE will be used.n");
up=0;
break;
// Set user priority using socket layer options (does not work with broadcast?)
if(setsockopt(sFd,SOL_SOCKET,SO_PRIORITY,&up,sizeof(up))!=0)
perror("setsockopt() for SO_PRIORITY error");
close(sFd);
exit(EXIT_FAILURE);
// Set broadcast permission using socket layer options (is this really required?)
if(setsockopt(sFd,SOL_SOCKET,SO_BROADCAST,(void *) &broadPerm,sizeof(broadPerm))!=0)
perror("setsockopt() for SO_BROADCAST error");
close(sFd);
exit(EXIT_FAILURE);
//... Prepare payload, headers and timer to periodically send data...
while(1)
// poll waiting for events happening on the timer descriptor (i.e. wait for timer expiration)
if(poll(&timerMon,1,INDEFINITE_BLOCK)>0)
// "Clear the event" by performing a read() on a junk variable
read(clockFd,&junk,sizeof(junk));
// Send brodcast data (if verbose==1, print '.' for each sent datagram)
// Prepare datagram
// ... Prepare datagram to be sent (contained in "ethernetpacket", with size "finalpktsize")
if(sendto(sFd,ethernetpacket,finalpktsize,0,(struct sockaddr *)&addrll,sizeof(struct sockaddr_ll))!=finalpktsize)
perror("sendto() for sending broadcasted data failed");
fprintf(stderr,"The program will be terminated now");
break;
if(verbose)
fprintf(stdout,".");
fflush(stdout);
//... free variables, close socket, ...
Thank you very much in advance.
c sockets queue broadcast wireless
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I'm having some issues with SO_PRIORITY, when used with setsockopt().
My doubt is about the WME MAC layer queues and socket priority when sending packets (defing, among other things, the AIFS times, in place of DIFS). I'm able to set a certain priority with:
setsockopt(sFd,SOL_SOCKET,SO_PRIORITY,&up,sizeof(up))
where "up" is the desired user priority (for instance, up=4 to use the AC_VO queue).
This seems to work both with raw and IP datagram sockets.
The problem is that the MAC queues are correctly used only when sending unicast packets (which are actually acknowledged); when sending broadcast (or multicast) data, as I'm required to do, only the "AC_BE" (up=0) queue is used, no matter what I set with SO_PRIORITY.
Do you know why? I actually want to properly use these queues also for broadcast transmissions, as it may be very useful for a research work I'm doing.
This is part of the code I'm using to send the packets out (here a raw socket is used, but the same happens with non-raw sockets, as AF_INET datagram ones):
// Open socket
sFd=socket(AF_PACKET,SOCK_RAW,htons(ETH_P_ALL));
if(sFd==-1)
perror("socket() error");
exit(EXIT_FAILURE);
// Getting WLAN interface index using a custom library (wlanLookup() and macAddrTypeGet() functions
ret_wlanl_val=wlanLookup(devname,&ifindex,srcmacaddr,0);
if(ret_wlanl_val<=0)
fprintf(stderr,"wlanLookup() error.n");
rs_printerror(stderr,ret_wlanl_val);
close(sFd);
exit(EXIT_FAILURE);
if(macAddrTypeGet(srcmacaddr)==MAC_BROADCAST)
fprintf(stderr,"Could not retrieve source MAC address.n");
close(sFd);
exit(EXIT_FAILURE);
// Prepare sockaddr_ll structure
bzero(&addrll,sizeof(addrll));
addrll.sll_ifindex=ifindex;
addrll.sll_family=AF_PACKET;
addrll.sll_protocol=htons(ETH_P_ALL);
// Bind to the wireless interface
if(bind(sFd,(struct sockaddr *) &addrll,sizeof(addrll))<0)
perror("Cannot bind to interface: bind() error");
close(sFd);
exit(EXIT_FAILURE);
// Print AC corresponding to selected UP (and handle possible wrong UP)
up=atoi(argv[3]);
switch(up)
case 0:
case 3:
fprintf(stdout,"AC_BE is selected, with UP: %d.n",up);
break;
case 1:
case 2:
fprintf(stdout,"AC_BK is selected, with UP: %d.n",up);
break;
case 4:
case 5:
fprintf(stdout,"AC_VI is selected, with UP: %d.n",up);
break;
case 6:
case 7:
fprintf(stdout,"AC_VO is selected, with UP: %d.n",up);
break;
default:
fprintf(stderr,"Wrong UP specified. AC_BE will be used.n");
up=0;
break;
// Set user priority using socket layer options (does not work with broadcast?)
if(setsockopt(sFd,SOL_SOCKET,SO_PRIORITY,&up,sizeof(up))!=0)
perror("setsockopt() for SO_PRIORITY error");
close(sFd);
exit(EXIT_FAILURE);
// Set broadcast permission using socket layer options (is this really required?)
if(setsockopt(sFd,SOL_SOCKET,SO_BROADCAST,(void *) &broadPerm,sizeof(broadPerm))!=0)
perror("setsockopt() for SO_BROADCAST error");
close(sFd);
exit(EXIT_FAILURE);
//... Prepare payload, headers and timer to periodically send data...
while(1)
// poll waiting for events happening on the timer descriptor (i.e. wait for timer expiration)
if(poll(&timerMon,1,INDEFINITE_BLOCK)>0)
// "Clear the event" by performing a read() on a junk variable
read(clockFd,&junk,sizeof(junk));
// Send brodcast data (if verbose==1, print '.' for each sent datagram)
// Prepare datagram
// ... Prepare datagram to be sent (contained in "ethernetpacket", with size "finalpktsize")
if(sendto(sFd,ethernetpacket,finalpktsize,0,(struct sockaddr *)&addrll,sizeof(struct sockaddr_ll))!=finalpktsize)
perror("sendto() for sending broadcasted data failed");
fprintf(stderr,"The program will be terminated now");
break;
if(verbose)
fprintf(stdout,".");
fflush(stdout);
//... free variables, close socket, ...
Thank you very much in advance.
c sockets queue broadcast wireless
I'm having some issues with SO_PRIORITY, when used with setsockopt().
My doubt is about the WME MAC layer queues and socket priority when sending packets (defing, among other things, the AIFS times, in place of DIFS). I'm able to set a certain priority with:
setsockopt(sFd,SOL_SOCKET,SO_PRIORITY,&up,sizeof(up))
where "up" is the desired user priority (for instance, up=4 to use the AC_VO queue).
This seems to work both with raw and IP datagram sockets.
The problem is that the MAC queues are correctly used only when sending unicast packets (which are actually acknowledged); when sending broadcast (or multicast) data, as I'm required to do, only the "AC_BE" (up=0) queue is used, no matter what I set with SO_PRIORITY.
Do you know why? I actually want to properly use these queues also for broadcast transmissions, as it may be very useful for a research work I'm doing.
This is part of the code I'm using to send the packets out (here a raw socket is used, but the same happens with non-raw sockets, as AF_INET datagram ones):
// Open socket
sFd=socket(AF_PACKET,SOCK_RAW,htons(ETH_P_ALL));
if(sFd==-1)
perror("socket() error");
exit(EXIT_FAILURE);
// Getting WLAN interface index using a custom library (wlanLookup() and macAddrTypeGet() functions
ret_wlanl_val=wlanLookup(devname,&ifindex,srcmacaddr,0);
if(ret_wlanl_val<=0)
fprintf(stderr,"wlanLookup() error.n");
rs_printerror(stderr,ret_wlanl_val);
close(sFd);
exit(EXIT_FAILURE);
if(macAddrTypeGet(srcmacaddr)==MAC_BROADCAST)
fprintf(stderr,"Could not retrieve source MAC address.n");
close(sFd);
exit(EXIT_FAILURE);
// Prepare sockaddr_ll structure
bzero(&addrll,sizeof(addrll));
addrll.sll_ifindex=ifindex;
addrll.sll_family=AF_PACKET;
addrll.sll_protocol=htons(ETH_P_ALL);
// Bind to the wireless interface
if(bind(sFd,(struct sockaddr *) &addrll,sizeof(addrll))<0)
perror("Cannot bind to interface: bind() error");
close(sFd);
exit(EXIT_FAILURE);
// Print AC corresponding to selected UP (and handle possible wrong UP)
up=atoi(argv[3]);
switch(up)
case 0:
case 3:
fprintf(stdout,"AC_BE is selected, with UP: %d.n",up);
break;
case 1:
case 2:
fprintf(stdout,"AC_BK is selected, with UP: %d.n",up);
break;
case 4:
case 5:
fprintf(stdout,"AC_VI is selected, with UP: %d.n",up);
break;
case 6:
case 7:
fprintf(stdout,"AC_VO is selected, with UP: %d.n",up);
break;
default:
fprintf(stderr,"Wrong UP specified. AC_BE will be used.n");
up=0;
break;
// Set user priority using socket layer options (does not work with broadcast?)
if(setsockopt(sFd,SOL_SOCKET,SO_PRIORITY,&up,sizeof(up))!=0)
perror("setsockopt() for SO_PRIORITY error");
close(sFd);
exit(EXIT_FAILURE);
// Set broadcast permission using socket layer options (is this really required?)
if(setsockopt(sFd,SOL_SOCKET,SO_BROADCAST,(void *) &broadPerm,sizeof(broadPerm))!=0)
perror("setsockopt() for SO_BROADCAST error");
close(sFd);
exit(EXIT_FAILURE);
//... Prepare payload, headers and timer to periodically send data...
while(1)
// poll waiting for events happening on the timer descriptor (i.e. wait for timer expiration)
if(poll(&timerMon,1,INDEFINITE_BLOCK)>0)
// "Clear the event" by performing a read() on a junk variable
read(clockFd,&junk,sizeof(junk));
// Send brodcast data (if verbose==1, print '.' for each sent datagram)
// Prepare datagram
// ... Prepare datagram to be sent (contained in "ethernetpacket", with size "finalpktsize")
if(sendto(sFd,ethernetpacket,finalpktsize,0,(struct sockaddr *)&addrll,sizeof(struct sockaddr_ll))!=finalpktsize)
perror("sendto() for sending broadcasted data failed");
fprintf(stderr,"The program will be terminated now");
break;
if(verbose)
fprintf(stdout,".");
fflush(stdout);
//... free variables, close socket, ...
Thank you very much in advance.
c sockets queue broadcast wireless
c sockets queue broadcast wireless
asked Nov 10 at 15:11
es483
426
426
add a comment |
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53240274%2fproblem-with-so-priority-when-sending-broadcast-packets%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown