Hi -
I've noticed that DelayUnqueue always updates the timestamp of output
packets to the current time. The enclosed patch adds an optional UPDATE
configuration parameter (default=true) that can turn off this behavior.
cheers,
- Ian
--- click-HEAD/elements/standard/delayunqueue.cc 2010-03-03 13:59:43.982635000 -0500
+++ click-1.7.0rc1/elements/standard/delayunqueue.cc 2010-05-06 12:57:37.221473000 -0400
@@ -25,7 +25,7 @@
CLICK_DECLS
DelayUnqueue::DelayUnqueue()
- : _p(0), _task(this), _timer(&_task)
+ : _p(0), _task(this), _timer(&_task), _set_timestamp(true)
{
}
@@ -38,6 +38,7 @@
{
return cp_va_kparse(conf, this, errh,
"DELAY", cpkP+cpkM, cpTimestamp, &_delay,
+ "UPDATE", cpkP, cpBool, &_set_timestamp,
cpEnd);
}
@@ -67,21 +68,22 @@
if (!_p && (_p = input(0).pull())) {
if (!_p->timestamp_anno().sec()) // get timestamp if not set
_p->timestamp_anno().assign_now();
- _p->timestamp_anno() += _delay;
}
if (_p) {
Timestamp now = Timestamp::now();
- if (_p->timestamp_anno() <= now) {
+ Timestamp send_time = _p->timestamp_anno() + _delay;
+ if (send_time <= now) {
// packet ready for output
- _p->timestamp_anno() = now;
+ if (_set_timestamp)
+ _p->timestamp_anno() = now;
output(0).push(_p);
_p = 0;
worked = true;
goto retry;
}
- Timestamp expiry = _p->timestamp_anno() - Timer::adjustment();
+ Timestamp expiry = send_time - Timer::adjustment();
if (expiry <= now)
// small delta, reschedule Task
/* Task rescheduled below */;
@@ -107,10 +109,21 @@
return u->_delay.unparse_interval();
}
+int
+DelayUnqueue::write_param(const String &s_in, Element *e, void *, ErrorHandler *errh)
+{
+ DelayUnqueue *u = (DelayUnqueue *)e;
+ if (!cp_time(s_in, &u->_delay))
+ return errh->error("delay must be a timestamp");
+ u->_task.reschedule();
+ return 0;
+}
+
void
DelayUnqueue::add_handlers()
{
add_read_handler("delay", read_param, (void *)0, Handler::CALM);
+ add_write_handler("delay", write_param, (void *)0);
add_task_handlers(&_task);
}
--- click-HEAD/elements/standard/delayunqueue.hh 2010-03-03 13:59:43.985622000 -0500
+++ click-1.7.0rc1/elements/standard/delayunqueue.hh 2010-05-06 12:56:58.727553000 -0400
@@ -9,7 +9,7 @@
/*
=c
-DelayUnqueue(DELAY)
+DelayUnqueue(DELAY[, UPDATE])
=s shaping
@@ -19,12 +19,16 @@
Pulls packets from the single input port. Delays them for at least DELAY
seconds, with microsecond precision. A packet with timestamp T will be emitted
-no earlier than time (T + DELAY). On output, the packet's timestamp is set to
-the current time.
+no earlier than time (T + DELAY). If UPDATE is true (which is the default), then
+each output packet's timestamp is set to the current time.
DelayUnqueue listens for upstream notification, such as that available from
Queue.
+=h delay read/write
+
+Returns or sets the DELAY parameter.
+
=a Queue, Unqueue, RatedUnqueue, BandwidthRatedUnqueue, LinkUnqueue,
DelayShaper, SetTimestamp */
@@ -44,6 +48,7 @@
bool run_task(Task *);
static String read_param(Element *e, void *);
+ static int write_param(const String&, Element *e, void*, ErrorHandler*);
private:
@@ -52,7 +57,7 @@
Task _task;
Timer _timer;
NotifierSignal _signal;
-
+ bool _set_timestamp;
};
CLICK_ENDDECLS
_______________________________________________
click mailing list
[email protected]
https://amsterdam.lcs.mit.edu/mailman/listinfo/click