⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 trans_design.nr

📁 早期freebsd实现
💻 NR
📖 第 1 页 / 共 4 页
字号:
.)b.lpWhen an Ecallout structure migrates to the headof the E timer list, and its \fIc_time\fRfield is decremented to zero, the function stored in \fIc_func\fR iscalled, with \fIc_arg1, c_arg2\fR, and \fIc_arg3\fRas arguments.Setting and cancelling these timersare accomplished by a linear search and oneinsertion or deletion from the timer queue.This queue is linked to the reference block associated with a communication endpoint.This form used for the reference timerand for the retransmission timers for data TPDUs..ppThe second form of timer, the type thattypically is cancelled, is used for severaltimers - the inactivity timer, the sendack timer,and the retransmissiontimer for all types of TPDUs except data TPDUs..(b\fC.TStab(+);l s s s.struct Ccallout {.T&l l l l.+int+c_time;+/* incremental time */+int+c_active;+/* this timer is active? */};.TE\fR.)b.lpAll of these timers are storeddirectlyin the reference block.These timers are decremented in one linear scan ofthe reference blocks.Cancelling, setting, and bothcancelling and resetting one of these timers is accomplished by asingle assignment to an array element..sh 1 "Driver".ppThis is the finite state machine for TP.A connection is managed by the finite state machine (fsm).All events that pertain to a connection cause thefinite state machine driver to be called.The driver takes two arguments - the pcb for the connectionand an event structure.The event structure contains a field that discriminatesthe different types of events, and a union of structures that are specific to the event types.The driver evaluates a set of predicates based on the currentstate of the finite state machine (which is kept in the pcb) and the event type.The result of the predicate evaluation determinesa set of actions to take and a state transition.The driver takes the actions and if they completewithout errors, the driver makes the state transition..ppThe states, event types, predicates, actions, and state transitions are allspecified as a \fIxebec transition file\fR.\fIXebec\fR is a utility that takes a human-readable descriptionof a finite state machineand produces a set of tables and C source code for the driver.The driver procedure is called \fItp_driver()\fR.It is located in a file generated by xebec, \fCtp_driver.c\fR.For more details about xebec, see the manual page \fIxebec(1)\fR..ppThe transition file for TP is \fCtp.trans\fR,and it is a good place to begin a perusal of the TPsource code..sh 1 "Input".ppThis is the module that decodes an incoming packet,locates or creates the pcb for which the packet is destined, and creates an event topass to the driver.The network layer passes a packet up to the appropriatetransport layer by indirectly calling a transport inputroutine through the protocol switch table for the networkdomain.There is one protocol switch entry for TP for each domain in whichTP will run (Internet, ISO).In the Internet domain, the protocol switch field \fIpr_input()\fRtakes the value \fItpip_input()\fR.This procedure accepts a packet from IP, with the IP headerstill intact.It extracts the network addresses from the IP header,strips the IP header, and calls the domain-independentinput procedure for TP,\fItp_input()\fR.\fITp_input()\fRdecodes a TPDU.The multitude of options, the variable-lengthnature of the options, the semantics of theoptions, and the possible combinations of concatenatedTPDUs make this a complex procedure.It is sensitive to changes, and from the point of view of a software maintenance, it is apotential hazard.Because it is in the critical path of TP however, some compromisewas made between maintainability and efficiency.Multiple copies of sections of code were avoided as much aspossible,not for the sake of saving space, but rather for the sakeof maintainability.Ironically,this detracts somewhat from the readability of the code..ppOnce a TPDU has been decoded and a pcb has beenidentified for the TPDU,the appropriate fields of the TPDUare extracted and their values are placed inan event structure.Finally, \fItp_driver()\fR is called withthe event structure and the pcb as parameters..sh 1 "Output".ppThis module creates a TPDU header of a given typewith field values that are appropriate to the connectionon which the TPDU is being sent, appends data if necessary,and hands a TPDUto the lower layer according to the transport-to-lower-layerinterface.Whenever a TPDU is to be sent to the peer or prospective peer,the function \fItp_emit()\fRis called, passing as arguments the pcb a TPDU type and several miscellaneousother type-specific arguments, possibly including some data.The data are in the form of an mbuf chain.\fITp_emit()\fR prepends to the data an mbuf containing a TP header,fills in the fields of the header according to the parametersgiven, performs the checksum if appropriate, andcalls a domain-specific output routine.For the Internet domain, this output routine is\fItpip_output()\fR, which takesas arguments the mbuf chain representing the TPDU,and a network level pcb.Some protocol errors cannot be associated with a connection but require that TP issuean ER TPDU or a DR TPDU. When these errors occur the routine\fItp_error_emit()\fR is called.This procedure creates the appropriate type of TPDUand passes it to a domain-dependent routine for transmitting datagrams.In the Internet domain,\fItpip_output_dg()\fR is called.This takes as arguments an mbuf chain representing the TPDU,a source network address, and a destination network address..sh 1 "Send".\" FIGURE.so figs/mbufsnd.nr.\".so figs/mbufsnd.grn.ppThis module packetizes data from the outboundsocket buffer, \fIso_snd\fR,handles retransmissions of packetized data, anddrops packetized data from the retransmission queue.The major routine in this module is \fItp_send()\fR, whichtakes a range of sequence numbers as arguments.For each sequence number in the range,it packetizes the an appropriate amountof outbound data, and places the resulting TPDU on a retransmission control queue subject to theconstraints imposed by the rules of expedited data,maximum packet sizes, and end-of-TSDU markers..ppThe most complicating factor is that of managingexpedited data.A normal datum may not be sent (for its first time) before theacknowledgment of any expedited datumthat was received from the user after the normal datum was received. In order to enforce this rule,each TPDU must be marked in some wayso that it will be known which expedited datummust be delivered and acknowledged by the peer before this TPDU may be transmittedfor the first time.Markers are placed in \fIso_snd\fR when anoutgoing expedited datum arrives from the user. A marker is an mbuf structure with an \fIm_len\fRof zero, but with the data area nevertheless containingthe sequence number of an expedited data TPDU.The \fIm_type\fR of a marker is a new type, MT_XPD..pp\fITp_send()\fR stops packetizing data when it encounters a markerfor an unacknowledged expedited datum.If it encounters a marker for an expedited TPDU that has alreadybeen acknowledged, the marker is jettisoned..CFillustrates the structure of the sending socket buffer usedfor normal data..ppWhen \fItp_send()\fR moves data from mbufs on \fIso_snd\fR to the retransmissioncontrol queue, it needs to knowhow many octets of data can be placed in each TPDU.The appropriate amount depends on, among other things,the maximum transmission unit of the network layeron the route the packet will take.To determine the maximum transmission unit,TP queries the network layer throughthe domain-dependent switch table's field, \fInl_mtu\fR.In the Internet domain, this resolves to \fItp_inmtu()\fR.The header sizes for the network and transport layersalso affect the amount of data that can go into a packet,and these sizes depend on the connection's characteristics..ppOnce the maximum amount of data per TPDU is determined,\fItp_send()\fR can pull this amount off the \fIso_snd\fR queue to forma TPDU,assign a TPDU sequence number,and place the new TPDU on the retransmission control queue.The retransmission control queue is a list of mbuf chains.Each mbuf chain represents one TPDU, preceded by an\fIrtc structure\fR:.(b\fC.TStab(+);l s s s.struct tp_rtc {.T&l l l l.+struct tp_rtc+*tprt_next;+/* next rtc struct in list */+SeqNum+tprt_seq;+/* seq # of this TPDU */+int+tprt_eot;+/* end of TSDU? */+int+tprt_octets;+/* # octets in this TPDU */+struct mbuf+*tprt_data;+/* ptr to the octets of data */.\"/* Performance measurment info: */.\"int	tprt_window;	/* in which call to tp_send() was.\"			  * this TPDU formed? .\"			  */.\"struct timeval	tprt_sess_time;	/* time session received the .\"			* majority of the data for this packet on send;.\"			* on recv, this is the time it's given to session .\"			*/.\"struct timeval	tprt_net_time;	/* time first copy was given to net layer.\"			* on send; on receive it's the time received from.\"			* the network .\"			*/};.TE\fR.)b.lpOnce TPDUs are on the retransmission control queue,they are retransmitted or dropped by the actionsof timers.The procedure \fItp_sbdrop()\fRremoves the TPDUs from the retransmission queue.It takes a sequence number as an argument and dropsall TPDUs up to and including the TPDU with that sequence number..ppWhen an AK TPDU arrives, the values fromits credit and sequence number fieldsare passed to \fItp_goodack()\fR, whichdetermines whether or not the AK brought any news with it,and therefore whether TP can send more dataor expedited data.If this AK acknowledges something heretofore unacknowledged,\fItp_goodack()\fR drops the appropriate TPDU(s) from the retransmissioncontrol list, computes the smoothed average round trip timeand standard deviation of the round trip time, and updatesthe retransmission timer based on these statistics.It sets a flag in the pcb if the TP entity is obliged tosend the flow control confirmation parameter on its nextAK TPDU.\fITp_goodack()\fR returns true if the AK brought some news with it,either with respect to a change in credit or with respect tonew acknowledgments..ppThe function \fItp_goodXack()\fR is called when an XAK TPDUarrives.It takes the XAK sequence number as an argument anddetermines if the XAK acknowledges the last XPD TPDU sent.If so, it drops the expedited data from the outgoingexpedited data buffer.By its definition in the TP specification,the expedited data stream has a windowof size 1,that is, only one expedited datum (packet) can be bufferedat a time.\fITp_goodXack()\fR returns true if the XAK acknowledgedthe last XPD TPDU sent and the data were dropped,and it returns false if the acknowledgment caused no action to be taken..\" NEXT FIGURE.so figs/mbufrcv.nr.\".so figs/mbufrcv.grn.sh 1 "Receive".ppThis module reorders incoming TPDUs if necessary,depacketizes data, passes it to the socket code module,and determines when acknowledgments should be sent.The function \fItp_stash()\fRtakes an DT TPDU as an argument, and if the TPDU is not insequence, it saves the TPDU in a \fItp_rtc\fR structure ina list, with the TPDUskept in order.When the next expected TPDU arrives, thelist of out-of-order TPDUs is scanned for more TPDUs in sequence, updatinga field in the pcb, \fItp_rcvnxt\fR whichalways contains the sequencenumber of the next expected TPDU.If an acknowledgment is to be generatedat any time, the value of tp_rcvnxt goes into the\fIYR-TU-NR\fR\** field of the acknowledgment TPDU..(f\** This is the name used in ISO 8073 for the fieldwhich indicates the sequence number of the next expected DT TPDU..)f.pp\fITp_stash()\fR returns true if an acknowledgment needs to be generatedimmediately, false not.The acknowledgment strategy is therefore implemented in this routine.Acknowledgments may be generated for one or more of several reasons,listed below.\fITp_stash()\fR increments a counter for each of these reasonsfor which an acknowledgment is generated, and a counter for TPDUsthat are not acknowledged immediately..ip "ACK_STRAT_EACH" 5The acknowledgment strategy in use calls for acknowledging each data packet with an AK TPDU..ip "ACK_STRAT_FULLWIN" 5The acknowledgment strategy in use calls for acknowledging upon receiving the DT TPDU that represents the upper windowedge of the last advertised window..ip "ACK_DUP" 5A duplicate data TPDU was received..ip "ACK_REORDER" 5A DT TPDU arrived in the window but out of order..ip "ACK_EOT" 5A DT TPDU arrived, and it had the end-of-TSDU flag set..ppUpon receipt of a DT TPDU that is in order, and upon reorderingDT TPDUs, \fItp_stash()\fRplaces the TSDUs into the socket's receivesocket buffer, \fIso->so_rcv\fR in mbuf chains, withTSDUs delimited by mbufs of the \fIm_type\fR MT_EOT,which is a new type with the ARGO kernel..CFillustrates the structure of the receiving socket buffer usedfor normal data..ppA separate socket buffer, \fItpcb->tp_Xrcv\fR,is used forbuffering expedited data.Only one expedited data packet may reside in this buffer at a timebecause the TP standard limits the size of the window on expedited flowto be 1.This means the data structures are straightforward;there is no need to distinguish between separate TSDUs in this socket buffer..pp

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -