csle_collector.client_manager.dao package
Submodules
csle_collector.client_manager.dao.arrival_config module
- class csle_collector.client_manager.dao.arrival_config.ArrivalConfig(client_arrival_type: ClientArrivalType)[source]
Bases:
JSONSerializable
Abstract arrival configuration class
- static from_dict(d: Dict[str, Any]) ArrivalConfig [source]
Converts a dict representation to an instance
- Parameters
d – the dict to convert
- Returns
the created instance
- static from_json_file(json_file_path: str) ArrivalConfig [source]
Reads a json file and converts it to a DTO
- Parameters
json_file_path – the json file path
- Returns
the converted DTO
csle_collector.client_manager.dao.client module
- class csle_collector.client_manager.dao.client.Client(id: int, workflow_distribution: List[float], arrival_config: ArrivalConfig, mu: float = 4, exponential_service_time: bool = False)[source]
Bases:
JSONSerializable
,GRPCSerializable
A client, which is characterized by its arrival process and its workflow distribution.
- static from_dict(d: Dict[str, Any]) Client [source]
Converts a dict representation to an instance
- Parameters
d – the dict to convert
- Returns
the created instance
- static from_grpc_object(obj: ClientDTO) Client [source]
Instantiates the object from a GRPC DTO
- Parameters
obj – the object to instantiate from
- Returns
the instantiated object
- static from_json_file(json_file_path: str) Client [source]
Reads a json file and converts it to a DTO
- Parameters
json_file_path – the json file path
- Returns
the converted DTO
- generate_commands(workflows_config: WorkflowsConfig) List[str] [source]
Generate the commands for the client
- Parameters
workflows_config – the workflows configuration
- Returns
sampled list of commands for the client
csle_collector.client_manager.dao.client_arrival_type module
Type of process that generates new clients for an emulation
- class csle_collector.client_manager.dao.client_arrival_type.ClientArrivalType(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]
Bases:
IntEnum
Enum representing the different process types for generating client process in an emulation
- CONSTANT = 0
- EPTMP = 4
- PIECE_WISE_CONSTANT = 3
- SINE_MODULATED = 1
- SPIKING = 2
csle_collector.client_manager.dao.constant_arrival_config module
- class csle_collector.client_manager.dao.constant_arrival_config.ConstantArrivalConfig(lamb: float)[source]
Bases:
ArrivalConfig
DTO representing the configuration of a stationary poisson arrival process with exponential service times
- static from_dict(d: Dict[str, Any]) ConstantArrivalConfig [source]
Converts a dict representation of the object to an instance
- Parameters
d – the dict to convert
- Returns
the created instance
- static from_grpc_object(obj: ConstantArrivalConfigDTO) ConstantArrivalConfig [source]
Instantiates the object from a GRPC DTO
- Parameters
obj – the object to instantiate from
- Returns
the instantiated object
- static from_json_file(json_file_path: str) ConstantArrivalConfig [source]
Reads a json file and converts it to a DTO
- Parameters
json_file_path – the json file path
- Returns
the converted DTO
csle_collector.client_manager.dao.eptmp_arrival_config module
- class csle_collector.client_manager.dao.eptmp_arrival_config.EPTMPArrivalConfig(thetas: List[float], gammas: List[float], phis: List[float], omegas: List[float])[source]
Bases:
ArrivalConfig
DTO representing the configuration of a homogenous poisson arrival process with an Exponential-Polynomial-Trigonometric rate function having Multiple Periodicities
- static from_dict(d: Dict[str, Any]) EPTMPArrivalConfig [source]
Converts a dict representation of the object to an instance
- Parameters
d – the dict to convert
- Returns
the created instance
- static from_grpc_object(obj: EPTMPArrivalConfigDTO) EPTMPArrivalConfig [source]
Instantiates the object from a GRPC DTO
- Parameters
obj – the object to instantiate from
- Returns
the instantiated object
- static from_json_file(json_file_path: str) EPTMPArrivalConfig [source]
Reads a json file and converts it to a DTO
- Parameters
json_file_path – the json file path
- Returns
the converted DTO
csle_collector.client_manager.dao.piece_wise_constant_arrival_config module
- class csle_collector.client_manager.dao.piece_wise_constant_arrival_config.PieceWiseConstantArrivalConfig(breakvalues: List[float], breakpoints: List[int])[source]
Bases:
ArrivalConfig
DTO representing the configuration of a piece-wise constant poisson arrival process with exponential service times
- static from_dict(d: Dict[str, Any]) PieceWiseConstantArrivalConfig [source]
Converts a dict representation of the object to an instance
- Parameters
d – the dict to convert
- Returns
the created instance
- static from_grpc_object(obj: PieceWiseConstantArrivalConfigDTO) PieceWiseConstantArrivalConfig [source]
Instantiates the object from a GRPC DTO
- Parameters
obj – the object to instantiate from
- Returns
the instantiated object
- static from_json_file(json_file_path: str) PieceWiseConstantArrivalConfig [source]
Reads a json file and converts it to a DTO
- Parameters
json_file_path – the json file path
- Returns
the converted DTO
csle_collector.client_manager.dao.sine_arrival_config module
- class csle_collector.client_manager.dao.sine_arrival_config.SineArrivalConfig(lamb: float, time_scaling_factor: float, period_scaling_factor: float)[source]
Bases:
ArrivalConfig
DTO representing the configuration of a sine-modulated poisson arrival process with exponential service times
- static from_dict(d: Dict[str, Any]) SineArrivalConfig [source]
Converts a dict representation of the object to an instance
- Parameters
d – the dict to convert
- Returns
the created instance
- static from_grpc_object(obj: SineArrivalConfigDTO) SineArrivalConfig [source]
Instantiates the object from a GRPC DTO
- Parameters
obj – the object to instantiate from
- Returns
the instantiated object
- static from_json_file(json_file_path: str) SineArrivalConfig [source]
Reads a json file and converts it to a DTO
- Parameters
json_file_path – the json file path
- Returns
the converted DTO
csle_collector.client_manager.dao.spiking_arrival_config module
- class csle_collector.client_manager.dao.spiking_arrival_config.SpikingArrivalConfig(exponents: List[float], factors: List[float])[source]
Bases:
ArrivalConfig
DTO representing the configuration of a poisson arrival process with spiking arrivals
- static from_dict(d: Dict[str, Any]) SpikingArrivalConfig [source]
Converts a dict representation of the object to an instance
- Parameters
d – the dict to convert
- Returns
the created instance
- static from_grpc_object(obj: SpikingArrivalConfigDTO) SpikingArrivalConfig [source]
Instantiates the object from a GRPC DTO
- Parameters
obj – the object to instantiate from
- Returns
the instantiated object
- static from_json_file(json_file_path: str) SpikingArrivalConfig [source]
Reads a json file and converts it to a DTO
- Parameters
json_file_path – the json file path
- Returns
the converted DTO
csle_collector.client_manager.dao.workflow_markov_chain module
- class csle_collector.client_manager.dao.workflow_markov_chain.WorkflowMarkovChain(transition_matrix: List[List[float]], initial_state: int, id: int)[source]
Bases:
JSONSerializable
,GRPCSerializable
A Markov chain representation of a workflow.
- copy() WorkflowMarkovChain [source]
- Returns
a copy of the DTO
- static from_dict(d: Dict[str, Any]) WorkflowMarkovChain [source]
Converts a dict representation to an instance
- Parameters
d – the dict to convert
- Returns
the created instance
- static from_grpc_object(obj: WorkflowMarkovChainDTO) WorkflowMarkovChain [source]
Instantiates the object from a GRPC DTO
- Parameters
obj – the object to instantiate from
- Returns
the instantiated object
- static from_json_file(json_file_path: str) WorkflowMarkovChain [source]
Reads a json file and converts it to a DTO
- Parameters
json_file_path – the json file path
- Returns
the converted DTO
- static markov_next_state(row: List[float]) int [source]
Samples the next state of the Markov chain
- Parameters
row – a numpy array of probabilities that sum up to 1.
- Returns
an integer from 0 to len(row)-1.
- step_forward() int [source]
Move t forward by one and possibly transition to a new state. Returns the new state.
csle_collector.client_manager.dao.workflow_service module
- class csle_collector.client_manager.dao.workflow_service.WorkflowService(ips_and_commands: List[Tuple[str, List[str]]], id: int)[source]
Bases:
JSONSerializable
,GRPCSerializable
A service of the network. The service might be distributed across several network nodes. The service is defined by the series of commands that a client executes to make use of the service.
- copy() WorkflowService [source]
- Returns
a copy of the DTO
- create_execution_config(ip_first_octet: int) WorkflowService [source]
Creates a new config for an execution
- Parameters
ip_first_octet – the first octet of the IP of the new execution
- Returns
the new config
- static from_dict(d: Dict[str, Any]) WorkflowService [source]
Converts a dict representation to an instance
- Parameters
d – the dict to convert
- Returns
the created instance
- static from_grpc_object(obj: WorkflowServiceDTO) WorkflowService [source]
Instantiates the object from a GRPC DTO
- Parameters
obj – the object to instantiate from
- Returns
the instantiated object
- static from_json_file(json_file_path: str) WorkflowService [source]
Reads a json file and converts it to a DTO
- Parameters
json_file_path – the json file path
- Returns
the converted DTO
- static replace_first_octet_of_ip(ip: str, ip_first_octet: int) str [source]
Utility function for changing the first octet in an IP address
- Parameters
ip – the IP to modify
ip_first_octet – the first octet to insert
- Returns
the new IP
csle_collector.client_manager.dao.workflows_config module
- class csle_collector.client_manager.dao.workflows_config.WorkflowsConfig(workflow_markov_chains: List[WorkflowMarkovChain], workflow_services: List[WorkflowService])[source]
Bases:
JSONSerializable
,GRPCSerializable
Workflows configuration
- commands() List[str] [source]
Gets the list of all commands across all services
- Returns
the list of commands
- copy() WorkflowsConfig [source]
- Returns
a copy of the DTO
- create_execution_config(ip_first_octet: int) WorkflowsConfig [source]
Creates a new config for an execution
- Parameters
ip_first_octet – the first octet of the IP of the new execution
- Returns
the new config
- static from_dict(d: Dict[str, Any]) WorkflowsConfig [source]
Converts a dict representation to an instance
- Parameters
d – the dict to convert
- Returns
the created instance
- static from_grpc_object(obj: WorkflowsConfigDTO) WorkflowsConfig [source]
Instantiates the object from a GRPC DTO
- Parameters
obj – the object to instantiate from
- Returns
the instantiated object
- static from_json_file(json_file_path: str) WorkflowsConfig [source]
Reads a json file and converts it to a DTO
- Parameters
json_file_path – the json file path
- Returns
the converted DTO
- get_workflow_mc(id: int) Optional[WorkflowMarkovChain] [source]
Gets the workflow Markov chain with a specific id
- Parameters
id – the id of the MC
- Returns
the MC or None
- get_workflow_service(id: int) Optional[WorkflowService] [source]
Gets the workflow service with a specific id
- Parameters
id – the id of the service
- Returns
the service or None