Re: Patch to allow for the ATM "cell tax"

Linux Advanced Routing and Traffic Control

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Am Donnerstag, 2. März 2006 20:54 schrieb Adam James:
> Hi,
>
> On Thu, 2006-03-02 at 15:49 +0000, Andy Furniss wrote:
> > Russell Stuart wrote:
> > > The following patch to tc allows it to perform an exact
> > > ATM / ADSL rate calculation.
> >
> > I probably haven't read the patch properly - but I don't think you
> > can do it exactly without patching net/sched/sched_htb.c aswell.
> > Specifically you need to add overhead - 1 before htb shifts the
> > length to get the slot num (-1 because you need to get 48 and 49
> > payload length to map to different slots 47 and 48 do). The table
> > should be filled according to this.
>
> As Markus mentioned in another post on this thread, Jesper Dangaard
> Brouer (http://www.adsl-optimizer.dk) has already written an iproute2
> and Linux kernel patch that implements the above. ATM cell alignment
> is done in tc_core.c, and the per packet overhead is passed to the
> relevant kernel modules.

once again i have thought about this topic and tried to built a rate 
table with exactly the same behaviour as the htb-overhead patch from 
Jesper. But now as static patch for iproute's tc, without need for 
patching htb or other kernel modules.

But in all my experiments i can't calculate an equivalent rate table.
It differs in behaviour from per packet calculated overhead. But i don't 
see the difference in mathematics in both calculations. I think it must 
be possible, but can't see my fault. With a rate table of at least one 
entry from zero (or 40b) to <mtu> it is possible. But, is it possible 
with only 256 rate table entries?

I've attached a simple program, which implements three versions of 
calculations. Two of them use a rate table, at first the static version 
(without htb-overhead patch), second one with "simulated" kernel patch 
(like Jesper's one) and at least a "realtime calculation" as a 
reference value.

The second rate table is 100% equivalent to realtime calc. But the 
static version differs for some ip-length values from it. And i don't 
understand why. 
Perhaps someone can point me to the difference?
The program is only for testing rate tables calculations.

It would be nice to do it without a htb or other qdisc module patch. And 
i think it should be possible :)

-- 	
Markus Schulz
#include <stdio.h>
#include <stdlib.h>

int align_to_cell(int packet_size, int cell_size, int cell_payload) 
{
  int needed_cells;
  needed_cells = packet_size / cell_payload;
  if((packet_size % cell_payload) > 0)
    needed_cells++;
  return needed_cells * cell_size;
}

int main(int argc, char** argv)
{
  if(argc < 4)
  {
    printf("usage: %s <bps> <mtu> <mpu> <overhead> <0|1 for show rate table>\n", argv[0]);
    return 1;
  }

  int bps = atoi(argv[1]);
  int mtu = atoi(argv[2]);
  int mpu = atoi(argv[3]);
  int overhead = atoi(argv[4]);
  int show_rates=0;
  if(argc > 5)
    show_rates = atoi(argv[5]); 

  if(mtu == 0 )
  {
    printf("mtu == 0\n");
    return 1;
  }

  int cell_log = 0;
  int i;
  while ((mtu>>cell_log) > 255)
    cell_log++;

  unsigned int rate_table_static[256];
  unsigned int rate_table_dynamic[256];

  printf("cell_log = %d\n", cell_log);
  for (i=0; i<256; i++) 
  {
    unsigned sz1 = ((i+1)<<cell_log);
    unsigned sz2 = ((i+1)<<cell_log);
    //static overhead calculated in rate table
    sz1 += overhead; 

    if (sz1 < mpu)
      sz1 = mpu;
    if (sz2 < mpu)
      sz2 = mpu;
    //align both rate tables to ATM cells
    sz1 = align_to_cell(sz1, 53, 48);
    sz2 = align_to_cell(sz2, 53, 48);

    rate_table_static[i] = (1000000*sz1)/bps;
    rate_table_dynamic[i] = (1000000*sz2)/bps; 
  }
     
  //print both tables?
  if(show_rates)
  {
    int j;
    printf("Complete rate table:\n");
    for(j=0; j < 256;j++)
    {
      printf("Entry:%d Static-overhead: %d    Dynamic-overhead: %d\n", j,rate_table_static[j], rate_table_dynamic[j]);
    }
  }
  int k=0;
  printf("check from 40 byte to <MTU all possible packets and compare rate table entries.\n");
  printf("rate1 -> static overhead calculation\n");
  printf("rate2 -> dynamic overhead calcuation\n");
  printf("rate3 -> realtime calculation. this is the reference value\n");
  int rate1_err=0;
  int rate2_err=0;
  for(k=40; k < mtu;k++)
  {
    //bytes to send at ip-layer (at least 40)
    int ps = k;

    //static overhead calculated already in rate table
    unsigned int rate1 = rate_table_static[ps >> cell_log];

    //dynamic overhead calculated in kernel L2T
    unsigned int rate2 = rate_table_dynamic[(ps-1 + overhead) >> cell_log];

    //realtime calculated
    int sz3 = ps + overhead;
    if(sz3 < mpu)
      sz3 = mpu;
    sz3 = align_to_cell(sz3, 53, 48);
    unsigned int rate3 = (1000000*sz3) /bps;


    if(rate1 != rate3)
    {
      printf("rate1 is wrong: Bytes at IP-Layer = %d rate1=%d rate3 = %d\n", ps, rate1, rate3);
      rate1_err++;
    }
    if(rate2 != rate3)
    {
      printf("rate2 is wrong: Bytes at IP-Layer = %d rate2=%d rate3 = %d\n", ps, rate2, rate3);
      rate2_err++;
    }
  }
  printf("Rate1 Error: %d    Rate2 Error: %d\n", rate1_err, rate2_err);
  return 0;
}
_______________________________________________
LARTC mailing list
LARTC@xxxxxxxxxxxxxxx
http://mailman.ds9a.nl/cgi-bin/mailman/listinfo/lartc

[Index of Archives]     [LARTC Home Page]     [Netfilter]     [Netfilter Development]     [Network Development]     [Bugtraq]     [GCC Help]     [Yosemite News]     [Linux Kernel]     [Fedora Users]
  Powered by Linux