Safe Haskell | None |
---|---|
Language | Haskell2010 |
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
- 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
-
newtype
ObservableNetworkState
addr =
ObservableNetworkState
{
- onsConnections :: Map (NormalisedId addr) addr
-
data
ResourceException
addr
- = NotReleasedListeningSockets [addr] ( Maybe SomeException )
- | NotReleasedConnections ( Map (NormalisedId addr) ConnectionState) ( Maybe SomeException )
- data SDUSize
- newtype Script a = Script ( NonEmpty a)
- type Size = Int64
-
data
SnocketTrace
m addr
- = 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))
- | STClosingQueue Bool
- | STClosedQueue Bool
- | STAcceptFailure SockType SomeException
- | STAccepting
- | STAccepted addr
- | STBearer (FD_ m addr)
- | STAttenuatedChannelTrace ( ConnectionId addr) AttenuatedChannelTrace
- data SockType
-
data
OpenType
- = SimOpen
- | NormalOpen
- normaliseId :: Ord addr => ConnectionId addr -> NormalisedId addr
-
data
BearerInfo
=
BearerInfo
{
- biConnectionDelay :: ! DiffTime
- biInboundAttenuation :: Time -> Size -> ( DiffTime , SuccessOrFailure )
- biOutboundAttenuation :: Time -> Size -> ( DiffTime , SuccessOrFailure )
- biInboundWriteFailure :: !( Maybe Int )
- biOutboundWriteFailure :: !( Maybe Int )
- biAcceptFailures :: !( Maybe ( DiffTime , IOErrType ))
- biSDUSize :: ! SDUSize
- data IOErrType
- data SuccessOrFailure
- data TimeoutDetail
- noAttenuation :: BearerInfo
- data FD m peerAddr
-
class
GlobalAddressScheme
addr
where
- getAddressType :: TestAddress addr -> AddressType
- ephemeralAddress :: AddressType -> Natural -> TestAddress addr
- data AddressType
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
.
ObservableNetworkState | |
|
Instances
Show addr => Show ( ObservableNetworkState addr) Source # | |
Defined in Simulation.Network.Snocket |
data ResourceException addr Source #
NotReleasedListeningSockets [addr] ( Maybe SomeException ) | |
NotReleasedConnections ( Map (NormalisedId addr) ConnectionState) ( Maybe SomeException ) |
Instances
Show addr => Show ( ResourceException addr) Source # | |
Defined in Simulation.Network.Snocket |
|
( Typeable addr, Show addr) => Exception ( ResourceException addr) Source # | |
Defined in Simulation.Network.Snocket toException :: ResourceException addr -> SomeException Source # fromException :: SomeException -> Maybe ( ResourceException addr) Source # displayException :: ResourceException addr -> String Source # |
Instances
Functor Script | |
Foldable Script | |
Defined in Ouroboros.Network.Testing.Data.Script fold :: Monoid m => Script m -> m Source # foldMap :: Monoid 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 # toList :: Script a -> [a] Source # null :: Script a -> Bool Source # length :: Script a -> Int Source # elem :: Eq a => a -> Script a -> Bool Source # maximum :: Ord a => Script a -> a Source # minimum :: Ord a => Script a -> a Source # |
|
Traversable Script | |
Defined in Ouroboros.Network.Testing.Data.Script |
|
Eq a => Eq ( Script a) | |
Show a => Show ( Script a) | |
Arbitrary a => Arbitrary ( Script a) | |
data SnocketTrace m addr Source #
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
Show addr => Show ( SnocketTrace m addr) Source # | |
Defined in Simulation.Network.Snocket |
Either simultaneous open or normal open. Unlike in TCP, only one side will will know that it is doing simultaneous open.
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.
BearerInfo | |
|
Instances
Show BearerInfo Source # | |
Defined in Simulation.Network.Snocket |
data TimeoutDetail Source #
Instances
Show TimeoutDetail Source # | |
Defined in Simulation.Network.Snocket |
noAttenuation :: BearerInfo Source #
BearerInfo
without attenuation and instantaneous connect delay. It also
using the production value of
SDUSize
.
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).
getAddressType :: TestAddress addr -> AddressType Source #
ephemeralAddress :: AddressType -> Natural -> TestAddress addr Source #
Instances
GlobalAddressScheme Int Source # |
All negative addresses are ephemeral. Even address are IPv4, while odd ones are IPv6. |
Defined in Simulation.Network.Snocket getAddressType :: TestAddress Int -> AddressType Source # ephemeralAddress :: AddressType -> Natural -> TestAddress Int Source # |
data AddressType Source #
Connection manager supports
IPv4
and
IPv6
addresses.