csle_collector.traffic_manager package

Submodules

csle_collector.traffic_manager.query_traffic_manager module

csle_collector.traffic_manager.query_traffic_manager.get_traffic_status(stub: csle_collector.traffic_manager.traffic_manager_pb2_grpc.TrafficManagerStub, timeout=60) traffic_manager_pb2.TrafficDTO[source]

Queries the server for the Traffic generator status

Parameters
  • stub – the stub to send the remote gRPC to the server

  • timeout – the GRPC timeout (seconds)

Returns

a TrafficDTO describing the status of the traffic generator

csle_collector.traffic_manager.query_traffic_manager.start_traffic(stub: csle_collector.traffic_manager.traffic_manager_pb2_grpc.TrafficManagerStub, commands: List[str], sleep_time: int, timeout=60) traffic_manager_pb2.TrafficDTO[source]

Sends a request to the traffic manager to start the traffic generator script

Parameters
  • stub – the stub to send the remote gRPC to the server

  • timeout – the GRPC timeout (seconds)

  • commands – list of commands for the traffic generator

  • sleep_time – sleep time for the traffic generator

Returns

an TrafficDTO describing the status of the traffic manager

csle_collector.traffic_manager.query_traffic_manager.stop_traffic(stub: csle_collector.traffic_manager.traffic_manager_pb2_grpc.TrafficManagerStub, timeout=60) traffic_manager_pb2.TrafficDTO[source]

Sends a request to the traffic manager to stop the traffic generator

Parameters
  • stub – the stub to send the remote gRPC to the server

  • timeout – the GRPC timeout (seconds)

Returns

a TrafficDTO describing the status of the traffic generator

csle_collector.traffic_manager.traffic_manager module

class csle_collector.traffic_manager.traffic_manager.TrafficManagerServicer[source]

Bases: csle_collector.traffic_manager.traffic_manager_pb2_grpc.TrafficManagerServicer

gRPC server for managing a traffic generator. Allows to start/stop the script and also to query the state of the script.

getTrafficStatus(request: traffic_manager_pb2.GetTrafficStatusMsg, context: grpc.ServicerContext) traffic_manager_pb2.TrafficDTO[source]

Gets the state of the traffic manager

Parameters
  • request – the gRPC request

  • context – the gRPC context

Returns

a TrafficDTO with the state of the traffic manager

startTraffic(request: traffic_manager_pb2.StartTrafficMsg, context: grpc.ServicerContext) traffic_manager_pb2.TrafficDTO[source]

Starts the traffic generator

Parameters
  • request – the gRPC request

  • context – the gRPC context

Returns

a TrafficDTO with the state of the traffic generator

stopTraffic(request: traffic_manager_pb2.StopTrafficMsg, context: grpc.ServicerContext)[source]

Stops the traffic generator

Parameters
  • request – the gRPC request

  • context – the gRPC context

Returns

a traffic DTO with the state of the traffic generator

csle_collector.traffic_manager.traffic_manager.serve(port: int = 50043, log_dir: str = '/', max_workers: int = 10, log_file_name: str = 'traffic_manager.log') None[source]

Starts the gRPC server for managing traffic scripts

Parameters
  • port – the port that the server will listen to

  • log_dir – the directory to write the log file

  • log_file_name – the file name of the log

  • max_workers – the maximum number of GRPC workers

Returns

None

csle_collector.traffic_manager.traffic_manager_pb2 module

Generated protocol buffer code.

csle_collector.traffic_manager.traffic_manager_pb2_grpc module

Client and server classes corresponding to protobuf-defined services.

class csle_collector.traffic_manager.traffic_manager_pb2_grpc.TrafficManager[source]

Bases: object

Interface exported by the server

static getTrafficStatus(request, target, options=(), channel_credentials=None, call_credentials=None, insecure=False, compression=None, wait_for_ready=None, timeout=None, metadata=None)[source]
static startTraffic(request, target, options=(), channel_credentials=None, call_credentials=None, insecure=False, compression=None, wait_for_ready=None, timeout=None, metadata=None)[source]
static stopTraffic(request, target, options=(), channel_credentials=None, call_credentials=None, insecure=False, compression=None, wait_for_ready=None, timeout=None, metadata=None)[source]
class csle_collector.traffic_manager.traffic_manager_pb2_grpc.TrafficManagerServicer[source]

Bases: object

Interface exported by the server

getTrafficStatus(request, context)[source]

Missing associated documentation comment in .proto file.

startTraffic(request, context)[source]

Missing associated documentation comment in .proto file.

stopTraffic(request, context)[source]

Missing associated documentation comment in .proto file.

class csle_collector.traffic_manager.traffic_manager_pb2_grpc.TrafficManagerStub(channel)[source]

Bases: object

Interface exported by the server

csle_collector.traffic_manager.traffic_manager_pb2_grpc.add_TrafficManagerServicer_to_server(servicer, server)[source]

csle_collector.traffic_manager.traffic_manager_util module

class csle_collector.traffic_manager.traffic_manager_util.TrafficManagerUtil[source]

Bases: object

Class with utility functions related to the Traffic Manager

static traffic_dto_empty() traffic_manager_pb2.TrafficDTO[source]
Returns

an empty TrafficDTO

static traffic_dto_from_dict(d: Dict[str, Any]) traffic_manager_pb2.TrafficDTO[source]

Converts a dict representation of a TrafficDTO to a DTO

Parameters

d – the dict to convert

Returns

the converted DTO

static traffic_dto_to_dict(traffic_dto: traffic_manager_pb2.TrafficDTO) Dict[str, Union[bool, str]][source]

Converts a TrafficDTO to a dict

Parameters

traffic_dto – the dto to convert

Returns

a dict representation of the DTO

Module contents