test module¶
-
class
test.Case¶ Bases:
enum.EnumAn enumeration defining different test cases.
-
one= None¶ Test case 1.
-
two= None¶ Test case 2.
-
zero= None¶ Test case 0.
-
-
class
test.Graph(adjacent, tcp='FAST', until=None)¶ Bases:
objectGraphing class for generating simulation results.
This class uses the
Networkclass to create and run a network simulation with the specified parameters, then groups the values monitored during that simulation by category (window title), assuming that all monitored identifiers have the form “window title,tags”, where tags may itself be a comma-delimited string of integer values, such as an index, address, etc. The instantiated object then provides various methods to graph/save the data sets using matplotlib. The only obvious caveat when using theGraphclass to run a simulation is that monitored data must be restricted to numerical values (anything that can be cast as a float) in order to actually produce graphical output.Parameters: -
static
graph(title, datasets, legend='', y_label='', scale=1.0, save=False)¶ Graph a set of data sets.
Parameters: - title (str) – graph title
- datasets ([(tuple,
numpy.ndarray,numpy.ndarray)]) – a list of tagged data sets given as (tags, x, y) - legend (str) – legend label for each data set (e.g. “flow”)
- y_label (str) – label for the plot’s y axis
- scale (float) – y is multiplied by
scalebefore graphing - save (bool) – flag indicating whether to save or display figures
-
graph_all(tags=None, save=False)¶ Graph all data sets.
If the
tagsparameter is given, graphical output for data sets whose title is a key intagswill be restricted to data sets with the specified tags.Parameters: - tags (dict) – dictionary mapping titles to data set tags
- save (bool) – flag indicating whether to save or display figures
Returns: None
-
graph_titles(titles, tags=None, save=False)¶ Graph sets of data sets by category title.
If the
tagsparameter is given, graphical output for data sets whose title is a key intagswill be restricted to data sets with the specified tags.Parameters: - titles (list) – titles of data categories to graph
- tags (dict) – dictionary mapping titles to data set tags
- save (bool) – flag indicating whether to save or display figures
Returns: None
-
title_kwargs= {'Link fill': {'y_label': 'packets', 'legend': 'link'}, 'Host received': {'y_label': 'Mbps', 'scale': 1000, 'legend': 'host'}, 'Host rate': {'y_label': 'Mbps', 'scale': 1000, 'legend': 'host'}, 'Round trip times': {'y_label': 'ms', 'scale': 1e-06, 'legend': 'flow'}, 'Window size': {'y_label': 'packets', 'legend': 'flow'}, 'Flow rate': {'y_label': 'Mbps', 'scale': 1000, 'legend': 'flow'}, 'Dropped packets': {'y_label': 'packets', 'legend': 'link'}, 'Flow received': {'y_label': 'Mbps', 'scale': 1000, 'legend': 'flow'}, 'Link rate': {'y_label': 'Mbps', 'scale': 1000, 'legend': 'link'}}¶ Maps graph title to
graph()keyword parameters.
-
titles¶ Data categories.
Returns: list of data categories Return type: [str]
-
static
-
class
test.Network(adjacent=None, tcp='FAST')¶ Bases:
objectThis class encapsulates a network simulation.
If
adjacentis None, then a GUI for drawing a network appears. The adjacency list should be formatted as [((src, dest), (capacity, buffer size, delay))], where src & dest are formatted as a string with a leading “h” or “r”, specifying a host or router, followed by an integer id. Flows should be given as [((src, dest), ((data, delay), (tcp, tcp_param)))], where src & dest are formatted as previously, but only host tags are allowed. Link arguments are all in bits/bps, as is the data parameter for flows. Delay is given in ns. The tcp parameter is a string which determines which TCP algorithm to use; seeprocess.Flow.allowed_tcpfor accepted TCP specifiers. The tcp_param parameter is a list containing the arguments for initializing the TCP object, and will change depending on the TCP algorithm specified. Seeprocessfor details of the currently implemented TCP algorithms. Alternatively, adjacent may be a test case, as defined by the enumerated typeCase. If so thetcpparameter may be a (valid) TCP specifier, used for all flows in the given test case.Parameters: -
simulate(until=None)¶ Run the initialized simulation.
Parameters: until (int or simpy.events.Event) – time or event to run the simulation untilReturns: all monitored values Return type: {str: [(int, object)]}
-
-
test.ONE= <Case.one: 1>¶ Convenience alias for test case 1 (type).
-
test.TWO= <Case.two: 2>¶ Convenience alias for test case 2 (type).
-
class
test.TestCase¶ Bases:
objectFactory class for producing test case adjacency lists.
See
adjacent()for details.-
adjacencies= {<Case.two: 2>: ([(('r0', 'r1'), (10000000, 1024000, 10000000)), (('r1', 'r2'), (10000000, 1024000, 10000000)), (('r2', 'r3'), (10000000, 1024000, 10000000)), (('h0', 'r0'), (12500000, 1024000, 10000000)), (('h1', 'r0'), (12500000, 1024000, 10000000)), (('h2', 'r2'), (12500000, 1024000, 10000000)), (('h3', 'r3'), (12500000, 1024000, 10000000)), (('h4', 'r1'), (12500000, 1024000, 10000000)), (('h5', 'r3'), (12500000, 1024000, 10000000))], [(('h0', 'h3'), (280000000, 500000000)), (('h1', 'h4'), (120000000, 10000000000)), (('h2', 'h5'), (240000000, 20000000000))]), <Case.one: 1>: ([(('h0', 'r0'), (12500000, 512000, 10000000)), (('r0', 'r1'), (10000000, 512000, 10000000)), (('r0', 'r2'), (10000000, 512000, 10000000)), (('r1', 'r3'), (10000000, 512000, 10000000)), (('r2', 'r3'), (10000000, 512000, 10000000)), (('r3', 'h1'), (12500000, 512000, 10000000))], [(('h0', 'h1'), (160000000, 500000000))]), <Case.zero: 0>: ([(('h0', 'h1'), (10000000, 512000, 10000000))], [(('h0', 'h1'), (160000000, 1000000000))])}¶ Edge & flow adjacency lists for each test case.
-
classmethod
adjacent(case, tcp='FAST')¶ Generate an adjanceny list for a given test case.
For the given test case & TCP specifier, an adjacency list of the type taken by
Networkis constructed from the adjacency lists inadjacenciesand the TCP parameters inttcp_parameters.Parameters: - case (
Case) – test case to build adjacency lists for - tcp (str) – TCP specifier (see
process.Flow.allowed_tcp)
Returns: Adjacency lists defining edges & flows
Return type: ([((str, str), (int, int, int))], [((str, str), ((int, int), (str, list)))])
- case (
-
tcp_parameters= {<Case.two: 2>: {'FAST': [[1, 150000000, 6], [1, 90000000, 6], [1, 90000000, 6]], 'Reno': [[1, 1500000000], [1, 90000000], [1, 90000000]]}, <Case.one: 1>: {'FAST': [[1, 120000000, 20]], 'Reno': [[1, 120000000]]}, <Case.zero: 0>: {'FAST': [[1, 30000000, 45]], 'Reno': [[1, 30000000]]}}¶ TCP parameters for each test case.
-
-
test.ZERO= <Case.zero: 0>¶ Convenience alias for test case 0 (type).