Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How do I shape traffic under Linux

Posted on 1999-10-01
1
Medium Priority
?
274 Views
Last Modified: 2010-03-18
I think I'm missing something. I've read the documentation on the shapeconfig module for Linux, but I can't find the module anywhere. Anyone know how to install this and get it running?
0
Comment
Question by:cdickinson
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 2

Accepted Solution

by:
canani earned 100 total points
ID: 2094119
1) You'll have to user 2.0.36 or later
2) Compile your kernel with the following options:


        Code maturity level options  --->
[*] Prompt for development and/or incomplete code/drivers
        Network device support  --->
<M> Traffic Shaper (EXPERIMENTAL)

Obs: ALWAYS user Traffic Shaper as a module

3. Activate kerneld in /etc/rc.d/rc.modules
4. edit file:
        /lib/modules/xxx/modules.dep (xxx = kernel version)

and put an entry for each shaper you want to use, for
example:
        /lib/modules/xxx/net/shaper.o:
        /lib/modules/xxx/net/shaper1.o:
        /lib/modules/xxx/net/shaper2.o:

5. cd /lib/modules/xxx/net, and link all shapers as follows:

ln -s shaper.o shaper1.o
ln -s shaper.o shaper2.o

6. Insert an entry for each shaper in file /etc/rc.d/rc.modules:

modprob shaper
modprob shaper1
modprob shaper2

7. Initialization file for the shapers in file
/etc/rc.d/rc.local:

##########################################
# Shaper for Subnet 0 - 64Kbps
/sbin/shapecfg attach shaper0 eth1
/sbin/shapecfg speed shaper0 65536
/sbin/ifconfig shaper0 200.208.96.129 broadcast 200.208.96.255 netmask 255.255.255.128
/sbin/route add -host 200.208.96.130 dev shaper0

# Shaper for subnet 1 - 64Kbps
/sbin/shapecfg attach shaper1 eth1
/sbin/shapecfg speed shaper1 65536
/sbin/ifconfig shaper1 200.208.96.3 broadcast 200.208.96.129 netmask 255.255.255.128
/sbin/route add -host 200.208.96.130 dev shaper1
##########################################

You'll have to add the routes for the subnet informing
the shaper as the interface as the last argument to the 'route' command.

Use only for outgoing traffic shapping

Use speeds from 9600 to 256000

Never use it with PPP interfaces.


Good Luck


shapecfg.c - compile it and move the executable to /sbin

/***************************** SHAPECFG  - BEGIN ******************************/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <linux/types.h>
#include <linux/if.h>
#include <linux/if_shaper.h>

void usage(char *name)
{
fprintf(stderr,"%s attach <device> <device>\n%s speed <device> <speed>\n",
name,name);
exit(1);
}

void main(int argc, char *argv[])
{
int s=socket(AF_INET, SOCK_DGRAM,0);
if(s==-1)
{
perror("socket");
exit(1);
}
if(argc!=4)
usage(argv[0]);
if(strcmp(argv[1],"attach")==0)
{
struct ifreq ifr;
struct shaperconf *shc=(struct shaperconf *)&ifr.ifr_data;
strcpy(ifr.ifr_name,argv[2]);
strcpy(shc->ss_name,argv[3]);
shc->ss_cmd=SHAPER_SET_DEV;
if(ioctl(s,SIOCDEVPRIVATE,&ifr)==-1)
{
perror("shaper");
exit(1);
}
exit(0);
}
if(strcmp(argv[1],"speed")==0)
{
int v;
struct ifreq ifr;
struct shaperconf *shc=(struct shaperconf *)&ifr.ifr_data;
strcpy(ifr.ifr_name,argv[2]);
sscanf(argv[3],"%d",&v);
shc->ss_speed=v;
shc->ss_cmd=SHAPER_SET_SPEED;
if(ioctl(s,SIOCDEVPRIVATE,&ifr)==-1)
{
perror("shaper");
exit(1);
}
exit(0);
}
usage(argv[0]);
}
/***************************** SHAPECFG  - END ******************************/
0

Featured Post

Building an interactive eFuture classroom

Watch and learn how ATEN provided a total control system solution including seamless switching matrix switch, HDBaseT extenders, PDU, lighting control to build an interactive eFuture classroom.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have seen several blogs and forum entries elsewhere state that because NTFS volumes do not support linux ownership or permissions, they cannot be used for anonymous ftp upload through the vsftpd program.   IT can be done and here's how to get i…
Note: for this to work properly you need to use a Cross-Over network cable. 1. Connect both servers S1 and S2 on the second network slots respectively. Note that you can use the 1st slots but usually these would be occupied by the Service Provide…
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question