def __init__(self, serverAddr): self.remoteAddr = serverAddr self.SequenceNumber = helpers.getISN() self.lastack = None try: self.sockd = socket(AF_INET,SOCK_DGRAM) except: raise self.sockd.connect(serverAddr) self.address = self.sockd.getsockname() self.sender = sender.Sender(self.sockd) self.receiver = receiver.Receiver(self) # send SYN to server print("Initial sequence number: " + str(self.SequenceNumber)) h = packet.Header(self.address[1], self.remoteAddr[1], self.SequenceNumber, 0, synf=1, ackf=0) self.sockd.send(h.pack()) self.SYNSent()
def SYNReceived(self): self.SequenceNumber = helpers.getISN() # send SYN/ACK h = packet.Header(self.port, self.clientPort, self.SequenceNumber, self.lastack, ackf=0,synf=1) self.sender.send(h.pack()) self.SequenceNumber = self.SequenceNumber + 1 self.established()
def SYNReceived(self): self.SequenceNumber = helpers.getISN() # send SYN/ACK h = packet.Header(self.port, self.clientPort, self.SequenceNumber, self.lastack, ackf=0, synf=1) self.sender.send(h.pack()) self.SequenceNumber = self.SequenceNumber + 1 self.established()