Compartilhar via


2.1.3 Virtual Circuits

In CIFS, a virtual circuit (VC) represents a transport-level connection between a client and a server. VCs are of use in situations in which multiple physical connections are being combined to provide improved overall bandwidth for an SMB connection. For example, VCs make it possible to multiplex SMB messages from a single SMB connection over multiple dial-up modem connections in order to increase throughput. Virtual circuits are rarely used over connection-oriented transports such as NBT; they are typically associated with connectionless transports such as Direct-hosting IPX. VC multiplexing is performed at the command level, with the exception of the SMB_COM_READ_MPX and SMB_COM_WRITE_MPX commands, which are specifically designed to be multiplexed.

VCs are established using the SMB_COM_SESSION_SETUP_ANDX command, and are combined based upon the SessionKey provided in the SMB_COM_NEGOTIATE response.<7> Every VC created between a client and server pair using the same SessionKey is considered to be part of the same SMB connection. Each VC thus created MUST have a unique VcNumber in the SMB_COM_SESSION_SETUP_ANDX request that is used to establish it. The first VC created SHOULD have a VcNumber of zero (0). The implementation-defined maximum number of virtual circuits that the client can establish per SMB connection is indicated by the MaxNumberVcs field in the server's SMB_COM_NEGOTIATE response.<8>

A VcNumber of zero (0) has special significance. It is possible for a connectionless transport to not provide any indication of failure when a client fails or is reset. A virtual circuit with a VcNumber of zero (0), regardless of the SessionKey value, is defined to indicate to the server that the client has abandoned all previous virtual circuits and that the server MUST close those VCs as well, ensuring proper cleanup of resources.<9> This behavior can have unintended consequences in situations where separate applications running on the same client establish individual connections to the same server, or in cases in which multiple clients connect to a single server through a Network Address Translation (NAT) device (see [KB301673] for a detailed explanation). In these situations, each connection attempt from the same client (or NAT device) can cause all others from that client to be disconnected. To avoid this, clients can use a VcNumber of greater than or equal to one, or servers MAY be configured to bypass special processing of VcNumber zero over connection-oriented transports.