本文整理汇总了Python中src.sim.Sim.print_rate_info方法的典型用法代码示例。如果您正苦于以下问题:Python Sim.print_rate_info方法的具体用法?Python Sim.print_rate_info怎么用?Python Sim.print_rate_info使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类src.sim.Sim
的用法示例。
在下文中一共展示了Sim.print_rate_info方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: send_one_packet
# 需要导入模块: from src.sim import Sim [as 别名]
# 或者: from src.sim.Sim import print_rate_info [as 别名]
def send_one_packet(self, sequence):
if sequence >= len(self.send_buffer):
return
if sequence + self.mss > len(self.send_buffer):
body = self.send_buffer[sequence : ]
else:
body = self.send_buffer[sequence : sequence + self.mss]
# get one packet worth of data
packet = TCPPacket(source_address=self.source_address,
source_port=self.source_port,
destination_address=self.destination_address,
destination_port=self.destination_port,
body=body,
sequence=sequence,ack_number=self.ack, flow_id=int(self.file_prefix.split("_")[-1]))
# send the packet
Sim.trace("%d sending My_RTP segment to %d for %d" % (self.source_address,self.destination_address,packet.sequence))
self.transport.send_packet(packet)
Sim.print_rate_info(packet)
# set a timer
if not self.timer_set:
self.timer = Sim.scheduler.add(delay=self.timeout, event='retransmit', handler=self.retransmit)
self.timer_set = True
return packet
示例2: handle_packet
# 需要导入模块: from src.sim import Sim [as 别名]
# 或者: from src.sim.Sim import print_rate_info [as 别名]
def handle_packet(self,packet):
# handle ACK
if packet.length == 0:
# this acks new data, so advance the window with slide_window()
Sim.trace("%d received My_RTP ACK from %d for %d" % (packet.destination_address,packet.source_address,packet.ack_number))
Sim.print_rate_info(packet)
self.slide_window(packet.ack_number)
# handle data
if packet.length > 0:
self.pkts_rcvd += 1
Sim.trace("%d received My_RTP segment from %d for %d" % (packet.destination_address,packet.source_address,packet.sequence))
# if the packet is the one we're expecting increment our
# ack number and add the data to the receive buffer
if packet.sequence >= self.ack:
self.receive_buffer.append(packet)
if packet.sequence == self.ack:
self.receive_buffer = sorted(self.receive_buffer, key=lambda TCPPacket: TCPPacket.sequence)
while self.receive_buffer and (self.ack == self.receive_buffer[0].sequence):
pkt = self.receive_buffer.pop(0)
self.increment_ack(pkt.sequence + pkt.length)
# deliver data that is in order
self.app.handle_packet(pkt)
# always send an ACK
self.send_ack()
if packet.queueing_delay > self.pkt_q_delay_threshold:
self.queueing_delay += packet.queueing_delay
print "\n[Average Queuing Delay so far:", str(self.queueing_delay / self.pkts_rcvd) + "]"
print "\n[Total Queueing Delay so far:", str(self.queueing_delay) + "]\n"