Commit ac01c40b authored by Shashi Guruprasad's avatar Shashi Guruprasad

Yet another bugfix + code to call a function that sends NSESWAP event

when it cannot keep up with real-time.

bug: This affected encapsulated simulator packets that had to cross
multiple physical nodes before arriving at the destination simulator
traffic agent. This bug didnt affect live packets from traffic sources
on real PCs.

The NSESWAP event is now sent via the tevc command. The nse scheduler
waits for the slop factor (diff between clock and event dispatch time
that exceeds a threshold) to be crossed multiple times in a second
before sending the NSESWAP event. Currently 5 times in 1 second.
However, this needs more careful thought and will get modified later.
When is it really necessary to declare that an nse is overloaded?
i.e. what is the right slop factor? How many times can we tolerate
that the slop factor is exceeded to ensure end-to-end performance
is within a certain percentage of the expected?
parent d9130657
......@@ -1129,7 +1129,7 @@
(HDR_CMN(p))->direction() = hdr_cmn::DOWN;
/* setting all direction of pkts to be downward as default;
--- dist-ns-allinone-2.26/ns-2.26/common/scheduler.cc Wed Feb 26 15:07:41 2003
+++ ns-allinone-2.26/ns-2.26/common/scheduler.cc Tue Dec 9 14:58:51 2003
+++ ns-allinone-2.26/ns-2.26/common/scheduler.cc Tue Jan 6 17:17:48 2004
@@ -46,12 +46,42 @@
#include "config.h"
#include "scheduler.h"
......@@ -1257,7 +1257,7 @@
return;
}
@@ -956,11 +1010,23 @@
@@ -956,11 +1010,29 @@
virtual void run();
double start() const { return start_; }
virtual void reset();
......@@ -1270,6 +1270,12 @@
double tod();
double slop_; // allowed drift between real-time and virt time
double start_; // starting time
+ int num_violation_; /* Number of times the clock has drifted by
+ * slop between real-time and virtual time
+ */
+ double clock_first_violation_; /* Value of clock when the first
+ * violation is detected
+ */
+#ifdef USEEVENTS
+ TbEventSink *evsink_;
+#endif
......@@ -1281,8 +1287,13 @@
};
static class RealTimeSchedulerClass : public TclClass {
@@ -974,16 +1040,85 @@
RealTimeScheduler::RealTimeScheduler() : start_(0.0)
@@ -971,19 +1043,89 @@
}
} class_realtime_sched;
-RealTimeScheduler::RealTimeScheduler() : start_(0.0)
+RealTimeScheduler::RealTimeScheduler() : start_(0.0), num_violation_(0),
+ clock_first_violation_(0.0)
{
bind("maxslop_", &slop_);
+#ifdef USEEVENTS
......@@ -1367,7 +1378,7 @@
}
void
@@ -991,20 +1126,42 @@
@@ -991,39 +1133,99 @@
{
clock_ = SCHED_START;
start_ = tod();
......@@ -1385,6 +1396,8 @@
{
static const double RTSCHEDULER_MINWAIT = 1.0e-3; // don't wait for less
+ static const double delta = 1.0e-4; // should be smaller than above
+ static const int VIOLATION_THRESHOLD = 5;
+ static const double VIOLATION_TIME_THRESHOLD = 1.0;
const Event *p;
+ bool gethead = true;
+
......@@ -1409,9 +1422,30 @@
- p = head();
+
if (p && (clock_ - p->time_) > slop_) {
fprintf(stderr,
"RealTimeScheduler: warning: slop "
@@ -1014,16 +1171,37 @@
- fprintf(stderr,
- "RealTimeScheduler: warning: slop "
- "%f exceeded limit %f [clock_:%f, p->time_:%f]\n",
- clock_ - p->time_, slop_, clock_, p->time_);
+ num_violation_++;
+ if (num_violation_ == 1 ) {
+ clock_first_violation_ = clock_;
+ } else if(num_violation_ == VIOLATION_THRESHOLD) {
+ double diff = clock_ - clock_first_violation_;
+ if (diff < VIOLATION_TIME_THRESHOLD) {
+ if (evsink_) {
+ evsink_->send_nseswap();
+ }
+ } else {
+ clock_first_violation_ = clock_;
+ num_violation_ = 1;
+ }
+ }
+ fprintf(stderr,
+ "RealTimeScheduler: warning: slop "
+ "%f exceeded limit %f [clock_:%f, p->time_:%f]\n",
+ clock_ - p->time_, slop_, clock_, p->time_);
+ clock_ = tod();
}
// handle "old events"
while (p && p->time_ <= clock_) {
......@@ -1450,7 +1484,7 @@
clock_ = tod();
} else {
double diff = p->time_ - clock_;
@@ -1031,12 +1209,14 @@
@@ -1031,12 +1233,14 @@
if (diff > RTSCHEDULER_MINWAIT) {
Tcl_Time to;
to.sec = long(diff);
......@@ -1693,7 +1727,7 @@
protected:
int command(int argc, const char*const* argv);
--- dist-ns-allinone-2.26/ns-2.26/emulate/iptap.cc Wed Feb 26 15:08:40 2003
+++ ns-allinone-2.26/ns-2.26/emulate/iptap.cc Sun Dec 14 20:48:47 2003
+++ ns-allinone-2.26/ns-2.26/emulate/iptap.cc Wed Jan 7 01:49:13 2004
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 1998 The Regents of the University of California.
......@@ -1822,7 +1856,7 @@
+
+ Packet::free(p);
+ return;
+
+#endif
+
+#if 0 //MEASURE_EVENT_RATE
......@@ -1832,7 +1866,7 @@
+ firstpacket++;
+ }
+#endif
+
+ /* PcapNetwork created this packet and does not know how
+ to initialize it. So, we need to do that here by calling
+ the base Agent class's initpkt method */
......@@ -1840,7 +1874,7 @@
/*
At this point, all I have to do is to grab the ttl value
from the received packet and put it in p's ttl field after
@@ -180,15 +281,55 @@
@@ -180,15 +281,56 @@
hdr_ip *ih = HDR_IP(p);
ih->ttl() = ttl;
......@@ -1873,12 +1907,13 @@
+ /* If there is an error in uncompress, we won't really know other than the
+ fact that we copied junk into the packet. Something to worry about later
+ */
+ goto inject;
+ }
+ } else {
+ ih->daddr() = ntohl(ipheader->ip_dst.s_addr);
+ /* Dunno how to take care of ports yet */
+ }
+ }
+ ih->daddr() = ntohl(ipheader->ip_dst.s_addr);
+ /* Dunno how to take care of ports yet */
+
+inject:
+
+#ifdef MEASURE_DELAYS
+ Scheduler::instance().schedule( target_, p, max_delay );
......@@ -1897,7 +1932,7 @@
* as there are from the packet capture facility.
* For every packet received through the callback, it populates the ns packet
* ttl value and inject it into the simulator by calling target_->recv
@@ -197,14 +338,17 @@
@@ -197,14 +339,17 @@
void
IPTapAgent::recvpkt()
{
......@@ -1917,7 +1952,7 @@
if (cc <= 0) {
if (cc < 0) {
perror("recv");
@@ -219,13 +363,64 @@
@@ -219,13 +364,64 @@
}
......@@ -1983,7 +2018,7 @@
*/
int
IPTapAgent::sendpkt(Packet* p)
@@ -233,10 +428,11 @@
@@ -233,10 +429,11 @@
int byteswritten;
unsigned char *packet;
unsigned char received_ttl;
......@@ -1997,7 +2032,7 @@
fprintf(stderr,
"IPTapAgent(%s): sendpkt called while in read-only mode!\n",
name());
@@ -245,7 +441,7 @@
@@ -245,7 +442,7 @@
// send packet into the live network
hdr_cmn* hc = HDR_CMN(p);
......@@ -2006,7 +2041,7 @@
fprintf(stderr,
"IPTapAgent(%s): sendpkt attempted with NULL net\n",
name());
@@ -273,27 +469,172 @@
@@ -273,27 +470,172 @@
return(-1);
}
......@@ -2360,7 +2395,7 @@
icp->icmp_cksum = Internet::in_cksum((u_short*)icp,
8 + sizeof(ip) + 8);
--- /dev/null Mon Jan 5 13:10:04 2004
--- /dev/null Wed Jan 7 01:55:37 2004
+++ ns-allinone-2.26/ns-2.26/emulate/icmp.h Sun Dec 14 20:33:36 2003
@@ -0,0 +1,50 @@
+/*
......
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