-
Notifications
You must be signed in to change notification settings - Fork 1
/
bridge.sal
executable file
·186 lines (149 loc) · 6.68 KB
/
bridge.sal
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
bridge : CONTEXT =
BEGIN
IMPORTING network;
LEARNTYPE : TYPE = {empty, static, dynamic};
FILTERINGENTRY : TYPE = [# acquisition: LEARNTYPE, interface : topology!LINK #];
LOOKUPTABLE : TYPE = ARRAY HOST OF FILTERINGENTRY;
messagewaiting?(me : HOST, msg : METAMESSAGE) : BOOLEAN =
msg.author /= topology!none AND
msg.author /= me AND
msg.forwarder /= me;
validmessage?(me : HOST, msg : METAMESSAGE) : BOOLEAN =
msg.payload.source /= me AND
msg.payload.destination /= me AND
msg.payload.source /= msg.payload.destination;
IEEE8021D04 [me : HOST, cable : ARRAY REALLINK OF BOOLEAN, staticentries : ARRAY HOST OF REALLINK] : MODULE =
BEGIN
LOCAL filteringdatabase : LOOKUPTABLE
LOCAL interface : topology!LINK
GLOBAL aether : NETWORK
INITIALIZATION
(FORALL (j : HOST) :
filteringdatabase[j] =
IF staticentries[j] = topology!NA THEN
(# acquisition := empty, interface := topology!NA #)
ELSE
(# acquisition := static, interface := staticentries[j] #)
ENDIF);
interface = topology!NA
TRANSITION
[
unicast:
TRUE
-->
interface' IN {a : REALLINK |
cable[a] AND
messagewaiting?(me, aether[a]) AND
validmessage?(me, aether[a]) AND
filteringdatabase[aether[a].payload.destination].interface /= topology!NA AND
filteringdatabase[aether[a].payload.destination].interface /= a};
filteringdatabase' = IF filteringdatabase[aether[interface'].payload.source].acquisition = static THEN
filteringdatabase
ELSE
(filteringdatabase WITH [aether[interface'].payload.source].acquisition := dynamic) WITH [aether[interface'].payload.source].interface := interface'
ENDIF;
aether' = (aether WITH [filteringdatabase[aether[interface'].payload.destination].interface] := (aether[interface'] WITH .forwarder := me)) WITH [interface'] := EMPTYMETAMESSAGE;
[]
broadcast:
TRUE
-->
interface' IN {a : REALLINK |
cable[a] AND
messagewaiting?(me, aether[a]) AND
validmessage?(me, aether[a]) AND
(aether[a].payload.destination = topology!broadcast OR
filteringdatabase[aether[a].payload.destination].interface = topology!NA)};
filteringdatabase' = IF filteringdatabase[aether[interface'].payload.source].acquisition = static THEN
filteringdatabase
ELSE
(filteringdatabase WITH [aether[interface'].payload.source].acquisition := dynamic) WITH [aether[interface'].payload.source].interface := interface'
ENDIF;
(FORALL (j : {v : REALLINK | cable[v]}) : aether'[j] = (IF j /= interface' THEN (aether[interface'] WITH .forwarder := me) ELSE EMPTYMETAMESSAGE ENDIF));
[]
discard:
TRUE
-->
interface' IN {a : REALLINK |
cable[a] AND
messagewaiting?(me, aether[a]) AND
aether[a].forwarder /= me AND
((NOT(validmessage?(me, aether[a]))) OR
filteringdatabase[aether[a].payload.destination].interface = a)};
filteringdatabase' = IF aether[interface'].payload.source /= me AND filteringdatabase[aether[interface'].payload.source].acquisition /= static THEN
(filteringdatabase WITH [aether[interface'].payload.source].acquisition := dynamic) WITH [aether[interface'].payload.source].interface := interface'
ELSE
filteringdatabase
ENDIF;
aether'[interface'] = EMPTYMETAMESSAGE;
]
END;
proposed [me : HOST, cable : ARRAY REALLINK OF BOOLEAN, staticentries : ARRAY HOST OF REALLINK] : MODULE =
BEGIN
LOCAL filteringdatabase : LOOKUPTABLE
LOCAL interface : topology!LINK
GLOBAL aether : NETWORK
INITIALIZATION
(FORALL (j : HOST) :
filteringdatabase[j] =
IF staticentries[j] = topology!NA THEN
(# acquisition := empty, interface := topology!NA #)
ELSE
(# acquisition := static, interface := staticentries[j] #)
ENDIF);
interface = topology!NA
TRANSITION
[
unicast:
TRUE
-->
interface' IN {a : REALLINK |
cable[a] AND
messagewaiting?(me, aether[a]) AND
validmessage?(me, aether[a]) AND
(filteringdatabase[aether[a].payload.source].acquisition /= static OR (filteringdatabase[aether[a].payload.source].acquisition = static AND a = filteringdatabase[aether[a].payload.source].interface)) AND
filteringdatabase[aether[a].payload.destination].interface /= topology!NA AND
filteringdatabase[aether[a].payload.destination].interface /= a};
filteringdatabase' = IF filteringdatabase[aether[interface'].payload.source].acquisition = static THEN
filteringdatabase
ELSE
(filteringdatabase WITH [aether[interface'].payload.source].acquisition := dynamic) WITH [aether[interface'].payload.source].interface := interface'
ENDIF;
aether' = (aether WITH [filteringdatabase[aether[interface'].payload.destination].interface] := (aether[interface'] WITH .forwarder := me)) WITH [interface'] := EMPTYMETAMESSAGE;
[]
broadcast:
TRUE
-->
interface' IN {a : REALLINK |
cable[a] AND
messagewaiting?(me, aether[a]) AND
validmessage?(me, aether[a]) AND
(filteringdatabase[aether[a].payload.source].acquisition /= static OR (filteringdatabase[aether[a].payload.source].acquisition = static AND a = filteringdatabase[aether[a].payload.source].interface)) AND
(aether[a].payload.destination = topology!broadcast OR
filteringdatabase[aether[a].payload.destination].interface = topology!NA)};
filteringdatabase' = IF filteringdatabase[aether[interface'].payload.source].acquisition = static THEN
filteringdatabase
ELSE
(filteringdatabase WITH [aether[interface'].payload.source].acquisition := dynamic) WITH [aether[interface'].payload.source].interface := interface'
ENDIF;
(FORALL (j : {v : REALLINK | cable[v]}) : aether'[j] = (IF j /= interface' THEN (aether[interface'] WITH .forwarder := me) ELSE EMPTYMETAMESSAGE ENDIF));
[]
discard:
TRUE
-->
interface' IN {a : REALLINK |
cable[a] AND
messagewaiting?(me, aether[a]) AND
aether[a].forwarder /= me AND
((NOT(validmessage?(me, aether[a]))) OR
filteringdatabase[aether[a].payload.destination].interface = a OR
(filteringdatabase[aether[a].payload.source].acquisition = static AND a /= filteringdatabase[aether[a].payload.source].interface))};
filteringdatabase' = IF aether[interface'].payload.source /= me AND
filteringdatabase[aether[interface'].payload.source].acquisition /= static THEN
(filteringdatabase WITH [aether[interface'].payload.source].acquisition := dynamic) WITH [aether[interface'].payload.source].interface := interface'
ELSE
filteringdatabase
ENDIF;
aether'[interface'] = EMPTYMETAMESSAGE;
]
END;
END