Commit 1f897669 authored by Mike Hibler's avatar Mike Hibler

Remove hokey loss rate code

parent 2ff95cee
...@@ -34,9 +34,6 @@ LDFLAGS = -static ...@@ -34,9 +34,6 @@ LDFLAGS = -static
# Define this to a non-zero value to enable recording of trace data # Define this to a non-zero value to enable recording of trace data
#CFLAGS += -DNEVENTS=20000 #CFLAGS += -DNEVENTS=20000
# Turn on server packet loss rate ability
#CFLAGS += -DDOLOSSRATE
# Turn on client event handling # Turn on client event handling
#CFLAGS += -DDOEVENTS #CFLAGS += -DDOEVENTS
#CLIENTOBJS += event.o $(OBJDIR)/event/lib/event.o $(OBJDIR)/event/lib/util.o #CLIENTOBJS += event.o $(OBJDIR)/event/lib/event.o $(OBJDIR)/event/lib/util.o
......
...@@ -34,10 +34,6 @@ static Event_t event; ...@@ -34,10 +34,6 @@ static Event_t event;
static int exitstatus; static int exitstatus;
#endif #endif
#ifdef DOLOSSRATE
int lossrate;
#endif
/* Tunable constants */ /* Tunable constants */
int maxchunkbufs = MAXCHUNKBUFS; int maxchunkbufs = MAXCHUNKBUFS;
int pkttimeout = PKTRCV_TIMEOUT; int pkttimeout = PKTRCV_TIMEOUT;
......
...@@ -21,15 +21,7 @@ ...@@ -21,15 +21,7 @@
#include <errno.h> #include <errno.h>
#include "decls.h" #include "decls.h"
#ifdef DOLOSSRATE
extern int lossrate;
#endif
#ifdef STATS #ifdef STATS
#ifdef DOLOSSRATE
unsigned long spackets, spacketslost;
unsigned long rpackets, rpacketslost;
#endif
unsigned long nonetbufs; unsigned long nonetbufs;
#define DOSTAT(x) (x) #define DOSTAT(x) (x)
#else #else
...@@ -202,29 +194,6 @@ PacketReceive(Packet_t *p) ...@@ -202,29 +194,6 @@ PacketReceive(Packet_t *p)
struct sockaddr_in from; struct sockaddr_in from;
int mlen, alen; int mlen, alen;
#ifdef DOLOSSRATE
struct timeval now, then;
if (lossrate) {
/*
* XXX cannot rely on socket timeout value since we need to
* treat received and dropped packets as though they never
* arrived. This is still not correct as a receive timeout
* could still be up to twice as long as it should be, but
* I don't want to mess with the socket timeout on every
* recv call.
*/
gettimeofday(&then, 0);
if ((then.tv_usec += PKTRCV_TIMEOUT) >= 1000000) {
then.tv_sec++;
then.tv_usec -= 1000000;
}
again:
gettimeofday(&now, 0);
if (timercmp(&now, &then, >=))
return -1;
}
#endif
alen = sizeof(from); alen = sizeof(from);
bzero(&from, alen); bzero(&from, alen);
if ((mlen = recvfrom(sock, p, sizeof(*p), 0, if ((mlen = recvfrom(sock, p, sizeof(*p), 0,
...@@ -233,13 +202,6 @@ PacketReceive(Packet_t *p) ...@@ -233,13 +202,6 @@ PacketReceive(Packet_t *p)
return -1; return -1;
pfatal("PacketReceive(recvfrom)"); pfatal("PacketReceive(recvfrom)");
} }
#ifdef DOLOSSRATE
DOSTAT(rpackets++);
if (lossrate && random() < lossrate) {
DOSTAT(rpacketslost++);
goto again;
}
#endif
if (mlen != sizeof(p->hdr) + p->hdr.datalen) if (mlen != sizeof(p->hdr) + p->hdr.datalen)
fatal("PacketReceive: Bad message length %d!=%d", fatal("PacketReceive: Bad message length %d!=%d",
...@@ -261,14 +223,6 @@ PacketSend(Packet_t *p, int *resends) ...@@ -261,14 +223,6 @@ PacketSend(Packet_t *p, int *resends)
struct sockaddr_in to; struct sockaddr_in to;
int len, delays; int len, delays;
#ifdef DOLOSSRATE
DOSTAT(spackets++);
if (lossrate && random() < lossrate) {
DOSTAT(spacketslost++);
return;
}
#endif
len = sizeof(p->hdr) + p->hdr.datalen; len = sizeof(p->hdr) + p->hdr.datalen;
p->hdr.srcip = myipaddr.s_addr; p->hdr.srcip = myipaddr.s_addr;
...@@ -307,14 +261,6 @@ PacketReply(Packet_t *p) ...@@ -307,14 +261,6 @@ PacketReply(Packet_t *p)
struct sockaddr_in to; struct sockaddr_in to;
int len; int len;
#ifdef DOLOSSRATE
DOSTAT(spackets++);
if (lossrate && random() < lossrate) {
DOSTAT(spacketslost++);
return;
}
#endif
len = sizeof(p->hdr) + p->hdr.datalen; len = sizeof(p->hdr) + p->hdr.datalen;
to.sin_family = AF_INET; to.sin_family = AF_INET;
......
...@@ -43,10 +43,6 @@ struct in_addr mcastif; ...@@ -43,10 +43,6 @@ struct in_addr mcastif;
char *filename; char *filename;
struct timeval IdleTimeStamp; struct timeval IdleTimeStamp;
#ifdef DOLOSSRATE
int lossrate;
#endif
/* Forward decls */ /* Forward decls */
void quit(int); void quit(int);
void reinit(int); void reinit(int);
...@@ -539,7 +535,7 @@ main(int argc, char **argv) ...@@ -539,7 +535,7 @@ main(int argc, char **argv)
off_t fsize; off_t fsize;
void *ignored; void *ignored;
while ((ch = getopt(argc, argv, "dhp:m:i:tbDT:R:B:G:L:")) != -1) while ((ch = getopt(argc, argv, "dhp:m:i:tbDT:R:B:G:")) != -1)
switch(ch) { switch(ch) {
case 'b': case 'b':
broadcast++; broadcast++;
...@@ -578,17 +574,6 @@ main(int argc, char **argv) ...@@ -578,17 +574,6 @@ main(int argc, char **argv)
case 'G': case 'G':
gapsize = atoi(optarg); gapsize = atoi(optarg);
break; break;
#ifdef DOLOSSRATE
/* XXX this is not the emulab way! */
case 'L':
{
double plr = atof(optarg);
if (plr < 0 || plr > 1)
fatal("bad loss rate: %f", plr);
lossrate = (int)(plr * 0x7fffffff);
break;
}
#endif
case 'h': case 'h':
case '?': case '?':
default: default:
...@@ -707,17 +692,6 @@ main(int argc, char **argv) ...@@ -707,17 +692,6 @@ main(int argc, char **argv)
Stats.filebytes - FileInfo.blocks * BLOCKSIZE); Stats.filebytes - FileInfo.blocks * BLOCKSIZE);
log(" net idle/blocked: %d/%d", Stats.goesidle, nonetbufs); log(" net idle/blocked: %d/%d", Stats.goesidle, nonetbufs);
log(" max workq size: %d", WorkQMax); log(" max workq size: %d", WorkQMax);
#ifdef DOLOSSRATE
{
extern unsigned long spackets, spacketslost;
extern unsigned long rpackets, rpacketslost;
log(" send total/lost: %d/%d",
spackets, spacketslost);
log(" recv total/lost: %d/%d",
rpackets, rpacketslost);
}
#endif
} }
#endif #endif
......
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