ObjectivesIn this experiment, we will be observing the behaviour of a queue under heavy load. We will be modeling an output queued packet switch (with only one port) as such: Each packet generator modeling the aggregate behaviour of a number of hosts attached to a LAN switch, which in turn is connected to a router for Internet access. Each link has a speed of 100 Mb/s (Megabits per second), which can be intepreted as 100,000 Kb/s or 100,000,000 b/s. Experiment:Part 1In this section, we will observe the behaviour of the queue length under increasing load. The Python script below represents the model detailed above, but with only one packet generator (id = LAN1). # lan_to_wan.py: Last modified on 22 Apr 2020. from random import expovariate import functools import simpy from SimComponents import PacketGenerator, PacketSink, SwitchPort, PortMonitor def run_sim(): # Create the SimPy environment env = simpy.Environment() # Our simulation componentns ps = PacketSink(env, debug=True) # debug: every packet arrival is printed pg = PacketGenerator(env, "LAN1", adist=functools.partial(expovariate, 1/1.5), sdist=functools.partial(expovariate, 1/100) ) switch_port = SwitchPort(env, rate=100e6) # We use a PortMonitor to track queue sizes over time # See SimComponents.py sample_dist = lambda : 1.0 pm = PortMonitor(env, switch_port, dist=sample_dist) # Wire the components together pg.out = switch_port switch_port.out = ps env.run(until=20) if __name__ == '__main__': run_sim() Go through the provided Python script and understand how the model is put together. It uses Dr. Bernstein's SimComponents.py. It would be a good idea to check out the contents of the SimComponents.py to find out more about the implementation of the simulated elements. Note: When defining the SimComponents.PacketGenerator, we use the Python functools module to slightly ease the definition of functions returning a random sample with a given parameter. This is equivalent to defining the distribution function as below: from random import expovariate # equivalent to functools.partial(expovariate, 1/1.5) def arrival_dist(): return expovariate(1/1.5) Once you understand how the model is built, go through the following steps:
Repeat the steps above for the following link loads: 10%, 20%, 30% … 90%, 99% Finally, using matplotlib.pyplot.plot, plot a graph of average queue length against the WAN link load. Show the output to your lab demonstrator. Part 2Next, we will observe the fairness of a first in, first out (FIFO) switch buffer. Modify the script by adding 2 more packet generators (ID = LAN2 and ID = LAN3) connected to the same switch port. The generators should be all be configured with the inter-arrival distribution you used in Part 1, but with a link load of 20%. Each switch port should have the following average packet size
Run your simulation for 600 seconds and record how many bytes each packet generator has been able to send. Comment on the results. Your ReportAfter finishing your experiments, you will need to prepare a short (maximum two pages, 10 pt Times-Roman font) report summarizing the key points you have learned in this exercise. Please convert your report to PDF (no other formats will be accepted), zip your report with all the Python code you have written for the experiment, and upload all as a single zip file to the unit's Moodle site before the due date (we will post the deadlines at the unit's Moodle site). References
|