Professional Documents
Culture Documents
event occurs, e.g., input arrives
react to input
Generate output
Transition to another state
Output and transition are functions of current state and input
1
3
2
a/x
c/z
c/z
c/x
b/y
b/z
0
Self loops not shown
Deterministic
56
Extended Finite State Machines
Finite state machines plus:
variables
logical operators (AND, OR, )
Do not give additional power
all ESFM can be mapped into a FSM by enumerating states
57
Communicating Finite State Machines
Typically used to model and specify protocols
inputs/outputs can be external messages (peer-to-peer) or primitives
inputs can be generated by internal event (time-outs)
Two models of communication
synchronous: state machines block for each other
asynchronous: queues between the state machines
EFSMs
used to model sequence numbers, etc.
58
Synchronous Coupling
Wait_app
Wait_ack
Wait_data
Wait_app
App?msg.request/receiver!msg Sender?msg/App!msg.indication
App?msg.response/sender!ack
Receiver?ack/App!msg.confirm
Sender Receiver
Wait_app
Wait_ack
App?msg.request/receiver!msg(seqno)
(Receiver?ack(seqno))&&(seqno ==
expected)/App!msg.confirm; expected++
(Receiver?ack(seqno))&&(seqno !=
expected)/App!error
Wait_data
Wait_app
(Sender?msg(seqno))&&(seqno ==
expected)/App!msg.indication; expected++
App?msg.response/sender!ack(seqno)
59
Asynchronous Coupling
Implemented by modeling queues in between communication FSMs
in practice, chaining FSMs
FSM A
FSM B
Model as a FSM
60
Mathematical background
Basic probability
if A and B are independent processes, P(A) and P(B) occurring is P(A)P(B)
for ordered sequence of independent events, simply multiply probabilities
e.g., P of A occurring three times, followed by B is P(A)P(A)P(A)P(B)
expected value
for unordered occurrence of a set of event with two outcomes, results come from Bernoulli trials
E.g., k occurrences in n trials
Applied to networks
e.g., p = probability a packet is received in error, 1-p = probability packet is correctly received
(1-p)p
k
= probability the packet is received correctly after k tries
P(n bit block has k random errors), P = probability of a random bit error
Expected number of tries to successfully transmit a packet if p(packet loss) = p
=
=
1
) ( ) (
i
i i
x p x X E
k n k
p p
k
n
k X P
|
|
.
|
\
|
= = ) 1 ( ) (
k n k
p p
k
n
k X P
|
|
.
|
\
|
= = ) 1 ( ) (
=
=
1
) 1 ( ) (
i
i
ip p tries E