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