Communication Systems and Networks

Download Report

Transcript Communication Systems and Networks

Automata
Summary

Deterministic Automata
 Languages


Stochastic Automata
Other Automata Formalisms
 Automata


with input and output
Protocol Representation with Finite State
Automata (FSM)
Timed Automata
Deterministic Automaton
G   X , E, f , , x0 , X m 



X is the state space
E is the event set associated with G
f: XEX is the transition function
 f(x,e)=y
means that when G is at state x and event e
occurs then G transitions to y

Γ is the feasible event set.
every state x, Γ(x) is the set of all events that are
active
 For


x0 is the initial state
Xm is the set of marked states and is a subset of X
Example: Computer Basic Functions


Design an automaton that describes the basic
functions of a computer: down, waiting, processing
State space


Event set



Γ(D)={r ,a}, Γ(I)={a, f}, Γ(B)={f, a, c}
Alternatively Γ(I)={a} (computer cannot fail when idle)
Transition functions




f: failure, r: repair, a: job arrival, c: job completion
Feasible event sets


D: down, I: Idle, B: Busy
p(D, r)= I, p(D, a)=D
p(I, a)= B, p(I, f)= D
p(B, f)= D, p(B, a)= B, p(B, c)= I.
Initial state x0= I
Example: Automaton Graphical
Representation
a
I
B
c
r
f
f
D
a
a
Languages Generated by Automata

A language is a set of a finite length event strings
to marked states
a
1
2
c
r
f
3

L={a, aa, aaa, …, ac, aac,
aca, acaa, ar, aar, ara,…}
a
a
Example: Automaton Graphical
Representation

Suppose that the technician has resigned and it is no
longer possible to fix the computer.
a
I
B
c
f


Now it is possible to
create a deadlock.
D is an absorbing
state
f
D
a
a
Example: Queueing

What is an automaton model for simple FIFO queueing
system?
a

State space



X={0, 1, 2, 3, …}


Feasible event sets


Event set


d

E={a, d}
a: customer arrival,
d: customer departure
0


a
1
d
Transition functions

State transition diagram
a
a
f(x, a)= x+1
f(x, d)= x-1, if x > 0
Initial state x0= 0
a
2
d
Γ(0)={a},
Γ(x)={a, d}, x > 0
…
3
d
d
Non-Deterministic Automaton
G   X , E   , f nd , , x0 , X m 

A non-deterministic automaton is similar to the
deterministic except
 fnd:
may probabilistically transition to a set of states.
 x0 the initial state may also be a set of states.

Example
a
1
2
b
a
b
3
Equivalent Deterministic Automaton

For each non-deterministic automaton there is an
equivalent automaton that generates the same language.
a
a
1
2
1
2
b
b
a
b
3
L={a, b, ab, ba. aba, bab,
abab, baba, ababa, …}
b
a
3
Automata with Inputs/Outputs


Each state “emits” an output symbol that is noted on the
state
Alternatively, each transition is marked with the event that
triggers the transition and below it lists the actions that are
taken as a result of the transition.
s1
s2
a
1
2
1
c
d
3
s3
b
d/s1
a/s2
c/s3
3
2
b/s2
Example of FSM Model for Protocol
Verification (Stop and Wait Protocol)

Transmitter
Timer

The transmitter sends a
frame and stops waiting for
an acknowledgement from
the receiver (ACK)
Once the receiver correctly
receives the expected
packet, it sends an
acknowledgement to let the
transmitter send the next
frame.
When the transmitter does
not receive an ACK within a
specified period of time
(timer) then it retransmits
the packet.
Timer

Receiver
FSM for Stop and Wait Protocol

Transmitter
Send Pkt 0
Ack 1
Received
Timeout or
Pkt 0
transmitted
Ack 1 Received
Wait Ack 0
Wait Ack 1
Timeout or
Ack 0 Received
Ack 0
Received
Pkt 1
transmitted
Send Pkt 1
FSM for Stop and Wait Protocol

Receiver
Pkt 0 received
Send Ack 0
Wait Pkt 1
Wait Pkt 0
Pkt 0
Received
Pkt 1
Received
Send Ack 1
Send Ack 0
Pkt 1 received
Send Ack 1
Timed Automata Models



So far, the models we studied did not consider the time
when an event occurred.
For dynamic systems, the sample path of the system is
specified by the sequence of pairs {(ei,ti)} where ei is the
i-th event and ti is the time that the event has occurred.
Timed automata are similar to the deterministic automata
with the addition of a clock structure
G   X , E, f , , x0 ,V 


V is the clock structure
Xm (the set of marked states) is omitted for simplicity
Simple Example

Assume a system with a single event, i.e., E={a} and
Γ(x)={a} for all xX. We are interested for the sequence
{(ei, ti)} where ei is the i-th event and ti is the time when ei
occurs.
e1 = a e2 = a
ek-1 = a
ek = a
…
t1
t2
t
tk-1
tk
zk
yk
vk



vk= tk-tk-1 is the event lifetime
zk= t - tk-1 is the age of event
yk= tk - t is the residual lifetime
time
Simple Example with Two Events that
are Always Feasible

Assume a system with two events, i.e., E={a, b} and
Γ(x)={a, b} for all xX. In addition we are given the
sequences va={va,1, va,2,… }, vb={vb,1, vb,2,… },
e1 = a
x0
e2 = b
x1
e4 = a
x2
t1
a
b
e3 = b
x3
t2
t3
t4
va1
vb1
a
b
va2
yb1
a
b
ya2
vb2
a
b
x4
ya3
vb3
…
time
Example with Two Events that are NOT
Always Feasible

Assume that in the previous example that
Γ(x)={a,b} for x{x0, x2, x4} Γ(x)={b} for x{x1 , x3,}
e1 = a
x0
e2 = b
x1
e4 = b
x2
t1
a
b
e3 = b
x3
t2
t3
t4
va1
vb1
b
yb1
a
b
va2
vb2
a
b
x4
ya2
vb3
…
time
The Score of an Event
The score Nik of an event iE after the kth state transition
on a given sample path is the number of times that i has
been activated (not occurred).

e1 = a
x0
e2 = b
x1
e4 = b
x2
t1
a
b
e3 = b
x3
t2
t3
t4
va1
vb1
a
b
Na0 = Nb0=1
Na1 = 2
Nb1=1
va2
yb1
a
b
ya2
vb2
a
b
Na2 = Nb2=2
x4
ya3
vb3
…
time
The Event Timing Dynamics

Notation
x
is the current state
 e is the event that caused the system to go into state x
 t is the time that the corresponding event occurred
is the next event (triggering event) (clearly e’ Γ(x))
 t’ is the next event time (corresponding to e’)
 x’ is the next state given by x’ = f(x, e’).
 e’
 N’i
is the next score of event i
 y’i is the next clock value of event i (after e’ occurs)
The Event Timing Dynamics




Step 1: Given x evaluate the feasible event set
Γ(x)
Step 2: From the clock value yi of all events i 
Γ(x) determine the minimum clock value
y*= miniΓ(x){yi}
Step 3: Determine the triggering event
e’= arg miniΓ(x){yi}
Step 4: Determine the next state
x’ = f(x, e’)
 where
f() is the state transition function.
The Event Timing Dynamics

Step 5: Determine

t’= t + y*
Step 6: Determine the new clock values
*

y

y
if i  e and i  ( x)
 i
yi  
, i  ( x)
if i  e or i  ( x)

vi , Ni 1

Step 7: Determine the new event scores
 N i  1 if i  e or i  ( x)
N i  
, i  ( x)
Otherwise
 Ni
State Space Model

The automaton timing dynamics can also be
represented as a dynamical system
v1  v1,1 , v1,2 ,...
…
v2  v2,1 , v2,2 ,...
INPUT


x  f  x, y, N , v1 ,..., vm 
y   g  x, y, N , v1 ,..., vm 
 e , t  , e , t  ,...
1
1
2
2
N   h  x, y, N , v1 ,..., vm 
OUTPUT
The initial conditions are given by x0, Ni,0=1 for all i  Γ(x0)
and Ni,0=0 for all i  Γ(x0) and yi = vi,1 for all i  Γ(x0).
What represents the state variables of the system?
Example: Queueing Model
a

d
State space




E={a, d}
a: customer arrival,
d: customer departure
Feasible event sets

X={0, 1, 2, 3, …}
Event set





Γ(0)={a},
Γ(x)={a, d}, x > 0
Transition functions
 x  1 if e  a
f  x, e    
 x  1 if e  d

Initial state x0= 0
Clock structure



Va ={0.5, 0.5, 1.0, 0.5, 2.0, 0.5, …}
Vd ={1.0, 1.5, 0.5, 0.5, 1.0, …}
In general, the numbers of the clock structure are generated by a
Random Number Generator
Example: Queueing Model
Clock structure


t=0
a 0.5
b
Va={0.5, 0.5, 1.0, 0.5, 2.0, 0.5, …}
t=0.5
t=1
0.5
t=1.5
1
1
t=2
t=2.5
t=3
t=3.5
0.5
1.5
Vd={1.0, 1.5, 0.5, 0.5, 1.0, …}

2
0.5
t=4
t=4.5
t=5
0.5
0.5
1
time
The Event Scheduling Scheme
INITIALIZE
TIME
STATE
CLOCK
STRUCTURE
…
Update State
x’=f(x,e1)
EVENT CALENDAR
e1
t1
e2
t2
Delete
Infeasible
Events
Add New
Feasible
Events
Update Time
t’=t1
Recall the Queueing System from
Introduction

System Input
1
u1 (t )  
0
1
u2 (t )  
0
if parcel arrives at t
otherwise
if truck arrives at t
otherwise

System Dynamics
 x(t )  1 if u1 (t )  1, u2 (t )  0,

x(t  )   x(t )  1 if u1 (t )  0, u2 (t )  1
 x(t )
otherwise

u1(t)
t
u2(t)
t
x(t)
t
Time Driven vs. Event Driven
Simulation Models

Time Driven Dynamics

 x(t )  1 if u1 (t )  1, u2 (t )  0,

x(t  )   x(t )  1 if u1 (t )  0, u2 (t )  1
 x(t )
otherwise


In this case, time is
divided in intervals of
length Δt, and the state is
updated at every step
Event Driven Dynamics
 x  1 if e  a
f  x, e    
 x  1 if e  d

State is updated only at
the occurrence of a
discrete event
Example: Two Queues in Series


Determine the automaton that describes the following
network where the B1 and B2 have finite capacities of 3
and 2 packets respectively (including the customer in the
server)
When a customer departs from B1 when B2 is full, then
the customer is lost!
B1

B2
State
x = [x1, x2] where xi denotes the number of customers in Bi
Example: Two Queues in Series
a


X={[x1, x2] : x1= 0,…,3, x2 = 0, 1, 2}
E={a, d1, d2}
Γ([0,0])= {a}, Γ([0, x])={a, d2} if x > 0, Γ([x, 0])= {a, d1} if x > 0,
Γ([x1, x2])= {a, d1, d2} if x1 > 0 and x2 > 0.
Transition functions
f [ x1 , x2 ], a   [min{x1  1,3}, x2 ]
f [ x1 , x2 ], d1   [ x1  1, min{x2  1, 2}]

d2
Feasible event sets


B2
Event set


d1
State space


B1
Initial state x0= [0,0].
f [ x1 , x2 ], d2   [ x1 , x2 1]
Communication Link

How would you model a transmission link that can
transmit packets at a rate G packets per second and has
a propagation delay equal to 100ms?
B1
B2
?
B1
…
Exercise

Write a simulation program that imitates the
behavior of the network shown below.
 The
inputs to your program are the capacities of each
buffer as well as the clock structure (three vectors
with the lifetimes of each event)
 The output from your program is the sample path of
the network i.e., the state trajectory and/or a “trace”
consisting of a sequence of events and its
corresponding time.
B1
a
B2
d1
d2
Example: Two Class FIFO Buffer

Assume the queueing model shown below. The arrival
process consists of two classes of customers (in general
n classes) and each class has different priority as well as
different service requirements.
a1
B1
d
a2

Define the following string operations



Concatenation: [a1,a2,…,am] + [am+1]= [a1,a2,…,am, am+1]
Reduction: [a1,a2,…,am]\[aj] = [a1,…, aj-1 , aj+1 ,…am]
Head Reduction: [a1,a2,…,am]\1= [a2,…,am]
Example: Two Class FIFO Buffer

Event Set


State Space:



Γ(ε)={a1,a2} and Γ(x)={a1,a2,d} for all other states x
Transition Functions




X={ x : {ε}  {all possible permutations of a1 and a2 with
length 0,…,K}}
K is the buffer size
Feasible Event set


E={a1,a2, d}
f(x, a1)= x + {a1}
f(x, a2)= x + {a2}
f(x, d)= x\1 for all x  {ε}.
Initial State: x0 = ε.
Exercise


Consider the two class FIFO buffer from the previous example
and determine how you would simulate the following policies
Threshold policy (with threshold B < K )



When a high priority customer arrives (e.g. a1), it is accommodated as
long as there is enough buffer space, i.e., as long as |x| < K where |x| is
the “cardinality” of the set x, (the number of elements in x or 0 if x=ε).
When a low priority customer arrives (e.g. a2), it is accommodated only
if the number of customers currently in the queue does not exceed B,
i.e., as long as |x| < B.
Push-out Policy


When a low priority customer arrives, it is accommodated if |x| < K.
When a high priority customer arrives, it is accommodated at the end
of the queue if |x| < K. However, if |x| = K then, the last low priority
customer from the queue (if one is present) is removed and the new
customer is accommodated the at the tail of the queue.
Single Queue Simulation Pseudo-code

a
d
onArr()




InitializeSimulator();
While
!end_of_simulation



event= GetNextEvent();
time= event(time);
Switch(event(type))






End

onDep()

case ‘a’: onArr();
case ‘d’: onDep();

EndSwitch;
EndWhile;
first=UpdateState();
ActivateNextArr();
If(first)
ActivateNextDep();

empty=UpdateState();
If(!empty)
ActivateNextDep();
End