]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - share/doc/smm/18.net/9.t
Add two missing eventhandler.h headers
[FreeBSD/FreeBSD.git] / share / doc / smm / 18.net / 9.t
1 .\" Copyright (c) 1983, 1986, 1993
2 .\"     The Regents of the University of California.  All rights reserved.
3 .\"
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
6 .\" are met:
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\"    notice, this list of conditions and the following disclaimer.
9 .\" 2. Redistributions in binary form must reproduce the above copyright
10 .\"    notice, this list of conditions and the following disclaimer in the
11 .\"    documentation and/or other materials provided with the distribution.
12 .\" 3. Neither the name of the University nor the names of its contributors
13 .\"    may be used to endorse or promote products derived from this software
14 .\"    without specific prior written permission.
15 .\"
16 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
17 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
20 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 .\" SUCH DAMAGE.
27 .\"
28 .\"     @(#)9.t 8.1 (Berkeley) 6/8/93
29 .\"
30 .nr H2 1
31 .\".ds RH "Protocol/network-interface
32 .br
33 .ne 2i
34 .NH
35 \s+2Protocol/network-interface interface\s0
36 .PP
37 The lowest layer in the set of protocols which comprise a
38 protocol family must interface itself to one or more network
39 interfaces in order to transmit and receive
40 packets.  It is assumed that
41 any routing decisions have been made before handing a packet
42 to a network interface, in fact this is absolutely necessary
43 in order to locate any interface at all (unless, of course,
44 one uses a single ``hardwired'' interface).  There are two
45 cases with which to be concerned, transmission of a packet
46 and receipt of a packet; each will be considered separately.
47 .NH 2
48 Packet transmission
49 .PP
50 Assuming a protocol has a handle on an interface, \fIifp\fP,
51 a (struct ifnet\ *),
52 it transmits a fully formatted packet with the following call,
53 .DS
54 error = (*ifp->if_output)(ifp, m, dst)
55 int error; struct ifnet *ifp; struct mbuf *m; struct sockaddr *dst;
56 .DE
57 The output routine for the network interface transmits the packet
58 \fIm\fP to the \fIdst\fP address, or returns an error indication
59 (a UNIX error number).  In reality transmission may
60 not be immediate or successful; normally the output
61 routine simply queues the packet on its send queue and primes
62 an interrupt driven routine to actually transmit the packet.
63 For unreliable media, such as the Ethernet, ``successful''
64 transmission simply means that the packet has been placed on the cable
65 without a collision.  On the other hand, an 1822 interface guarantees
66 proper delivery or an error indication for each message transmitted.
67 The model employed in the networking system attaches no promises
68 of delivery to the packets handed to a network interface, and thus
69 corresponds more closely to the Ethernet.  Errors returned by the
70 output routine are only those that can be detected immediately,
71 and are normally trivial in nature (no buffer space, 
72 address format not handled, etc.).
73 No indication is received if errors are detected after the call has returned.
74 .NH 2
75 Packet reception
76 .PP
77 Each protocol family must have one or more ``lowest level'' protocols.
78 These protocols deal with internetwork addressing and are responsible
79 for the delivery of incoming packets to the proper protocol processing
80 modules.  In the PUP model [Boggs78] these protocols are termed Level
81 1 protocols,
82 in the ISO model, network layer protocols.  In this system each such
83 protocol module has an input packet queue assigned to it.  Incoming
84 packets received by a network interface are queued for the protocol
85 module, and a VAX software interrupt is posted to initiate processing.  
86 .PP
87 Three macros are available for queuing and dequeuing packets:
88 .IP "IF_ENQUEUE(ifq, m)"
89 .br
90 This places the packet \fIm\fP at the tail of the queue \fIifq\fP.
91 .IP "IF_DEQUEUE(ifq, m)"
92 .br
93 This places a pointer to the packet at the head of queue \fIifq\fP 
94 in \fIm\fP
95 and removes the packet from the queue.
96 A zero value will be returned in \fIm\fP if the queue is empty.
97 .IP "IF_DEQUEUEIF(ifq, m, ifp)"
98 .br
99 Like IF_DEQUEUE, this removes the next packet from the head of a queue
100 and returns it in \fIm\fP.
101 A pointer to the interface on which the packet was received
102 is placed in \fIifp\fP, a (struct ifnet\ *).
103 .IP "IF_PREPEND(ifq, m)"
104 .br
105 This places the packet \fIm\fP at the head of the queue \fIifq\fP.
106 .PP
107 Each queue has a maximum length associated with it as a simple form
108 of congestion control.  The macro IF_QFULL(ifq) returns 1 if the queue
109 is filled, in which case the macro IF_DROP(ifq) should be used to
110 increment the count of the number of packets dropped, and the offending
111 packet is dropped.  For example, the following code fragment is commonly
112 found in a network interface's input routine,
113 .DS 
114 ._f
115 if (IF_QFULL(inq)) {
116         IF_DROP(inq);
117         m_freem(m);
118 } else
119         IF_ENQUEUE(inq, m);
120 .DE