Commit e6df0656 authored by Stephen Hemminger's avatar Stephen Hemminger Committed by Linus Torvalds

[PKT_SCHED]: Add loss option to network delay scheduler.

This enhances the network simulation scheduler to do simple random loss.

The loss parameter is a simple 32 bit value such that 0 means no loss, and
0xffffffff is always drop.  I have a new version of the tc command which takes
care of conversion from percent to this value.

Same patch for 2.4 and 2.6
Signed-off-by: default avatarStephen Hemminger <shemminger@osdl.org>
Signed-off-by: default avatarDavid S. Miller <davem@redhat.com>
parent e200c64b
...@@ -437,5 +437,6 @@ struct tc_dly_qopt ...@@ -437,5 +437,6 @@ struct tc_dly_qopt
{ {
__u32 latency; __u32 latency;
__u32 limit; __u32 limit;
__u32 loss;
}; };
#endif #endif
...@@ -40,6 +40,7 @@ ...@@ -40,6 +40,7 @@
struct dly_sched_data { struct dly_sched_data {
u32 latency; u32 latency;
u32 limit; u32 limit;
u32 loss;
struct timer_list timer; struct timer_list timer;
struct Qdisc *qdisc; struct Qdisc *qdisc;
}; };
...@@ -58,6 +59,12 @@ static int dly_enqueue(struct sk_buff *skb, struct Qdisc *sch) ...@@ -58,6 +59,12 @@ static int dly_enqueue(struct sk_buff *skb, struct Qdisc *sch)
struct dly_skb_cb *cb = (struct dly_skb_cb *)skb->cb; struct dly_skb_cb *cb = (struct dly_skb_cb *)skb->cb;
int ret; int ret;
/* Random packet drop 0 => none, ~0 => all */
if (q->loss >= net_random()) {
sch->stats.drops++;
return 0; /* lie about loss so TCP doesn't know */
}
PSCHED_GET_TIME(cb->queuetime); PSCHED_GET_TIME(cb->queuetime);
/* Queue to underlying scheduler */ /* Queue to underlying scheduler */
...@@ -197,6 +204,7 @@ static int dly_change(struct Qdisc *sch, struct rtattr *opt) ...@@ -197,6 +204,7 @@ static int dly_change(struct Qdisc *sch, struct rtattr *opt)
} else { } else {
q->latency = qopt->latency; q->latency = qopt->latency;
q->limit = qopt->limit; q->limit = qopt->limit;
q->loss = qopt->loss;
} }
return err; return err;
} }
...@@ -233,6 +241,7 @@ static int dly_dump(struct Qdisc *sch, struct sk_buff *skb) ...@@ -233,6 +241,7 @@ static int dly_dump(struct Qdisc *sch, struct sk_buff *skb)
qopt.latency = q->latency; qopt.latency = q->latency;
qopt.limit = q->limit; qopt.limit = q->limit;
qopt.loss = q->loss;
RTA_PUT(skb, TCA_OPTIONS, sizeof(qopt), &qopt); RTA_PUT(skb, TCA_OPTIONS, sizeof(qopt), &qopt);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment