Вы находитесь на странице: 1из 68

. ..

.. , ..


CPN Tools




5
16.11.2006

2008

621.39, 004.7

: . .A. ,
..., . .A.
: ..., . .A. ,
..
Zaitsev D.A., Shmeleva T.R. Simulating Telecommunication Systems with CPN Tools: Students'
book. Odessa: ONAT, 2006. 60 p.
:

.. 1, .. 2

CPN Tools.

()

.
.

Ethernet.



4
10.11.2006

1
2

ICQ: 323989272, e-mail: tatyanaONAC@yandex.ru


ICQ: 406926201, e-mail: hani_13@mail.ru

.
1. , CPN Tools...
1.1. CPN ML.....
1.2. ....
2. CPN Tools.
2.1. CPN Tools...
2.2. CPN Tools.
3. CPN Tools ..
3.1.
3.2.
3.3. -
3.4. .
3.5. (Help)..
3.6. CPN Tools.
4. CPN Tools .
4.1. ....
4.2. ...
4.3. ....
4.4. ...
5. CPN ML.
5.1. ...
5.2.
5.3.
5.4. ..
5.5. ...
5.6. ..
5.7. ...
6.
6.1. .............
6.2. ..
6.3. ..
7. CPN Tools..
8. ..
9. ...........
10. .
10.1. .
10.2. ...
10.3. ...
11. .
11.1. ...
11.2. .
11.3.
11.4. .

5
5
6
7
10
10
11
12
12
13
14
15
16
17
19
20
20
22
24
25
25
27
29
29
31
32
33
34
34
35
36
39
40
43
45
45
47
47
48
48
49
52
54

12. CPN Tools


12.1. .
12.2. ...
:

1. .
2.
3. ..
4. ..
5.
6.
7. .
.

55
55
56
58
58
59
61
62
63
64
66
68

CPN Tools ,
.

http://www.daimi.au.dk/CPNTools/.
CPN Tools
.
, .
Nokia CPN Tools
.

1. , CPN Tools
CPN Tools
.
. ,

. ,
.

.
: 1 , 2, 3, ..
CPN Tools .
,
, .
,
.

.
, ,

.
, ,
.
.
. CPN Tools
. ,
: .
. , ,
,
.

1.1. CPN ML
CPN Tools
CPN ML.
.
: ,
, :
TRANSITION

PLACE

:
p1

ARC

ARC

t1

ARC

p3

p2

.
, ,
:
2`token

2`token
2 2`token
x

p1
t

t1
x
3`token
3 3`token

p2
t

1 1`token
x

p1
x

t
t1

p3

3`token

1 1`token

p3
t

2 2`token

p2
t

.
. ,
. : student (), pasty
(). , :

7
5`pasty

5`pasty
food

5 5`pasty
y
p

food

eat

replete
student

eat
x
3`student

3`student
hungry
student

4 4`pasty
y

hungry
student

3 3`student

replete
student

1 1`student
s

2 2`student
s

CPN Tools
. ,
, , .
:
colset s=unit with student;
colset p=unit with pasty;
var x:s;
var y:p;
: s student
p pasty. hungry student (
) replete student ( )
s student. food ()
p pasty. eat (),
: student pasty. x y ,

.
,
.
, ,
Ethernet, , , ..
, ,
.
hungry student, s,
3`student 2` student ,
. x
; y
. , x
hungry student, replete
student, eat,
x.
1.2.

CPN
Tools. .
; ,
.

8
u

go
home

tranport
p

x
x
1 1`Cinderella
Cinderella

go
to
ball

home
c

ball
c

1`pumpkin
x

sack of rice

1 1`Fairy

g
Fairy

supernature

magic

12`mouse

if y=rice then 1`rice else empty


mice

1000`rice++2000`wheat++3000`oat

sack of wheat
g

if y=wheat then 1`wheat else empty


1000`rice++
6000 2000`wheat++
3000`oat

sack with
mixture
g

sort
if y=oat then 1`oat else empty

sack of oat
g


:
colset
colset
colset
colset
colset
var x:
var y:
var z:
var u:
var v:

p=unit
c=unit
g=with
m=unit
f=unit
c;
g;
f;
p;
m;

with
with
rice
with
with

pumpkin;
Cinderella;
| wheat | oat;
mouse;
Fairy;

: f
Fairy (), c Cinderella (), p
Pumpkin () g
( ) rice (), wheat (), oat
(). Magic
(), .
, 12 1 Magic .
,
.
go to ball
( ) go home ( ),
.

Sort (),
.
. Magic
Cinderella , Pumpkin go to
ball go home, .
. ,
, .
.
.
, sort y; y
g; , sack with mixture
( ) .
.
.
() ,
. , go to ball Cinderella
home () x
Cinderella ball ()
x . Magic
: Fairy ,
z, z
; Cinderella home
Magic, x,
, home; 12 mice ()
1 pumpkin ,
. 5000 :
u

go
home

1 1`pumpkin

tranport
p

x
x
Cinderella

go
to
ball

home
c

1 1`Cinderella

ball

1`pumpkin
x

431 431`rice

sack of rice
g

Fairy
supernature

magic

12`mouse

mice

if y=rice then 1`rice else empty


12 12`mouse
m

1000`rice++2000`wheat++3000`oat

822 822`wheat

sack of wheet
g

if y=wheat then 1`wheat else empty


569`rice++
3484 1178`wheat++
1737`oat

sack with
mixture
g

sort
if y=oat then 1`oat else empty

1263 1263`oat

sack of oat
g

10

, , .
431 , 822 1263 .
: sort go home.
. sort
y, :
sack of rice ( ), sack of wheat (
), sack of oat ( ).
, ,
Empty (). Empty
.

. ,
.
.
CPN Tools ,
.
,
.
.
Ethernet . ,
, ,
.

2.

CPN Tools
2.1. CPN Tools

CPN Tools .

.
,
, ,
.
CPN Tools http://www.daimi.au.dk/CPNTools/. CPN Tools
Windows Unix; ,
, DesignCPN.
, CPN Tools
,
,
. Nokia CPN Tools
.

.
.

11

.

,
,
.
,
( ?). ,
,
,
.
CPN
Tools, ,
. ,
,
.
,
.

.
CPN Tools
( ,
).

.
, , Klashka.
2.2. CPN Tools
CPN Tools :
() ;
;
.

.
,
CPN ML. .
.

( ).
, , . CPN Tools

,
, . ,
CPN ML

12

,
. ,
,
.

. CPN Tools
,
.

.

, ,
.

3. CPN Tools
CPN Tools ,
MS Open GL,
,
- .
( ).

,
.
3.1.
CPN Tools.
,
, :

CPN Tools:

:
. (Tool box),

13

(Help) (Options), (
).
. CPN Tools
.
, ,
. , :

3.2.
,
.
(Create):

.
, .
. ,
:

14

,
Esc .
,
.
, (Net) :
- (Black/White):

3.3. -
CPN Tools
- ,
. .
, ,
.
- . ,
,
:

15

-
:

-
.
. , ,
:

3.4.
CPN Tools (net).
.
:

16

CPN Tools :
.cpn;
, ;
;
, ;
, , , ;
.
model1.cpn,
, , Top page.
, Top page ;
, .
, .
:

3.5. (Help)
CPN Tools : ,
offline online.
,
. :

17


CPN Tools:

CPN Tools,
.
, ,
CPN Tools . ,
,
, .
3.6. CPN Tools
CPN Tools ,
.
:
;
;
();
.
,
- .
,
,
. ,
:

, :
;
;
;
;
CPN ML;

18

. ,
.
,
.
, :

:
, ;
,
;
,
, .
( ) ,

. ,
, , , , ,
, :

:
-
;
-
;
;
-
, , ;
, ;
,
;
,
;
,
;
/
/ .

19

, ,
. :

;

,
;
,
;

,
. ,
: , ,
.
, ,
;
, ,
, , ,
.
/
.

4. CPN Tools
:

(Net): ;
(Create):
;
(Simulate): ;
(State Space):
;
(Hierarchy): ;

20

(Style):
;
(View):
;
(Auxiliary):
.
4.1.

(
):
;
;
;
;
;
;
.
,
.
,
. .eps (Encapsulated
PostScript) , , MS
Word. .
4.2.

:
;
;
;
;
;
;

21

;
.
:

, ,
. ,
INT x
:

. ,
a 6 : 1 3, 3 4 2 5.
.

22

. ,
Tab :
INITIAL
MARKING

NAME

PLACE
TYPE

GUARD

TIME
DELAY
NAME

ACTION

.
CPN Tools .

.
(). :

4.3.

:
;
;
;
;
,
;

;
ML .
, ,
. ,
(
CPN Tools ). :

23

4 x a
b c.
.
, ,
:

3, 4, 5 5
.
,
CPN Tools.
:

() .
, CPN Tools

24

.
, , ,
.
.

, - ,
.
, :

ML
.
4.4.
CPN Tools ,
(Auxiliary), (Style),
(View), , (Hierarchy),
(State Space).

.
,
, ,
.
, ,
, , ()

. .

,
.

. ,
, .


,
, , ,
.

25

5. CPN ML
CPN Tools CPN ML
(). CPN ML
( ), , , ().

;
.
.
, .
:
E , INT , BOOL , STRING
.
, - . ,
CPN Tools ,
.
CPN Tools
. () ,
. ,
, .
,
. ,
.
.
( ,
). , , ,
-
.
, .
, , , ,
. ,
. ,
.
.
, , .

. , , ,
, .
5.1.
CPN ML : unit,
boolean, integer, string, enumerated, index.

26

unit .
:
colset name = unit [with new_unit];

().
unit:
colset
colset
colset
colset

p=unit
c=unit
m=unit
f=unit

with
with
with
with

pumpkin;
Cinderella;
mouse;
Fairy;

boolean ( ) true
() false ().
:
colset name = bool [with (new_false, new_true)];
true false, ,
yes () no ():
colset Answer = bool with (no, yes);
:
not b
b1 andalso b2
b1 orelse b2

b,
(),
(),

Integers ( ) .
:
colset name = int [with int-exp1...int-exp2];
,
: int-exp1 int-exp2:
colset Dozen = int with 1..12;
:
+, -, div, mod, abs, Int.min, Int.max, ~ .
Strings ( ) ASCII
( ) .
:
colset name = string [with string-exp1..string-exp2
[and int-exp1..int-exp2]];
:

27

colset LowerString = with "a".."z";


: ^
( ),
String.size , substring .
Enumerated ()
.
:
colset name = with id0 | id1 | ... | idn;

:
colset g=with rice | wheat | oat;
Indexed ( ) ,
:
colset name = index id with int-exp1..int-exp2;
: id i id (i), i
int-exp1 <= i <= int-exp2. ,

:
colset PH = index ph with 1..5;
colset FR = index fork with 1..5;
ph(1) : fork(1) fork(2).
5.2.

. CPN ML :
product, record, union, list, subset alias. list
union ,
.
Product record ,
.
,
product ,
record .
record
C.
product :

28

colset name = product name1 * name2 * ... * namen;


:
(v1, v2, ..., vn) vi namei 1<=i<=n.
i ,
:
#i name
record :
colset name = record id1:name1 * id2:name2 * ... *
idn:namen;
:
{id1=v1, id2=v2, ..., idn=vn} vi
namei 1<=i<=n.
i ,
:
#idi name

Ethernet. Ethernet ,
. - integer
string:
colset
colset
colset
colset

MAC = int;
DATA = string;
frame = product MAC * MAC * DATA;
frame1 = record src : MAC * dst : MAC * d : DATA;

Ethernet frame,
frame1. frame
x = (2, 4, Hello), , ,
2 4, Hello.
frame1 x1 = { dst=4, src=2, d
= Hello }.
, frame, :
#2 x
frame1:
#dst x1

29

alias ,
. ,
.
:
colset name = name0;
5.3.
,
.
.
:
var id1, id2, ..., idn : cs_name;
idi , cs_name
. :
var f1, f2 : frame;
var f3, f4 : frame1;


( ). :
val id = exp;
id exp CPN ML.
, . :
val CheckFrame = (3, 5, Ping );
val ResponseFrame1 = {src=5, dst=3, d=OK};

5.4.
CPN ML
, if case. ML
, , ,

.
:
fun
|
|
|

id pat1 = exp1
id pat2 = exp2
...
id patn = expn;

pat1, pat2, , patn exp1, exp2, ...,


expn . , ,
pati,

30

expi. ,
, :
fun fact ( 0 ) = 1
| fact ( i ) = i * fact( i-1);

if-then-else case
:
if bool-exp then exp1 else exp2;
exp1 exp2 .
case exp of
pat1 => exp1
| pat2 => exp2
| ...
| patn => expn;
exp1, exp2, ..., expn .
, . , ,
, :
fun sign (x) = if x>0 then 1 else if x<0 then ~1 else 0;

, , :
fun nname (x) =
case sign(x) of
1 => "positive"
| ~1 => "negative"
| _ => "zero";

_ ,
zero
((sign (x)).
let :
let

in

val pat1 = exp1


val pat2 = exp2

val patn = expn

exp
end;
:
:

31

fun metr (x) =


let
val mminm=1000;
in
x div mminm
end;

5.5.

. ,

. CPN
Tools:
() ;
ran;
.
()
,
.
.
.
. ,
.
, ( 100)
, .
unit, Boolean, index enumerated .
i
1.. 31. ;
i CPN Tools :
d

INT
colset mday = int with 1..31;
var i : mday;

INT
colset mday = int with 1..31;
var i : mday;

1`10++
1`13++
4 1`14++
1`20

ran
. ranRange()
1..10000:
d

1`ranRange()

colset Range = int with 1..10000;


fun ranRange () = Range.ran();

INT

1`ranRange()

colset Range = int with 1..10000;


fun ranRange () = Range.ran();

1`158++
1`569++
4 1`728++
INT 1`8978

32

PN Tools
:
, , , , , ,
, ( ). ,
erlang(n:int, r:real) : real
n>=1 r>0.0, n
r.
5.6.
CPN Tools
.
. ,
,

.
(`) .
, 3`5 ,
() 5. :
i`c,
i ,
. ,
(++) (-) ,
. ,
1, sack of mixture
:
1000`rice ++ 2000`wheat ++ 3000`oat

, 1000 , 2000
3000 .
: (`), (').
Ethernet frame1
:
1`{src=2, dst=5, d=request} ++ 1`{src=5, dst=2, d=answer}

: request,
5 2, answer,
2 5.
,
:

33
empty
ms1
ms1
ms1
ms1
ms1
ms1
ms1

== ms2
<><> ms2
>> ms2
>>== ms2
<< ms2
<<== ms2
++ ms2

ms1 -- ms2
i ** ms
size ms
random ms
cf(c,ms)
filter p ms

empty ,



,

,


(ms2 ms1),
, ms2 ms1.




p ms
ms, p

,
m1 = 2`5 ++ 3`4 ++ 4`5;
m2 = 1`5 ++ 2`4 ++ 3`5;

m1 ++ m2 = 3`5 ++ 5`4 ++ 7`5


m1 m2 = 1`5 ++ 1`4 ++ 1`3
m1 >> m2
true
size m1 = 9
cf(4,m1) = 3

CPN Tools
, .
CPN Tools
, random.
5.7.
CPN Tools,
.
timed.
@, @+, @@ + , .
x c
, + x, c.
:
c @ t
ms @+ i
tms1 +++ tms2

( Time.time) c
i
ms,

34

,
colset tint = int timed;
var t : tint;
t = 1`2@100 ++ 1`3@200 ++ 1`4@300;
, 2@100 CPN Tools
100, 3@200
200 ..
.

6.
CPN Tools ,
CPN ML.
, .
.
Tab
. Esc
;
.
.
6.1.
, .
:
;
;
.

INITIAL
MARKING

NAME

COLOR
SET
CPN Tools
,
. , :
1000`rice++2000`wheat++3000`oat
sack with
mixture
g

1000`rice++
6000 2000`wheat++
3000`oat

35

6.2.
:

expr
, .
,
,
.
.
.
,
filter, .
,
, .
2`5++3`4++1`3
x

1`3++ INT
6 3`4++
var x: INT;
2`5

INT

6 x.
,
Ethernet:
1`(2,5,"a")++1`(3,4,"b")++1`(2,4,"c")
(2,dst,d)

buffer
frame
3

1`(2,4,"c")++
1`(2,5,"a")++
1`(3,4,"b")

get

colset MAC=INT;
colset DATA=string;
colset frame=product MAC * MAC * DATA;
var src, dst : MAC;
var d : DATA;

(2,5,"a") (2,4,"c")
(2,dst,d).

.
.
sum :

36
5`10++4`20

5`10++4`20

5`10++
9 4`20
x

a
INT

7`3++5`4
b

INT
1`(x+y)

sum

7`3++5`4

INT
7`3++
12 5`4

INT

3`10++
6 3`20
x

sum

1`(x+y)

1`13++
3 1`14++
1`24
INT

6`3++
9 3`4

INT

,
. ()
100 :
(2,4,"ping")

(2,4,"ping")

x@+100

clock

gen

tframe
1 1`(2,4,"ping")@0

x@+100

clock

buf
tframe

colset tframe=frame timed;


var x: tframe;

x
gen

tframe

buf

1`(2,4,"ping")@200+++
3 1`(2,4,"ping")@100+++
1`(2,4,"ping")@0
tframe

1 1`(2,4,"ping")@300 colset tframe=frame timed;


var x: tframe;

6.3.
,
. :
;
;
;
.
[GUARD]

@ +

@+(TIME
DELAY)
NAME

CODE
SEGMENT

.
, @+, ,
@+delayexpr. , ,
@+.
. ,
10 @+2, ,
, 12.
. ,
.
. ,
6.2:

37
(2,4,"ping")
clock

(2,4,"ping")

@+100
x

gen

buf

tframe

clock
tframe

@+100
x

gen

buf

tframe

1 1`(2,4,"ping")@0

1`(2,4,"ping")@300+++
3 1`(2,4,"ping")@200+++
1`(2,4,"ping")@100
tframe

1 1`(2,4,"ping")@300

CPN
ML, true () false ().
, : [].

[b-exp1, b-exp2,..., b-expn].
, ,
. , ,
6.2, :
1`(2,5,"a")++1`(3,4,"b")++1`(2,4,"c")

[src=2]

(src,dst,d)

buffer
frame

get

colset MAC=INT;
colset DATA=string;
colset frame=product MAC * MAC * DATA;
var src, dst : MAC;
var d : DATA;

1`(2,4,"c")++
3 1`(2,5,"a")++
1`(3,4,"b")

,
, .
Ethernet:
1`(2,5,"a")++1`(3,4,"b")++1`(2,4,"c")
f

segment
frame
1`(2,4,"c")++
3 1`(2,5,"a")++
1`(3,4,"b")

var f : frame;
var addr : MAC;

[#1 f = addr]
f

get

buffer
frame

addr
1`2
own

1 1`2
MAC

own.
.
,
ML. ,
.
CPN CPN,
, .
:
();
();
().

38

CPN,
input. CPN,
.
CPN, . CPN,
,
, ML
. ,
, CPN
.
CPN,
output. CPN,
.
CPN CPN .
, , CPN
.
ML,
action. ,
CPN . ,
,
, . ,
let-in-end.
,
CPN, . ,

CPN, .
, CPN
. ,
,
. ,
unit.

. , , 6.2,
, :
5`10++4`20
a

5`10++
9 4`20
x

7`3++5`4

INT

b
INT

7`3++
12 5`4

sum

z
input (x,y);
output (z);
action
(x+y);

c
INT

39

7. CPN Tools
CPN Tools , ,
.
timed, untimed.
CPN Tools Step,
.
CPN Tools :

Create
the set

of permitted

transitions

:
STEP:=STEP+1

,
,

.
, ,
:



NTime

Time:=NTime


Time+1.
Time:=timeofnearestfutureevent ,
,
Step, .
,
,
. . ,

:
(2,4,"ping")
1 1`(2,4,"ping")

clock

@+100
x

frame

gen

buf

42 42`(2,4,"ping")@100
tframe

, CPN Tools
,
(). t (k@t).
Time<t
;

40

. t
k .
.
, (k@t+d),
.
CPN Tools:
1`5@+100++1`4@+100++1`3@+100++
1`3@200+++
1`4@+200++1`3@+200++
1`3@100+++
1`5@+300++1`4@+300
1`4@300+++
7 1`4@200+++
@+50
1`4@100+++
x
x
1`5@300+++
a
b
1`5@100
tint
Step: 0
Time: 0
1`5@+100++1`4@+100++1`3@+100++
1`3@200+++ 1`4@+200++1`3@+200++
1`4@300+++ 1`5@+300++1`4@+300
5 1`4@200+++
@+50
1`4@100+++
x
x
1`5@300
a
b

1`4@300+++
2 1`5@300

tint

tint

tint

1`5@+100++1`4@+100++1`3@+100++
1`4@+200++1`3@+200++
1`5@+300++1`4@+300

@+50
c

tint

1`3@250+++
1`3@150+++
5 1`4@250+++
1`4@150+++
tint 1`5@150

@+50
x

tint

Step: 7
Time: 300

1 1`3@150
tint

1`5@+100++1`4@+100++1`3@+100++
1`4@+200++1`3@+200++
1`3@200+++ 1`5@+300++1`4@+300
1`4@300+++
4 1`4@200+++
@+50
1`5@300
x
x
a
b

1`5@+100++1`4@+100++1`3@+100++
1`4@+200++1`3@+200++
1`5@+300++1`4@+300
x

tint

Step: 1
Time: 100

Step: 3
Time: 200

a
Step: 5
Time: 300

1`3@150+++
2 1`5@150

tint

Step: 2
Time: 100

1`5@+100++1`4@+100++1`3@+100++
1`3@200+++
1`4@+200++1`3@+200++
1`4@300+++
1`5@+300++1`4@+300
1`4@200+++
6 1`4@100+++
@+50
1`5@300+++
x
x
1`5@100
a
b

1`3@150+++
3 1`4@150+++
1`5@150
tint

1`3@250+++
1`3@150+++
1`4@350+++
7 1`4@250+++
1`4@150+++
tint 1`5@350+++
1`5@150

0 ,
0. 100. CPN Tools
3 , 3 c;
, 100.
200 2 200 , ,
300 2 .

.
, .
.

.
, 5.6,
.
() :
x

(2,4,"ping")
clock

x@+poisson(100.0)
tframe

gen

buf
tframe

1 1`(2,4,"ping")@642

1`(2,4,"ping")@536+++
1`(2,4,"ping")@430+++
1`(2,4,"ping")@329+++
6 1`(2,4,"ping")@217+++
1`(2,4,"ping")@105+++
1`(2,4,"ping")@0

8.
,
.
(, Corel Draw)
. CPN Tools

41

.
()
, .
, Clone Tool
(Create).
,
(New group).
, :

(New group).
, .
,
:


, .
( , None)
: .
,
. ,
Toggle group. ,
Toggle group:

42

,
. , ,
:

,
Toggle group. ,
Toggle group. ,
( ).
:
;
;
() ;
.

. , ,
, , .

. ,
,
.
.
,
.

, .

43

, , ,
, .
,
,
.

. 3
Ethernet
.
:


.
,
. ,
. ,
.

9.
:
.
,

44

(Fusion)
(Hierarchy).

: CPN Tools
.
.
.
Ethernet:
1`(1,1)++1`(2,1)++1`(3,2)++
1`(4,2)++1`(5,3)++1`(6,3)++1`(7,3)

Model of Switch
[dst=target]
I/O

f(src,dst,nf)

Port1In

avail

seg
Port1

f(src,dst,nf)

I/O Port1Out

avail

seg

(target,port)

In1

SwitchTable
swi

@+5
(target,port)
Out1
(target,port)

@+5

[dst=target]
I/O

avail

seg

Port2

I/O

f(src,dst,nf)

Port2In

f(src,dst,nf)

Port2Out

avail

seg

In2

(src,dst,nf,port)

@+5
(src,dst,nf,1)
Out2
(src,dst,nf,port)
@+5
(src,dst,nf,2)
[dst=target]

I/O

avail

seg

Port3

I/O

f(src,dst,nf)

Port3In

f(src,dst,nf)

Port3Out

avail

seg

(src,dst,nf,port)

In3
@+5

Out3

Buffer

(src,dst,nf,3)

@+5

swf

Port*In,
Buffer,
Port*Out. ,
SwitchTable.
,
. 3
: SwitchTable Buffer.
Model of Switch

1`(1,1)++1`(2,1)++1`(3,2)++1`(4,2)++1`(5,3)++1`(6,3)++1`(7,3)
[dst=target]
f(src,dst,nf)

Port1In
I/O

avail

seg
Port1

f(src,dst,nf)

Port1Out
I/O

avail

seg

In1
@+5

Out1

Port2In
I/O
Port2

avail

seg

f(src,dst,nf)

Port2Out
I/O

avail

seg

In2
@+5

Out2

Port3

seg

Port3Out
I/O
seg

avail

f(src,dst,nf)
avail

(src,dst,nf,port)
(src,dst,nf,1)

Bu1

Out3
@+5

Buffer
swf

1`(1,1)++1`(2,1)++1`(3,2)++1`(4,2)++1`(5,3)++1`(6,3)++1`(7,3)
(target,port)

SwTa2

(src,dst,nf,2)

SwitchTable
swi

(src,dst,nf,port)

Bu2

Buffer
swf

1`(1,1)++1`(2,1)++1`(3,2)++1`(4,2)++1`(5,3)++1`(6,3)++1`(7,3)
(target,port)

In3
@+5

SwitchTable
swi

@+5

[dst=target]
f(src,dst,nf)

Port3In
I/O

SwTa1

@+5

[dst=target]
f(src,dst,nf)

(target,port)

SwTa3
(src,dst,nf,port)
(src,dst,nf,3)

SwitchTable
swi

Bu3

Buffer
swf

45


.
Assign fusion
set . ,
.
. ,
,
. ,
. ,
.
,
.
.

10.

.
, ,
, , ..
(, ).
: .
, CPN Tools
.
10.1.
, , .

. LAN, . LAN
WS3 WS:
LAN

WS WS3. ,
, WS
LAN:

46

,
,
(I/O).
.
LANin, LANout, Own WS p3out, p3in, WS3
LAN.
:
, , ,
(LAN, WS);
(LANin, LANout, Own);
, (3).
:
(WS3>WS);
(LANin>p3out, LANout
>p3in, Own>aWS3).
,
:

: In, Out, I/O. In ,



. Out
,
.

47

/.
, I/O.
,
, .

. (WS3)
(WS).
.

,
.
. .
, ,
.
,
, .
-, . , . ,
LAN 5 2 ,
(WS) (S).
10.2.
,
. ,
. ,

, .
.
, LAN WS, S,
MWS, SWI, LAN,
(WS1WS4>WS,
S1S4>S,
WS5>MWS)
.
10.3.
,
, (
) . LAN
LAN.

( ).
, .
,
. .

48

. ,
WS3 LAN
:
p3out avail
I/O
seg

p3in
I/O

avail
seg

WS3

1`5
aWS3
I/O
mac


. , WS3 WS,
p3out LANin, p3in LANout, aWS3 Own, WS3
WS, .
,
. ,
.
, ,
,

. , SWI, MWS, WS
WS1 S S1. WS2WS4 S2, WS
S .

11.
CPN Tools :
. ,
,
.
,
.
, .
, ,
.
,
. 5
Ethernet.
11.1.

. CPN Tools

49

. ,
. ,
, .
, ,
CPN. ,
.
.
( , ).
, , , -
,
. ,
(, , ) .
, .
, , , ,
. ,
.
. , ,
, , ,
. ,
.
.
, .
, 4.3, ,
. ,
Ethernet, ,
.
, ,
.
,
.
11.2.
,

.
,
( ).

-
. l- m
lm.
, , ,
, ,
, ..

50

:
(Enter SS);
;
(SCC);
( );
( );
.
,
, .
,
. . ,
, ,
,
. ,
, ,
.
, . ,

.
CPN Tools.
:
;
.
,
,
.
.
CPN ML.
.
CPN Tools
.
:

51
PH.all()
Think
p

1`ph(1)++
1`ph(2)++
PH
1`ph(3)++
1`ph(4)++
1`ph(5)

Take
Chopsticks

val n = 5;
colset PH = index ph with 1..n;
colset CS = index cs with 1..n;
var p: PH;
fun Chopsticks(ph(i)) =
1`cs(i) ++ 1`cs(if i=n then 1 else i+1);

Chopsticks(p)
p
CS.all()
p

Unused
Chopsticks

Eat
PH
p

5 1`cs(1)++
1`cs(2)++
CS 1`cs(3)++
1`cs(4)++
1`cs(5)

Chopsticks(p)
Put Down
Chopsticks

CPN Tools
(PH)
(CS), Chipsticks,
, ph(i).
:
Statistics
-----------------------------------------------------------------------State Space
Nodes: 11
Arcs:
30
Secs:
0
Status: Full
Scc Graph
Nodes: 1
Arcs:
0
Secs:
0
Boundedness Properties
-----------------------------------------------------------------------Best Integers
Bounds
Upper
Lower
Page'Eat
1
2
0
Page'Think
1
5
3
Page'Unused_Chopsticks
1
5
1
Best Upper Multi-set Bounds
Page'Eat 1
1`ph(1)++
1`ph(2)++
1`ph(3)++
1`ph(4)++
1`ph(5)
Page'Think 1
1`ph(1)++
1`ph(2)++
1`ph(3)++
1`ph(4)++
1`ph(5)
Page'Unused_Chopsticks 1
1`cs(1)++
1`cs(2)++
1`cs(3)++
1`cs(4)++
1`cs(5)

52
Best Lower Multi-set Bounds
Page'Eat 1
empty
Page'Think 1
empty
Page'Unused_Chopsticks 1
empty
Home Properties
-----------------------------------------------------------------------Home Markings: All
Liveness Properties
-----------------------------------------------------------------------Dead Markings: None
Dead Transitions Instances: None
Live Transitions Instances: All
Fairness Properties
-----------------------------------------------------------------------Page'Put_Down_Chopsticks 1
Impartial
Page'Take_Chopsticks 1 Impartial
------------------------------------------------------------------------

(Statistics)
.
(Boundedness)
. (Home)
. (Liveness)
.
(Fairness) .
, CPN Tools
,
CPN Tools. ,
CPN
ML.
11.3.
CPN Tools
. ,

. ,
,
, . ,
Ethernet
,
..
CPN
Tools .
CPN Tools ,
.

53

,
, .
, CPN Tools ,
,
, ..
;

.
,
.

. . CPN
Tools (MTU),
, .
,
.
7 Ethernet.
(, )
. MTU, .
MTU
. ,
Ethernet 500 ,
MTU, 100 . MTU.
, 200 200000 / 100 = 2000 MTU.

. ,
389 MTU 38900 38.9 .
.
, .

.

.
,
. , ,
; , 100 /
10 /.
( )
. ,
, ,
, .
, ,
20.
.

54

11.4.

,
. ,

, , .
.
put, get,
:
f

put

buffer

get

frame

,
:
0

i-1

count
i+1

INT
i

put

buffer

get

frame

buffer,
:
0

i-1

count
i+1

INT
i

put

buffer
m

get

frame

0
if i+1>m then i+1 else m

max
INT

,
, :
ac=(c1*dt1 + c2 *dt2 + + ck*dtk) / dt
ac , ci dti
dt .
buffer:

55
0
count
i+1
fr
clock
frame

i-1

INT
i

put

buffer
frame

@+10

f1

get
@+20

fr
clock1
frame

m
0

m+i*(cT()-pt)

sum

m+i*(cT()-pt)

INT
pt

cT()

prevt

pt
cT()

INT
a

a
0
if cT()>0 then (m+i*(cT()-pt)) div cT() else 0

average
INT

if cT()>0 then (m+i*(cT()-pt)) div cT() else 0

: (put)
(get) . cT(),
2, . sum
. prevt
, buffer .
average buffer.

Ethernet 5.

,
(QoS).

12. CPN Tools


CPN Tools ,
, ,
, ML.

.
12.1.

. ,
;
.
( )
.
:
colset name = union id1[:name1] + id2[:name2] +... + idn[:namen];

56

namei , idi
(unit), idi.
,
:
idi v idi(v),
v name.
Ethernet,
Ethernet.
,
Ethernet, , .
, seg:
colset seg = union f:frm + avail timed;
avail ,
. f. CPN Tools

( ), seg.
.
Port*In f
avail. ,
.
Port*Out avail ,
.
12.2.

.
. .
.
:
colset name = list name0 [with int-exp1..int-exp2];
with .
:
[v1, v2,..., vn], vi name0 i=1..n.
:
nil
e::l
l_1^^l_2
hd l

( [])
e l
l_1 l_2
, l

57
tl l
length l
rev l
map f l
List.nth(l,n)
List.take(l,n)
List.drop(l,n)
List.exists p l
List.null l

,
l
l
f l

n , 0 <= n < l
n l
, n l
, p l
, l

CPN Tools ,
:
frames

put

buffer

frame

get

frame
var f: frame;


( , FIFO), ,
( , LIFO) .
.
(FIFO):
lf

lf

[]
frames

put

lf^^[f]

frame

f::lf

buffer

get

lframe
colset lframe=list frame;

var lf: lframe;

,
frames . ,
buffer
. [].
CPN Tools LIFO
. ;
CPN Tools.
[5].

58

:


1.
Ethernet
, .
;
(10Gbps).

,
.
(LAN), Ethernet (IEEE
802.x), .
. LAN (,
) ,
, .
,
.
,
, . ,

.
. 1.

. 1 LAN
, Ethernet ,
.

59

.
MAC .
;
[5].
2.
LAN, . 1, . 2.
. ,
, ,
, , .
, ,
.

. 2. LAN
:
(SWI), (S), (WS)
(MWS). WS1WS4
, WS, WS5
MWS. . S1 S2
S.
.

p*in p*out .
.
MAC ,
aS*, aWS*.
(p*in) (p*out) .

60

, .
.
,
.
(colset), (var) (fun)
, . 3. MAC Ethernet
(colset mac). Ethernet
frm, (src),
(dst), nfrm ,
.
, Ethernet.
seg ,
(f.frm), (avail),
(union). ,
timed , ,
, .
colset mac = INT timed;
colset portnum = INT;
colset nfrm = INT;
colset sfrm = product nfrm * INT timed;
colset frm = product mac * mac * nfrm timed;
colset seg = union f:frm + avail timed;
colset swi = product mac * portnum;
colset swf = product mac * mac * nfrm * portnum timed;
colset remsv = product mac * nfrm timed;
var src, dst, target: mac;
var port: portnum;
var nf, rnf: nfrm;
var t1, t2, s, q, r: INT;
colset Delta = int with 1000..2000;
fun Delay() = Delta.ran();
colset dex = int with 100..200;
fun Dexec() = dex.ran();
colset dse = int with 10..20;
fun Dsend() = dse.ran();
colset nse = int with 10..20;
fun Nsend() = nse.ran();
fun cT()=IntInf.toInt(!CPN'Time.model_time)

. 3
CPN Tools .
,
. , aWS2
1`4. , aWS2 1 4.
(++).
x @ t; , x
t. @+d
d.

61

3.
.

. (SWI)
. 4. . 1
.

. 4
swi .
MAC- (mac) (nport).
swf ,
. portnum
. Port*In Port*Out
. SwitchTable
;
. , 1`(4,2)
, MAC 4 2.
Buffer . ,
(, SwitchTable Buffer) .
SwitchTable SwTa1, SwTa2, SwTa3.
Buffer Bu1, Bu2, Bu3.
,
.
In* .
,
, (dst=target);

62

(port) . Out*

. .
(@+5)
.
CSMA
LAN.
In*, avail. avail ,
. Out*
, , ,
avail.
, Port*In Port*Out .
I/O.
. ,
SWI (. 2) SWI,
. 3. Port*In Port*Out
p*in p*out .
4.
,
,
.
.

.
()
.
.
(WS) . 5. LANin
LANout
. Receive,
,
(dst=target), Own.
.

Send. Remote.

, Delay().
, LAN ,
LANout avail.
, ,
Remote.

63

. 5
, , nfrm,
WS.
.
MWS. WS
WS1WS4.
Own.
(. 2) MAC- .
(S) . 6.
, ,
Remote. Exec
.
Nsend() ,
Reply.
Send. , nf
Remote. ,
.

. 6
5.
(MWS) . 7.
,
WS, .

64

.
,
num. , nSnd.
cT() .
nSnd : nf
cT().
return .
,
.
NRTs , . IsFirst
. , IsFirst
NRTs, (t2t1).

. sum quant
. new
Culc.
NRTime.

. 7
6.

. ,

65

, .

.

.

.

.
. 8.
( )
;
. LANin (1,5,1). LANout
avail. ,
num, 7. return , 83
. NRTs 6
, . , 5
235. , 389,
NRTime, 2337/6
sum quant.

. 8.

66

7.

,
.
.
, . 1,
,
.
S1 S2. WS1WS5
.

In*,
Out*, Send, Receive. ,
-
Delta
dex. , ,
, .
Ethernet 1.5 .
1.
1

LAN
Intel EtherExpress 10/100
LAN
Intel SS101TX8EU

HP Brio BA600

HP Brio BA200
2 .

,
-. , Ethernet
, , ,
.

.
/ (500 ).
,
(MTU), , 100
.

67

In*

500

Out*

500

Receive

10

Send

10

Dex

1020

100-200

Delta

100200

1000-2000

Nse

1.2
1530

1
10-20

, 389 MTU
39 .
.

68

1 Jensen K. Colored Petri Nets - Basic Concepts, Analysis Methods and


Practical Use. Springer-Verlag, 1997. Vol. 1-3. 673 p.
2 Albert K., Jensen K., Shapiro R. Design/CPN: A Tool Package Supporting the
Use of Colored Nets // Petri Net Newsletter. April 1989. P. 22-35.
3 Zaitsev D.A. Switched LAN Simulation by Colored Petri Nets // Mathematics
and Computers in Simulation. 2004. Vol. 65, 3. P. 245-249.
4 Zaitsev D.A. An Evaluation of Network Response Time using a Colored Petri
Net Model of Switched LAN // Proc. of Fifth Workshop and Tutorial on Practical
Use of Colored Petri Nets and the CPN Tools, October 8-11, 2004. Aarhus
(Denmark). 2004. P. 157-167.
5 Zaitsev D.A., Shmeleva T.R. Switched Ethernet Response Time Evaluation
via Colored Petri Net Model // Proc. of International Middle Eastern Multiconference
on Simulation and Modelling, August 28-30, 2006. Alexandria (Egypt). 2006.
P. 68-77.


.., ..
// ', 2(46), 2004, . 56-60.
.. //
' 2(54), 2005, . 65-71.
.., ..

// : 1-
- , 4-7 2005, , , 2005,
.207-215.
.., ..

Bluetooth // . . . - 2006,
1. - C. 57-63.
.., .. MPLS
// '. - 2006, 5. - C. 49-55.

.., ..

// ', 4, 2007. - . 62-67.

Ethernet