本文整理汇总了Python中network.Network.loss方法的典型用法代码示例。如果您正苦于以下问题:Python Network.loss方法的具体用法?Python Network.loss怎么用?Python Network.loss使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类network.Network
的用法示例。
在下文中一共展示了Network.loss方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run
# 需要导入模块: from network import Network [as 别名]
# 或者: from network.Network import loss [as 别名]
def run(self):
# parameters
Sim.scheduler.reset()
if "a" in self.debug:
Sim.set_debug('AppHandler')
if "t" in self.debug:
Sim.set_debug('TCP')
# setup network
networkPlotter = Plotter('out/2-flows-simple')
net = Network(config='networks/one-hop.txt',plotter=networkPlotter)
net.loss(self.loss)
# setup routes
n1 = net.get_node('n1')
n2 = net.get_node('n2')
n1.add_forwarding_entry(address=n2.get_address('n1'),link=n1.links[0])
n2.add_forwarding_entry(address=n1.get_address('n2'),link=n2.links[0])
# setup transport
t1 = Transport(n1)
t2 = Transport(n2)
# setup connection
c1 = TCP(t1,n1.get_address('n2'),1,n2.get_address('n1'),1,AppHandler(inputfile=self.inputfile,identifier="c1"),window=self.window,type=self.type,window_size_plot=True,sequence_plot=True)
c2 = TCP(t2,n2.get_address('n1'),1,n1.get_address('n2'),1,AppHandler(inputfile=self.inputfile,plot=True,identifier="c2"),window=self.window,type=self.type,receiver_flow_plot=True)
c3 = TCP(t1,n1.get_address('n2'),2,n2.get_address('n1'),2,AppHandler(inputfile=self.inputfile,identifier="c3"),window=self.window,type=self.type,window_size_plot=True,sequence_plot=True)
c4 = TCP(t2,n2.get_address('n1'),2,n1.get_address('n2'),2,AppHandler(inputfile=self.inputfile,plot=True,identifier="c4"),window=self.window,type=self.type,receiver_flow_plot=True)
global tcps
tcps = [c1, c2, c3, c4]
global original_size
f = open(self.inputfile, "rb")
try:
data = f.read(1000)
while data != "":
original_size += len(data)
Sim.scheduler.add(delay=0, event=data, handler=c1.send)
Sim.scheduler.add(delay=0, event=data, handler=c3.send)
data = f.read(1000)
finally:
f.close()
# run the simulation
global decisecondEvent
decisecondEvent = Sim.scheduler.add(delay=0.1, event=Sim, handler=self.decisecond)
Sim.scheduler.run()
networkPlotter.plot(self.sequencefile)
plotter.plot(self.sequencefile);
示例2: run
# 需要导入模块: from network import Network [as 别名]
# 或者: from network.Network import loss [as 别名]
def run(self):
# parameters
Sim.scheduler.reset()
if "a" in self.debug:
Sim.set_debug("AppHandler")
if "t" in self.debug:
Sim.set_debug("TCP")
# setup network
networkPlotter = Plotter("out/5-flows-simple")
net = Network(config="networks/one-hop.txt", plotter=networkPlotter)
net.loss(self.loss)
# setup routes
n1 = net.get_node("n1")
n2 = net.get_node("n2")
n1.add_forwarding_entry(address=n2.get_address("n1"), link=n1.links[0])
n2.add_forwarding_entry(address=n1.get_address("n2"), link=n2.links[0])
# setup transport
t1 = Transport(n1)
t2 = Transport(n2)
# setup connection
c1 = TCP(
t1,
n1.get_address("n2"),
1,
n2.get_address("n1"),
1,
AppHandler(inputfile=self.inputfile, identifier="c1"),
window=self.window,
type=self.type,
)
c2 = TCP(
t2,
n2.get_address("n1"),
1,
n1.get_address("n2"),
1,
AppHandler(inputfile=self.inputfile, plot=True, identifier="c2"),
window=self.window,
type=self.type,
receiver_flow_plot=True,
)
c3 = TCP(
t1,
n1.get_address("n2"),
2,
n2.get_address("n1"),
2,
AppHandler(inputfile=self.inputfile, identifier="c3"),
window=self.window,
type=self.type,
)
c4 = TCP(
t2,
n2.get_address("n1"),
2,
n1.get_address("n2"),
2,
AppHandler(inputfile=self.inputfile, plot=True, identifier="c4"),
window=self.window,
type=self.type,
receiver_flow_plot=True,
)
c5 = TCP(
t1,
n1.get_address("n2"),
3,
n2.get_address("n1"),
3,
AppHandler(inputfile=self.inputfile, identifier="c5"),
window=self.window,
type=self.type,
)
c6 = TCP(
t2,
n2.get_address("n1"),
3,
n1.get_address("n2"),
3,
AppHandler(inputfile=self.inputfile, plot=True, identifier="c6"),
window=self.window,
type=self.type,
receiver_flow_plot=True,
)
c7 = TCP(
t1,
n1.get_address("n2"),
4,
n2.get_address("n1"),
4,
AppHandler(inputfile=self.inputfile, identifier="c7"),
window=self.window,
type=self.type,
#.........这里部分代码省略.........
示例3: run
# 需要导入模块: from network import Network [as 别名]
# 或者: from network.Network import loss [as 别名]
def run(self):
# parameters
Sim.scheduler.reset()
if "a" in self.debug:
Sim.set_debug("AppHandler")
if "t" in self.debug:
Sim.set_debug("TCP")
# setup network
networkPlotter = Plotter("out/1-flow-advanced-aimd")
net = Network(config="networks/one-hop.txt", plotter=networkPlotter)
net.loss(self.loss)
# setup routes
n1 = net.get_node("n1")
n2 = net.get_node("n2")
n1.add_forwarding_entry(address=n2.get_address("n1"), link=n1.links[0])
n2.add_forwarding_entry(address=n1.get_address("n2"), link=n2.links[0])
# setup transport
t1 = Transport(n1)
t2 = Transport(n2)
c1 = TCP(
t1,
n1.get_address("n2"),
1,
n2.get_address("n1"),
1,
AppHandler(inputfile=self.inputfile, plot=True),
window=self.window,
type=self.type,
receiver_flow_plot=True,
)
c2 = TCP(
t2,
n2.get_address("n1"),
1,
n1.get_address("n2"),
1,
AppHandler(inputfile=self.inputfile),
window=self.window,
type=self.type,
window_size_plot=True,
sequence_plot=True,
)
global tcps
tcps = [c1, c2]
global original_size
f = open(self.inputfile, "rb")
try:
data = f.read(1000)
while data != "":
original_size += len(data)
Sim.scheduler.add(delay=0, event=data, handler=c1.send)
Sim.scheduler.add(delay=0, event=data, handler=c2.send)
data = f.read(1000)
finally:
f.close()
# run the simulation
global decisecondEvent
decisecondEvent = Sim.scheduler.add(delay=0.1, event=Sim, handler=self.decisecond)
Sim.scheduler.run()
networkPlotter.plot(self.sequencefile)
plotter.plot(self.sequencefile)
示例4: run
# 需要导入模块: from network import Network [as 别名]
# 或者: from network.Network import loss [as 别名]
def run(self):
# parameters
Sim.scheduler.reset()
if "a" in self.debug:
Sim.set_debug('AppHandler')
if "t" in self.debug:
Sim.set_debug('TCP')
# setup network
networkPlotter = Plotter('out/2-flows-advanced-competing-rtt')
net = Network(config='networks/competing-rtt.txt',plotter=networkPlotter)
net.loss(self.loss)
# setup routes
A = net.get_node('A')
B = net.get_node('B')
C = net.get_node('C')
D = net.get_node('D')
# A forwarding entries
A.add_forwarding_entry(address=B.get_address('C'),link=A.links[0])
A.add_forwarding_entry(address=C.get_address('A'),link=A.links[0])
A.add_forwarding_entry(address=D.get_address('C'),link=A.links[0])
# B forwarding entries
B.add_forwarding_entry(address=A.get_address('C'),link=B.links[0])
B.add_forwarding_entry(address=C.get_address('B'),link=B.links[0])
B.add_forwarding_entry(address=D.get_address('C'),link=B.links[0])
# C forwarding entries
C.add_forwarding_entry(address=A.get_address('C'),link=C.links[0])
C.add_forwarding_entry(address=B.get_address('C'),link=C.links[1])
C.add_forwarding_entry(address=D.get_address('C'),link=C.links[2])
# D forwarding entries
D.add_forwarding_entry(address=A.get_address('C'),link=D.links[0])
D.add_forwarding_entry(address=B.get_address('C'),link=D.links[0])
D.add_forwarding_entry(address=C.get_address('D'),link=D.links[0])
# setup transport
t1 = Transport(A)
t2 = Transport(B)
t4 = Transport(D)
# setup connection
c1 = TCP(t1,A.get_address('C'),1,D.get_address('C'),1,AppHandler(inputfile=self.inputfile,identifier="c1"),window=self.window,type=self.type,window_size_plot=True,sequence_plot=True)
c2 = TCP(t4,D.get_address('C'),1,A.get_address('C'),1,AppHandler(inputfile=self.inputfile,plot=True,identifier="c2"),window=self.window,type=self.type,receiver_flow_plot=True)
c3 = TCP(t2,B.get_address('C'),2,D.get_address('C'),2,AppHandler(inputfile=self.inputfile,identifier="c3"),window=self.window,type=self.type,window_size_plot=True,sequence_plot=True)
c4 = TCP(t4,D.get_address('C'),2,B.get_address('C'),2,AppHandler(inputfile=self.inputfile,plot=True,identifier="c4"),window=self.window,type=self.type,receiver_flow_plot=True)
global tcps
tcps = [c1, c2, c3, c4]
global original_size
f = open(self.inputfile, "rb")
try:
data = f.read(1000)
while data != "":
original_size += len(data)
Sim.scheduler.add(delay=0, event=data, handler=c1.send)
Sim.scheduler.add(delay=0, event=data, handler=c3.send)
data = f.read(1000)
finally:
f.close()
# run the simulation
global decisecondEvent
decisecondEvent = Sim.scheduler.add(delay=0.1, event=Sim, handler=self.decisecond)
Sim.scheduler.run()
networkPlotter.plot(self.sequencefile)
plotter.plot(self.sequencefile);