2.2.4 Packet Fragment

A WS-MAN packet can carry only a limited amount of data (as specified in [MS-WSMV] section 3.1.4.1.7). Some PSRP messages (as specified in section 2.2.1) do not fit into a single WS-MAN packet. To overcome this, the PowerShell Remoting Protocol fragments messages before sending.

An individual fragment MUST be sent in a single WS-MAN packet; in other words, an individual fragment cannot be broken down into smaller pieces and sent in separate WS-MAN packets.

A single WS-MAN packet, however, can contain multiple fragments. For instance, fragments belonging to a SESSION_CAPABILITY message and a INIT_RUNSPACEPOOL message could be sent together in the open content of a single wxf:Create WS-MAN packet.

Each message MUST be fragmented into one or more fragments with the fragment structure as described in the following section. Each fragment MUST fit into the payload of a WS-MAN message.


0


1


2


3


4


5


6


7


8


9

1
0


1


2


3


4


5


6


7


8


9

2
0


1


2


3


4


5


6


7


8


9

3
0


1

ObjectId

...

FragmentId

...

Reserved

E

S

BlobLength

...

Blob (variable)

...

ObjectId (8 bytes): An unsigned 8-byte integer specifying the ID of the PSRP message (see section 2.2.1) to which the fragment belongs. Because a PSRP message can be sent as multiple packets, the receiver will use the ObjectId to map them to the same PSRP message. The value of this field MUST be greater than 0 and unique within a given RunspacePool and its associated pipelines. The value is in the network-byte order.

FragmentId (8 bytes): An unsigned 8-byte integer that identifies where in the sequence of message fragments this fragment falls. The FragmentId values determine the order in which different fragments are combined to construct the PSRP message on the receiver's end. The value is in the network-byte order. The value of this field MUST start with 0.

Reserved (6 bits): Reserved for future use. MUST be set to 0 and ignored upon receipt.

E (1 bit): Specifies if the packet represents the End fragment. This will be used by the receiver to combine different packets for the same deserialized object. A value of 1 means the packet is End fragment.

If a deserialized object fits into 1 packet, then both the E field and the S field MUST be 1

Value

Meaning

0

Not an End fragment.

1

End fragment.

S (1 bit): Specifies if the packet represents the Start fragment. A value of 1 means the packet is Start fragment. If a deserialized object fits into 1 packet, then both the E field and the S field MUST be 1. The Start fragment MUST have a FragmentId of 0.

Value

Meaning

0

Not a Start fragment.

1

Start fragment.

BlobLength (4 bytes): The length, in bytes, of the Blob field. This field MUST be set to a value greater than or equal to 0 and less than or equal to 32768. The value is in network-byte order

Blob (variable): An entire PSRP message (as specified in section 2.2.1) or a part of a fragmented PSRP message