|
|
1.1 ! root 1: .\" Copyright (c) 1983, 1986 The Regents of the University of California. ! 2: .\" All rights reserved. ! 3: .\" ! 4: .\" Redistribution and use in source and binary forms are permitted ! 5: .\" provided that the above copyright notice and this paragraph are ! 6: .\" duplicated in all such forms and that any documentation, ! 7: .\" advertising materials, and other materials related to such ! 8: .\" distribution and use acknowledge that the software was developed ! 9: .\" by the University of California, Berkeley. The name of the ! 10: .\" University may not be used to endorse or promote products derived ! 11: .\" from this software without specific prior written permission. ! 12: .\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR ! 13: .\" IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED ! 14: .\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ! 15: .\" ! 16: .\" @(#)9.t 6.4 (Berkeley) 3/7/89 ! 17: .\" ! 18: .nr H2 1 ! 19: .\".ds RH "Protocol/network-interface ! 20: .br ! 21: .ne 2i ! 22: .NH ! 23: \s+2Protocol/network-interface interface\s0 ! 24: .PP ! 25: The lowest layer in the set of protocols which comprise a ! 26: protocol family must interface itself to one or more network ! 27: interfaces in order to transmit and receive ! 28: packets. It is assumed that ! 29: any routing decisions have been made before handing a packet ! 30: to a network interface, in fact this is absolutely necessary ! 31: in order to locate any interface at all (unless, of course, ! 32: one uses a single ``hardwired'' interface). There are two ! 33: cases with which to be concerned, transmission of a packet ! 34: and receipt of a packet; each will be considered separately. ! 35: .NH 2 ! 36: Packet transmission ! 37: .PP ! 38: Assuming a protocol has a handle on an interface, \fIifp\fP, ! 39: a (struct ifnet\ *), ! 40: it transmits a fully formatted packet with the following call, ! 41: .DS ! 42: error = (*ifp->if_output)(ifp, m, dst) ! 43: int error; struct ifnet *ifp; struct mbuf *m; struct sockaddr *dst; ! 44: .DE ! 45: The output routine for the network interface transmits the packet ! 46: \fIm\fP to the \fIdst\fP address, or returns an error indication ! 47: (a UNIX error number). In reality transmission may ! 48: not be immediate or successful; normally the output ! 49: routine simply queues the packet on its send queue and primes ! 50: an interrupt driven routine to actually transmit the packet. ! 51: For unreliable media, such as the Ethernet, ``successful'' ! 52: transmission simply means that the packet has been placed on the cable ! 53: without a collision. On the other hand, an 1822 interface guarantees ! 54: proper delivery or an error indication for each message transmitted. ! 55: The model employed in the networking system attaches no promises ! 56: of delivery to the packets handed to a network interface, and thus ! 57: corresponds more closely to the Ethernet. Errors returned by the ! 58: output routine are only those that can be detected immediately, ! 59: and are normally trivial in nature (no buffer space, ! 60: address format not handled, etc.). ! 61: No indication is received if errors are detected after the call has returned. ! 62: .NH 2 ! 63: Packet reception ! 64: .PP ! 65: Each protocol family must have one or more ``lowest level'' protocols. ! 66: These protocols deal with internetwork addressing and are responsible ! 67: for the delivery of incoming packets to the proper protocol processing ! 68: modules. In the PUP model [Boggs78] these protocols are termed Level ! 69: 1 protocols, ! 70: in the ISO model, network layer protocols. In this system each such ! 71: protocol module has an input packet queue assigned to it. Incoming ! 72: packets received by a network interface are queued for the protocol ! 73: module, and a VAX software interrupt is posted to initiate processing. ! 74: .PP ! 75: Three macros are available for queuing and dequeuing packets: ! 76: .IP "IF_ENQUEUE(ifq, m)" ! 77: .br ! 78: This places the packet \fIm\fP at the tail of the queue \fIifq\fP. ! 79: .IP "IF_DEQUEUE(ifq, m)" ! 80: .br ! 81: This places a pointer to the packet at the head of queue \fIifq\fP ! 82: in \fIm\fP ! 83: and removes the packet from the queue. ! 84: A zero value will be returned in \fIm\fP if the queue is empty. ! 85: .IP "IF_DEQUEUEIF(ifq, m, ifp)" ! 86: .br ! 87: Like IF_DEQUEUE, this removes the next packet from the head of a queue ! 88: and returns it in \fIm\fP. ! 89: A pointer to the interface on which the packet was received ! 90: is placed in \fIifp\fP, a (struct ifnet\ *). ! 91: .IP "IF_PREPEND(ifq, m)" ! 92: .br ! 93: This places the packet \fIm\fP at the head of the queue \fIifq\fP. ! 94: .PP ! 95: Each queue has a maximum length associated with it as a simple form ! 96: of congestion control. The macro IF_QFULL(ifq) returns 1 if the queue ! 97: is filled, in which case the macro IF_DROP(ifq) should be used to ! 98: increment the count of the number of packets dropped, and the offending ! 99: packet is dropped. For example, the following code fragment is commonly ! 100: found in a network interface's input routine, ! 101: .DS ! 102: ._f ! 103: if (IF_QFULL(inq)) { ! 104: IF_DROP(inq); ! 105: m_freem(m); ! 106: } else ! 107: IF_ENQUEUE(inq, m); ! 108: .DE
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.