Exemple #1
0
    def A_handle_timer(self):
        # go back n, A_handle_timer
        # Read all the sent packet that it is not acknowledged
        # using "read_all()" of the circular buffer and resend them
        # If you need to resend packets, set a timer after that

        for ptk in self.window.read_all() :
            if ptk.seqnum >= self.base :
                to_layer_three("A", ptk)
        
        evl.start_timer("A", self.estimated_rtt)
Exemple #2
0
 def A_input(self, pkt):
     # go back n, A_input
     # Verify that the packet is not corrupted
     # Update the circular buffer according to
     # the acknowledgement number using "pop()
     if pkt.checksum == pkt.get_checksum() :
         # remove all teh acknowledged ptk
         while self.base < pkt.acknum + 1 :
             self.window.pop()
             self.base += 1
     
         if self.base == self.nextSeq :
             evl.remove_timer()
         else :
             evl.start_timer("A", self.estimated_rtt)
Exemple #3
0
    def A_output(self, m):
        # go back n, A_output
        # If the buffer is full, just drop the packet
        # Construct the packet based on the message. 
        # Make sure that the sequence number is correct
        # Send the packet and save it to the circular buffer using "push()" of circular_buffer
        # Set the timer using "evl.start_timer(entity, time)", and the time should be set to estimated_rtt. 
        # iMake sure that there is only one timer started in the event list
        
        # if not self.window.isfull() : 
        if self.nextSeq < self.base + self.windowSize :
            pkt = packet(seqnum=self.nextSeq, payload=m)
            # print(str(pkt.payload.data))
            self.window.push(pkt)
            to_layer_three("A", pkt)

            # if self.base == self.nextSeq : 
            evl.start_timer("A", self.estimated_rtt)
            self.nextSeq += 1
Exemple #4
0
 def A_handle_timer(self):
     # resend the packet as needed
     to_layer_three("A", self.lastPkt)
     evl.start_timer("A", self.estimated_rtt)
Exemple #5
0
 def A_output(self, m):
     pkt = packet(seqnum=self.seq, payload=m)
     to_layer_three("A", pkt)
     evl.start_timer("A", self.estimated_rtt)
     self.state = "WAIT_ACK"
     self.lastPkt = pkt