You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
In function update_stats of sp.py, the debug message should use packet.flow_id instead of packet.packet_id to map a flow to its class.
ifself.debug:
print(
f"Sent out packet {packet.packet_id} from flow {packet.flow_id} "f"belonging to class {self.flow_classes(packet.packet_id)} "f"of priority {packet.prio[self.element_id]}")
To Reproduce
Run the following code, where the flow class is assigned at runtime depending on the number of transmitted packets, by looking up the flows dictionary:
"""A basic example that connects two packet generators to a network wire witha propagation delay distribution, and then to a packet sink."""fromfunctoolsimportpartialimportsimpyfrombisectimportbisect_leftfromns.packet.dist_generatorimportDistPacketGeneratorfromns.packet.sinkimportPacketSinkfromns.scheduler.spimportSPServerfromns.switch.switchimportSimplePacketSwitch# priortiy queues per serverk=2# number of serversn=2# rate of each servermu=100# demotion thresholdsdemotion_thresholds= [5]
defarrival_1():
""" Packets arrive with a constant interval of 1.5 seconds. """return1.5defarrival_2():
""" Packets arrive with a constant interval of 2.0 seconds. """return2.0defpacket_size():
return100defflow_to_classes(f_id, flows, thresholds):
attained_service=flows[f_id].packets_sentreturnbisect_left(thresholds, attained_service)
#return (f_id + n_id + fib[f_id]) % n_classes_per_portenv=simpy.Environment()
# simple switch with infinite rate, just used as entrypoint node# for flows to handle routing to different serversswitch=SimplePacketSwitch(
env,
nports=n,
port_rate=0, # in bits/secondbuffer_size=None, # in packetsdebug=True)
pg1=DistPacketGenerator(env, "flow_1", arrival_1, packet_size, flow_id=0)
pg2=DistPacketGenerator(env, "flow_2", arrival_2, packet_size, flow_id=1)
# connect all packet generators to switchpg1.out=switchpg2.out=switch# route flowsfib= {0: 0, 1: 1}
switch.demux.fib=fibflows= {
0: pg1,
1: pg2
}
flow_classes=partial(flow_to_classes, flows=flows, thresholds=demotion_thresholds)
servers= []
foriinrange(n):
sp=SPServer(
env,
mu,
list(range(k)),
flow_classes=flow_classes,
debug=True
)
ps=PacketSink(env, rec_flow_ids=False, debug=True)
sp.out=psswitch.ports[i].out=spservers.append(sp)
env.run(until=20)
Expected behavior
You get following exception:
Traceback (most recent call last):
File "C:\Users\d067567\AppData\Local\anaconda3\envs\ns.py\lib\site-packages\ns\scheduler\sp.py", line 190, in run
self.update_stats(packet)
File "C:\Users\d067567\AppData\Local\anaconda3\envs\ns.py\lib\site-packages\ns\scheduler\sp.py", line 107, in update_stats
f"belonging to class {self.flow_classes(packet.packet_id)} "
File "g:\My Drive\Politecnico\Thesis\python-ns\examples\spatial_diversity.py", line 40, in flow_to_classes
attained_service = flows[f_id].packets_sent
KeyError: 6
The text was updated successfully, but these errors were encountered:
alessandrocornacchia
changed the title
[BUG] SP scheduler bug for dynamic flow id to class mappings
[BUG] SP scheduler bug flow id to class mappings
Aug 11, 2023
Describe the bug
In function
update_stats
ofsp.py
, the debug message should usepacket.flow_id
instead ofpacket.packet_id
to map a flow to its class.To Reproduce
Run the following code, where the flow class is assigned at runtime depending on the number of transmitted packets, by looking up the
flows
dictionary:Expected behavior
You get following exception:
The text was updated successfully, but these errors were encountered: