core package

Submodules

core.basicHostIPCLayer module

core.defines module

Helper functions.

core.defines.decode_raw_ip_payload_src_dst(buf)

Get src,dst ip address from raw ip payload string

Parameters:buf – A string buffer containing raw ip payload
Returns:A typle with source and destination IP strings
core.defines.get_ip_ethernet(buf)

Unpack the data within the Ethernet frame (the IP packet)

Pulling out src, dst, length, fragment info, TTL, and Protocol

Parameters:buf (str) – A string buffer containing the entire packet
Returns:ip of type (dpkt.IP)
core.defines.get_ip_loopback(buf)

Unpack the data within the Ethernet frame (the IP packet)

Pulling out src, dst, length, fragment info, TTL, and Protocol

Parameters:buf (str) – A string buffer containing the entire packet
Returns:ip of type (dpkt.IP)
core.defines.get_ip_sll(buf)

Unpack the data within the SLL frame (the IP packet)

Pulling out src, dst, length, fragment info, TTL, and Protocol

Parameters:buf (str) – A string buffer containing the entire packet
Returns:ip of type (dpkt.IP)
core.defines.get_pkt_src_dst_IP(buf, dl_type=1)

Get src and dst IP from raw packet string

Parameters:
  • buf (str) – A string buffer containing the entire packet
  • dl_type (int) – Link Layer type defined in dpkt.pcap. (Default ETH_TYPE_FRAME)
Returns:

A tuple with source and destination IP strings

core.defines.get_raw_ip_pkt(buf, dl_type=1)

Get IP payload from raw packet string

Parameters:
  • buf (str) – A string buffer containing the entire packet
  • dl_type (int) – Link Layer type defined in dpkt.pcap. (Default ETH_TYPE_FRAME)
Returns:

A string buffer with IP payload

core.defines.getid()

Returns a random unique string ID

Returns:str
core.defines.inet_to_str(inet)

Convert inet object to a string

Parameters:inet (inet struct) – inet network address
Returns:str of printable/readable IP address
core.defines.rpc_process()

Sends a batch processing GRPC request request.

Called by Melody to initiate processing of all read/write requests received in the last batch.

Returns:None
core.defines.rpc_read(readlist)

Makes a GRPC read request call to the proxy. It may be used to read some values from the power simulation.

It takes in as input a list of read requests and composes and sends a single GRPC read request to the proxy. It waits until the proxy sends a response and returns the values contained in the response or None if there was an error.

Parameters:readlist (list of tuples) – A list of tuples (objtype (str), objid (str), fieldtype (str)). Refer src/proto/pss.proto
Returns:list of str or None
core.defines.rpc_write(writelist)

Makes a GRPC write request call to the proxy. It may be used to write some values to the power simulation

It takes in as input a list of write requests and composes and sends a single GRPC write request to the proxy. It waits until the proxy sends a response and returns the status response or None if there was an error.

Parameters:writelist (list of tuples) – A list of tuples (objtype (str), objid (str), fieldtype (str), value(str)). Refer src/proto/pss.proto
Returns:list of int (Refer src/proto/pss.proto: WriteStatus) or None
core.defines.str_to_inet(str)

Convert string object to an inet

Parameters:str (str) – printable/readable IP address
Returns:inet (inet struct) - an inet network address

core.disturbance_gen module

Disturbance generator

core.disturbance_gen.init_shared_buffers(shared_buf_array)

Initialize shared buffers used for communication with the main Melody process

Parameters:shared_buf_array – A shared buffer array object (defined in src/core/shared_buffer.py)
Returns:None
core.disturbance_gen.main(path_to_disturbance_file)

Starts the disturbance generator and sends disturbances to the power simulation at specified relative timestamps

Disturbances and their relative timestamps are specified in a file according to the Disturbance message format defined in src/proto/configuration.proto

Parameters:path_to_disturbance_file (str) – Absolute path to file containing disturbances specified in Disturbance proto format. (Refer src/proto/configuration.proto : Disturbances)
Returns:None

core.emulation_driver module

core.host module

core.kronos_helper_functions module

core.logger module

core.net_power module

core.parse_project_configuration module

core.pss_driver module

Drivers for interacting with power system simulator.

class core.pss_driver.PSSDriverAbstract

Bases: object

Abstract class for implementing power system simulation-specific driver.

close()
open()
read(case)
run_pf(method=None)
save(newcase)
write(objtype, objid, fieldtype, value)
write_multiple(writelist)

core.pss_server module

core.replay_driver module

core.replay_orchestrator module

core.shared_buffer module

Shared Buffer

class core.shared_buffer.shared_buffer(bufName, isProxy)

Bases: object

Uses the shared_buffer library defined in src/core/libs

close()

Closes the shared buffer

open()

Opens the shared buffer

read()

Reads from the shared buffer :return: str or None

write(msg, dstID=0)

Write message to the shared buffer

Parameters:
  • msg (str) – message to write
  • dstID – Not used
class core.shared_buffer.shared_buffer_array

Bases: object

Can be used to create an array of shared buffers

close()

Closes all opened shared buffers

Returns:None
open(bufName, isProxy)

Opens a new shared buffer and adds it to the array

Parameters:
  • bufName (str) – buffer name
  • isProxy (int) – Specifies if the buffer is opened by the master or slave. 1-Master, 0-Slave
Returns:

None

read(bufName)

Reads a buffer specified by buffer name. It is Non-Blocking.

Parameters:bufName (str) – buffer name to read
Returns:str or None if there is nothing to read in the buffer.
read_until(bufName, cool_off_time=0.01)

Reads until something appears in the buffer.

Parameters:
  • bufName (str) – buffer name to read
  • cool_off_time (float) – time to sleep in secs between two successive reads
Returns:

str

write(bufName, msg, dstID=0)

Write a message to the buffer.

Parameters:
  • bufName (str) – buffer name to write
  • msg (str) – Message to write
  • dstID – Not used
Returns:

number of bytes written (int)

Module contents