本文整理汇总了Python中src.sim.Sim.trace_custom方法的典型用法代码示例。如果您正苦于以下问题:Python Sim.trace_custom方法的具体用法?Python Sim.trace_custom怎么用?Python Sim.trace_custom使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类src.sim.Sim
的用法示例。
在下文中一共展示了Sim.trace_custom方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: handle_packet
# 需要导入模块: from src.sim import Sim [as 别名]
# 或者: from src.sim.Sim import trace_custom [as 别名]
def handle_packet(self,packet):
# handle ACK (Sender)
# if the ACK number is greater than our send base...
# update the acknowledged segment counter, restart timer and send if possible
if packet.ack_number > self.send_base:
Sim.trace("ACK RCVD: %d <=== %d : %d" % (packet.destination_address,packet.source_address,packet.ack_number))
bytes_acked = packet.ack_number - self.send_base
self.not_yet_acknowledged_segments -= bytes_acked
if self.cwnd >= self.ssthreshold:
self.cwnd += (self.mss * bytes_acked) / self.cwnd
else:
self.cwnd += bytes_acked
self.cancel_timer()
self.timer = Sim.scheduler.add(delay=self.timeout, event='new_ack_data', handler=self.retransmit)
self.send_if_possible()
self.send_base = packet.ack_number
# print congestion window
if self.source_port > 3:
Sim.trace_custom("%f" % (self.cwnd/self.mss), 'cwnd', self.source_port)
# handle data (Receiver)
if packet.length > 0:
Sim.trace("SEGMENT RCVD: %d <=== %d : %d" % (packet.destination_address,packet.source_address,packet.sequence))
self.receive_temp_buffer.add(packet.sequence)
self.receive_packet_buffer.append(packet)
self.send_cumulative_ack()
示例2: send_cumulative_ack
# 需要导入模块: from src.sim import Sim [as 别名]
# 或者: from src.sim.Sim import trace_custom [as 别名]
def send_cumulative_ack(self):
sequences = sorted(self.receive_temp_buffer)
for i in range(self.ack/self.mss, len(sequences)):
if sequences[i] == self.ack:
pkt = self.find_packet(self.ack)
self.increment_ack(pkt.sequence + pkt.length)
self.app.handle_packet(pkt)
Sim.trace_custom("%d %d" % (pkt.sequence, pkt.length), 'rate', self.source_port)
self.send_ack()
示例3: loss_detected
# 需要导入模块: from src.sim import Sim [as 别名]
# 或者: from src.sim.Sim import trace_custom [as 别名]
def loss_detected(self):
Sim.trace_custom("%f" % (self.cwnd/self.mss), 'cwnd', self.source_port)
self.ssthreshold = max(self.cwnd/2, self.mss)
self.cwnd = 1 * self.mss
Sim.trace_custom("%f" % (self.cwnd/self.mss), 'cwnd', self.source_port)