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

Achtung! QoS mit DSL (war: UL/DL-Bremse)



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hallo,

> QoS und http://lartc.org/

kleiner Tip an alle die Trafficshaping mit tc aus dem iproute2-packet und an 
einem DSL-Anschluss nutzen wollen:

Da DSL auf ATM-Basis arbeitet, "verrechnet" sich tc bei der Bestimmung der 
aktuell genutzten Bandbreite (ATM benutzt immer 53 byte große Zellen, wenn 
die nicht zu 100% gefüllt sind, geht Bandbreite effektiv verloren). Das hat 
den Effekt, das das Trafficshaping, z.B. mit HTB, zwar korrekt eingerichtet 
ist, man aber kein ordenliches QoS zustande bringt, da sich die Packete 
weiterhin am DSL-Modem stauen.

Nachzulesen ist das ganze in diesem Artikel und dem folgenden Thread:
http://mailman.ds9a.nl/pipermail/lartc/2004q2/012752.html

In diesem Artikel wurde ein Patch für tc veröffentlicht, um das Problem zu 
beheben.

Ich habe mir mal den Patch genommen und ein bißchen herumexperimentiert.
Hiermit habe ich die besten Ergebnisse erzielt (an einem T-DSL Anschluss, 
dürfte aber an jedem beliebigen PPPoE Anschluss gleich sein):

	
	// HACK - UK ATM Params
	int encaps_cell_sz = 53;
	int encaps_cell_overhead = 5;
	int encaps_data_sz = encaps_cell_sz - encaps_cell_overhead;
	int proto_overhead = 40; // 10 LLC + 14 ethernet + 8 PPPoE  + 8 AAL5


Ich hänge das komplette Sourcefile nochmal an diese Mail. Die Datei stammt 
ursprünglich aus dem iproute2-2.6.8 Packet von 
http://developer.osdl.org/dev/iproute2.

Mit diesem Patch für tc kann ich 98% meiner Upload-Badbreite nutzen, und habe 
trotzdem gutes QoS. :-)

Bei Bedarf kann ich euch auch meine Binary zukommen lassen, weiß aber nicht ob 
es da Probleme mit verschiedenen Kernel-Versionen gibt.

Viele Grüsse,
    Stefan

- -- 
In a free world nobody needs Windows and Gates.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)

iD8DBQFBU/N5Fdd7dooRJzsRAsMTAJ95Iuxx6Q3bglWsdh7YB2R9jaerIwCfd7wG
EG5BQV65eL0DHp1eKY9SRzM=
=LISK
-----END PGP SIGNATURE-----
/*
 * tc_core.c		TC core library.
 *
 *		This program is free software; you can redistribute it and/or
 *		modify it under the terms of the GNU General Public License
 *		as published by the Free Software Foundation; either version
 *		2 of the License, or (at your option) any later version.
 *
 * Authors:	Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru>
 *
 */

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <syslog.h>
#include <fcntl.h>
#include <math.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <string.h>

#include "tc_core.h"

static __u32 t2us=1;
static __u32 us2t=1;
static double tick_in_usec = 1;

long tc_core_usec2tick(long usec)
{
	return usec*tick_in_usec;
}

long tc_core_tick2usec(long tick)
{
	return tick/tick_in_usec;
}

unsigned tc_calc_xmittime(unsigned rate, unsigned size)
{
	return tc_core_usec2tick(1000000*((double)size/rate));
}

/*
   rtab[pkt_len>>cell_log] = pkt_xmit_time
 */

int tc_calc_rtable(unsigned bps, __u32 *rtab, int cell_log, unsigned mtu,
		   unsigned mpu)
{
	int i;
	unsigned overhead = (mpu >> 8) & 0xFF;
	mpu = mpu & 0xFF;

	if (mtu == 0)
		mtu = 2047;

	if (cell_log < 0) {
		cell_log = 0;
		while ((mtu>>cell_log) > 255)
			cell_log++;
	}
	
	// HACK - UK ATM Params
	int encaps_cell_sz = 53;
	int encaps_cell_overhead = 5;
	int encaps_data_sz = encaps_cell_sz - encaps_cell_overhead;
	int proto_overhead = 40; // 10 LLC + 14 ethernet + 8 PPPoE  + 8 AAL5

	
	for (i=0; i<256; i++) {
		unsigned sz = ((i+1)<<cell_log)-1;
		if (overhead)
			sz += overhead;
//		sz = ((i+1)<<cell_log)-1;
		sz = sz + proto_overhead;
		sz = (  (int)((sz-1)/encaps_data_sz) + 1) * encaps_cell_sz;

		rtab[i] = tc_core_usec2tick(1000000*((double)sz/bps));
	}
	return cell_log;
}

int tc_core_init()
{
	FILE *fp = fopen("/proc/net/psched", "r");

	if (fp == NULL)
		return -1;

	if (fscanf(fp, "%08x%08x", &t2us, &us2t) != 2) {
		fclose(fp);
		return -1;
	}
	fclose(fp);
	tick_in_usec = (double)t2us/us2t;
	return 0;
}

Reply to: