本文整理汇总了Python中src.sim.Sim.close_rate_file方法的典型用法代码示例。如果您正苦于以下问题:Python Sim.close_rate_file方法的具体用法?Python Sim.close_rate_file怎么用?Python Sim.close_rate_file使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类src.sim.Sim
的用法示例。
在下文中一共展示了Sim.close_rate_file方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run
# 需要导入模块: from src.sim import Sim [as 别名]
# 或者: from src.sim.Sim import close_rate_file [as 别名]
def run(self):
# parameters
Sim.scheduler.reset()
Sim.set_debug(True)
# setup network
n1 = Node()
n2 = Node()
l = Link(address=1,startpoint=n1,endpoint=n2,queue_size=self.queue_size,bandwidth=10000000,propagation=0.01,loss=self.loss, printOut=True)
n1.add_link(l)
n1.add_forwarding_entry(address=2,link=l)
l = Link(address=2,startpoint=n2,endpoint=n1,queue_size=self.queue_size,bandwidth=10000000,propagation=0.01,loss=self.loss)
n2.add_link(l)
n2.add_forwarding_entry(address=1,link=l)
# setup transport
t1 = Transport(n1)
t2 = Transport(n2)
# setup application
a = AppHandler("2_1-" + self.filename)
# setup connection
c1 = My_RTP(t1,1,1,2,1,a)
c2 = My_RTP(t2,2,1,1,1,a)
# setup application
a = AppHandler("2_2-" + self.filename)
# setup connection
c3 = My_RTP(t1,1,2,2,2,a)
c4 = My_RTP(t2,2,2,1,2,a)
# send a file
with open(self.filename,'r') as f:
while True:
data = f.read(1000)
if not data:
break
c1.load_buffer(data)
c3.load_buffer(data)
c1.set_file_prefix("2_1")
c2.set_file_prefix("2_1")
c3.set_file_prefix("2_2")
c4.set_file_prefix("2_2")
c1.open_window_file()
c3.open_window_file()
Sim.scheduler.add(delay=0, event="window_init", handler=c1.window_init)
Sim.scheduler.add(delay=0, event="window_init", handler=c3.window_init)
# run the simulation
Sim.scheduler.run()
n1.links[0].myfile.close()
c1.close_window_file()
c3.close_window_file()
Sim.close_rate_file()