ouroboros-network-framework-0.1.0.0
Safe HaskellNone
LanguageHaskell2010

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 ∷ ∀ 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))) → BearerInfoMap (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

  • onsConnectionsMap (NormalisedId addr) addr

    Registry of active connections and respective provider

Instances

Instances details
Show addr ⇒ Show (ObservableNetworkState addr) Source # 
Instance details

Defined in Simulation.Network.Snocket

data ResourceException addr Source #

Constructors

NotReleasedListeningSockets [addr] (Maybe SomeException) 
NotReleasedConnections (Map (NormalisedId addr) ConnectionState) (Maybe SomeException) 

Instances

Instances details
Show addr ⇒ Show (ResourceException addr) Source # 
Instance details

Defined in Simulation.Network.Snocket

(Typeable addr, Show addr) ⇒ Exception (ResourceException addr) Source # 
Instance details

Defined in Simulation.Network.Snocket

data SDUSize Source #

Instances

Instances details
Show SDUSize 
Instance details

Defined in Network.Mux.Types

Generic SDUSize 
Instance details

Defined in Network.Mux.Types

Associated Types

type Rep SDUSizeTypeType Source #

Methods

fromSDUSizeRep SDUSize x Source #

toRep SDUSize x → SDUSize Source #

type Rep SDUSize 
Instance details

Defined in Network.Mux.Types

type Rep SDUSize = D1 ('MetaData "SDUSize" "Network.Mux.Types" "network-mux-0.1.0.0-inplace" 'True) (C1 ('MetaCons "SDUSize" 'PrefixI 'True) (S1 ('MetaSel ('Just "getSDUSize") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Word16)))

newtype Script a Source #

Constructors

Script (NonEmpty a) 

Instances

Instances details
Functor Script 
Instance details

Defined in Ouroboros.Network.Testing.Data.Script

Methods

fmap ∷ (a → b) → Script a → Script b Source #

(<$) ∷ a → Script b → Script a Source #

Foldable Script 
Instance details

Defined in Ouroboros.Network.Testing.Data.Script

Methods

foldMonoid m ⇒ Script m → m Source #

foldMapMonoid m ⇒ (a → m) → Script a → m Source #

foldMap'Monoid m ⇒ (a → m) → Script a → m Source #

foldr ∷ (a → b → b) → b → Script a → b Source #

foldr' ∷ (a → b → b) → b → Script a → b Source #

foldl ∷ (b → a → b) → b → Script a → b Source #

foldl' ∷ (b → a → b) → b → Script a → b Source #

foldr1 ∷ (a → a → a) → Script a → a Source #

foldl1 ∷ (a → a → a) → Script a → a Source #

toListScript a → [a] Source #

nullScript a → Bool Source #

lengthScript a → Int Source #

elemEq a ⇒ a → Script a → Bool Source #

maximumOrd a ⇒ Script a → a Source #

minimumOrd a ⇒ Script a → a Source #

sumNum a ⇒ Script a → a Source #

productNum a ⇒ Script a → a Source #

Traversable Script 
Instance details

Defined in Ouroboros.Network.Testing.Data.Script

Methods

traverseApplicative f ⇒ (a → f b) → Script a → f (Script b) Source #

sequenceAApplicative f ⇒ Script (f a) → f (Script a) Source #

mapMMonad m ⇒ (a → m b) → Script a → m (Script b) Source #

sequenceMonad m ⇒ Script (m a) → m (Script a) Source #

Eq a ⇒ Eq (Script a) 
Instance details

Defined in Ouroboros.Network.Testing.Data.Script

Methods

(==)Script a → Script a → Bool Source #

(/=)Script a → Script a → Bool Source #

Show a ⇒ Show (Script a) 
Instance details

Defined in Ouroboros.Network.Testing.Data.Script

Methods

showsPrecIntScript a → ShowS Source #

showScript a → String Source #

showList ∷ [Script a] → ShowS Source #

Arbitrary a ⇒ Arbitrary (Script a) 
Instance details

Defined in Ouroboros.Network.Testing.Data.Script

Methods

arbitrary ∷ Gen (Script a)

shrinkScript a → [Script a]

data SnocketTrace m addr Source #

Constructors

STConnecting (FD_ m addr) addr 
STConnected (FD_ m addr) OpenType 
STBearerInfo BearerInfo 
STConnectError (FD_ m addr) addr IOError 
STConnectTimeout TimeoutDetail 
STBindError (FD_ m addr) addr IOError 
STClosing SockType (Wedge (ConnectionId addr) [addr]) 
STClosed SockType (Maybe (Maybe ConnectionState))

TODO: Document meaning of 'Maybe (Maybe OpenState)'

STClosingQueue Bool 
STClosedQueue Bool 
STAcceptFailure SockType SomeException 
STAccepting 
STAccepted addr 
STBearer (FD_ m addr) 
STAttenuatedChannelTrace (ConnectionId addr) AttenuatedChannelTrace 

Instances

Instances details
Show addr ⇒ Show (SnocketTrace m addr) Source # 
Instance details

Defined in Simulation.Network.Snocket

Methods

showsPrecIntSnocketTrace m addr → ShowS Source #

showSnocketTrace m addr → String Source #

showList ∷ [SnocketTrace m addr] → ShowS Source #

data SockType Source #

Instances

Instances details
Show SockType Source # 
Instance details

Defined in Simulation.Network.Snocket

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

Instances

Instances details
Show OpenType Source # 
Instance details

Defined in Simulation.Network.Snocket

normaliseIdOrd 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

Instances

Instances details
Show BearerInfo Source # 
Instance details

Defined in Simulation.Network.Snocket

data IOErrType Source #

Error types.

Instances

Instances details
Eq IOErrType Source # 
Instance details

Defined in Simulation.Network.Snocket

Show IOErrType Source # 
Instance details

Defined in Simulation.Network.Snocket

noAttenuationBearerInfo 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

data AddressType Source #

Connection manager supports IPv4 and IPv6 addresses.

Constructors

IPv4Address 
IPv6Address 

Instances

Instances details
Show AddressType Source # 
Instance details

Defined in Ouroboros.Network.ConnectionManager.Types