From: Srikanth <srikanth_w@naturesoft.net>
To: lartc@vger.kernel.org
Subject: Re: [LARTC] CBQ DEVICE BW?
Date: Fri, 23 May 2003 12:38:20 +0000 [thread overview]
Message-ID: <marc-lartc-105369312612546@msgid-missing> (raw)
In-Reply-To: <marc-lartc-105367981700469@msgid-missing>
[-- Attachment #1: Type: text/plain, Size: 2891 bytes --]
One more question,
Stef Coene wrote:
>On Friday 23 May 2003 10:44, Srikanth wrote:
>
>
>>Hi,
>>
>>The CBQ config file shud be some thing like this.
>>
>>DEVICE=eth0,10Mbit,1Mbit
>>RATE=50Kbit
>>WEIGHT=5Kbit
>>
>>Shall i hardcode the DEVICE BW as 10/100 Mbit
>>or
>>Shall i use any other tool like ethtool for getting this.
>>ethtool gives Speed: 10Mbps
>>
>>If so, how about, if i use some other Interfaces other than eth0,
>>like ppp0 or some other?
>>
>>C'd anybody can give a suggestion over this?
>>
>>
>Bandwidth should be the real physical bandwidth of the device.
>
>
How do i get the real physical bandwidth of the device?
The below program attached is giving the value 6, on my system.
In some other systems, it's giving 2 (don't know whether Kbps/Mbps).
>Stef
>
/*
* Gets the bandwidth of the interface.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <db.h>
#include <sys/types.h>
#include <sys/time.h>
#include <fcntl.h>
#include <sys/socket.h>
#include <sys/ioctl.h>
//#include <netdb.h>
#include <linux/in.h>
#include <linux/if.h>
#include "ifstats.h"
extern int errno;
int
IFSGetBandwidth (if_stats_desc_struct * ifsd)
{
//#ifdef HAS_SIOCGIFINDEX
int s, status;
struct ifreq ifr;
struct in_addr ina;
if_ip_addr_union ip;
if (ifsd == NULL)
{
printf("case 1\n");
return (-1);
}
/* Must have a specified interface. */
if (ifsd->interface == NULL)
{
printf("case 2\n");
return (-1);
}
/* Create a UDP socket. */
s = socket (AF_INET, SOCK_DGRAM, 0);
if (s < 0)
{
printf("case 3\n");
return (-1);
}
/* Set interface name explicitly from ifsd. */
strncpy (ifr.ifr_name, ifsd->interface, IFNAMSIZ);
ifr.ifr_name[IFNAMSIZ - 1] = '\0';
/* Get bandwidth of interface and put into interface request
* * structure.
* */
status = ioctl(s, SIOCGIFINDEX, &ifr);
/* Close socket. */
close (s);
/* ioctl() failed? */
if (status < 0)
{
perror("! Ioctl");
printf("case 4\n");
return (-1);
}
ifsd->bandwidth = ifr.ifr_bandwidth;
printf("Hello World\n");
printf("Bandwidth: %i\n", ifsd->bandwidth);
//#endif /* HAS_SIOCGIFINDEX */
return (0);
}
main ()
{
int retVal;
if_stats_desc_struct * ifsd;
ifsd = (if_stats_desc_struct *) malloc(sizeof(if_stats_desc_struct));
if (ifsd == NULL)
perror("! Malloc");
ifsd->interface = (char *) malloc(20);
if (ifsd->interface == NULL)
perror("! Malloc");
strcpy(ifsd->interface, "eth0");
retVal = IFSGetBandwidth (ifsd);
free(ifsd->interface);
free(ifsd);
printf("retVal = %d\n", retVal);
}
regards,
Srikanth.
>
>
>
[-- Attachment #2: Type: text/html, Size: 5363 bytes --]
next prev parent reply other threads:[~2003-05-23 12:38 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-05-23 8:56 [LARTC] CBQ DEVICE BW? Srikanth
2003-05-23 10:14 ` Stef Coene
2003-05-23 11:49 ` Srikanth
2003-05-23 12:38 ` Srikanth [this message]
2003-05-23 16:53 ` Stef Coene
2003-05-24 4:30 ` Srikanth
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=marc-lartc-105369312612546@msgid-missing \
--to=srikanth_w@naturesoft.net \
--cc=lartc@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox