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