BaseSimulator

class NetworkSim.simulation.simulator.base.BaseSimulator(until=None, convergence=True, sem_tr=None, bs=None, extended=True, env=None, model=None, transmitter_type=None, receiver_type=None, traffic_generation_method=None, bidirectional=False, id=0, seed=None)[source]

Simulation wrapper to create a discrete event simulation of the ring network.

Parameters
  • until (float) – The end time of the simulation. Default is None.

  • convergence (bool) – Automatic convergence mode of simulation. Default is True.

  • sem_tr (float) – The threshold standard error of mean (SEM) for convergence. Default is 0.05.

  • bs (int) – The batch size for SEM calculation during convergence. Default is 10000.

  • env (simpy Environment, optional) – The environment in which the simulation is carried out. Default is simpy.Environment().

  • model (Model, optional) – The network model used for the simulation. Default is Model().

  • transmitter_type (str) – The type of transmitter used for the simulation, chosen from the list:

    • fixed, f or F

      Fixed transmitter.

    • tunable, t or T

      Tunable transmitter.

    Default is tunable.

  • receiver_type (str) – The type of receiver used for the simulation, chosen from the list:

    • fixed, f or F

      Fixed receiver.

    • tunable, t, or T

      Tunable receiver.

    Default is fixed.

  • traffic_generation_method (str) – The method used for generate source traffic, chosen from the list:

    • poisson

      Poisson distribution.

    • pareto

      Pareto distribution.

    Default is poisson.

  • bidirectional (bool, optional) – The type of network architecture, either bidirectional or unidirectional. Default is False, which is unidirectional.

  • seed (int, optional) – The seed used for source traffic generation. Default is 1.

  • ———-

  • latency (list) – A list of packet transmission latency recorded during the simulation, containing the keys:

    • Latency Timestampfloat

      The timestamp when the latency is recorded.

    • Source IDint

      The ID of the source node.

    • Destination IDint

      The ID of the destination node.

    • Queueing Delayfloat

      The recorded queueing delay latency.

    • Transfer Delayfloat

      The recorded transfer delay latency.

    • Data Ratefloat

      The data rate recorded as the operation is completed.

  • error (list) – A list of transmission errors occurred during the simulation, containing the keys:

    • Error Timestampfloat

      The timestamp when the error occurred.

    • Source IDint

      The ID of the source node.

    • Destination IDint

      The ID of the destination node.

    • Error Typestr

      The type of error recorded.

export_data_as_csv(file_name=None, data=None, index=None, columns=None)[source]

Export a python list as a csv file.

Parameters
  • file_name (string) – Name of the output csv file

  • data (ndarray (structured or homogeneous), Iterable, dict, or DataFrame) – The data to be exported as csv file

  • index (list, optional) – Index to use for resulting csv file

  • columns (list, optional) – Column labels to use for csv file

info(info_type=None, component_type=None, component_id=None)[source]

Obtain information of simulation components. Check Info class fore more details.

Parameters
  • info_type (str) – The type of information requested, chosen from the following:

    • control or c

      Information on control ring. When device_type == None, this returns all packet transmission information on the control ring, otherwise it refers to control packets transmitted by a transmitter or control packets received by a receiver. component_id is not required in this case.

    • data or d

      Information on data ring. When device_type == None, this returns all packet transmission information on the data ring, otherwise it refers to data packets transmitted by a transmitter or data packets received by a receiver. An component_id must be specified in this case.

  • component_type (str) – The type of component in the simulation, chosen from the following:

    • ram or RAM

      Transmitter RAM information, where data packets are generated. An component_id must be specified in this case, but info_type is not required.

    • transmitter or t

      Transmitter packet information. Both component_id and info_type must be specified.

    • receiver or r

      Receiver packet information. Both component_id and info_type must be specified.

  • component_id (int) – The ID of the component of choice.

Returns

info – A DataFrame containing the information requested.

Return type

pandas DataFrame

initialise()[source]

Initialisation of the simulation, where RAM, transmitter, and receiver processes are added to the environment.

run()[source]

Run simulation.

summary(summary_type=None, output_format='df', node_id=None, latency_type=None, bar3d=False, data_range=None)[source]

Obtain a summary of the simulation performed. Refer to Summary class for more details.

Parameters
  • summary_type (str, optional) – The type of summary, chosen from the following:

    • None

      No summary_type input, and a generic summary is returned.

    • latency or l

      Latency summary, with latency information for all source-destination combinations.

    • ram or RAM

      Transmitter RAM data generation summary.

    • transmitter or t

      Transmitter summary.

    • receiver or r

      Receiver summary.

    • count or c

      Total packet transmission count.

    • queue or q

      Queue size in RAMs.

  • output_format (str, optional) – The format of the summary, chosen from the following:

    • df

      Return a pandas DataFrame, which is the default output format.

    • csv

      Export a summary of the simulation performed as a csv file. Refer to Summary class for more details.

    • plot

      A plot of the summary selected.

  • node_id (int, optional) – The node ID used for latency summary plot output.

  • latency_type (string, optional) – The latency type of interset, by default is None, which is transfer delay. Setting it as queueing delay or qd switches it to queueing delay.

  • bar3d (bool, optional) – Enable 3d bar plot for queueing delay, default is False.

  • data_range (str, optional) – The range of data selected for latency and delay summary, chosen from the following:

    • all or a

      All simulation data.

    • extended or e

      Extended simulation data in convergence mode.

    • batch or b

      Last batch data in convergence mode.

    Default is None, which is extended data for convergence mode and all data for non-convergence mode.