Ejemplo n.º 1
0
    def send_message(self, message, destination):
        send = Packet(src_port=self.routes['Jan'],
                      dest_port=self.routes[destination])
        send.data = message
        send.actor = 'Jan'

        if 'FIN' in message or message == 'Goodbye.':
            send.FIN = True
            send.TER = True

        if 'CONGRATULATIONS WE FRIED DRY GREEN LEAVES' in message:
            send.URG = True

        self.log.debug('Message from Jan to be delivered to ' + destination)
        send.pretty_print()
        deliverable = send.serialize().encode()
        self.sockets['F'].sendall(deliverable)
Ejemplo n.º 2
0
from packet import Packet

if __name__ == '__main__':
    packet1 = Packet()
    packet2 = Packet()
    packet2.FIN = 1
    packet2.SYN = 1

    print(packet2.encode())