示例#1
0
文件: link.py 项目: Steve525/bene
 def next(self,event):
     if len(self.queue) > 0:
         Sim.trace_custom('%d' % (len(self.queue)), 'queue', self.filename)
         packet = self.queue.pop(0)
         #Sim.trace_custom('%d' % (len(self.queue)), 'queue', self.filename)
         self.transmit(packet)
     else:
         self.busy = False
示例#2
0
文件: link.py 项目: Steve525/bene
 def handle_packet(self,packet):
     # drop packet due to queue overflow
     if self.queue_size and len(self.queue) == self.queue_size:
         Sim.trace("! %d dropped packet due to queue overflow" % (self.address))
         Sim.trace_custom('x', 'queue', self.filename)
         return
     # drop packet due to random loss
     if self.loss > 0 and random.random() < self.loss:
         Sim.trace("! %d dropped packet due to random loss" % (self.address))
         return
     packet.enter_queue = Sim.scheduler.current_time()
     #Sim.trace("packet %d entered queue" % packet.sequence)
     if len(self.queue) == 0 and not self.busy:
         # packet can be sent immediately
         self.busy = True
         self.transmit(packet)
     else:
         # add packet to queue
         Sim.trace_custom('%d' % (len(self.queue)), 'queue', self.filename)
         self.queue.append(packet)