Client.py 1.2 KB

123456789101112131415161718192021222324252627282930313233343536
  1. import numpy as np
  2. import copy
  3. import sys
  4. import random
  5. from classes.Packet import Packet
  6. from classes.Message import Message
  7. from classes.Node import Node
  8. from classes.Utilities import StructuredMessage, setup_logger, random_string
  9. class Client(Node):
  10. def __init__(self, env, conf, net, loggers=None, label=0, id=None, p2p=False):
  11. self.conf = conf
  12. super().__init__(env=env, conf=conf, net=net, loggers=loggers, id=id, label=label)
  13. def schedule_retransmits(self):
  14. pass
  15. def schedule_message(self, message):
  16. # This function is used in the transcript mode
  17. ''' schedule_message adds given message into the outgoing client's buffer. Before adding the message
  18. to the buffer the function records the time at which the message was queued.'''
  19. #print("> Scheduled message")
  20. current_time = self.env.now
  21. message.time_queued = current_time
  22. for pkt in message.pkts:
  23. pkt.time_queued = current_time
  24. self.add_to_buffer(message.pkts)
  25. def print_msgs(self):
  26. ''' Method prints all the messages gathered in the buffer of incoming messages.'''
  27. for msg in self.msg_buffer_in.values():
  28. msg.output()