diff --git a/repo.py b/repo.py index ed499c716d0e2be853d671f645b0783216c0814b..a7ab4f8603761ae98b6a777425bcf0f5d864ff9b 100755 --- a/repo.py +++ b/repo.py @@ -4,7 +4,7 @@ ############################################################################################### #Marca - 1 Byte Marca inicio de transmissao, inicio de msg fim de msg -#Tipo - 0 Token, 1 - Msg, 2 - ACK, 3 - NACK +#Tipo - 0 Token, 1 - Msg, #Destino - pode variar de 1 a 4 #Origem - pode variar de 1 a 4 #Prioridade - pode variar de 0 a 7 @@ -34,13 +34,11 @@ import time import Queue global TOKEN -global StartTime global HighPriority global RECEBIDA global PRIORITY_TOKEN PRIORITY_TOKEN = 8 RECEBIDA = 1 -StartTime = 0 HighPriority = 10 TOKEN = 0 SEND_PORT = 3131 # Porta que o Servidor envia @@ -118,6 +116,7 @@ def token (): tokenMessage = Protocol() msgProtocol = Protocol() dest = (HOST, SEND_PORT) + time.sleep(2) if (TOKEN == 2): TOKEN = 0 tokenMessage.type = str(0) @@ -143,7 +142,6 @@ def client (): global TOKEN protocolMessage = Protocol() global queue - queue = Queue.PriorityQueue() while True: protocolMessage.setDestiny() protocolMessage.setPriority() @@ -160,7 +158,6 @@ def client (): def server (): global TOKEN - global StartTime global RECEBIDA global queue global PRIORITY_TOKEN @@ -211,7 +208,6 @@ def server (): aux1.setDesempacota(msg) aux1.priority = str(HighPriorat) msg = aux1.getEmpacotar() - print msg udp.sendto (msg, dest) udp.close() @@ -222,13 +218,11 @@ if len(sys.argv) > 1: TOKEN = 2 print 'COMECEI COM O TOKEN' PRIORITY_TOKEN = 7 - StartTime = time.time() print 'ID Dessa maquina, escolha entre 1 e 4' MACHINE_ID = raw_input () print "Ip da proxima maquina" HOST = raw_input() -if TOKEN == 1: - StartTime = time.time() +queue = Queue.PriorityQueue() threadServer = threading.Thread(target=server) threadClient = threading.Thread(target=client) threadServer.start()