Add KTR, a facility that logs kernel events to help debugging. You can access
[dragonfly.git] / share / man / man4 / natm.4
1 .\" $FreeBSD: src/share/man/man4/natm.4,v 1.4.2.3 2001/08/17 13:08:38 ru Exp $
2 .\" $DragonFly: src/share/man/man4/natm.4,v 1.2 2003/06/17 04:36:59 dillon Exp $
3 .\"
4 .Dd December 29, 1997
5 .Dt NATM 4
6 .Os
7 .Sh NAME
8 .Nm natm
9 .Nd Native Mode ATM protocol layer
10 .Sh DESCRIPTION
11 The
12 .Bx
13 ATM software comes with a
14 .Em native mode ATM protocol layer
15 which provides socket level access to AAL0 and AAL5 virtual circuits.
16 To enable this protocol layer, add
17 .Dl options NATM
18 to your kernel configuration file and re-make the kernel (don't forget
19 to do
20 .Dq make clean ) .
21 .Sh NATM API
22 The NATM layer uses a
23 .Dv struct sockaddr_natm
24 to specify a virtual circuit:
25 .Bd -literal -offset indent
26 struct sockaddr_natm {
27   u_int8_t      snatm_len;              /* length */
28   u_int8_t      snatm_family;           /* AF_NATM */
29   char          snatm_if[IFNAMSIZ];     /* interface name */
30   u_int16_t     snatm_vci;              /* vci */
31   u_int8_t      snatm_vpi;              /* vpi */
32 };
33 .Ed
34 .Pp
35 To create an AAL5 connection to a virtual circuit with VPI 0, VCI 201
36 one would use the following:
37 .Bd -literal -offset indent
38   struct sockaddr_natm snatm;
39   int s, r;
40   s = socket(AF_NATM, SOCK_STREAM, PROTO_NATMAAL5);
41                        /* note: PROTO_NATMAAL0 is AAL0 */
42   if (s < 0) { perror("socket"); exit(1); }
43   bzero(&snatm, sizeof(snatm));
44   snatm.snatm_len = sizeof(snatm);
45   snatm.snatm_family = AF_NATM;
46   sprintf(snatm.snatm_if, "en0");
47   snatm.snatm_vci = 201;
48   snatm.snatm_vpi = 0;
49   r = connect(s, (struct sockaddr *)&snatm, sizeof(snatm));
50   if (r < 0) { perror("connect"); exit(1); }
51   /* s now connected to ATM! */
52 .Ed
53 .Pp
54 The
55 .Fn socket
56 call simply creates an unconnected NATM socket.  The
57 .Fn connect
58 call associates an unconnected NATM socket with a
59 virtual circuit and tells the driver to enable that virtual circuit
60 for receiving data.  After the
61 .Fn connect
62 call one can
63 .Fn read
64 or
65 .Fn write
66 to the socket to perform ATM I/O.
67 .Sh Internal NATM operation
68 Internally, the NATM protocol layer keeps a list of all active virtual
69 circuits on the system in
70 .Dv natm_pcbs .
71 This includes circuits currently being used for IP to prevent NATM and
72 IP from clashing over virtual circuit usage.
73 .Pp
74 When a virtual circuit is enabled for receiving data, the NATM
75 protocol layer passes the address of the protocol control block down
76 to the driver as a receive
77 .Dq handle .
78 When inbound data arrives, the driver passes the data back with the
79 appropriate receive handle.   The NATM layer uses this to avoid the
80 overhead of a protocol control block lookup.   This allows us to take
81 advantage of the fact that ATM has already demultiplexed the data for
82 us.
83 .Sh Other NATM issues
84 We are currently involved with a video server project and are using
85 this driver as part of it.  We have a device we build called an MMX.
86 You can connect a video camera to an MMX and have it send you a stream
87 of AAL0 cells with the video output in it.  Of course this stream
88 is pretty rapid (in fact, it is massive!), and the normal AAL0
89 handling of the driver is unable to handle it (you end up with a cell
90 per small mbuf trying to make it to the application ... it turns out
91 the socket layer can't keep up with that sort of data stream).  To
92 solve this problem we have implemented a
93 .Dq raw
94 mode which batches unprocessed AAL0 info from the card into larger
95 data chunks blocks.  We can save this data to disk in real-time
96 without the socket layer freaking out.    Unfortunately, the data has
97 RBD (receive buffer descriptors) and cells headers in it, and this has
98 to be filtered out after capture.
99 To enable
100 .Dq raw
101 mode one does the following ioctl:
102 .Bd -literal -offset indent
103   int size = 4000; /* bytes */
104   ret = ioctl(s, SIOCRAWATM, (caddr_t)&size);
105 .Ed
106 .Pp
107 This tells the driver to batch AAL0 data into 4000 bytes chunks,
108 rather than the usual 48 bytes chunks.     Admittedly this is somewhat
109 gross, but our current application requires it.    In the future we
110 hope that video sources send data in nice large AAL5 frames.
111 .Sh CAVEAT
112 The NATM protocol support is subject to change as
113 the ATM protocols develop.  Users should not depend
114 on details of the current implementation, but rather
115 the services exported.
116 .Sh SEE ALSO
117 .Xr en 4
118 .Sh AUTHORS
119 .An Chuck Cranor
120 of Washington University implemented the NATM protocol layer
121 along with the EN ATM driver in 1996 for
122 .Nx .