-
Notifications
You must be signed in to change notification settings - Fork 122
/
tutorial.dat
417 lines (307 loc) · 7.77 KB
/
tutorial.dat
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
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
start;
insert Word1("Hello," , CategoryOther),
insert Word1("Goodbye," , CategoryOther),
insert Word2("World" , CategoryOther),
insert Word2("Ruby Tuesday", CategoryOther);
insert Word1("Help me," , CategoryStarWars),
insert Word1("I am your" , CategoryStarWars),
insert Word2("Obi-Wan Kenobi", CategoryStarWars),
insert Word2("father" , CategoryStarWars);
commit;
echo Phrases:;
dump Phrases;
start;
insert Host(0, "h0", 0xaabbccdd),
insert Host(1, "h1", 0xaabbccee),
insert Host(2, "h2", 0xaaff1234),
insert Subnet(0, 0xaabb0000, 0xffff0000),
insert Subnet(1, 0xaaff0000, 0xffff0000);
commit;
echo HostInSubnet:;
dump HostInSubnet;
start;
insert School("school1", ""),
insert School("school2", ""),
insert Student(1, "Adam", "school1", 1400),
insert Student(1, "Aaron", "school2", 1500),
insert Student(1, "Alice", "school1", 1300),
insert Student(1, "Ann", "school2", 1600),
commit;
echo TopScore;
dump TopScore;
start;
insert OnlineOrder(1, "milk"),
insert OnlineOrder(1, "eggs"),
insert OnlineOrder(1, "jackfruit"),
insert OnlineOrder(2, "sursild"),
insert OnlineOrder(2, "milk"),
insert OnlineOrder(2, "eggs"),
commit dump_changes;
start;
insert StoreInventory(StoreItem{"milk", "Just your regular cow milk"}),
insert StoreInventory(StoreItem{"kumis", "Horse milk"}),
insert StoreInventory(StoreItem{"goat milk", "Another milk variety"}),
commit dump_changes;
start;
insert Logical_Switch(0),
insert Logical_Switch(1),
insert Load_Balancer(0, 0, "10.10.10.101", ddlog_std::Some{"TCP"}, "lb1"),
insert Load_Balancer(0, 0, "10.10.10.102", ddlog_std::None, "lb2"),
insert Load_Balancer(0, 1, "10.10.10.103", ddlog_std::Some{"UDP"}, "lb3"),
insert Load_Balancer(0, 1, "10.10.10.104", ddlog_std::None, "lb4");
commit;
echo Flows:;
dump Flow;
echo Flows generated using FTL:;
dump Flow1;
start;
insert Number(1),
insert Number(10),
insert Number(100),
insert Number(1000),
insert Number(10000),
insert Number(100000),
insert Number(1000000),
insert Number(10000000),
insert Number(100000000);
commit;
echo Pow2:;
dump Pow2;
start;
insert NetHost(1, NHost{IPAddr{0xaabbccdd}, MACAddr{0x112233445566}}),
insert NetHost(2, NHost{IPAddr{0xa0b0c0d0}, MACAddr{0x102030405060}});
commit;
echo NetHostString:;
dump NetHostString;
start;
insert Bytes(10,10,10,101),
insert Bytes(127,0,0,1),
insert Bytes(224,0,0,1);
commit;
echo Address:;
dump Address;
echo MCastAddress:;
dump MCastAddress;
start;
insert Endpoint(IPAddr{0xaabbccdd}, "FTP", 0),
insert Endpoint(IPAddr{0xaabbccdd}, "HTTPS", 0),
insert Endpoint(IPAddr{0xaabbccdd}, "HTTP", 0),
insert Endpoint(IPAddr{0xaabbccdd}, "HTTP", 8080);
commit;
echo EndpointString;
dump EndpointString;
echo First5;
dump First5;
start;
insert Blocklisted("170.187.204.221:80"),
insert Blocklisted("170.187.204.221:20");
commit;
echo SanitizedEndpoint:;
dump SanitizedEndpoint;
start;
insert HostAddress(1, "10.10.10.101 10.10.10.102"),
insert HostAddress(2, "192.168.0.1"),
insert HostAddress(3, "192.168.0.3 192.168.0.4 192.168.0.5 192.168.0.6");
commit;
echo HostIP:;
dump HostIP;
echo HostIPVSep:;
dump HostIPVSep;
start;
insert Library(Book{"Ernest Hemingway", "For Whom the Bell Tolls"}),
insert Library(Book{"Dav Pilkey", "For Whom the Ball Rolls"}),
insert Author("Ernest Hemingway", 1899),
insert Author("Dav Pilkey", 1966),
commit;
echo BookByAuthor;
dump BookByAuthor;
start;
insert EvensAndOdds([0,1,2,3,4,5]),
insert EvensAndOdds([1,3,5,7]),
commit;
echo Evens:;
dump Evens;
start;
insert Vect(["a", "--", "b"], "--"),
insert Vect(["--", "a", "b"], "--"),
insert Vect(["a", "b", "--"], "--"),
commit;
echo Prefix:;
dump Prefix;
start;
insert X(10),
insert X(20),
insert X(100),
insert X(150);
commit;
echo Sum:;
dump Sum;
echo Product;
dump Product;
start;
insert Price("A", "Overpriced Inc", 120),
insert Price("A", "Scrooge Ltd", 110),
insert Price("A", "Discount Corp", 100),
insert Price("B", "Overpriced Inc", 123),
insert Price("B", "Scrooge Ltd", 150),
insert Price("B", "Discount Corp", 111);
commit;
start;
delete Price("A", "Discount Corp", 100),
delete Price("B", "Discount Corp", 111),
commit;
echo BestPrice:;
dump BestPrice;
echo WorstPrice:;
dump WorstPrice;
echo BestVendor:;
dump BestVendor;
echo BestDeal:;
dump BestDeal;
start;
insert Article("D. L. Parnas", "On the Criteria To Be Used in Decomposing System into Modules", 1974, 6),
insert Article("C. A. R. Hoare", "Communicating Sequential Processes", 1980, 40),
insert Article("Test Author", "Test Title", 2020, 10),
# Delete test record by only specifying its primary key.
delete_key Article ("Test Author", "Test Title"),
# We accidentally specified incorrect year for Parnas's article.
# Modify the record by only specifying values of field(s) we want to change.
modify Article ("D. L. Parnas", "On the Criteria To Be Used in Decomposing System into Modules") <- Article{.year = 1972},
# Delete Hoare's paper and replace it with a new record with the same primary key.
insert_or_update Article("C. A. R. Hoare", "Communicating Sequential Processes", 1978, 30),
commit;
echo OutArticle:;
dump OutArticle;
start;
insert MSetIn(0),
# Insert the same value twice; due to the multiset semantics, it will appear twice in MSetOut.
insert MSetIn(1),
insert MSetIn(1),
commit dump_changes;
# expected output:
# MSetOut:
# MSetOut{.x = 0}: +1
# MSetOut{.x = 1}: +2
start;
# Add one more instance of the same record.
insert MSetIn(1),
commit dump_changes;
# expected output:
# MSetOut:
# MSetOut{.x = 1}: +1
start;
# Delete one instance of the record; we're down to 2.
delete MSetIn(1),
commit dump_changes;
# expected output:
# MSetOut:
# MSetOut{.x = 1}: -1
dump MSetOut;
# expected output:
# MSetOut{.x = 0} +1
# MSetOut{.x = 1} +2
echo Populating the zip code table.;
start;
insert ZipCodes(94022, "Los Altos"),
insert ZipCodes(94035, "Moffett Field"),
insert ZipCodes(94039, "Mountain View"),
insert ZipCodes(94085, "Sunnyvale"),
commit dump_changes;
echo Feeding data to the Parcel stream;
start;
insert Parcel(94022, 2),
insert Parcel(94085, 6),
commit dump_changes;
echo Send more parcels!;
start;
insert Parcel(94022, 8),
insert Parcel(94085, 10),
insert Parcel(94022, 1),
commit dump_changes;
echo Modifying both inputs in the same transaction.;
start;
insert ZipCodes(94301, "Palo Alto"),
insert Parcel(94301, 4),
insert Parcel(94035, 1),
commit dump_changes;
start;
insert Packet(EthPacket{
0xaabbccddeeff,
0x112233445566,
EthIP4{
IP4Pkt{
5,
0xa1b1c1d1,
0xa1a2a3a4,
IPTCP {
TCPPkt {
100,
80,
0
}
}
}
}
}),
insert Packet(EthPacket{
0x112233445566,
0xaabbccddeeff,
EthIP6{
IP6Pkt{
5,
0xa1b1c1d1,
0xa1a2a3a4,
IPTCP {
TCPPkt {
200,
8080,
0
}
}
}
}
}),
insert Packet(EthPacket{
0x112233445566,
0xaabbccddeeff,
EthIP6{
IP6Pkt{
5,
0xa1b1c1d1,
0xa1a2a3a4,
IPUDP {
UDPPkt {
300,
22,
100
}
}
}
}
});
commit;
echo TCPDstPort:;
dump TCPDstPort;
echo UDPDstPort:;
dump UDPDstPort;
echo UDPDstPort2:;
dump UDPDstPort2;
start;
insert KnownHost(0xc0a80001),
insert KnownHost(0xc0a80102),
insert KnownHost(0xc0100001),
insert KnownHost(0x0a0a0001);
commit;
echo IntranetHost:;
dump IntranetHost;
echo IntranetHost2:;
dump IntranetHost2;
echo IntranetHost3:;
dump IntranetHost3;
start;
insert Person("Alice", "USA", "student");
insert Person("Bob", "USA", "engineer");
insert Person("Eve", "UK", "student");
commit;
echo TargetAudience:;
dump TargetAudience;