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

Remove hokey loss rate code

parent 2ff95cee
......@@ -34,9 +34,6 @@ LDFLAGS = -static
# Define this to a non-zero value to enable recording of trace data
#CFLAGS += -DNEVENTS=20000
# Turn on server packet loss rate ability
#CFLAGS += -DDOLOSSRATE
# Turn on client event handling
#CFLAGS += -DDOEVENTS
#CLIENTOBJS += event.o $(OBJDIR)/event/lib/event.o $(OBJDIR)/event/lib/util.o
......
......@@ -34,10 +34,6 @@ static Event_t event;
static int exitstatus;
#endif
#ifdef DOLOSSRATE
int lossrate;
#endif
/* Tunable constants */
int maxchunkbufs = MAXCHUNKBUFS;
int pkttimeout = PKTRCV_TIMEOUT;
......
......@@ -21,15 +21,7 @@
#include <errno.h>
#include "decls.h"
#ifdef DOLOSSRATE
extern int lossrate;
#endif
#ifdef STATS
#ifdef DOLOSSRATE
unsigned long spackets, spacketslost;
unsigned long rpackets, rpacketslost;
#endif
unsigned long nonetbufs;
#define DOSTAT(x) (x)
#else
......@@ -202,29 +194,6 @@ PacketReceive(Packet_t *p)
struct sockaddr_in from;
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);
bzero(&from, alen);
if ((mlen = recvfrom(sock, p, sizeof(*p), 0,
......@@ -233,13 +202,6 @@ PacketReceive(Packet_t *p)
return -1;
pfatal("PacketReceive(recvfrom)");
}
#ifdef DOLOSSRATE
DOSTAT(rpackets++);
if (lossrate && random() < lossrate) {
DOSTAT(rpacketslost++);
goto again;
}
#endif
if (mlen != sizeof(p->hdr) + p->hdr.datalen)
fatal("PacketReceive: Bad message length %d!=%d",
......@@ -261,14 +223,6 @@ PacketSend(Packet_t *p, int *resends)
struct sockaddr_in to;
int len, delays;
#ifdef DOLOSSRATE
DOSTAT(spackets++);
if (lossrate && random() < lossrate) {
DOSTAT(spacketslost++);
return;
}
#endif
len = sizeof(p->hdr) + p->hdr.datalen;
p->hdr.srcip = myipaddr.s_addr;
......@@ -307,14 +261,6 @@ PacketReply(Packet_t *p)
struct sockaddr_in to;
int len;
#ifdef DOLOSSRATE
DOSTAT(spackets++);
if (lossrate && random() < lossrate) {
DOSTAT(spacketslost++);
return;
}
#endif
len = sizeof(p->hdr) + p->hdr.datalen;
to.sin_family = AF_INET;
......
......@@ -43,10 +43,6 @@ struct in_addr mcastif;
char *filename;
struct timeval IdleTimeStamp;
#ifdef DOLOSSRATE
int lossrate;
#endif
/* Forward decls */
void quit(int);
void reinit(int);
......@@ -539,7 +535,7 @@ main(int argc, char **argv)
off_t fsize;
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) {
case 'b':
broadcast++;
......@@ -578,17 +574,6 @@ main(int argc, char **argv)
case 'G':
gapsize = atoi(optarg);
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 '?':
default:
......@@ -707,17 +692,6 @@ main(int argc, char **argv)
Stats.filebytes - FileInfo.blocks * BLOCKSIZE);
log(" net idle/blocked: %d/%d", Stats.goesidle, nonetbufs);
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
......
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