ouroboros-network-framework-0.1.0.1
Safe Haskell None
Language Haskell2010

Simulation.Network.Snocket

Description

This module provides simulation environment and a snocket implementation suitable for IOSim .

Though this module is designed for simulation / testing, it lives in the library, since it is needed in `ouroboros-network-framework:test` and `ouroboros-network:test' components.

TODO: Create a snocket package, in order to avoid having to have ouroboros-network-testing as a dependency for this cabal library.

Synopsis

Simulated Snocket

withSnocket :: forall m peerAddr a. ( MonadCatch m, MonadLabelledSTM m, MonadMask m, MonadTime m, MonadTimer m, MonadThrow ( STM m), GlobalAddressScheme peerAddr, Ord peerAddr, Typeable peerAddr, Show peerAddr) => Tracer m (WithAddr ( TestAddress peerAddr) ( SnocketTrace m ( TestAddress peerAddr))) -> BearerInfo -> Map (NormalisedId ( TestAddress peerAddr)) ( Script BearerInfo ) -> ( Snocket m ( FD m ( TestAddress peerAddr)) ( TestAddress peerAddr) -> m ( ObservableNetworkState ( TestAddress peerAddr)) -> m a) -> m a Source #

A bracket which runs a network simulation. When the simulation terminates it verifies that all listening sockets and all connections are closed. It might throw ResourceException .

newtype ObservableNetworkState addr Source #

Simulation accessible network environment consumed by simSnocket .

Constructors

ObservableNetworkState

Fields

newtype Script a Source #

Constructors

Script ( NonEmpty a)

Instances

Instances details
Functor Script
Instance details

Defined in Ouroboros.Network.Testing.Data.Script

Foldable Script
Instance details

Defined in Ouroboros.Network.Testing.Data.Script

Traversable Script
Instance details

Defined in Ouroboros.Network.Testing.Data.Script

Eq a => Eq ( Script a)
Instance details

Defined in Ouroboros.Network.Testing.Data.Script

Show a => Show ( Script a)
Instance details

Defined in Ouroboros.Network.Testing.Data.Script

Arbitrary a => Arbitrary ( Script a)
Instance details

Defined in Ouroboros.Network.Testing.Data.Script

data OpenType Source #

Either simultaneous open or normal open. Unlike in TCP, only one side will will know that it is doing simultaneous open.

Constructors

SimOpen

Simultaneous open

NormalOpen

Normal open

normaliseId :: Ord addr => ConnectionId addr -> NormalisedId addr Source #

Safe constructor of NormalisedId

data BearerInfo Source #

Each bearer info describes outbound and inbound side of a point to point bearer.

Constructors

BearerInfo

Fields

noAttenuation :: BearerInfo Source #

BearerInfo without attenuation and instantaneous connect delay. It also using the production value of SDUSize .

data FD m peerAddr Source #

File descriptor type.

class GlobalAddressScheme addr where Source #

A type class for global IP address scheme. Every node in the simulation has an ephemeral address. Every node in the simulation has an implicit ipv4 and ipv6 address (if one is not bound by explicitly).

Instances

Instances details
GlobalAddressScheme Int Source #

All negative addresses are ephemeral. Even address are IPv4, while odd ones are IPv6.

Instance details

Defined in Simulation.Network.Snocket