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 :: (Alternative (STM m), MonadDelay m, MonadLabelledSTM m, MonadMask 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
- = (Typeable addr, Show addr) => NotReleasedListeningSockets [addr] (Maybe SomeException)
- | (Typeable addr, Ord addr, Show addr) => NotReleasedConnections (Map (NormalisedId addr) ConnectionState) (Maybe SomeException)
- data SDUSize
- newtype Script a = Script (NonEmpty a)
- type Size = Int64
- data SnocketTrace (m :: Type -> Type) 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
- | STAttenuatedChannelTrace (ConnectionId addr) AttenuatedChannelTrace
- data SockType
- data OpenType
- 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, IOError))
- biSDUSize :: !SDUSize
- data IOErrType
- data SuccessOrFailure
- data TimeoutDetail
- noAttenuation :: BearerInfo
- data FD (m :: Type -> Type) peerAddr
- makeFDBearer :: forall addr (m :: Type -> Type). (MonadMonotonicTime m, MonadSTM m, MonadThrow m, Show addr) => MakeBearer m (FD m (TestAddress addr))
- class GlobalAddressScheme addr where
- getAddressType :: TestAddress addr -> AddressType
- ephemeralAddress :: AddressType -> Natural -> TestAddress addr
- data AddressType
- data WithAddr addr event = WithAddr {
- waLocalAddr :: Maybe addr
- waRemoteAddr :: Maybe addr
- waEvent :: event
Simulated Snocket
withSnocket :: (Alternative (STM m), MonadDelay m, MonadLabelledSTM m, MonadMask 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 showsPrec :: Int -> ObservableNetworkState addr -> ShowS # show :: ObservableNetworkState addr -> String # showList :: [ObservableNetworkState addr] -> ShowS # |
data ResourceException Source #
(Typeable addr, Show addr) => NotReleasedListeningSockets [addr] (Maybe SomeException) | |
(Typeable addr, Ord addr, Show addr) => NotReleasedConnections (Map (NormalisedId addr) ConnectionState) (Maybe SomeException) |
Instances
Exception ResourceException Source # | |
Defined in Simulation.Network.Snocket | |
Show ResourceException Source # | |
Defined in Simulation.Network.Snocket showsPrec :: Int -> ResourceException -> ShowS # show :: ResourceException -> String # showList :: [ResourceException] -> ShowS # |
Instances
Enum SDUSize | |||||
Generic SDUSize | |||||
Defined in Network.Mux.Types
| |||||
Num SDUSize | |||||
Integral SDUSize | |||||
Defined in Network.Mux.Types | |||||
Real SDUSize | |||||
Defined in Network.Mux.Types toRational :: SDUSize -> Rational # | |||||
Show SDUSize | |||||
Eq SDUSize | |||||
Ord SDUSize | |||||
type Rep SDUSize | |||||
Defined in Network.Mux.Types |
Instances
Functor Script | |
Foldable Script | |
Defined in Ouroboros.Network.Testing.Data.Script fold :: Monoid m => Script m -> m # foldMap :: Monoid m => (a -> m) -> Script a -> m # foldMap' :: Monoid m => (a -> m) -> Script a -> m # foldr :: (a -> b -> b) -> b -> Script a -> b # foldr' :: (a -> b -> b) -> b -> Script a -> b # foldl :: (b -> a -> b) -> b -> Script a -> b # foldl' :: (b -> a -> b) -> b -> Script a -> b # foldr1 :: (a -> a -> a) -> Script a -> a # foldl1 :: (a -> a -> a) -> Script a -> a # elem :: Eq a => a -> Script a -> Bool # maximum :: Ord a => Script a -> a # minimum :: Ord a => Script a -> a # | |
Traversable Script | |
Arbitrary a => Arbitrary (Script a) | |
Show a => Show (Script a) | |
Eq a => Eq (Script a) | |
data SnocketTrace (m :: Type -> Type) 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 | |
STAttenuatedChannelTrace (ConnectionId addr) AttenuatedChannelTrace |
Instances
Show addr => Show (SnocketTrace m addr) Source # | |
Defined in Simulation.Network.Snocket showsPrec :: Int -> SnocketTrace m addr -> ShowS # show :: SnocketTrace m addr -> String # showList :: [SnocketTrace m addr] -> ShowS # |
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 showsPrec :: Int -> BearerInfo -> ShowS # show :: BearerInfo -> String # showList :: [BearerInfo] -> ShowS # |
data TimeoutDetail Source #
Instances
Show TimeoutDetail Source # | |
Defined in Simulation.Network.Snocket showsPrec :: Int -> TimeoutDetail -> ShowS # show :: TimeoutDetail -> String # showList :: [TimeoutDetail] -> ShowS # |
noAttenuation :: BearerInfo Source #
BearerInfo
without attenuation and instantaneous connect delay. It also
using the production value of SDUSize
.
makeFDBearer :: forall addr (m :: Type -> Type). (MonadMonotonicTime m, MonadSTM m, MonadThrow m, Show addr) => MakeBearer m (FD m (TestAddress addr)) Source #
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.
Instances
Show AddressType Source # | |
Defined in Ouroboros.Network.ConnectionManager.Types showsPrec :: Int -> AddressType -> ShowS # show :: AddressType -> String # showList :: [AddressType] -> ShowS # |
data WithAddr addr event Source #
WithAddr | |
|