qns.entity.cchannel package

Submodules

qns.entity.cchannel.cchannel module

class qns.entity.cchannel.cchannel.ClassicChannel(name: Optional[str] = None, node_list: List[qns.entity.node.node.QNode] = [], bandwidth: int = 0, delay: Union[float, qns.models.delay.delay.DelayModel] = 0, drop_rate: float = 0, max_buffer_size: int = 0)[source]

Bases: qns.entity.entity.Entity

ClassicChannel is the channel for classic message

install(simulator: qns.simulator.simulator.Simulator) None[source]

install is called before simulator runs to initialize or set initial events

Parameters

simulator (qns.simulator.simulator.Simulator) – the simulator

send(packet: qns.entity.cchannel.cchannel.ClassicPacket, next_hop: qns.entity.node.node.QNode)[source]

Send a classic packet to the next_hop

Parameters
Raises

qns.entity.cchannel.cchannel.NextHopNotConnectionException – the next_hop is not connected to this channel

class qns.entity.cchannel.cchannel.ClassicPacket(msg: Union[str, bytes, Any], src: Optional[qns.entity.node.node.QNode] = None, dest: Optional[qns.entity.node.node.QNode] = None)[source]

Bases: object

ClassicPacket is the message that transfer on a ClassicChannel

encode() bytes[source]

encode the self.msg if it is a str

Returns

(bytes) a bytes object

get()[source]

get the message from packet

Returns

(Union[str, bytes, Any])

exception qns.entity.cchannel.cchannel.NextHopNotConnectionException[source]

Bases: Exception

class qns.entity.cchannel.cchannel.RecvClassicPacket(t: Optional[qns.simulator.ts.Time] = None, name: Optional[str] = None, cchannel: Optional[qns.entity.cchannel.cchannel.ClassicChannel] = None, packet: Optional[qns.entity.cchannel.cchannel.ClassicPacket] = None, dest: Optional[qns.entity.node.node.QNode] = None, by: Optional[Any] = None)[source]

Bases: qns.simulator.event.Event

The event for a QNode to receive a classic packet

invoke() None[source]

Invoke the event, should be implemented

Module contents

class qns.entity.cchannel.ClassicChannel(name: Optional[str] = None, node_list: List[qns.entity.node.node.QNode] = [], bandwidth: int = 0, delay: Union[float, qns.models.delay.delay.DelayModel] = 0, drop_rate: float = 0, max_buffer_size: int = 0)[source]

Bases: qns.entity.entity.Entity

ClassicChannel is the channel for classic message

install(simulator: qns.simulator.simulator.Simulator) None[source]

install is called before simulator runs to initialize or set initial events

Parameters

simulator (qns.simulator.simulator.Simulator) – the simulator

send(packet: qns.entity.cchannel.cchannel.ClassicPacket, next_hop: qns.entity.node.node.QNode)[source]

Send a classic packet to the next_hop

Parameters
Raises

qns.entity.cchannel.cchannel.NextHopNotConnectionException – the next_hop is not connected to this channel

class qns.entity.cchannel.ClassicPacket(msg: Union[str, bytes, Any], src: Optional[qns.entity.node.node.QNode] = None, dest: Optional[qns.entity.node.node.QNode] = None)[source]

Bases: object

ClassicPacket is the message that transfer on a ClassicChannel

encode() bytes[source]

encode the self.msg if it is a str

Returns

(bytes) a bytes object

get()[source]

get the message from packet

Returns

(Union[str, bytes, Any])

class qns.entity.cchannel.RecvClassicPacket(t: Optional[qns.simulator.ts.Time] = None, name: Optional[str] = None, cchannel: Optional[qns.entity.cchannel.cchannel.ClassicChannel] = None, packet: Optional[qns.entity.cchannel.cchannel.ClassicPacket] = None, dest: Optional[qns.entity.node.node.QNode] = None, by: Optional[Any] = None)[source]

Bases: qns.simulator.event.Event

The event for a QNode to receive a classic packet

invoke() None[source]

Invoke the event, should be implemented