Netdev List
 help / color / mirror / Atom feed
From: Eric Dumazet <eric.dumazet@gmail.com>
To: Hagen Paul Pfeifer <hagen@jauu.net>
Cc: netdev@vger.kernel.org, Stephen Hemminger <shemminger@vyatta.com>
Subject: Re: [PATCH v2 net-next 2/2] netem: add cell concept to simulate special MAC behavior
Date: Tue, 29 Nov 2011 00:01:07 +0100	[thread overview]
Message-ID: <1322521267.2970.43.camel@edumazet-laptop> (raw)
In-Reply-To: <1322187773-27768-2-git-send-email-hagen@jauu.net>

Le vendredi 25 novembre 2011 à 03:22 +0100, Hagen Paul Pfeifer a écrit :
> This extension can be used to simulate special link layer
> characteristics. Simulate because packet data is not modified, only the
> calculation base is changed to delay a packet based on the original
> packet size and artificial cell information.
> 
> packet_overhead can be used to simulate a link layer header compression
> scheme (e.g. set packet_overhead to -20) or with a positive
> packet_overhead value an additional MAC header can be simulated. It is
> also possible to "replace" the 14 byte Ethernet header with something
> else.
> 
> cell_size and cell_overhead can be used to simulate link layer schemes,
> based on cells, like some TDMA schemes. Another application area are MAC
> schemes using a link layer fragmentation with a (small) header each.
> Cell size is the maximum amount of data bytes within one cell. Cell
> overhead is an additional variable to change the per-cell-overhead (e.g.
> 5 byte header per fragment).
> 
> Example (5 kbit/s, 20 byte per packet overhead, cellsize 100 byte, per
> cell overhead 5 byte):
> 
> 	tc qdisc add dev eth0 root netem rate 5kbit 20 100 5
> 
> Signed-off-by: Hagen Paul Pfeifer <hagen@jauu.net>
> ---
>  include/linux/pkt_sched.h |    3 +++
>  net/sched/sch_netem.c     |   30 +++++++++++++++++++++++++++---
>  2 files changed, 30 insertions(+), 3 deletions(-)
> 
> diff --git a/include/linux/pkt_sched.h b/include/linux/pkt_sched.h
> index 26c37ca..63845cf 100644
> --- a/include/linux/pkt_sched.h
> +++ b/include/linux/pkt_sched.h
> @@ -498,6 +498,9 @@ struct tc_netem_corrupt {
>  
>  struct tc_netem_rate {
>  	__u32	rate;	/* byte/s */
> +	__s32   packet_overhead;
> +	__u32   cell_size;
> +	__s32   cell_overhead;
>  };
>  
>  enum {
> diff --git a/net/sched/sch_netem.c b/net/sched/sch_netem.c
> index 9b7af9f..11ca527 100644
> --- a/net/sched/sch_netem.c
> +++ b/net/sched/sch_netem.c
> @@ -80,6 +80,9 @@ struct netem_sched_data {
>  	u32 reorder;
>  	u32 corrupt;
>  	u32 rate;
> +	s32 packet_overhead;
> +	u32 cell_size;
> +	s32 cell_overhead;
>  
>  	struct crndstate {
>  		u32 last;
> @@ -299,9 +302,24 @@ static psched_tdiff_t tabledist(psched_tdiff_t mu, psched_tdiff_t sigma,
>  	return  x / NETEM_DIST_SCALE + (sigma / NETEM_DIST_SCALE) * t + mu;
>  }
>  
> -static psched_time_t packet_len_2_sched_time(unsigned int len, u32 rate)
> +static psched_time_t packet_len_2_sched_time(unsigned int len,
> +					     struct netem_sched_data *q)
>  {
> -	return PSCHED_NS2TICKS((u64)len * NSEC_PER_SEC / rate);
> +	len += q->packet_overhead;
> +
> +	if (q->cell_size) {
> +		u32 carry = len % q->cell_size;
> +		len += carry;

I dont understand this part  (len += carry;)

Also you use a lot of divides... Probably OK for netem...

> +
> +		if (q->cell_overhead) {
> +			u32 cells = len / q->cell_size;
> +			if (carry)
> +				cells += 1;
> +			len += cells * q->cell_overhead;
> +		}
> +	}
> +
> +	return PSCHED_NS2TICKS((u64)len * NSEC_PER_SEC / q->rate);
>  }

  reply	other threads:[~2011-11-28 23:01 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-24 17:39 [PATCH net-next 1/2] netem: rate-latency extension Hagen Paul Pfeifer
2011-11-24 17:39 ` [PATCH net-next 2/2] netem: add cell concept to simulate special MAC behavior Hagen Paul Pfeifer
2011-11-24 22:14 ` [PATCH net-next 1/2] netem: rate-latency extension Eric Dumazet
2011-11-24 22:31   ` Hagen Paul Pfeifer
2011-11-25  1:06     ` Bill Fink
2011-11-25  1:23       ` Hagen Paul Pfeifer
2011-11-25  5:09   ` Stephen Hemminger
2011-11-25  6:13     ` Eric Dumazet
2011-11-25 12:02       ` Hagen Paul Pfeifer
2011-11-25  2:22 ` [PATCH v2 net-next 1/2] netem: rate extension Hagen Paul Pfeifer
2011-11-25  2:22   ` [PATCH v2 net-next 2/2] netem: add cell concept to simulate special MAC behavior Hagen Paul Pfeifer
2011-11-28 23:01     ` Eric Dumazet [this message]
2011-11-28 23:30       ` Hagen Paul Pfeifer
2011-11-28 23:48         ` Eric Dumazet
2011-11-29  0:07           ` Hagen Paul Pfeifer
2011-11-26 11:00   ` [PATCH v2 net-next 1/2] netem: rate extension Eric Dumazet
2011-11-25  2:23 ` [PATCH v2 iproute2 1/2] utils: add s32 parser Hagen Paul Pfeifer
2011-11-25  2:23   ` [PATCH v2 iproute2 2/2] tc: netem rate shaping and cell extension Hagen Paul Pfeifer

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=1322521267.2970.43.camel@edumazet-laptop \
    --to=eric.dumazet@gmail.com \
    --cc=hagen@jauu.net \
    --cc=netdev@vger.kernel.org \
    --cc=shemminger@vyatta.com \
    /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