📄 trans_design.nr
字号:
.NC "The Design of the ARGO Transport Entity".sh 1 "Protocol Hooks".ppThe design of the AOS kernel IPC support to someextent mandates thedesign of protocols. Each protocol must provide the following protocol hooks, which are procedures called through aprotocol switch table(an array of type \fIprotosw\fR as described inChapter Five..ip "pr_input()" 5Called when data are to be passed up from a lower layer..ip "pr_output()" 5Called when data are to be passed down from a higher layer..ip "pr_init()" 5Called when the system is brought up..ip "pr_fasttimo()" 5Called every 200 milliseconds by the clock functional unit..ip "pr_slowtimo()" 5Called every 500 milliseconds by the clock functional unit..ip "pr_drain()" 5This is meant to be called when buffer space is low.Each protocol is expected to provide this routine to freenon-critical buffer space.This is not yet called anywhere..ip "pr_ctlinput()" 5Used for exchanging information betweenprotocols, such as notifying a transport protocol of changesin routing or configuration information..ip "pr_ctloutput()" 5Supports the protocol-dependent \fIgetsockopt()\fRand \fIsetsockopt()\fRoptions..ip "pr_usrreq()" 5Called by the socket code to pass along a \*(lquser request\*(rq -in other words a service primitive.This call is also used for other protocol functions.The functions served by the \fIpr_usrreq()\fR routine are:.ip " PRU_ATTACH" 10Creates a protocol control block and attaches it to a given socket.Called as a result of a \fIsocket()\fR system call..ip " PRU_DISCONNECT" 10Called as a result of a \fIclose()\fR system call.Initiates disconnection..ip " PRU_DETACH" 10Disassociates a protocol control block from a socket and recyclesthe buffer space used for the protocol control block.Called after PRU_DISCONNECT..ip " PRU_SHUTDOWN" 10Called as a result of a \fIshutdown()\fR system call.If the protocol supports the notion of half-open connections,this closes the connection in one direction or both directions,depending on the arguments passed to\fIshutdown\fR..ip " PRU_BIND" 10Gives an address to a socket.Called as a result of a \fIbind()\fR system call, alsowhen socket without a bound address is used.In the latter case, an unused transport suffix is located andbound to the socket..ip " PRU_LISTEN" 10Called as a result of a \fIlisten()\fR system call.Marks the socket as willing to queue incoming connectionrequests..ip " PRU_CONNECT" 10Called as a result of a \fIconnect()\fR system call.Initiates a connection request..ip " PRU_ACCEPT" 10Called as a result of an \fIaccept()\fR system call.Dequeues a pending connection request, or blocks waiting fora connection request to arrive.In the latter case, it marks the socket as willing to acceptconnections..ip " PRU_RCVD" 10The protocol module is expected to have put incoming datainto the socket's receive buffer, \fIso_rcv\fR.When a receive primitive is used(\fIrecv(), recvmsg(), recvfrom(),read(), readv(), \fRand \fIrecvv()\fR system calls)the socket code module copies data from the\fIso_rcv\fR to the user'saddress space.The protocol module may arrange to be informed each time the socket codedoes this, in which case the socket code calls \fIpr_usrreq\fR(PRU_RCVD)after the data were copied to the user..ip " PRU_SEND" 10This performs the protocol-dependent part of a send primitive(\fIsend(), sendmsg(), sendto(), write(), writev(), \fRand \fIsendv()\fR system calls).The socket code (procedures \fIsendit() and \fIsosend()\fR)moves outgoing data from the user'saddress space into a chain of \fImbufs\fR.The socket code takes as much data from the user as itdetermines will fit into the outgoing socket buffer, so_snd. It passes this much data in the form of an mbuf chain to the protocolvia \fIpr_usrreq\fR(PRU_SEND).If there are more data than the so_snd can accommodate,the socket code, which is running on behalf of a user process,puts the user process to sleep.The protocol module is expected to wake up the user process whenmore room appears in so_snd..ip " PRU_ABORT" 10Called when a socket is closed and that socketis accepting connections and hasqueued pendingconnection requests orpartially open connections..ip " PRU_CONTROL" 10Called as a result of an \fIioctl()\fR system call..ip " PRU_SENSE" 10Called as a result of an \fIfstat()\fR system call..ip " PRU_RCVOOB" 10Performs the work of receiving \*(lqout-of-band\*(rq data.The socket module has already allocated an mbuf into whichthe protocol module is expected to put the incoming \*(lqout-of-band\*(rq data.The socket code will then move the data from this mbufto the user's address space..ip " PRU_SENDOOB" 10Performs the work of sending \*(lqout-of-band\*(rq data.The socket module has already moved the datafrom the user's address space into a chain of mbufs,which it now passes to the protocol module..ip " PRU_SOCKADDR" 10Supports the system call\fIgetsockname()\fR.Puts the socket's bound address into an mbuf..ip " PRU_PEERADDR" 10Supports the system call\fIgetpeername\fR().Puts the peer's address into an mbuf..ip " PRU_CONNECT2" 10This is used in the Unix domain to support pipes.It is not generally supported by transport protocols..ip " PRU_FASTTIMO, PRU_SLOWTIMO" 10These are superfluous.None of the transport protocols uses them..ip " PRU_PROTORCV, PRU_PROTOSEND" 10None of the transport protocols uses these..ip " PRU_SENDEOT" 10This was added to support TP.This indicates that the end of the data sent in thissend primitive shouldbe marked by the protocol as the end of the TSDU..sh 1 "The Interface Between the Transport Entity and Lower Layers".ppThe transport layer may run over a network layer such as IPor the ISO connectionless network layer,or it may run over a multi-purpose layer such as the serviceprovided by X.25.X.25 is viewed as a network layer whenTP runs over X.25, and as a subnetwork layer when IP is running over X.25.The software interface between data link and network layers differsconsiderably from the software interface between transport and networklayers in AOS.For this reason some modification of the transport-to-lower-layerinterface is necessary to support the suite of protocols included in ARGO..ppIn AOS it is assumed that the transport layer will run over oneand only one network layer, and therefore it may call thenetwork layer output procedure directly.In order to allow TP to run over a set of lower layers,all domain-specific functions have been put into a set of routinesthat are called indirectly through a domain-specific switch table.The primary reason for this is that the transport and networklayers share information, mostly information pertaining to addresses.The protocol control blocks for different network layersdiffer, so the transport layer cannot just directlyaccess the network layer's pcb.Similarly, a network layer may not directly access the transportpcb because a multitude of transport protocols can run over eachof the network protocols..ppTo permit different network-layer protocol control blocks to coexistunder one transport layer, all transport-dependent controlinformation was put into a transport-specific protocol control block.A new field, \fIso_tpcb\fR,was added to the \fIsocket\fR structure to hold a pointer tothe transport-layer protocol control block. The existingfield \fCso_pcb\fR is used for the network layer pcb..ppThe following structure was added to allow domain-specificfunctions to be called indirectly.All these functions operate on a network-layer pcb..pp.(b\fC.TStab(+);l s s s.struct nl_protosw {.T&l l l l.+int+nlp_afamily;+/* address family */+int+(*nlp_putnetaddr)();+/* puts addrs in pcb */+int+(*nlp_getnetaddr)();+/* gets addrs from pcb */+int+(*nlp_putsufx)();+/* transp suffix -> pcb */+int+(*nlp_getsufx)();+/* gets t-suffix */+int+(*nlp_recycle_suffix)();+/* zeroes suffix */+int+(*nlp_mtu)();+/* get maximum+++transmission unit size */+int+(*nlp_pcbbind)();+/* bind to pcb */+int+(*nlp_pcbconn)();+/* connect */+int+(*nlp_pcbdisc)();+/* disconnect */+int+(*nlp_pcbdetach)();+/* detach pcb */+int+(*nlp_pcballoc)();+/* allocate a pcb */+int+(*nlp_output)();+/* emit packet */+int+(*nlp_dgoutput)();+/* emit datagram */+caddr_t+nlp_pcblist;+/* list of pcbs +++for management +++of connections */};.TE\fR.)b.lpThe switch is based on the address family chosen when the\fIsocket()\fR system call is made prior to connection establishment.This unfortunately ties the address family to the domain,but the only alternative is to add an argument to the \fIsocket()\fRsystem call to let the user specify the desired network layer.In the case of a connection oriented environment with no multi-homing,it would be possible to determine which network layer is to beusedfrom routinginformation, but to do this requires unrealistic assumptionsabout the environment.For these reasons, linking the address family to the networklayer protocol is seen as the least of the evils.The transport suffixes are kept in the network layer's pcbas well as in the transport layer because full transport address pairs are used to identify a connectionin the Internet domain..sh 1 "The Architecture of the Transport Protocol Entity".ppA set of protocol hooks is requiredby the AOS IPC architecture.These hooks are used by the protocol-independent parts of the kernelto gain entry to protocol-specific code.The protocol code can be entered in one of the following ways:.ip "1) " 5at boot time, when autoconfigurationinitializes each protocol throughthe \fIpr_init()\fRhook,.ip "2) " 5from above, eithera user program making a system call, throughthe \fIpr_usrreq()\fR or \fIpr_ctloutput()\fR hooks, orfrom a higher layer protocol using the\fIpr_output()\fR hook,.ip "3) " 5from below, a device interrupt servicing an incoming packetthrough the \fIpr_input()\fR and \fIpr_ctlinput()\fR hooks, and.ip "4) " 5from a clock interrupt through the \fIpr_slowtimo()\fRor the\fIpr_fasttimo()\fR hook..\" FIGURE.so figs/trans_flow.nr.\".so figs/trans_flow.grn.ppThe protocol code can be divided intothe following modules, which are described in more detail below..CFshows the flow of data and control among these modules..in +5.ip "Timers and References:" 5The code executed on behalf of \fIpr_slowtimo()\fR.The fast timeout is not used by TP..ip "Driver:" 5This is the finite state machine for TP..ip "Input: " 5This is the module that decodes incoming packets,identifies or creates the pcb for which the packet is destined, and creates an "event" topass to the driver..ip "Output:" 5This is the module that creates a packet header of a given typewith fields containing values that are appropriate to the connectionon which the packet is being sent, appends data if necessary,and hands a packetto the lower layer, according to the transport-to-lower-layerinterface..ip "Send: " 5This module packetizes data from the outboundsocket buffer, \fIso_snd\fR,handles retransmissions of packetized data, anddrops packetized data from the retransmission queue..ip "Receive:" 5This module reorders packets if necessary,depacketizes data, passes it to the socket code module,and determines when acknowledgments should be sent..in -5.sh 1 "Timers and References".ppTP identifies sockets by \fIreference numbers\fR, or\fIreferences\fR,which are \*(lqfrozen\*(rq (may not be reassigned)until some locally defined time aftera connection is broken and its protocol control blockis discarded.An array of \fIreference blocks\fR is maintained by TP.The reference number of a reference block is itsoffset in the array.When a reference block is in use it contains a pointer to the pcb for the socket to which thereference applies..ppThe system clock calls the \fIpr_slowtimo()\fR and \fIpr_fasttimo()\fR hooks for each protocol in the protocol switch tableevery 500 and 200 microseconds, respectively.Each protocol handles its own timers its own way.The timers in TP take two forms- those that typically are cancelled andthose that usually expire.The latter form may have more than one instantiation at any giventime.The former may not.The two are implemented slightlydifferently for the sake of performance..ppThe timers that normally expire are kept in a queue, their values all relativeto the value of preceding timer.Thus all timer values are decremented by a singleoperation on the value of the first timer.The timer is represented by the Ecallout structure:.(b\fC.TStab(+);l s s s.struct Ecallout {.T&l l l l.+int+c_time;+/* incremental time */+int+c_func;+/* function to call */+u_int+c_arg1;+/* argument to routine */+u_int+c_arg2;+/* argument to routine */+int+c_arg3;+/* argument to routine */+struct Ecallout+*c_next;};.TE\fR
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -