Commit 49199451 authored by thomas alfroy's avatar thomas alfroy
Browse files

modif ecn

parent 35b587ee
......@@ -111,12 +111,12 @@ def parse_new_messages_server(msg):
debug = False
verb = False
second = 0.0
ecn = False
ecn = 0.0
hybride = False
options, remainder = getopt.getopt(sys.argv[1:], 'dvs:ehl:', ['debug', 'verbose', 'second=', 'ecn', 'help', 'limit=',])
options, remainder = getopt.getopt(sys.argv[1:], 'dvs:e:hl:', ['debug', 'verbose', 'second=', 'ecn=', 'help', 'limit=',])
for opt, arg in options:
if opt in ('-d', '--debug'):
......@@ -126,7 +126,7 @@ for opt, arg in options:
if opt in ('-s', '--second'):
second = float(arg) / 1000.0
if opt in ('-e','--ecn'):
ecn = True
ecn = float(arg) / 1000.0
if opt in ('-l','--limit'):
MAX_PACKETS = int(arg)
if opt in ('-h', '--help'):
......@@ -159,11 +159,18 @@ while con:
if act_time + second <= time.time():
if second != 0.0 :
print("{} packets received last second".format(nb_packets))
if act_time + 1.0 <= time.time():
nb_packets = 0
act_time = time.time()
tagged = False
if ecn != 0.0:
if act_time + ecn <= time.time():
nb_packets = 0
act_time = time.time()
tagged = False
else:
if act_time + 1.0 <= time.time():
nb_packets = 0
act_time = time.time()
tagged = False
i_ready, o_ready, e_ready = select.select(input, [], [], second)
......@@ -174,7 +181,7 @@ while con:
nb_packets += 1
if nb_packets > MAX_PACKETS:
if random.random() <= 0.7:
if ecn :
if ecn != 0.0 :
if not tagged:
data_tmp = bytearray(data)
data_tmp[6] = ECN_ACTIVE
......
Supports Markdown
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