-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpacketflow-slides.tex
1306 lines (1231 loc) · 49 KB
/
packetflow-slides.tex
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
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
% Copyright (c) 2024 Alexander Bluhm <[email protected]>
%
% Permission to use, copy, modify, and distribute this software for any
% purpose with or without fee is hereby granted, provided that the above
% copyright notice and this permission notice appear in all copies.
%
% THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
% WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
% MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
% ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
% WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
% ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
% OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
\documentclass[14pt]{beamer}
\usetheme{Frankfurt}
\usepackage{tikz}
\usepackage{framed}
\usepackage{graphicx}
\usepackage{varwidth}
\usepackage{tipa}
\usepackage{alltt}
\usepackage{xcolor}
\usepackage{upquote}
\usepackage[T1]{fontenc}
\usepackage{textcomp}
\usetikzlibrary{shapes.arrows}
\usetikzlibrary{shapes.geometric}
\usetikzlibrary{shapes.multipart}
\usetikzlibrary{shapes.symbols}
\author{Alexander Bluhm}
\title{A Packet's Journey Through the OpenBSD Network Stack}
\institute{genua GmbH\\ \url{[email protected]}\\ \url{[email protected]}}
\date{September 2024}
\let\Tiny\tiny
\begin{document}
\begin{frame}
\titlepage
\end{frame}
\setcounter{tocdepth}{1}
\section{Networking}
\begin{frame}{Agenda}
\tableofcontents[currentsection]
\end{frame}
\subsection{Environment}
\begin{frame}{Environment}
\begin{tikzpicture}
\node [cloud, draw, aspect=2]
at (-3.8, 0)
{Network};
\node [align=center, arrow box, draw,
arrow box arrows={east:1cm, north:.5cm, west:1cm}]
at (0, 0)
{\begin{varwidth}{\textwidth}\centering OpenBSD \\ Kernel\end{varwidth}};
\node [cloud, draw, aspect=2]
at (3.8, 0)
{Internet};
\node [ellipse, draw, aspect=2]
at (0, 1.8)
{Application};
\end{tikzpicture}
\end{frame}
\subsection{Layer}
\begin{frame}{Layer}
\begin{tikzpicture}
\draw (-1,0) rectangle +(6,1) node(l1) [midway] {Physical};
\draw (-1,1) rectangle +(6,1) node(l1) [midway] {Driver};
\draw (-1,2) rectangle +(6,1) node(l2) [midway] {Ethernet};
\draw (-1,3) rectangle +(6,1) node(l3) [midway] {Network IP};
\draw (-1,4) rectangle +(6,1) node(l4) [midway] {TCP/UDP/Raw};
\draw (-1,5) rectangle +(6,1) node(l5) [midway] {Socket};
\draw (-1,6) rectangle +(6,1) node(l5) [midway] {Application};
\draw[thick] (-4,5.5) node(context) {} -- +(5,0) +(7,0) -- +(10.5,0);
\node [below right] at (context) {Kernel};
\node [above right] at (context) {User Land};
\draw[thick] (-4,1) node(hardware) {} -- +(10.5,0);
\node [below right] at (hardware) {Hardware};
\end{tikzpicture}
\end{frame}
\section{Measurement}
\begin{frame}{Agenda}
\tableofcontents[currentsection]
\end{frame}
\subsection{Protocol Statistics Counter}
\begin{frame}[fragile]{Protocol Statistics Counter}
netstat -ss
\scriptsize
\begin{verbatim}
ip:
2208239 total packets received
2204405 packets for this host
3717 packets for unknown/unsupported protocol
101 packets not forwardable
tcp:
1542163 packets sent
616615 data packets (165690394 bytes)
333 data packets (296898 bytes) retransmitted
740242 ack-only packets (646590 delayed)
153288 window update packets
\end{verbatim}
\end{frame}
\subsection{pf States}
\begin{frame}[fragile]{pf State}
pfctl -s states
\scriptsize
\begin{verbatim}
em0 tcp 80.154.94.48:22 <- 84.191.39.187:60436
ESTABLISHED:ESTABLISHED
em0 tcp 192.168.0.31:22 (80.154.94.48:10031) <- 80.154.94.10:19890
ESTABLISHED:ESTABLISHED
em1 tcp 80.154.94.10:19890 -> 192.168.0.31:22
ESTABLISHED:ESTABLISHED
em0 tcp 192.168.0.31:443 (80.154.94.48:443) <- 193.30.66.53:51727
CLOSING:ESTABLISHED
\end{verbatim}
\end{frame}
\subsection{Network Sockets}
\begin{frame}[fragile]{Network Sockets}
netstat -an
\scriptsize
\begin{verbatim}
Active Internet connections (including servers)
Proto Recv-Q Send-Q Local Address Foreign Address TCP-State
tcp 0 0 10.0.1.37.22 10.0.1.2.30176 ESTABLISHED
tcp 0 1144 10.0.1.37.22 10.0.1.1.27069 ESTABLISHED
tcp 0 44 10.0.1.37.22 10.0.1.2.49002 ESTABLISHED
tcp 0 0 *.22 *.* LISTEN
Active Internet connections (including servers)
Proto Recv-Q Send-Q Local Address Foreign Address
udp 0 0 10.0.1.37.7040 10.0.1.1.123
udp 0 0 10.0.1.37.161 *.*
udp 0 0 *.* *.*
\end{verbatim}
\end{frame}
\subsection{Tcpdump Traffic}
\begin{frame}[fragile]{Tcpdump Traffic}
tcpdump -ni enc0 -v
\scriptsize
\begin{verbatim}
18:45:13.665393 (unprotected): SPI 0x00006861:
fdd7:e83e:66bc:100::17 > fdd7:e83e:66bc:100::70:
10.188.168.17 > 10.188.175.72:
icmp: echo request
(id:c52b seq:0) (ttl 255, id 8945, len 1028) (len 1028, hlim 64)
18:45:13.665849 (unprotected): SPI 0x00006862:
fdd7:e83e:66bc:100::70 > fdd7:e83e:66bc:100::17:
10.188.175.72 > 10.188.168.17:
icmp: echo reply
(id:c52b seq:0) (ttl 253, id 7503, len 1028) (len 1028, hlim 64)
\end{verbatim}
\end{frame}
\section{Packet Queues}
\begin{frame}{Agenda}
\tableofcontents[currentsection]
\end{frame}
\subsection{Input Queues}
\begin{frame}{Input Queues}
\begin{tikzpicture}
\draw (0,0)
node (ni) [right] {network interface} ++(.1,.6)
rectangle ++(.4,.4) rectangle ++(.4,-.4)
rectangle ++(.4,.4) rectangle ++(.4,-.4)
rectangle ++(.4,.4) ++(0,-.2)
node (rx) [right] {receive DMA ring} ++(-.5-1*.4,.8)
node (dd) [right] {device driver} ++(.1,.6)
rectangle ++(.4,.4) rectangle ++(.4,-.4)
rectangle ++(.4,.4) rectangle ++(.4,-.4) ++(0,.2)
node (iq) [right] {interface input queue} ++(-.5,.8)
node (is) [right] {IP stack} ++(.1,.6)
rectangle ++(.4,.4) rectangle ++(.4,-.4)
rectangle ++(.4,.4) rectangle ++(.4,-.4) ++(0,.2)
node (rb) [right] {socket receive buffer} ++(-.5,.8)
node (so) [right] {socket}
;
\path (node cs:name=ni,anchor=west) +(.3+1*.4,.3) coordinate (nio) {};
\path (node cs:name=rx,anchor=west) +(-.2-3*.4,0) coordinate (rxi) {};
\draw[->] (nio) -- (rxi);
\path (node cs:name=rx,anchor=west) +(-.2-1*.4,0) coordinate (rxo) {};
\path (node cs:name=dd,anchor=west) +(.3,-.3) coordinate (ddi) {};
\draw[->] (rxo) -- (ddi);
\path (node cs:name=dd,anchor=west) +(.3+1*.4,.3) coordinate (ddo) {};
\path (node cs:name=iq,anchor=west) +(-.2-2*.4,0) coordinate (iqi) {};
\draw[->] (ddo) -- (iqi);
\path (node cs:name=iq,anchor=west) +(-.2,0) coordinate (iqo) {};
\path (node cs:name=is,anchor=west) +(.3,-.3) coordinate (isi) {};
\draw[->] (iqo) -- (isi);
\path (node cs:name=is,anchor=west) +(.3+1*.4,.3) coordinate (iso) {};
\path (node cs:name=rb,anchor=west) +(-.2-2*.4,0) coordinate (rbi) {};
\draw[->] (iso) -- (rbi);
\path (node cs:name=rb,anchor=west) +(-.2,0) coordinate (rbo) {};
\path (node cs:name=so,anchor=west) +(.3,-.3) coordinate (soi) {};
\draw[->] (rbo) -- (soi);
\end{tikzpicture}
\end{frame}
\subsection{Output Queues}
\begin{frame}{Output Queues}
\begin{tikzpicture}
\draw (0,0)
node (so) [right] {socket} ++(.1,-.6)
rectangle ++(.4,-.4) rectangle ++(.4,.4)
rectangle ++(.4,-.4) rectangle ++(.4,.4) ++(0,-.2)
node (sb) [right] {socket send buffer} ++(-.5,-.8)
node (is) [right] {IP stack} ++(.1,-.6)
rectangle ++(.4,-.4) rectangle ++(.4,.4)
rectangle ++(.4,-.4) rectangle ++(.4,.4) ++(0,-.2)
node (oq) [right] {interface output queue} ++(-.5,-.8)
node (dd) [right] {device driver} ++(.1,-.6)
rectangle ++(.4,-.4) rectangle ++(.4,.4)
rectangle ++(.4,-.4) rectangle ++(.4,.4)
rectangle ++(.4,-.4) ++(0,.2)
node (tx) [right] {transmit DMA ring} ++(-.5-1*.4,-.8)
node (ni) [right] {network interface}
;
\path (node cs:name=so,anchor=west) +(.3+1*.4,-.3) coordinate (soo) {};
\path (node cs:name=sb,anchor=west) +(-.2-2*.4,0) coordinate (sbi) {};
\draw[->] (soo) -- (sbi);
\path (node cs:name=sb,anchor=west) +(-.2,0) coordinate (sbo) {};
\path (node cs:name=is,anchor=west) +(.3,.3) coordinate (isi) {};
\draw[->] (sbo) -- (isi);
\path (node cs:name=is,anchor=west) +(.3+1*.4,-.3) coordinate (iso) {};
\path (node cs:name=oq,anchor=west) +(-.2-2*.4,0) coordinate (oqi) {};
\draw[->] (iso) -- (oqi);
\path (node cs:name=oq,anchor=west) +(-.2,0) coordinate (oqo) {};
\path (node cs:name=dd,anchor=west) +(.3,.3) coordinate (ddi) {};
\draw[->] (oqo) -- (ddi);
\path (node cs:name=dd,anchor=west) +(.3+1*.4,-.3) coordinate (ddo) {};
\path (node cs:name=tx,anchor=west) +(-.2-3*.4,0) coordinate (txi) {};
\draw[->] (ddo) -- (txi);
\path (node cs:name=tx,anchor=west) +(-.2-1*.4,0) coordinate (txo) {};
\path (node cs:name=ni,anchor=west) +(.3,.3) coordinate (nii) {};
\draw[->] (txo) -- (nii);
\end{tikzpicture}
\end{frame}
\subsection{Socket Buffer Recv-Q Send-Q}
\begin{frame}[fragile]{Socket Buffer Recv-Q Send-Q}
\begin{framed}
\begin{tikzpicture}
\draw (0,0)
node (iis) [right] {IP stack} ++(.1,.6)
rectangle ++(.4,.4) rectangle ++(.4,-.4)
rectangle ++(.4,.4) rectangle ++(.4,-.4) ++(0,.2)
node (irb) [right] {receive buffer} ++(-.5,.8)
node (iso) [right] {socket} ++(4.5,0)
node (oso) [right] {socket} ++(.1,-.6)
rectangle ++(.4,-.4) rectangle ++(.4,.4)
rectangle ++(.4,-.4) rectangle ++(.4,.4) ++(0,-.2)
node (osb) [right] {send buffer} ++(-.5,-.8)
node (ois) [right] {IP stack}
;
\path (node cs:name=iis,anchor=west) +(.3+1*.4,.3) coordinate (iiso) {};
\path (node cs:name=irb,anchor=west) +(-.2-2*.4,0) coordinate (irbi) {};
\draw[->] (iiso) -- (irbi);
\path (node cs:name=irb,anchor=west) +(-.2,0) coordinate (irbo) {};
\path (node cs:name=iso,anchor=west) +(.3,-.3) coordinate (isoi) {};
\draw[->] (irbo) -- (isoi);
\path (node cs:name=oso,anchor=west) +(.3+1*.4,-.3) coordinate (osoo) {};
\path (node cs:name=osb,anchor=west) +(-.2-2*.4,0) coordinate (osbi) {};
\draw[->] (osoo) -- (osbi);
\path (node cs:name=osb,anchor=west) +(-.2,0) coordinate (osbo) {};
\path (node cs:name=ois,anchor=west) +(.3,.3) coordinate (oisi) {};
\draw[->] (osbo) -- (oisi);
\end{tikzpicture}
\end{framed}
netstat -n -p tcp
\scriptsize
\begin{verbatim}
Active Internet connections (including servers)
Proto Recv-Q Send-Q Local Address Foreign Address TCP-State
tcp 65160 0 10.10.11.2.35477 10.10.11.1.41996 ESTABLISHED
tcp 0 131732 10.10.12.3.44648 10.10.12.4.12345 ESTABLISHED
\end{verbatim}
\end{frame}
\subsection{Interface Queue qdrops}
\begin{frame}[fragile]{Interface Queue qdrops}
\begin{framed}
\begin{tikzpicture}
\draw (0,0)
node (idd) [right] {device driver} ++(.1,.6)
rectangle ++(.4,.4) rectangle ++(.4,-.4)
rectangle ++(.4,.4) rectangle ++(.4,-.4) ++(0,.2)
node (iq) [right] {input queue} ++(-.5,.8)
node (iis) [right] {IP stack} ++(4,0)
node (ois) [right] {IP stack} ++(.1,-.6)
rectangle ++(.4,-.4) rectangle ++(.4,.4)
rectangle ++(.4,-.4) rectangle ++(.4,.4) ++(0,-.2)
node (oq) [right] {output queue} ++(-.5,-.8)
node (odd) [right] {device driver}
;
\path (node cs:name=idd,anchor=west) +(.3+1*.4,.3) coordinate (iddo) {};
\path (node cs:name=iq,anchor=west) +(-.2-2*.4,0) coordinate (iqi) {};
\draw[->] (iiso) -- (iqi);
\path (node cs:name=iq,anchor=west) +(-.2,0) coordinate (iqo) {};
\path (node cs:name=iis,anchor=west) +(.3,-.3) coordinate (iisi) {};
\draw[->] (iqo) -- (iisi);
\path (node cs:name=ois,anchor=west) +(.3+1*.4,-.3) coordinate (oiso) {};
\path (node cs:name=oq,anchor=west) +(-.2-2*.4,0) coordinate (oqi) {};
\draw[->] (oiso) -- (oqi);
\path (node cs:name=oq,anchor=west) +(-.2,0) coordinate (oqo) {};
\path (node cs:name=odd,anchor=west) +(.3,.3) coordinate (oddi) {};
\draw[->] (oqo) -- (oddi);
\end{tikzpicture}
\end{framed}
kstat
\\
\vspace{.2cm}
\scriptsize
\begin{tabular}{ll}
\begin{minipage}{4.8cm}
\begin{verbatim}
ix0:0:rxq:0
packets: 158069114 packets
bytes: 300328302395 bytes
qdrops: 7902615 packets
qlen: 0 packets
enqueues: 6947931
dequeues: 5729695
\end{verbatim}
\end{minipage}
&
\begin{minipage}{4.8cm}
\begin{verbatim}
ix0:0:txq:0
packets: 11094621 packets
bytes: 894601044 bytes
qdrops: 0 packets
qlen: 0 packets
maxqlen: 255 packets
\end{verbatim}
\end{minipage}
\\
\end{tabular}
\end{frame}
\subsection{Device Driver OACTIVE}
\begin{frame}[fragile]{Device Driver OACTIVE}
\begin{framed}
\begin{tikzpicture}
\draw (0,0) ++(3.5,0)
node (dd) [right] {device driver} ++(.1,-.6)
rectangle ++(.4,-.4) rectangle ++(.4,.4)
rectangle ++(.4,-.4) rectangle ++(.4,.4)
rectangle ++(.4,-.4) ++(0,.2)
node (tx) [right] {transmit DMA ring} ++(-.5-1*.4,-.8)
node (ni) [right] {network interface}
;
\path (node cs:name=dd,anchor=west) +(.3+1*.4,-.3) coordinate (ddo) {};
\path (node cs:name=tx,anchor=west) +(-.2-3*.4,0) coordinate (txi) {};
\draw[->] (ddo) -- (txi);
\path (node cs:name=tx,anchor=west) +(-.2-1*.4,0) coordinate (txo) {};
\path (node cs:name=ni,anchor=west) +(.3,.3) coordinate (nii) {};
\draw[->] (txo) -- (nii);
\end{tikzpicture}
\end{framed}
ifconfig em1
\scriptsize
\begin{verbatim}
em1: flags=8c43<UP,BROADCAST,RUNNING,OACTIVE,SIMPLEX,MULTICAST> mtu 1500
lladdr 0c:c4:7a:78:f3:55
description: Intel I210
index 6 priority 0 llprio 3
media: Ethernet autoselect (1000baseT full-duplex)
status: active
inet 10.10.12.3 netmask 0xffffff00 broadcast 10.10.12.255
\end{verbatim}
\end{frame}
\subsection{Transmit Rings oactives}
\begin{frame}[fragile]{Transmit Rings oactives}
dmesg
\scriptsize
\begin{verbatim}
ix1 at pci1 dev 0 function 1 "Intel X550T" rev 0x01, msix,
4 queues, address a0:36:9f:e0:52:55
\end{verbatim}
\normalsize
kstat txq
\\
\vspace{.3cm}
\scriptsize
\begin{tabular}{ll}
\begin{minipage}{4.8cm}
\begin{verbatim}
ix1:0:txq:0
qlen: 90 packets
maxqlen: 255 packets
oactive: true
oactives: 1919595
\end{verbatim}
\end{minipage}
&
\begin{minipage}{4.8cm}
\begin{verbatim}
ix1:0:txq:1
qlen: 141 packets
maxqlen: 255 packets
oactive: true
oactives: 2251633
\end{verbatim}
\end{minipage}
\\
\begin{minipage}{4.8cm}
\begin{verbatim}
ix1:0:txq:2
qlen: 6 packets
maxqlen: 255 packets
oactive: true
oactives: 1788971
\end{verbatim}
\end{minipage}
&
\begin{minipage}{4.8cm}
\begin{verbatim}
ix1:0:txq:3
qlen: 55 packets
maxqlen: 255 packets
oactive: true
oactives: 1925063
\end{verbatim}
\end{minipage}
\\
\end{tabular}
\end{frame}
\section{IP Stack}
\begin{frame}{Agenda}
\tableofcontents[currentsection]
\end{frame}
\subsection{Protocol Stack}
\begin{frame}{Protocol Stack}
\begin{tikzpicture}
\draw (0,0)
node (idd) [right] {device driver} ++(.1,.6)
rectangle ++(.4,.4) rectangle ++(.4,-.4)
rectangle ++(.4,.4) rectangle ++(.4,-.4) ++(0,.2)
node (iq) [right] {input queue} ++(-.5,.8)
node (ei) [right] {ether\_input()} ++(0,.8)
node (ii) [right] {ip\_input()} ++(0,.8)
node (ti) [right] {tcp\_input()} ++(.1,.6)
rectangle ++(.4,.4) rectangle ++(.4,-.4)
rectangle ++(.4,.4) rectangle ++(.4,-.4) ++(0,.2)
node (rb) [right] {receive} ++(-.5,.8)
node (iso) [right] {socket} ++(3.2,0)
node (oso) [right] {socket} ++(.1,-.6)
rectangle ++(.4,-.4) rectangle ++(.4,.4)
rectangle ++(.4,-.4) rectangle ++(.4,.4) ++(0,-.2)
node (sb) [right] {send buffer} ++(-.5,-.8)
node (to) [right] {tcp\_output()} ++(0,-.8)
node (io) [right] {ip\_output()} ++(0,-.8)
node (eo) [right] {ether\_output()} ++(.1,-.6)
rectangle ++(.4,-.4) rectangle ++(.4,.4)
rectangle ++(.4,-.4) rectangle ++(.4,.4) ++(0,-.2)
node (oq) [right] {output} ++(-.5,-.8)
node (odd) [right] {device}
;
\path (node cs:name=idd,anchor=west) +(.3+1*.4,.3) coordinate (iddo) {};
\path (node cs:name=iq,anchor=west) +(-.2-2*.4,0) coordinate (iqi) {};
\draw[->] (iddo) -- (iqi);
\path (node cs:name=iq,anchor=west) +(-.2,0) coordinate (iqo) {};
\path (node cs:name=ei,anchor=west) +(.3,-.3) coordinate (iei) {};
\draw[->] (iqo) -- (iei);
\path (node cs:name=ei,anchor=west) +(.3,.3) coordinate (eio) {};
\path (node cs:name=ii,anchor=west) +(.3,-.3) coordinate (iii) {};
\draw[->] (eio) -- (iii);
\path (node cs:name=ii,anchor=west) +(.3,.3) coordinate (iio) {};
\path (node cs:name=ti,anchor=west) +(.3,-.3) coordinate (tii) {};
\draw[->] (iio) -- (tii);
\path (node cs:name=ti,anchor=west) +(.3+1*.4,.3) coordinate (iti) {};
\path (node cs:name=rb,anchor=west) +(-.2-2*.4,0) coordinate (rbi) {};
\draw[->] (iti) -- (rbi);
\path (node cs:name=rb,anchor=west) +(-.2,0) coordinate (rbo) {};
\path (node cs:name=iso,anchor=west) +(.3,-.3) coordinate (isoi) {};
\draw[->] (rbo) -- (isoi);
\path (node cs:name=oso,anchor=west) +(.3+1*.4,-.3) coordinate (osoo) {};
\path (node cs:name=sb,anchor=west) +(-.2-2*.4,0) coordinate (sbi) {};
\draw[->] (osoo) -- (sbi);
\path (node cs:name=sb,anchor=west) +(-.2,0) coordinate (sbo) {};
\path (node cs:name=to,anchor=west) +(.3,.3) coordinate (toi) {};
\draw[->] (sbo) -- (toi);
\path (node cs:name=to,anchor=west) +(.3,-.3) coordinate (too) {};
\path (node cs:name=io,anchor=west) +(.3,.3) coordinate (ioi) {};
\draw[->] (too) -- (ioi);
\path (node cs:name=io,anchor=west) +(.3,-.3) coordinate (ioo) {};
\path (node cs:name=eo,anchor=west) +(.3,.3) coordinate (eoi) {};
\draw[->] (ioo) -- (eoi);
\path (node cs:name=eo,anchor=west) +(.3+1*.4,-.3) coordinate (eoo) {};
\path (node cs:name=oq,anchor=west) +(-.2-2*.4,0) coordinate (oqi) {};
\draw[->] (eoo) -- (oqi);
\path (node cs:name=oq,anchor=west) +(-.2,0) coordinate (oqo) {};
\path (node cs:name=odd,anchor=west) +(.3,.3) coordinate (oddi) {};
\draw[->] (oqo) -- (oddi);
\end{tikzpicture}
\end{frame}
\subsection{IP Forwarding}
\begin{frame}{IP Forwarding}
\begin{tikzpicture}
\draw (0,0)
node (idd) [right] {device driver} ++(.1,.6)
rectangle ++(.4,.4) rectangle ++(.4,-.4)
rectangle ++(.4,.4) rectangle ++(.4,-.4) ++(0,.2)
node (iq) [right] {input queue} ++(-.5,.8)
node (ei) [right] {ether\_input()} ++(0,.8)
node (ii) [right] {ip\_input()} ++(0,1.2)
node (ti) [right] {tcp\_input()} ++(.1,.6)
rectangle ++(.4,.4) rectangle ++(.4,-.4)
rectangle ++(.4,.4) rectangle ++(.4,-.4) ++(0,.2)
node (rb) [right] {receive} ++(-.5,.8)
node (iso) [right] {socket} ++(3.2,0)
node (oso) [right] {socket} ++(.1,-.6)
rectangle ++(.4,-.4) rectangle ++(.4,.4)
rectangle ++(.4,-.4) rectangle ++(.4,.4) ++(0,-.2)
node (sb) [right] {send buffer} ++(-.5,-.8)
node (to) [right] {tcp\_output()} ++(0,-1.2)
node (io) [right] {ip\_output()} ++(0,-.8)
node (eo) [right] {ether\_output()} ++(.1,-.6)
rectangle ++(.4,-.4) rectangle ++(.4,.4)
rectangle ++(.4,-.4) rectangle ++(.4,.4) ++(0,-.2)
node (oq) [right] {output} ++(-.5,-.8)
node (odd) [right] {device}
;
\path (node cs:name=idd,anchor=west) +(.3+1*.4,.3) coordinate (iddo) {};
\path (node cs:name=iq,anchor=west) +(-.2-2*.4,0) coordinate (iqi) {};
\draw[->] (iddo) -- (iqi);
\path (node cs:name=iq,anchor=west) +(-.2,0) coordinate (iqo) {};
\path (node cs:name=ei,anchor=west) +(.3,-.3) coordinate (iei) {};
\draw[->] (iqo) -- (iei);
\path (node cs:name=ei,anchor=west) +(.3,.3) coordinate (eio) {};
\path (node cs:name=ii,anchor=west) +(.3,-.3) coordinate (iii) {};
\draw[->] (eio) -- (iii);
\path (node cs:name=ii,anchor=west) +(.3,.3) coordinate (iio) {};
\path (node cs:name=ti,anchor=west) +(.3,-.3) coordinate (tii) {};
\draw[->] (iio) -- (tii);
\path (node cs:name=ti,anchor=west) +(.3+1*.4,.3) coordinate (iti) {};
\path (node cs:name=rb,anchor=west) +(-.2-2*.4,0) coordinate (rbi) {};
\draw[->] (iti) -- (rbi);
\path (node cs:name=rb,anchor=west) +(-.2,0) coordinate (rbo) {};
\path (node cs:name=iso,anchor=west) +(.3,-.3) coordinate (isoi) {};
\draw[->] (rbo) -- (isoi);
\path (node cs:name=oso,anchor=west) +(.3+1*.4,-.3) coordinate (osoo) {};
\path (node cs:name=sb,anchor=west) +(-.2-2*.4,0) coordinate (sbi) {};
\draw[->] (osoo) -- (sbi);
\path (node cs:name=sb,anchor=west) +(-.2,0) coordinate (sbo) {};
\path (node cs:name=to,anchor=west) +(.3,.3) coordinate (toi) {};
\draw[->] (sbo) -- (toi);
\path (node cs:name=to,anchor=west) +(.3,-.3) coordinate (too) {};
\path (node cs:name=io,anchor=west) +(.3,.3) coordinate (ioi) {};
\draw[->] (too) -- (ioi);
\path (node cs:name=io,anchor=west) +(.3,-.3) coordinate (ioo) {};
\path (node cs:name=eo,anchor=west) +(.3,.3) coordinate (eoi) {};
\draw[->] (ioo) -- (eoi);
\path (node cs:name=eo,anchor=west) +(.3+1*.4,-.3) coordinate (eoo) {};
\path (node cs:name=oq,anchor=west) +(-.2-2*.4,0) coordinate (oqi) {};
\draw[->] (eoo) -- (oqi);
\path (node cs:name=oq,anchor=west) +(-.2,0) coordinate (oqo) {};
\path (node cs:name=odd,anchor=west) +(.3,.3) coordinate (oddi) {};
\draw[->] (oqo) -- (oddi);
\path (node cs:name=ii,anchor=east) +(.1,0) coordinate (ifo) {};
\path (node cs:name=io,anchor=west) +(-.1,0) coordinate (ifi) {};
\draw[->] (ifo) -- (ifi) node [midway,above] {ip\_forward()};
\end{tikzpicture}
\end{frame}
\subsection{UDP}
\begin{frame}{UDP}
\begin{tikzpicture}
\draw (0,0)
node (idd) [right] {device driver} ++(.1,.6)
rectangle ++(.4,.4) rectangle ++(.4,-.4)
rectangle ++(.4,.4) rectangle ++(.4,-.4) ++(0,.2)
node (iq) [right] {input queue} ++(-.5,.8)
node (ei) [right] {ether\_input()} ++(0,.8)
node (ii) [right] {ip\_input()} ++(0,1.2)
node (ui) [right] {udp\_input()} ++(.1,.6)
rectangle ++(.4,.4) rectangle ++(.4,-.4)
rectangle ++(.4,.4) rectangle ++(.4,-.4) ++(0,.2)
node (rb) [right] {receive buffer} ++(-.5,.8)
node (iso) [right] {socket} ++(4.4,0)
node (oso) [right] {socket} ++(0,-1.6)
node (uo) [right] {udp\_output()} ++(0,-1.2)
node (io) [right] {ip\_output()} ++(0,-.8)
node (eo) [right] {ether\_output()} ++(.1,-.6)
rectangle ++(.4,-.4) rectangle ++(.4,.4)
rectangle ++(.4,-.4) rectangle ++(.4,.4) ++(0,-.2)
node (oq) [right] {output} ++(-.5,-.8)
node (odd) [right] {device}
;
\path (node cs:name=idd,anchor=west) +(.3+1*.4,.3) coordinate (iddo) {};
\path (node cs:name=iq,anchor=west) +(-.2-2*.4,0) coordinate (iqi) {};
\draw[->] (iddo) -- (iqi);
\path (node cs:name=iq,anchor=west) +(-.2,0) coordinate (iqo) {};
\path (node cs:name=ei,anchor=west) +(.3,-.3) coordinate (iei) {};
\draw[->] (iqo) -- (iei);
\path (node cs:name=ei,anchor=west) +(.3,.3) coordinate (eio) {};
\path (node cs:name=ii,anchor=west) +(.3,-.3) coordinate (iii) {};
\draw[->] (eio) -- (iii);
\path (node cs:name=ii,anchor=west) +(.3,.3) coordinate (iio) {};
\path (node cs:name=ui,anchor=west) +(.3,-.3) coordinate (uii) {};
\draw[->] (iio) -- (uii);
\path (node cs:name=ti,anchor=west) +(.3+1*.4,.3) coordinate (iti) {};
\path (node cs:name=rb,anchor=west) +(-.2-2*.4,0) coordinate (rbi) {};
\draw[->] (iti) -- (rbi);
\path (node cs:name=rb,anchor=west) +(-.2,0) coordinate (rbo) {};
\path (node cs:name=iso,anchor=west) +(.3,-.3) coordinate (isoi) {};
\draw[->] (rbo) -- (isoi);
\path (node cs:name=oso,anchor=west) +(.3,-.3) coordinate (osoo) {};
\path (node cs:name=uo,anchor=west) +(.3,.3) coordinate (uoi) {};
\draw[->] (osoo) -- (uoi);
\path (node cs:name=uo,anchor=west) +(.3,-.3) coordinate (uoo) {};
\path (node cs:name=io,anchor=west) +(.3,.3) coordinate (ioi) {};
\draw[->] (uoo) -- (ioi);
\path (node cs:name=io,anchor=west) +(.3,-.3) coordinate (ioo) {};
\path (node cs:name=eo,anchor=west) +(.3,.3) coordinate (eoi) {};
\draw[->] (ioo) -- (eoi);
\path (node cs:name=eo,anchor=west) +(.3+1*.4,-.3) coordinate (eoo) {};
\path (node cs:name=oq,anchor=west) +(-.2-2*.4,0) coordinate (oqi) {};
\draw[->] (eoo) -- (oqi);
\path (node cs:name=oq,anchor=west) +(-.2,0) coordinate (oqo) {};
\path (node cs:name=odd,anchor=west) +(.3,.3) coordinate (oddi) {};
\draw[->] (oqo) -- (oddi);
\path (node cs:name=ii,anchor=east) +(.1,0) coordinate (ifo) {};
\path (node cs:name=io,anchor=west) +(-.1,0) coordinate (ifi) {};
\draw[->] (ifo) -- (ifi) node [midway,above] {ip\_forward()};
\end{tikzpicture}
\end{frame}
\subsection{IPv6}
\begin{frame}{IPv6}
\begin{tikzpicture}
\draw (0,0)
node (idd) [right] {device driver} ++(.1,.6)
rectangle ++(.4,.4) rectangle ++(.4,-.4)
rectangle ++(.4,.4) rectangle ++(.4,-.4) ++(0,.2)
node (iq) [right] {input queue} ++(-.5,.8)
node (ei) [right] {ether\_input()} ++(0,.8)
node (ii) [right] {ip6\_input()} ++(0,1.2)
node (ti) [right] {tcp\_input()} ++(.1,.6)
rectangle ++(.4,.4) rectangle ++(.4,-.4)
rectangle ++(.4,.4) rectangle ++(.4,-.4) ++(0,.2)
node (rb) [right] {receive} ++(-.5,.8)
node (iso) [right] {socket} ++(3.2,0)
node (oso) [right] {socket} ++(.1,-.6)
rectangle ++(.4,-.4) rectangle ++(.4,.4)
rectangle ++(.4,-.4) rectangle ++(.4,.4) ++(0,-.2)
node (sb) [right] {send buffer} ++(-.5,-.8)
node (to) [right] {tcp\_output()} ++(0,-1.2)
node (io) [right] {ip6\_output()} ++(0,-.8)
node (eo) [right] {ether\_output()} ++(.1,-.6)
rectangle ++(.4,-.4) rectangle ++(.4,.4)
rectangle ++(.4,-.4) rectangle ++(.4,.4) ++(0,-.2)
node (oq) [right] {output} ++(-.5,-.8)
node (odd) [right] {device}
;
\path (node cs:name=idd,anchor=west) +(.3+1*.4,.3) coordinate (iddo) {};
\path (node cs:name=iq,anchor=west) +(-.2-2*.4,0) coordinate (iqi) {};
\draw[->] (iddo) -- (iqi);
\path (node cs:name=iq,anchor=west) +(-.2,0) coordinate (iqo) {};
\path (node cs:name=ei,anchor=west) +(.3,-.3) coordinate (iei) {};
\draw[->] (iqo) -- (iei);
\path (node cs:name=ei,anchor=west) +(.3,.3) coordinate (eio) {};
\path (node cs:name=ii,anchor=west) +(.3,-.3) coordinate (iii) {};
\draw[->] (eio) -- (iii);
\path (node cs:name=ii,anchor=west) +(.3,.3) coordinate (iio) {};
\path (node cs:name=ti,anchor=west) +(.3,-.3) coordinate (tii) {};
\draw[->] (iio) -- (tii);
\path (node cs:name=ti,anchor=west) +(.3+1*.4,.3) coordinate (iti) {};
\path (node cs:name=rb,anchor=west) +(-.2-2*.4,0) coordinate (rbi) {};
\draw[->] (iti) -- (rbi);
\path (node cs:name=rb,anchor=west) +(-.2,0) coordinate (rbo) {};
\path (node cs:name=iso,anchor=west) +(.3,-.3) coordinate (isoi) {};
\draw[->] (rbo) -- (isoi);
\path (node cs:name=oso,anchor=west) +(.3+1*.4,-.3) coordinate (osoo) {};
\path (node cs:name=sb,anchor=west) +(-.2-2*.4,0) coordinate (sbi) {};
\draw[->] (osoo) -- (sbi);
\path (node cs:name=sb,anchor=west) +(-.2,0) coordinate (sbo) {};
\path (node cs:name=to,anchor=west) +(.3,.3) coordinate (toi) {};
\draw[->] (sbo) -- (toi);
\path (node cs:name=to,anchor=west) +(.3,-.3) coordinate (too) {};
\path (node cs:name=io,anchor=west) +(.3,.3) coordinate (ioi) {};
\draw[->] (too) -- (ioi);
\path (node cs:name=io,anchor=west) +(.3,-.3) coordinate (ioo) {};
\path (node cs:name=eo,anchor=west) +(.3,.3) coordinate (eoi) {};
\draw[->] (ioo) -- (eoi);
\path (node cs:name=eo,anchor=west) +(.3+1*.4,-.3) coordinate (eoo) {};
\path (node cs:name=oq,anchor=west) +(-.2-2*.4,0) coordinate (oqi) {};
\draw[->] (eoo) -- (oqi);
\path (node cs:name=oq,anchor=west) +(-.2,0) coordinate (oqo) {};
\path (node cs:name=odd,anchor=west) +(.3,.3) coordinate (oddi) {};
\draw[->] (oqo) -- (oddi);
\path (node cs:name=ii,anchor=east) +(.1,0) coordinate (ifo) {};
\path (node cs:name=eo,anchor=west) +(-.1,0) coordinate (ifi) {};
\draw[->] (ifo) -- (ifi) node [midway,above,sloped] {ip6\_forward()};
\end{tikzpicture}
\end{frame}
\subsection{Netstat Counter}
\begin{frame}[fragile]{Netstat Counter}
netstat -ss
\scriptsize
\begin{verbatim}
ip:
393285673 total packets received
246049103 packets for this host
126364372 packets forwarded
242653961 packets sent from this host
tcp:
86520236 packets sent
123883097 packets received
udp:
400260722 datagrams received
82147309 dropped due to full socket buffers
318113273 delivered
396391499 datagrams output
ip6:
434697159 total packets received
278214439 packets for this host
146543897 packets forwarded
240423068 packets sent from this host
\end{verbatim}
\end{frame}
\subsection{pf Test}
\begin{frame}{pf Test}
\begin{tikzpicture}
\draw (0,0)
node (idd) [right] {device driver} ++(.1,.6)
rectangle ++(.4,.4) rectangle ++(.4,-.4)
rectangle ++(.4,.4) rectangle ++(.4,-.4) ++(0,.2)
node (iq) [right] {input queue} ++(-.5,.8)
node (ei) [right] {ether\_input()} ++(0.4,1)
node (pi) [right] {pf\_test(IN)} ++(-0.4,.9)
node (ii) [right] {ip\_input()} ++(0,1.2)
node (ti) [right] {tcp\_input()} ++(5.6,0)
node (to) [right] {tcp\_output()} ++(0,-1.2)
node (io) [right] {ip\_output()} ++(0.4,-.9)
node (po) [right] {pf\_test(OUT)} ++(-0.4,-1)
node (eo) [right] {ether\_output()} ++(.1,-.6)
rectangle ++(.4,-.4) rectangle ++(.4,.4)
rectangle ++(.4,-.4) rectangle ++(.4,.4) ++(0,-.2)
node (oq) [right] {output} ++(-.5,-.8)
node (odd) [right] {device}
;
\path (node cs:name=idd,anchor=west) +(.3+1*.4,.3) coordinate (iddo) {};
\path (node cs:name=iq,anchor=west) +(-.2-2*.4,0) coordinate (iqi) {};
\draw[->] (iddo) -- (iqi);
\path (node cs:name=iq,anchor=west) +(-.2,0) coordinate (iqo) {};
\path (node cs:name=ei,anchor=west) +(.3,-.3) coordinate (iei) {};
\draw[->] (iqo) -- (iei);
\path (node cs:name=ei,anchor=west) +(.3,.3) coordinate (eio) {};
\path (node cs:name=ii,anchor=west) +(.3,-.3) coordinate (iii) {};
\draw[->] (eio) -- (iii);
\path (node cs:name=ii,anchor=west) +(.3,.3) coordinate (iio) {};
\path (node cs:name=ti,anchor=west) +(.3,-.3) coordinate (tii) {};
\draw[->] (iio) -- (tii);
\path (node cs:name=ii,anchor=west) +(.7,-.3) coordinate (iip) {};
\path (node cs:name=pi,anchor=west) +(.3,.3) coordinate (pii) {};
\draw[<->] (iip) -- (pii);
\path (node cs:name=to,anchor=west) +(.3,-.3) coordinate (too) {};
\path (node cs:name=io,anchor=west) +(.3,.3) coordinate (ioi) {};
\draw[->] (too) -- (ioi);
\path (node cs:name=io,anchor=west) +(.3,-.3) coordinate (ioo) {};
\path (node cs:name=eo,anchor=west) +(.3,.3) coordinate (eoi) {};
\draw[->] (ioo) -- (eoi);
\path (node cs:name=eo,anchor=west) +(.3+1*.4,-.3) coordinate (eoo) {};
\path (node cs:name=oq,anchor=west) +(-.2-2*.4,0) coordinate (oqi) {};
\draw[->] (eoo) -- (oqi);
\path (node cs:name=oq,anchor=west) +(-.2,0) coordinate (oqo) {};
\path (node cs:name=odd,anchor=west) +(.3,.3) coordinate (oddi) {};
\draw[->] (oqo) -- (oddi);
\path (node cs:name=io,anchor=west) +(.7,-.3) coordinate (iop) {};
\path (node cs:name=po,anchor=west) +(.3,.3) coordinate (poi) {};
\draw[<->] (iop) -- (poi);
\path (node cs:name=ii,anchor=east) +(.1,0) coordinate (ifo) {};
\path (node cs:name=io,anchor=west) +(-.1,0) coordinate (ifi) {};
\draw[->] (ifo) -- (ifi) node [midway,above] {ip\_forward()};
\end{tikzpicture}
\end{frame}
\subsection{pf IPv6}
\begin{frame}{pf IPv6}
\begin{tikzpicture}
\draw (0,0)
node (idd) [right] {device driver} ++(.1,.6)
rectangle ++(.4,.4) rectangle ++(.4,-.4)
rectangle ++(.4,.4) rectangle ++(.4,-.4) ++(0,.2)
node (iq) [right] {input queue} ++(-.5,.8)
node (ei) [right] {ether\_input()} ++(0.4,1)
node (pi) [right] {pf\_test(IN)} ++(-0.4,.9)
node (ii) [right] {ip6\_input()} ++(0,1.2)
node (ti) [right] {tcp\_input()} ++(5.6,0)
node (to) [right] {tcp\_output()} ++(0,-1.2)
node (io) [right] {ip6\_output()} ++(0.4,-.9)
node (po) [right] {pf\_test(OUT)} ++(-0.4,-1)
node (eo) [right] {ether\_output()} ++(.1,-.6)
rectangle ++(.4,-.4) rectangle ++(.4,.4)
rectangle ++(.4,-.4) rectangle ++(.4,.4) ++(0,-.2)
node (oq) [right] {output} ++(-.5,-.8)
node (odd) [right] {device}
;
\path (node cs:name=idd,anchor=west) +(.3+1*.4,.3) coordinate (iddo) {};
\path (node cs:name=iq,anchor=west) +(-.2-2*.4,0) coordinate (iqi) {};
\draw[->] (iddo) -- (iqi);
\path (node cs:name=iq,anchor=west) +(-.2,0) coordinate (iqo) {};
\path (node cs:name=ei,anchor=west) +(.3,-.3) coordinate (iei) {};
\draw[->] (iqo) -- (iei);
\path (node cs:name=ei,anchor=west) +(.3,.3) coordinate (eio) {};
\path (node cs:name=ii,anchor=west) +(.3,-.3) coordinate (iii) {};
\draw[->] (eio) -- (iii);
\path (node cs:name=ii,anchor=west) +(.3,.3) coordinate (iio) {};
\path (node cs:name=ti,anchor=west) +(.3,-.3) coordinate (tii) {};
\draw[->] (iio) -- (tii);
\path (node cs:name=ii,anchor=west) +(.7,-.3) coordinate (iip) {};
\path (node cs:name=pi,anchor=west) +(.3,.3) coordinate (pii) {};
\draw[<->] (iip) -- (pii);
\path (node cs:name=to,anchor=west) +(.3,-.3) coordinate (too) {};
\path (node cs:name=io,anchor=west) +(.3,.3) coordinate (ioi) {};
\draw[->] (too) -- (ioi);
\path (node cs:name=io,anchor=west) +(.3,-.3) coordinate (ioo) {};
\path (node cs:name=eo,anchor=west) +(.3,.3) coordinate (eoi) {};
\draw[->] (ioo) -- (eoi);
\path (node cs:name=eo,anchor=west) +(.3+1*.4,-.3) coordinate (eoo) {};
\path (node cs:name=oq,anchor=west) +(-.2-2*.4,0) coordinate (oqi) {};
\draw[->] (eoo) -- (oqi);
\path (node cs:name=oq,anchor=west) +(-.2,0) coordinate (oqo) {};
\path (node cs:name=odd,anchor=west) +(.3,.3) coordinate (oddi) {};
\draw[->] (oqo) -- (oddi);
\path (node cs:name=io,anchor=west) +(.7,-.3) coordinate (iop) {};
\path (node cs:name=po,anchor=west) +(.3,.3) coordinate (poi) {};
\draw[<->] (iop) -- (poi);
\path (node cs:name=ii,anchor=east) +(.1,0) coordinate (ifo) {};
\path (node cs:name=eo,anchor=west) +(-.1,0) coordinate (ifi) {};
\draw[->] (ifo) -- (ifi) node (if) [midway,above,sloped] {ip6\_forward()};
\draw[<->] (node cs:name=if,anchor=south) -- +(0,-.6)
node (pf) [below,align=center] {pf\_test\\ (FWD)};
\end{tikzpicture}
\end{frame}
\subsection{pf Rules}
\begin{frame}[fragile]{pf Rules}
pfctl -s rules
\scriptsize
\begin{verbatim}
block return all
pass all flags S/SA
block return in on ! lo0 proto tcp from any to any port 6000:6010
block return out log proto tcp all user = 55
block return out log proto udp all user = 55
\end{verbatim}
\end{frame}
\section{Pseudo Devices}
\begin{frame}{Agenda}
\tableofcontents[currentsection]
\end{frame}
\subsection{Create Device}
\begin{frame}[fragile]{Create Device}
ifconfig -C
\scriptsize
\begin{verbatim}
aggr bpe bridge carp egre enc eoip etherip gif gre lo mgre mpe mpip
mpw nvgre pair pflog pflow pfsync ppp pppoe rport sec svlan tap
tpmr trunk tun veb vether vlan vport vxlan wg
\end{verbatim}
\normalsize
ifconfig vlan0 create vnetid 42 parent em0 up
\scriptsize
\begin{verbatim}
vlan0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
lladdr 0c:c4:7a:78:f3:54
index 22 priority 0 llprio 3
encap: vnetid 42 parent em0 txprio packet rxprio outer
groups: vlan
media: Ethernet autoselect (1000baseT full-duplex)
status: active
\end{verbatim}
\end{frame}
\subsection{Hardware Receive and Tcpdump}
\begin{frame}{Hardware Receive and Tcpdump}
\begin{tikzpicture}
\draw (0,0)
node (ni) [right] {network interface} ++(.1,.6)
rectangle ++(.4,.4) rectangle ++(.4,-.4)
rectangle ++(.4,.4) rectangle ++(.4,-.4)
rectangle ++(.4,.4) ++(0,-.2)
node (rx) [right] {receive DMA ring} ++(-.5-1*.4,.8)
node (em) [right] {em\_intr()} ++(0,.8)
node (fq) [right] {ifiq\_input()} ++(.1,.6)
rectangle ++(.4,.4) rectangle ++(.4,-.4)
rectangle ++(.4,.4) rectangle ++(.4,-.4) ++(0,.2)
node (iq) [right] {interface input queue} ++(-.5,.8)
node (ei) [right] {ether\_input()} ++(0,.8)
node (ii) [right] {ip\_input()}
;
\path (node cs:name=ni,anchor=west) +(.3+1*.4,.3) coordinate (nio) {};
\path (node cs:name=rx,anchor=west) +(-.2-3*.4,0) coordinate (rxi) {};
\draw[->] (nio) -- (rxi);
\path (node cs:name=rx,anchor=west) +(-.2-1*.4,0) coordinate (rxo) {};
\path (node cs:name=em,anchor=west) +(.3,-.3) coordinate (emi) {};
\draw[->] (rxo) -- (emi);
\path (node cs:name=em,anchor=west) +(.3,.3) coordinate (emo) {};
\path (node cs:name=fq,anchor=west) +(.3,-.3) coordinate (fqi) {};
\draw[->] (emo) -- (fqi);
\path (node cs:name=fq,anchor=west) +(.3+1*.4,.3) coordinate (fqo) {};
\path (node cs:name=iq,anchor=west) +(-.2-2*.4,0) coordinate (iqi) {};
\draw[->] (fqo) -- (iqi);
\path (node cs:name=iq,anchor=west) +(-.2,0) coordinate (iqo) {};
\path (node cs:name=ei,anchor=west) +(.3,-.3) coordinate (eii) {};
\draw[->] (iqo) -- (eii);
\path (node cs:name=ei,anchor=west) +(.3,.3) coordinate (eio) {};
\path (node cs:name=ii,anchor=west) +(.3,-.3) coordinate (iii) {};
\draw[->] (eio) -- (iii);
\draw[<->] (node cs:name=fq,anchor=east) -- +(.4,0)
node (bm) [right] {bpf\_mtap\_ether(IN)};
\end{tikzpicture}
\end{frame}
\subsection{VLan Receive and Tcpdump}
\begin{frame}{VLan Receive and Tcpdump}
\begin{tikzpicture}
\draw (0,0)
node (em) [right] {em\_intr()} ++(0,.8)
node (fq) [right] {ifiq\_input()} ++(.1,.6)
rectangle ++(.4,.4) rectangle ++(.4,-.4)
rectangle ++(.4,.4) rectangle ++(.4,-.4) ++(0,.2)
node (iq) [right] {interface input queue} ++(-.5,.8)
node (ev) [right] {ether\_input()} ++(0,.8)
node (vi) [right] {vlan\_input()} ++(0,.8)
node (fv) [right] {ifv\_input()} ++(0,.8)
node (ei) [right] {ether\_input()}
;
\path (node cs:name=em,anchor=west) +(.3,.3) coordinate (emo) {};
\path (node cs:name=fq,anchor=west) +(.3,-.3) coordinate (fqi) {};
\draw[->] (emo) -- (fqi);
\path (node cs:name=fq,anchor=west) +(.3+1*.4,.3) coordinate (fqo) {};
\path (node cs:name=iq,anchor=west) +(-.2-2*.4,0) coordinate (iqi) {};
\draw[->] (fqo) -- (iqi);
\path (node cs:name=iq,anchor=west) +(-.2,0) coordinate (iqo) {};
\path (node cs:name=ev,anchor=west) +(.3,-.3) coordinate (evi) {};
\draw[->] (iqo) -- (evi);
\path (node cs:name=ev,anchor=west) +(.3,.3) coordinate (evo) {};
\path (node cs:name=vi,anchor=west) +(.3,-.3) coordinate (vii) {};
\draw[->] (evo) -- (vii);
\path (node cs:name=vi,anchor=west) +(.3,.3) coordinate (vio) {};
\path (node cs:name=fv,anchor=west) +(.3,-.3) coordinate (fvi) {};
\draw[->] (vio) -- (fvi);
\path (node cs:name=fv,anchor=west) +(.3,.3) coordinate (fvo) {};
\path (node cs:name=ei,anchor=west) +(.3,-.3) coordinate (eii) {};
\draw[->] (fvo) -- (eii);
\draw[<->] (node cs:name=fq,anchor=east) -- +(.4,0)
node (bm) [right] {bpf\_mtap\_ether(IN)};
\draw[<->] (node cs:name=vi,anchor=east) -- +(.4,0)
node (vs) [right] {vlan\_strip()};
\draw[<->] (node cs:name=fv,anchor=east) -- +(.4,0)
node (bv) [right] {bpf\_mtap\_ether(IN)};
\end{tikzpicture}
\end{frame}
\subsection{Hardware Transmit and Tcpdump}
\begin{frame}{Hardware Transmit and Tcpdump}
\begin{tikzpicture}
\draw (0,0)
node (io) [right] {ip\_output()} ++(0,-.8)