<section>
 <h1 class="contains-headerlink leafygreen-ui-41fr9s" weight="medium">
  MongoDB Wire Protocol
  <a class="headerlink leafygreen-ui-1kepx47" href="#mongodb-wire-protocol" title="Permalink to this heading">
   <svg aria-label="Link Icon" class="leafygreen-ui-a30zj9" fill="none" height="12" role="img" viewbox="0 0 16 16" width="12" xmlns="http://www.w3.org/2000/svg">
    <path d="M6.039 9.953a3.596 3.596 0 0 1-.327-.38l1.45-1.445a1.553 1.553 0 0 0 2.496.423l2.885-2.87a1.57 1.57 0 0 0 .01-2.213 1.553 1.553 0 0 0-2.203-.01l-.379.377A.995.995 0 0 1 8.56 3.83a1.005 1.005 0 0 1 .006-1.418l.38-.377a3.542 3.542 0 0 1 5.024.023 3.58 3.58 0 0 1-.022 5.047l-2.884 2.871a3.542 3.542 0 0 1-5.025-.022Z" fill="currentColor">
    </path>
    <path d="M9.961 6.047c.12.12.228.248.327.38l-1.45 1.445a1.553 1.553 0 0 0-2.496-.423l-2.885 2.87a1.57 1.57 0 0 0-.01 2.213 1.553 1.553 0 0 0 2.203.01l.379-.377a.995.995 0 0 1 1.411.006 1.005 1.005 0 0 1-.006 1.418l-.38.377a3.542 3.542 0 0 1-5.024-.023 3.58 3.58 0 0 1 .022-5.047l2.884-2.871a3.542 3.542 0 0 1 5.025.022Z" fill="currentColor">
    </path>
   </svg>
   <div class="css-1btu0w3 evvkmar0" id="mongodb-wire-protocol">
   </div>
  </a>
 </h1>
 <div class="leafygreen-ui-a5yxub">
  <p class="css-1cmx2d4 ef7gu8j0">
   On this page
  </p>
  <ul class="css-1qb0mst ef7gu8j1">
   <li class="leafygreen-ui-1e7a0ei">
    <a class="lg-ui-0001 leafygreen-ui-e98ikf" href="#introduction" target="_self">
     <span>
      Introduction
     </span>
    </a>
   </li>
   <li class="leafygreen-ui-1jqtqlb">
    <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#tcp-ip-socket" target="_self">
     <span>
      TCP/IP Socket
     </span>
    </a>
   </li>
   <li class="leafygreen-ui-1jqtqlb">
    <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#messages-types-and-formats" target="_self">
     <span>
      Messages Types and Formats
     </span>
    </a>
   </li>
   <li class="leafygreen-ui-1jqtqlb">
    <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#standard-message-header" target="_self">
     <span>
      Standard Message Header
     </span>
    </a>
   </li>
   <li class="leafygreen-ui-1jqtqlb">
    <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#opcodes" target="_self">
     <span>
      Opcodes
     </span>
    </a>
   </li>
  </ul>
 </div>
 <div class="leafygreen-ui-15mdk4" role="note">
  <h2 class="leafygreen-ui-6n7b7d">
   Note
  </h2>
  <div class="leafygreen-ui-9mycqc">
   <p class="leafygreen-ui-1kp3ins">
    This MongoDB Wire Protocol Specification is licensed under a
    <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://creativecommons.org/licenses/by-nc-sa/3.0/us/" rel="noopener noreferrer">
     <span>
      Creative Commons Attribution-NonCommercial-ShareAlike 3.0 United States License
     </span>
     <svg alt="" aria-hidden="true" class="leafygreen-ui-1ie5kuq" height="16" role="presentation" viewbox="0 0 16 16" width="16">
      <path d="M13.823 2.4491C13.8201 2.30008 13.6999 2.17994 13.5509 2.17704L9.5062 2.09836C9.25654 2.09351 9.12821 2.39519 9.30482 2.5718L10.3856 3.65257L7.93433 6.10383C7.87964 6.15852 7.83047 6.21665 7.78683 6.27752L5.99909 8.06525C5.46457 8.59977 5.46457 9.4664 5.99909 10.0009C6.53361 10.5354 7.40023 10.5354 7.93475 10.0009L9.72249 8.21317C9.78336 8.16953 9.84148 8.12037 9.89618 8.06567L12.3474 5.61441L13.4282 6.69518C13.6048 6.87179 13.9065 6.74347 13.9016 6.4938L13.823 2.4491Z" fill="currentColor">
      </path>
      <path d="M7.25 3.12893C7.66421 3.12893 8 3.46472 8 3.87893C8 4.29315 7.66421 4.62893 7.25 4.62893H4C3.72386 4.62893 3.5 4.85279 3.5 5.12893V11.9929C3.5 12.2691 3.72386 12.4929 4 12.4929H10.864C11.1401 12.4929 11.364 12.2691 11.364 11.9929V8.75C11.364 8.33579 11.6998 8 12.114 8C12.5282 8 12.864 8.33579 12.864 8.75V11.9929C12.864 13.0975 11.9686 13.9929 10.864 13.9929H4C2.89543 13.9929 2 13.0975 2 11.9929V5.12893C2 4.02436 2.89543 3.12893 4 3.12893H7.25Z" fill="currentColor">
      </path>
     </svg>
    </a>
    . You may
not use or adapt this material for any commercial purpose, such as
to create a commercial database or database-as-a-service offering.
   </p>
  </div>
 </div>
 <section>
  <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium">
   Introduction
   <a class="headerlink leafygreen-ui-1kepx47" href="#introduction" title="Permalink to this heading">
    <svg aria-label="Link Icon" class="leafygreen-ui-a30zj9" fill="none" height="12" role="img" viewbox="0 0 16 16" width="12" xmlns="http://www.w3.org/2000/svg">
     <path d="M6.039 9.953a3.596 3.596 0 0 1-.327-.38l1.45-1.445a1.553 1.553 0 0 0 2.496.423l2.885-2.87a1.57 1.57 0 0 0 .01-2.213 1.553 1.553 0 0 0-2.203-.01l-.379.377A.995.995 0 0 1 8.56 3.83a1.005 1.005 0 0 1 .006-1.418l.38-.377a3.542 3.542 0 0 1 5.024.023 3.58 3.58 0 0 1-.022 5.047l-2.884 2.871a3.542 3.542 0 0 1-5.025-.022Z" fill="currentColor">
     </path>
     <path d="M9.961 6.047c.12.12.228.248.327.38l-1.45 1.445a1.553 1.553 0 0 0-2.496-.423l-2.885 2.87a1.57 1.57 0 0 0-.01 2.213 1.553 1.553 0 0 0 2.203.01l.379-.377a.995.995 0 0 1 1.411.006 1.005 1.005 0 0 1-.006 1.418l-.38.377a3.542 3.542 0 0 1-5.024-.023 3.58 3.58 0 0 1 .022-5.047l2.884-2.871a3.542 3.542 0 0 1 5.025.022Z" fill="currentColor">
     </path>
    </svg>
    <div class="css-1btu0w3 evvkmar0" id="introduction">
    </div>
   </a>
  </h2>
  <p class="leafygreen-ui-1kp3ins">
   The MongoDB Wire Protocol is a simple socket-based, request-response
style protocol. Clients communicate with the database server through a
regular TCP/IP socket.
  </p>
 </section>
 <section>
  <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium">
   TCP/IP Socket
   <a class="headerlink leafygreen-ui-1kepx47" href="#tcp-ip-socket" title="Permalink to this heading">
    <svg aria-label="Link Icon" class="leafygreen-ui-a30zj9" fill="none" height="12" role="img" viewbox="0 0 16 16" width="12" xmlns="http://www.w3.org/2000/svg">
     <path d="M6.039 9.953a3.596 3.596 0 0 1-.327-.38l1.45-1.445a1.553 1.553 0 0 0 2.496.423l2.885-2.87a1.57 1.57 0 0 0 .01-2.213 1.553 1.553 0 0 0-2.203-.01l-.379.377A.995.995 0 0 1 8.56 3.83a1.005 1.005 0 0 1 .006-1.418l.38-.377a3.542 3.542 0 0 1 5.024.023 3.58 3.58 0 0 1-.022 5.047l-2.884 2.871a3.542 3.542 0 0 1-5.025-.022Z" fill="currentColor">
     </path>
     <path d="M9.961 6.047c.12.12.228.248.327.38l-1.45 1.445a1.553 1.553 0 0 0-2.496-.423l-2.885 2.87a1.57 1.57 0 0 0-.01 2.213 1.553 1.553 0 0 0 2.203.01l.379-.377a.995.995 0 0 1 1.411.006 1.005 1.005 0 0 1-.006 1.418l-.38.377a3.542 3.542 0 0 1-5.024-.023 3.58 3.58 0 0 1 .022-5.047l2.884-2.871a3.542 3.542 0 0 1 5.025.022Z" fill="currentColor">
     </path>
    </svg>
    <div class="css-1btu0w3 evvkmar0" id="tcp-ip-socket">
    </div>
   </a>
  </h2>
  <p class="leafygreen-ui-1kp3ins">
   Clients should connect to the database with a regular TCP/IP socket.
  </p>
  <section>
   <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium">
    Port
    <a class="headerlink leafygreen-ui-1kepx47" href="#port" title="Permalink to this heading">
     <svg aria-label="Link Icon" class="leafygreen-ui-a30zj9" fill="none" height="12" role="img" viewbox="0 0 16 16" width="12" xmlns="http://www.w3.org/2000/svg">
      <path d="M6.039 9.953a3.596 3.596 0 0 1-.327-.38l1.45-1.445a1.553 1.553 0 0 0 2.496.423l2.885-2.87a1.57 1.57 0 0 0 .01-2.213 1.553 1.553 0 0 0-2.203-.01l-.379.377A.995.995 0 0 1 8.56 3.83a1.005 1.005 0 0 1 .006-1.418l.38-.377a3.542 3.542 0 0 1 5.024.023 3.58 3.58 0 0 1-.022 5.047l-2.884 2.871a3.542 3.542 0 0 1-5.025-.022Z" fill="currentColor">
      </path>
      <path d="M9.961 6.047c.12.12.228.248.327.38l-1.45 1.445a1.553 1.553 0 0 0-2.496-.423l-2.885 2.87a1.57 1.57 0 0 0-.01 2.213 1.553 1.553 0 0 0 2.203.01l.379-.377a.995.995 0 0 1 1.411.006 1.005 1.005 0 0 1-.006 1.418l-.38.377a3.542 3.542 0 0 1-5.024-.023 3.58 3.58 0 0 1 .022-5.047l2.884-2.871a3.542 3.542 0 0 1 5.025.022Z" fill="currentColor">
      </path>
     </svg>
     <div class="css-1btu0w3 evvkmar0" id="port">
     </div>
    </a>
   </h3>
   <p class="leafygreen-ui-1kp3ins">
    The default port number for
    <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod">
     <code class="leafygreen-ui-1l06pbn">
      mongod
     </code>
    </a>
    and
    <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongos/#mongodb-binary-bin.mongos">
     <code class="leafygreen-ui-1l06pbn">
      mongos
     </code>
    </a>
    instances is 27017. The port number for
    <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod">
     <code class="leafygreen-ui-1l06pbn">
      mongod
     </code>
    </a>
    and
    <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongos/#mongodb-binary-bin.mongos">
     <code class="leafygreen-ui-1l06pbn">
      mongos
     </code>
    </a>
    is configurable and may vary.
   </p>
  </section>
  <section>
   <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium">
    Byte Ordering
    <a class="headerlink leafygreen-ui-1kepx47" href="#byte-ordering" title="Permalink to this heading">
     <svg aria-label="Link Icon" class="leafygreen-ui-a30zj9" fill="none" height="12" role="img" viewbox="0 0 16 16" width="12" xmlns="http://www.w3.org/2000/svg">
      <path d="M6.039 9.953a3.596 3.596 0 0 1-.327-.38l1.45-1.445a1.553 1.553 0 0 0 2.496.423l2.885-2.87a1.57 1.57 0 0 0 .01-2.213 1.553 1.553 0 0 0-2.203-.01l-.379.377A.995.995 0 0 1 8.56 3.83a1.005 1.005 0 0 1 .006-1.418l.38-.377a3.542 3.542 0 0 1 5.024.023 3.58 3.58 0 0 1-.022 5.047l-2.884 2.871a3.542 3.542 0 0 1-5.025-.022Z" fill="currentColor">
      </path>
      <path d="M9.961 6.047c.12.12.228.248.327.38l-1.45 1.445a1.553 1.553 0 0 0-2.496-.423l-2.885 2.87a1.57 1.57 0 0 0-.01 2.213 1.553 1.553 0 0 0 2.203.01l.379-.377a.995.995 0 0 1 1.411.006 1.005 1.005 0 0 1-.006 1.418l-.38.377a3.542 3.542 0 0 1-5.024-.023 3.58 3.58 0 0 1 .022-5.047l2.884-2.871a3.542 3.542 0 0 1 5.025.022Z" fill="currentColor">
      </path>
     </svg>
     <div class="css-1btu0w3 evvkmar0" id="byte-ordering">
     </div>
    </a>
   </h3>
   <p class="leafygreen-ui-1kp3ins">
    All integers in the MongoDB wire protocol use little-endian byte order:
that is, least-significant byte first.
   </p>
  </section>
 </section>
 <section>
  <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium">
   Messages Types and Formats
   <a class="headerlink leafygreen-ui-1kepx47" href="#messages-types-and-formats" title="Permalink to this heading">
    <svg aria-label="Link Icon" class="leafygreen-ui-a30zj9" fill="none" height="12" role="img" viewbox="0 0 16 16" width="12" xmlns="http://www.w3.org/2000/svg">
     <path d="M6.039 9.953a3.596 3.596 0 0 1-.327-.38l1.45-1.445a1.553 1.553 0 0 0 2.496.423l2.885-2.87a1.57 1.57 0 0 0 .01-2.213 1.553 1.553 0 0 0-2.203-.01l-.379.377A.995.995 0 0 1 8.56 3.83a1.005 1.005 0 0 1 .006-1.418l.38-.377a3.542 3.542 0 0 1 5.024.023 3.58 3.58 0 0 1-.022 5.047l-2.884 2.871a3.542 3.542 0 0 1-5.025-.022Z" fill="currentColor">
     </path>
     <path d="M9.961 6.047c.12.12.228.248.327.38l-1.45 1.445a1.553 1.553 0 0 0-2.496-.423l-2.885 2.87a1.57 1.57 0 0 0-.01 2.213 1.553 1.553 0 0 0 2.203.01l.379-.377a.995.995 0 0 1 1.411.006 1.005 1.005 0 0 1-.006 1.418l-.38.377a3.542 3.542 0 0 1-5.024-.023 3.58 3.58 0 0 1 .022-5.047l2.884-2.871a3.542 3.542 0 0 1 5.025.022Z" fill="currentColor">
     </path>
    </svg>
    <div class="css-1btu0w3 evvkmar0" id="messages-types-and-formats">
    </div>
   </a>
  </h2>
  <p class="leafygreen-ui-1kp3ins">
   MongoDB uses the
   <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-wire-op-msg" target="_self">
    <span>
     OP_MSG
    </span>
   </a>
   opcode for both client
requests and database replies. There are several message formats used in
older versions of MongoDB which have been deprecated in favor of
   <code class="leafygreen-ui-1l06pbn">
    OP_MSG
   </code>
   .
  </p>
  <div class="leafygreen-ui-15mdk4" role="note">
   <h2 class="leafygreen-ui-6n7b7d">
    Note
   </h2>
   <div class="leafygreen-ui-9mycqc">
    <p class="leafygreen-ui-1kp3ins">
     This page uses a C-like
     <code class="leafygreen-ui-1l06pbn">
      struct
     </code>
     to describe the message
structure.
    </p>
    <p class="leafygreen-ui-1kp3ins">
     The types used in this document, such as
     <code class="leafygreen-ui-1l06pbn">
      int32
     </code>
     and
     <code class="leafygreen-ui-1l06pbn">
      cstring
     </code>
     ,
are the same as those defined in the
     <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="http://bsonspec.org/#/specification" rel="noopener noreferrer">
      <span>
       BSON specification
      </span>
      <svg alt="" aria-hidden="true" class="leafygreen-ui-1ie5kuq" height="16" role="presentation" viewbox="0 0 16 16" width="16">
       <path d="M13.823 2.4491C13.8201 2.30008 13.6999 2.17994 13.5509 2.17704L9.5062 2.09836C9.25654 2.09351 9.12821 2.39519 9.30482 2.5718L10.3856 3.65257L7.93433 6.10383C7.87964 6.15852 7.83047 6.21665 7.78683 6.27752L5.99909 8.06525C5.46457 8.59977 5.46457 9.4664 5.99909 10.0009C6.53361 10.5354 7.40023 10.5354 7.93475 10.0009L9.72249 8.21317C9.78336 8.16953 9.84148 8.12037 9.89618 8.06567L12.3474 5.61441L13.4282 6.69518C13.6048 6.87179 13.9065 6.74347 13.9016 6.4938L13.823 2.4491Z" fill="currentColor">
       </path>
       <path d="M7.25 3.12893C7.66421 3.12893 8 3.46472 8 3.87893C8 4.29315 7.66421 4.62893 7.25 4.62893H4C3.72386 4.62893 3.5 4.85279 3.5 5.12893V11.9929C3.5 12.2691 3.72386 12.4929 4 12.4929H10.864C11.1401 12.4929 11.364 12.2691 11.364 11.9929V8.75C11.364 8.33579 11.6998 8 12.114 8C12.5282 8 12.864 8.33579 12.864 8.75V11.9929C12.864 13.0975 11.9686 13.9929 10.864 13.9929H4C2.89543 13.9929 2 13.0975 2 11.9929V5.12893C2 4.02436 2.89543 3.12893 4 3.12893H7.25Z" fill="currentColor">
       </path>
      </svg>
     </a>
     .
    </p>
   </div>
  </div>
  <span class="leafygreen-ui-1qnjd6d" id="std-label-wp-message-header">
  </span>
 </section>
 <section>
  <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium">
   Standard Message Header
   <a class="headerlink leafygreen-ui-1kepx47" href="#standard-message-header" title="Permalink to this heading">
    <svg aria-label="Link Icon" class="leafygreen-ui-a30zj9" fill="none" height="12" role="img" viewbox="0 0 16 16" width="12" xmlns="http://www.w3.org/2000/svg">
     <path d="M6.039 9.953a3.596 3.596 0 0 1-.327-.38l1.45-1.445a1.553 1.553 0 0 0 2.496.423l2.885-2.87a1.57 1.57 0 0 0 .01-2.213 1.553 1.553 0 0 0-2.203-.01l-.379.377A.995.995 0 0 1 8.56 3.83a1.005 1.005 0 0 1 .006-1.418l.38-.377a3.542 3.542 0 0 1 5.024.023 3.58 3.58 0 0 1-.022 5.047l-2.884 2.871a3.542 3.542 0 0 1-5.025-.022Z" fill="currentColor">
     </path>
     <path d="M9.961 6.047c.12.12.228.248.327.38l-1.45 1.445a1.553 1.553 0 0 0-2.496-.423l-2.885 2.87a1.57 1.57 0 0 0-.01 2.213 1.553 1.553 0 0 0 2.203.01l.379-.377a.995.995 0 0 1 1.411.006 1.005 1.005 0 0 1-.006 1.418l-.38.377a3.542 3.542 0 0 1-5.024-.023 3.58 3.58 0 0 1 .022-5.047l2.884-2.871a3.542 3.542 0 0 1 5.025.022Z" fill="currentColor">
     </path>
    </svg>
    <div class="css-1btu0w3 evvkmar0" id="standard-message-header">
    </div>
   </a>
  </h2>
  <p class="leafygreen-ui-1kp3ins">
   In general, each message consists of a standard message header followed
by request-specific data. The standard message header is structured as
follows:
  </p>
  <script class="structured_data" type="application/ld+json">
   {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"struct MsgHeader {\n    int32   messageLength; // total message size, including this\n    int32   requestID;     // identifier for this message\n    int32   responseTo;    // requestID from the original request\n                           //   (used in responses from the database)\n    int32   opCode;        // message type\n}","programmingLanguage":"C"}
  </script>
  <div class="css-16lmvu9">
   <div class="leafygreen-ui-196mwvg">
    <div class="leafygreen-ui-1b1bvay">
     <pre class="leafygreen-ui-11itue3" tabindex="0"><code class="lg-highlight-hljs-light c leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx"><span class="lg-highlight-keyword lg-highlight-class">struct</span><span class="lg-highlight-class"> </span><span class="lg-highlight-title lg-highlight-class">MsgHeader</span><span class="lg-highlight-class"> {</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx">    int32   messageLength; <span class="lg-highlight-comment">// total message size, including this</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx">    int32   requestID;     <span class="lg-highlight-comment">//</span><span class="lg-highlight-comment"> identifier for this </span><span class="lg-highlight-comment">message</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx">    int32   responseTo;    <span class="lg-highlight-comment">// requestID</span><span class="lg-highlight-comment"> from the original </span><span class="lg-highlight-comment">request</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx">                           <span class="lg-highlight-comment">//   (used</span><span class="lg-highlight-comment"> in responses from </span><span class="lg-highlight-comment">the database)</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx">    int32   opCode;        <span class="lg-highlight-comment">// message type</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx">}</td></tr></tbody></table></code></pre>
     <div class="leafygreen-ui-1bqcprk" data-testid="leafygreen-code-panel">
      <button aria-disabled="false" aria-label="Copy" class="leafygreen-ui-1c6zwke" data-testid="code_copy-button" tabindex="0">
       <div class="leafygreen-ui-xhlipt">
        <svg aria-label="Copy Icon" class="leafygreen-ui-1st74h4" height="16" role="img" viewbox="0 0 16 16" width="16">
         <path clip-rule="evenodd" d="M1 5.71428V10.2857C1 11.2325 1.76751 12 2.71429 12H5.75V7.10957C5.75 6.54414 5.97724 6.00244 6.38065 5.60623L8.67403 3.35381C8.77447 3.25516 8.88376 3.16757 9 3.09182V2.71429C9 1.76751 8.23249 1 7.28571 1H5.8V4.42857C5.8 5.13865 5.22437 5.71428 4.51429 5.71428H1ZM9 4.78571L7.25654 6.49804C7.24689 6.50752 7.23749 6.5172 7.22834 6.52708C7.22208 6.53383 7.21594 6.54068 7.20991 6.54762C7.07504 6.70295 7 6.90234 7 7.10957V7.79762H9H10.0095C10.4829 7.79762 10.8667 7.41386 10.8667 6.94047V4H10.1505C9.92587 4 9.7102 4.0882 9.54992 4.24562L9 4.78571ZM4.86667 1H4.15053C3.92587 1 3.7102 1.0882 3.54992 1.24562L1.25654 3.49804C1.09244 3.65921 1 3.87957 1 4.10957V4.79762H4.00952C4.48291 4.79762 4.86667 4.41386 4.86667 3.94047V1ZM7 12V8.71428H9H10.5143C11.2244 8.71428 11.8 8.13865 11.8 7.42857V4H13.2857C14.2325 4 15 4.76751 15 5.71429V13.2857C15 14.2325 14.2325 15 13.2857 15H8.71429C7.76751 15 7 14.2325 7 13.2857V12Z" fill="currentColor" fill-rule="evenodd">
         </path>
        </svg>
       </div>
      </button>
     </div>
    </div>
   </div>
  </div>
  <div class="leafygreen-ui-skkc39" tabindex="0">
   <table class="leafygreen-ui-hr8lsv">
    <colgroup>
     <col style="width:20%"/>
     <col style="width:80%"/>
    </colgroup>
    <thead class="leafygreen-ui-a9ho40">
     <tr data-testid="leafygreen-ui-header-row">
      <th class="leafygreen-ui-1trtg6r" role="columnheader" scope="col">
       <div class="leafygreen-ui-ui0te9">
        <div>
         Field
        </div>
       </div>
      </th>
      <th class="leafygreen-ui-13uteka" role="columnheader" scope="col">
       <div class="leafygreen-ui-ui0te9">
        <div>
         Description
        </div>
       </div>
      </th>
     </tr>
    </thead>
    <tbody>
     <tr class="">
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         <code class="leafygreen-ui-1l06pbn">
          messageLength
         </code>
        </div>
       </div>
      </td>
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         The total size of the message in bytes. This total includes the
4 bytes that holds the message length.
        </div>
       </div>
      </td>
     </tr>
     <tr class="">
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         <code class="leafygreen-ui-1l06pbn">
          requestID
         </code>
        </div>
       </div>
      </td>
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         A client or database-generated identifier that uniquely
identifies the message.
        </div>
       </div>
      </td>
     </tr>
     <tr class="">
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         <code class="leafygreen-ui-1l06pbn">
          responseTo
         </code>
        </div>
       </div>
      </td>
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         The
         <code class="leafygreen-ui-1l06pbn">
          requestID
         </code>
         taken from the messages from the client.
        </div>
       </div>
      </td>
     </tr>
     <tr class="">
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         <code class="leafygreen-ui-1l06pbn">
          opCode
         </code>
        </div>
       </div>
      </td>
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         Type of message. See
         <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-wp-request-opcodes" target="_self">
          <span>
           Opcodes
          </span>
         </a>
         for details.
        </div>
       </div>
      </td>
     </tr>
    </tbody>
   </table>
  </div>
  <span class="leafygreen-ui-1qnjd6d" id="std-label-wp-request-opcodes">
  </span>
 </section>
 <section>
  <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium">
   Opcodes
   <a class="headerlink leafygreen-ui-1kepx47" href="#opcodes" title="Permalink to this heading">
    <svg aria-label="Link Icon" class="leafygreen-ui-a30zj9" fill="none" height="12" role="img" viewbox="0 0 16 16" width="12" xmlns="http://www.w3.org/2000/svg">
     <path d="M6.039 9.953a3.596 3.596 0 0 1-.327-.38l1.45-1.445a1.553 1.553 0 0 0 2.496.423l2.885-2.87a1.57 1.57 0 0 0 .01-2.213 1.553 1.553 0 0 0-2.203-.01l-.379.377A.995.995 0 0 1 8.56 3.83a1.005 1.005 0 0 1 .006-1.418l.38-.377a3.542 3.542 0 0 1 5.024.023 3.58 3.58 0 0 1-.022 5.047l-2.884 2.871a3.542 3.542 0 0 1-5.025-.022Z" fill="currentColor">
     </path>
     <path d="M9.961 6.047c.12.12.228.248.327.38l-1.45 1.445a1.553 1.553 0 0 0-2.496-.423l-2.885 2.87a1.57 1.57 0 0 0-.01 2.213 1.553 1.553 0 0 0 2.203.01l.379-.377a.995.995 0 0 1 1.411.006 1.005 1.005 0 0 1-.006 1.418l-.38.377a3.542 3.542 0 0 1-5.024-.023 3.58 3.58 0 0 1 .022-5.047l2.884-2.871a3.542 3.542 0 0 1 5.025.022Z" fill="currentColor">
     </path>
    </svg>
    <div class="css-1btu0w3 evvkmar0" id="opcodes">
    </div>
   </a>
  </h2>
  <p class="leafygreen-ui-1kp3ins">
   MongoDB uses these
   <code class="leafygreen-ui-1l06pbn">
    opCode
   </code>
   values:
  </p>
  <div class="leafygreen-ui-skkc39" tabindex="0">
   <table class="leafygreen-ui-hr8lsv">
    <colgroup>
     <col style="width:35%"/>
     <col style="width:10%"/>
     <col style="width:65%"/>
    </colgroup>
    <thead class="leafygreen-ui-a9ho40">
     <tr data-testid="leafygreen-ui-header-row">
      <th class="leafygreen-ui-1trtg6r" role="columnheader" scope="col">
       <div class="leafygreen-ui-ui0te9">
        <div>
         Opcode Name
        </div>
       </div>
      </th>
      <th class="leafygreen-ui-13uteka" role="columnheader" scope="col">
       <div class="leafygreen-ui-ui0te9">
        <div>
         Value
        </div>
       </div>
      </th>
      <th class="leafygreen-ui-13uteka" role="columnheader" scope="col">
       <div class="leafygreen-ui-ui0te9">
        <div>
         Comment
        </div>
       </div>
      </th>
     </tr>
    </thead>
    <tbody>
     <tr class="leafygreen-ui-15dvrnp">
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         <code class="leafygreen-ui-1l06pbn">
          OP_COMPRESSED
         </code>
        </div>
       </div>
      </td>
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         2012
        </div>
       </div>
      </td>
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         Wraps other opcodes using compression
        </div>
       </div>
      </td>
     </tr>
     <tr class="leafygreen-ui-15dvrnp">
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         <code class="leafygreen-ui-1l06pbn">
          OP_MSG
         </code>
        </div>
       </div>
      </td>
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         2013
        </div>
       </div>
      </td>
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         Send a message using the standard format. Used for both client
requests and database replies.
        </div>
       </div>
      </td>
     </tr>
     <tr class="leafygreen-ui-15dvrnp">
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         <div class="line-block">
          <div class="line">
           <code class="leafygreen-ui-1l06pbn">
            OP_REPLY
           </code>
          </div>
         </div>
         <div class="line-block">
          <div class="line">
           <em>
            Deprecated in MongoDB 5.0. Removed in MongoDB 5.1.
           </em>
          </div>
         </div>
        </div>
       </div>
      </td>
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         1
        </div>
       </div>
      </td>
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         Reply to a client request.
         <code class="leafygreen-ui-1l06pbn">
          responseTo
         </code>
         is set.
        </div>
       </div>
      </td>
     </tr>
     <tr class="leafygreen-ui-15dvrnp">
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         <div class="line-block">
          <div class="line">
           <code class="leafygreen-ui-1l06pbn">
            OP_UPDATE
           </code>
          </div>
         </div>
         <div class="line-block">
          <div class="line">
           <em>
            Deprecated in MongoDB 5.0. Removed in MongoDB 5.1.
           </em>
          </div>
         </div>
        </div>
       </div>
      </td>
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         2001
        </div>
       </div>
      </td>
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         Update document.
        </div>
       </div>
      </td>
     </tr>
     <tr class="leafygreen-ui-15dvrnp">
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         <div class="line-block">
          <div class="line">
           <code class="leafygreen-ui-1l06pbn">
            OP_INSERT
           </code>
          </div>
         </div>
         <div class="line-block">
          <div class="line">
           <em>
            Deprecated in MongoDB 5.0. Removed in MongoDB 5.1.
           </em>
          </div>
         </div>
        </div>
       </div>
      </td>
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         2002
        </div>
       </div>
      </td>
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         Insert new document.
        </div>
       </div>
      </td>
     </tr>
     <tr class="leafygreen-ui-15dvrnp">
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         <code class="leafygreen-ui-1l06pbn">
          RESERVED
         </code>
        </div>
       </div>
      </td>
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         2003
        </div>
       </div>
      </td>
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         Formerly used for OP_GET_BY_OID.
        </div>
       </div>
      </td>
     </tr>
     <tr class="leafygreen-ui-15dvrnp">
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         <div class="line-block">
          <div class="line">
           <code class="leafygreen-ui-1l06pbn">
            OP_QUERY
           </code>
          </div>
         </div>
         <div class="line-block">
          <div class="line">
           <em>
            Deprecated in MongoDB 5.0. Removed in MongoDB 5.1.
           </em>
          </div>
         </div>
        </div>
       </div>
      </td>
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         2004
        </div>
       </div>
      </td>
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         Query a collection.
        </div>
       </div>
      </td>
     </tr>
     <tr class="leafygreen-ui-15dvrnp">
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         <div class="line-block">
          <div class="line">
           <code class="leafygreen-ui-1l06pbn">
            OP_GET_MORE
           </code>
          </div>
         </div>
         <div class="line-block">
          <div class="line">
           <em>
            Deprecated in MongoDB 5.0. Removed in MongoDB 5.1.
           </em>
          </div>
         </div>
        </div>
       </div>
      </td>
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         2005
        </div>
       </div>
      </td>
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         Get more data from a query. See Cursors.
        </div>
       </div>
      </td>
     </tr>
     <tr class="leafygreen-ui-15dvrnp">
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         <div class="line-block">
          <div class="line">
           <code class="leafygreen-ui-1l06pbn">
            OP_DELETE
           </code>
          </div>
         </div>
         <div class="line-block">
          <div class="line">
           <em>
            Deprecated in MongoDB 5.0. Removed in MongoDB 5.1.
           </em>
          </div>
         </div>
        </div>
       </div>
      </td>
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         2006
        </div>
       </div>
      </td>
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         Delete documents.
        </div>
       </div>
      </td>
     </tr>
     <tr class="leafygreen-ui-15dvrnp">
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         <div class="line-block">
          <div class="line">
           <code class="leafygreen-ui-1l06pbn">
            OP_KILL_CURSORS
           </code>
          </div>
         </div>
         <div class="line-block">
          <div class="line">
           <em>
            Deprecated in MongoDB 5.0. Removed in MongoDB 5.1.
           </em>
          </div>
         </div>
        </div>
       </div>
      </td>
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         2007
        </div>
       </div>
      </td>
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         Notify database that the client has finished with the cursor.
        </div>
       </div>
      </td>
     </tr>
    </tbody>
   </table>
  </div>
  <span class="leafygreen-ui-1qnjd6d" id="std-label-wire-op-compressed">
  </span>
  <section>
   <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium">
    <code class="leafygreen-ui-1l06pbn">
     OP_COMPRESSED
    </code>
    <a class="headerlink leafygreen-ui-1kepx47" href="#op_compressed" title="Permalink to this heading">
     <svg aria-label="Link Icon" class="leafygreen-ui-a30zj9" fill="none" height="12" role="img" viewbox="0 0 16 16" width="12" xmlns="http://www.w3.org/2000/svg">
      <path d="M6.039 9.953a3.596 3.596 0 0 1-.327-.38l1.45-1.445a1.553 1.553 0 0 0 2.496.423l2.885-2.87a1.57 1.57 0 0 0 .01-2.213 1.553 1.553 0 0 0-2.203-.01l-.379.377A.995.995 0 0 1 8.56 3.83a1.005 1.005 0 0 1 .006-1.418l.38-.377a3.542 3.542 0 0 1 5.024.023 3.58 3.58 0 0 1-.022 5.047l-2.884 2.871a3.542 3.542 0 0 1-5.025-.022Z" fill="currentColor">
      </path>
      <path d="M9.961 6.047c.12.12.228.248.327.38l-1.45 1.445a1.553 1.553 0 0 0-2.496-.423l-2.885 2.87a1.57 1.57 0 0 0-.01 2.213 1.553 1.553 0 0 0 2.203.01l.379-.377a.995.995 0 0 1 1.411.006 1.005 1.005 0 0 1-.006 1.418l-.38.377a3.542 3.542 0 0 1-5.024-.023 3.58 3.58 0 0 1 .022-5.047l2.884-2.871a3.542 3.542 0 0 1 5.025.022Z" fill="currentColor">
      </path>
     </svg>
     <div class="css-1btu0w3 evvkmar0" id="op_compressed">
     </div>
    </a>
   </h3>
   <p class="leafygreen-ui-1kp3ins">
    Any opcode can be compressed and wrapped in an
    <code class="leafygreen-ui-1l06pbn">
     OP_COMPRESSED
    </code>
    header.
The
    <code class="leafygreen-ui-1l06pbn">
     OP_COMPRESSED
    </code>
    message contains the original compressed opcode
message alongside the metadata necessary to process and decompress it.
   </p>
   <p class="leafygreen-ui-1kp3ins">
    The format of the
    <code class="leafygreen-ui-1l06pbn">
     OP_COMPRESSED
    </code>
    message is:
   </p>
   <script class="structured_data" type="application/ld+json">
    {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"struct {\n    MsgHeader header;            // standard message header\n    int32  originalOpcode;       // value of wrapped opcode\n    int32  uncompressedSize;     // size of deflated compressedMessage, excluding MsgHeader\n    uint8  compressorId;         // ID of compressor that compressed message\n    char    *compressedMessage;  // opcode itself, excluding MsgHeader\n}","programmingLanguage":"Bash"}
   </script>
   <div class="css-16lmvu9">
    <div class="leafygreen-ui-196mwvg">
     <div class="leafygreen-ui-1b1bvay">
      <pre class="leafygreen-ui-11itue3" tabindex="0"><code class="lg-highlight-hljs-light bash leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">struct {</td></tr><tr class=""><td class="leafygreen-ui-7razhx">    MsgHeader header;            // standard message header</td></tr><tr class=""><td class="leafygreen-ui-7razhx">    int32  originalOpcode;       // value of wrapped opcode</td></tr><tr class=""><td class="leafygreen-ui-7razhx">    int32  uncompressedSize;     // size of deflated compressedMessage, excluding MsgHeader</td></tr><tr class=""><td class="leafygreen-ui-7razhx">    uint8  compressorId;         // ID of compressor that compressed message</td></tr><tr class=""><td class="leafygreen-ui-7razhx">    char    *compressedMessage;  // opcode itself, excluding MsgHeader</td></tr><tr class=""><td class="leafygreen-ui-7razhx">}</td></tr></tbody></table></code></pre>
      <div class="leafygreen-ui-1bqcprk" data-testid="leafygreen-code-panel">
       <button aria-disabled="false" aria-label="Copy" class="leafygreen-ui-1c6zwke" data-testid="code_copy-button" tabindex="0">
        <div class="leafygreen-ui-xhlipt">
         <svg aria-label="Copy Icon" class="leafygreen-ui-1st74h4" height="16" role="img" viewbox="0 0 16 16" width="16">
          <path clip-rule="evenodd" d="M1 5.71428V10.2857C1 11.2325 1.76751 12 2.71429 12H5.75V7.10957C5.75 6.54414 5.97724 6.00244 6.38065 5.60623L8.67403 3.35381C8.77447 3.25516 8.88376 3.16757 9 3.09182V2.71429C9 1.76751 8.23249 1 7.28571 1H5.8V4.42857C5.8 5.13865 5.22437 5.71428 4.51429 5.71428H1ZM9 4.78571L7.25654 6.49804C7.24689 6.50752 7.23749 6.5172 7.22834 6.52708C7.22208 6.53383 7.21594 6.54068 7.20991 6.54762C7.07504 6.70295 7 6.90234 7 7.10957V7.79762H9H10.0095C10.4829 7.79762 10.8667 7.41386 10.8667 6.94047V4H10.1505C9.92587 4 9.7102 4.0882 9.54992 4.24562L9 4.78571ZM4.86667 1H4.15053C3.92587 1 3.7102 1.0882 3.54992 1.24562L1.25654 3.49804C1.09244 3.65921 1 3.87957 1 4.10957V4.79762H4.00952C4.48291 4.79762 4.86667 4.41386 4.86667 3.94047V1ZM7 12V8.71428H9H10.5143C11.2244 8.71428 11.8 8.13865 11.8 7.42857V4H13.2857C14.2325 4 15 4.76751 15 5.71429V13.2857C15 14.2325 14.2325 15 13.2857 15H8.71429C7.76751 15 7 14.2325 7 13.2857V12Z" fill="currentColor" fill-rule="evenodd">
          </path>
         </svg>
        </div>
       </button>
      </div>
     </div>
    </div>
   </div>
   <div class="leafygreen-ui-skkc39" tabindex="0">
    <table class="leafygreen-ui-hr8lsv">
     <colgroup>
      <col style="width:25%"/>
      <col style="width:75%"/>
     </colgroup>
     <thead class="leafygreen-ui-a9ho40">
      <tr data-testid="leafygreen-ui-header-row">
       <th class="leafygreen-ui-1trtg6r" role="columnheader" scope="col">
        <div class="leafygreen-ui-ui0te9">
         <div>
          Field
         </div>
        </div>
       </th>
       <th class="leafygreen-ui-13uteka" role="columnheader" scope="col">
        <div class="leafygreen-ui-ui0te9">
         <div>
          Description
         </div>
        </div>
       </th>
      </tr>
     </thead>
     <tbody>
      <tr class="leafygreen-ui-15dvrnp">
       <td class="leafygreen-ui-1drjk7h">
        <div class="leafygreen-ui-1n4j8xf">
         <div>
          <code class="leafygreen-ui-1l06pbn">
           MsgHeader
          </code>
         </div>
        </div>
       </td>
       <td class="leafygreen-ui-1drjk7h">
        <div class="leafygreen-ui-1n4j8xf">
         <div>
          Message header, as described in
          <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-wp-message-header" target="_self">
           <span>
            Standard Message Header
            <!-- -->
            .
           </span>
          </a>
         </div>
        </div>
       </td>
      </tr>
      <tr class="leafygreen-ui-15dvrnp">
       <td class="leafygreen-ui-1drjk7h">
        <div class="leafygreen-ui-1n4j8xf">
         <div>
          <code class="leafygreen-ui-1l06pbn">
           originalOpcode
          </code>
         </div>
        </div>
       </td>
       <td class="leafygreen-ui-1drjk7h">
        <div class="leafygreen-ui-1n4j8xf">
         <div>
          Contains the value of the wrapped opcode.
         </div>
        </div>
       </td>
      </tr>
      <tr class="leafygreen-ui-15dvrnp">
       <td class="leafygreen-ui-1drjk7h">
        <div class="leafygreen-ui-1n4j8xf">
         <div>
          <code class="leafygreen-ui-1l06pbn">
           uncompressedSize
          </code>
         </div>
        </div>
       </td>
       <td class="leafygreen-ui-1drjk7h">
        <div class="leafygreen-ui-1n4j8xf">
         <div>
          The size of the deflated
          <code class="leafygreen-ui-1l06pbn">
           compressedMessage
          </code>
          , which excludes
the
          <code class="leafygreen-ui-1l06pbn">
           MsgHeader
          </code>
          .
         </div>
        </div>
       </td>
      </tr>
      <tr class="leafygreen-ui-15dvrnp">
       <td class="leafygreen-ui-1drjk7h">
        <div class="leafygreen-ui-1n4j8xf">
         <div>
          <code class="leafygreen-ui-1l06pbn">
           compressorId
          </code>
         </div>
        </div>
       </td>
       <td class="leafygreen-ui-1drjk7h">
        <div class="leafygreen-ui-1n4j8xf">
         <div>
          The ID of the compressor that compressed the message. A list of
          <code class="leafygreen-ui-1l06pbn">
           compressorId
          </code>
          values is provided below.
         </div>
        </div>
       </td>
      </tr>
      <tr class="leafygreen-ui-15dvrnp">
       <td class="leafygreen-ui-1drjk7h">
        <div class="leafygreen-ui-1n4j8xf">
         <div>
          <code class="leafygreen-ui-1l06pbn">
           compressedMessage
          </code>
         </div>
        </div>
       </td>
       <td class="leafygreen-ui-1drjk7h">
        <div class="leafygreen-ui-1n4j8xf">
         <div>
          The opcode itself, excluding the
          <code class="leafygreen-ui-1l06pbn">
           MsgHeader
          </code>
          .
         </div>
        </div>
       </td>
      </tr>
     </tbody>
    </table>
   </div>
   <p class="leafygreen-ui-1kp3ins">
    Each compressor is assigned a predefined compressor ID as follows:
   </p>
   <div class="leafygreen-ui-skkc39" tabindex="0">
    <table class="leafygreen-ui-hr8lsv">
     <colgroup>
      <col style="width:15%"/>
      <col style="width:25%"/>
      <col style="width:60%"/>
     </colgroup>
     <thead class="leafygreen-ui-a9ho40">
      <tr data-testid="leafygreen-ui-header-row">
       <th class="leafygreen-ui-1trtg6r" role="columnheader" scope="col">
        <div class="leafygreen-ui-ui0te9">
         <div>
          compressorId
         </div>
        </div>
       </th>
       <th class="leafygreen-ui-13uteka" role="columnheader" scope="col">
        <div class="leafygreen-ui-ui0te9">
         <div>
          Handshake Value
         </div>
        </div>
       </th>
       <th class="leafygreen-ui-13uteka" role="columnheader" scope="col">
        <div class="leafygreen-ui-ui0te9">
         <div>
          Description
         </div>
        </div>
       </th>
      </tr>
     </thead>
     <tbody>
      <tr class="leafygreen-ui-15dvrnp">
       <td class="leafygreen-ui-1drjk7h">
        <div class="leafygreen-ui-1n4j8xf">
         <div>
          <code class="leafygreen-ui-1l06pbn">
           0
          </code>
         </div>
        </div>
       </td>
       <td class="leafygreen-ui-1drjk7h">
        <div class="leafygreen-ui-1n4j8xf">
         <div>
          noop
         </div>
        </div>
       </td>
       <td class="leafygreen-ui-1drjk7h">
        <div class="leafygreen-ui-1n4j8xf">
         <div>
          The content of the message is uncompressed. This is used for
testing.
         </div>
        </div>
       </td>
      </tr>
      <tr class="leafygreen-ui-15dvrnp">
       <td class="leafygreen-ui-1drjk7h">
        <div class="leafygreen-ui-1n4j8xf">
         <div>
          <code class="leafygreen-ui-1l06pbn">
           1
          </code>
         </div>
        </div>
       </td>
       <td class="leafygreen-ui-1drjk7h">
        <div class="leafygreen-ui-1n4j8xf">
         <div>
          snappy
         </div>
        </div>
       </td>
       <td class="leafygreen-ui-1drjk7h">
        <div class="leafygreen-ui-1n4j8xf">
         <div>
          The content of the message is compressed using snappy.
         </div>
        </div>
       </td>
      </tr>
      <tr class="leafygreen-ui-15dvrnp">
       <td class="leafygreen-ui-1drjk7h">
        <div class="leafygreen-ui-1n4j8xf">
         <div>
          <code class="leafygreen-ui-1l06pbn">
           2
          </code>
         </div>
        </div>
       </td>
       <td class="leafygreen-ui-1drjk7h">
        <div class="leafygreen-ui-1n4j8xf">
         <div>
          zlib
         </div>
        </div>
       </td>
       <td class="leafygreen-ui-1drjk7h">
        <div class="leafygreen-ui-1n4j8xf">
         <div>
          The content of the message is compressed using zlib.
         </div>
        </div>
       </td>
      </tr>
      <tr class="leafygreen-ui-15dvrnp">
       <td class="leafygreen-ui-1drjk7h">
        <div class="leafygreen-ui-1n4j8xf">
         <div>
          <code class="leafygreen-ui-1l06pbn">
           3
          </code>
         </div>
        </div>
       </td>
       <td class="leafygreen-ui-1drjk7h">
        <div class="leafygreen-ui-1n4j8xf">
         <div>
          zstd
         </div>
        </div>
       </td>
       <td class="leafygreen-ui-1drjk7h">
        <div class="leafygreen-ui-1n4j8xf">
         <div>
          The content of the message is compressed using zstd.
         </div>
        </div>
       </td>
      </tr>
      <tr class="leafygreen-ui-15dvrnp">
       <td class="leafygreen-ui-1drjk7h">
        <div class="leafygreen-ui-1n4j8xf">
         <div>
          <code class="leafygreen-ui-1l06pbn">
           4-255
          </code>
         </div>
        </div>
       </td>
       <td class="leafygreen-ui-1drjk7h">
        <div class="leafygreen-ui-1n4j8xf">
         <div>
          reserved
         </div>
        </div>
       </td>
       <td class="leafygreen-ui-1drjk7h">
        <div class="leafygreen-ui-1n4j8xf">
         <div>
          Reserved for future use.
         </div>
        </div>
       </td>
      </tr>
     </tbody>
    </table>
   </div>
   <span class="leafygreen-ui-1qnjd6d" id="std-label-wire-op-msg">
   </span>
  </section>
  <section>
   <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium">
    <code class="leafygreen-ui-1l06pbn">
     OP_MSG
    </code>
    <a class="headerlink leafygreen-ui-1kepx47" href="#op_msg" title="Permalink to this heading">
     <svg aria-label="Link Icon" class="leafygreen-ui-a30zj9" fill="none" height="12" role="img" viewbox="0 0 16 16" width="12" xmlns="http://www.w3.org/2000/svg">
      <path d="M6.039 9.953a3.596 3.596 0 0 1-.327-.38l1.45-1.445a1.553 1.553 0 0 0 2.496.423l2.885-2.87a1.57 1.57 0 0 0 .01-2.213 1.553 1.553 0 0 0-2.203-.01l-.379.377A.995.995 0 0 1 8.56 3.83a1.005 1.005 0 0 1 .006-1.418l.38-.377a3.542 3.542 0 0 1 5.024.023 3.58 3.58 0 0 1-.022 5.047l-2.884 2.871a3.542 3.542 0 0 1-5.025-.022Z" fill="currentColor">
      </path>
      <path d="M9.961 6.047c.12.12.228.248.327.38l-1.45 1.445a1.553 1.553 0 0 0-2.496-.423l-2.885 2.87a1.57 1.57 0 0 0-.01 2.213 1.553 1.553 0 0 0 2.203.01l.379-.377a.995.995 0 0 1 1.411.006 1.005 1.005 0 0 1-.006 1.418l-.38.377a3.542 3.542 0 0 1-5.024-.023 3.58 3.58 0 0 1 .022-5.047l2.884-2.871a3.542 3.542 0 0 1 5.025.022Z" fill="currentColor">
      </path>
     </svg>
     <div class="css-1btu0w3 evvkmar0" id="op_msg">
     </div>
    </a>
   </h3>
   <p class="leafygreen-ui-1kp3ins">
    <code class="leafygreen-ui-1l06pbn">
     OP_MSG
    </code>
    is an extensible message format used to encode both client
requests and server replies on the wire.
   </p>
   <p class="leafygreen-ui-1kp3ins">
    <code class="leafygreen-ui-1l06pbn">
     OP_MSG
    </code>
    has the following format:
   </p>
   <script class="structured_data" type="application/ld+json">
    {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"OP_MSG {\n    MsgHeader header;           // standard message header\n    uint32 flagBits;            // message flags\n    Sections[] sections;        // data sections\n    optional&lt;uint32&gt; checksum;  // optional CRC-32C checksum\n}"}
   </script>
   <div class="css-16lmvu9">
    <div class="leafygreen-ui-196mwvg">
     <div class="leafygreen-ui-1b1bvay">
      <pre class="leafygreen-ui-11itue3" tabindex="0"><code class="lg-highlight-hljs-light none leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">OP_MSG {</td></tr><tr class=""><td class="leafygreen-ui-7razhx">    MsgHeader header;           // standard message header</td></tr><tr class=""><td class="leafygreen-ui-7razhx">    uint32 flagBits;            // message flags</td></tr><tr class=""><td class="leafygreen-ui-7razhx">    Sections[] sections;        // data sections</td></tr><tr class=""><td class="leafygreen-ui-7razhx">    optional&lt;uint32&gt; checksum;  // optional CRC-32C checksum</td></tr><tr class=""><td class="leafygreen-ui-7razhx">}</td></tr></tbody></table></code></pre>
      <div class="leafygreen-ui-1bqcprk" data-testid="leafygreen-code-panel">
       <button aria-disabled="false" aria-label="Copy" class="leafygreen-ui-1c6zwke" data-testid="code_copy-button" tabindex="0">
        <div class="leafygreen-ui-xhlipt">
         <svg aria-label="Copy Icon" class="leafygreen-ui-1st74h4" height="16" role="img" viewbox="0 0 16 16" width="16">
          <path clip-rule="evenodd" d="M1 5.71428V10.2857C1 11.2325 1.76751 12 2.71429 12H5.75V7.10957C5.75 6.54414 5.97724 6.00244 6.38065 5.60623L8.67403 3.35381C8.77447 3.25516 8.88376 3.16757 9 3.09182V2.71429C9 1.76751 8.23249 1 7.28571 1H5.8V4.42857C5.8 5.13865 5.22437 5.71428 4.51429 5.71428H1ZM9 4.78571L7.25654 6.49804C7.24689 6.50752 7.23749 6.5172 7.22834 6.52708C7.22208 6.53383 7.21594 6.54068 7.20991 6.54762C7.07504 6.70295 7 6.90234 7 7.10957V7.79762H9H10.0095C10.4829 7.79762 10.8667 7.41386 10.8667 6.94047V4H10.1505C9.92587 4 9.7102 4.0882 9.54992 4.24562L9 4.78571ZM4.86667 1H4.15053C3.92587 1 3.7102 1.0882 3.54992 1.24562L1.25654 3.49804C1.09244 3.65921 1 3.87957 1 4.10957V4.79762H4.00952C4.48291 4.79762 4.86667 4.41386 4.86667 3.94047V1ZM7 12V8.71428H9H10.5143C11.2244 8.71428 11.8 8.13865 11.8 7.42857V4H13.2857C14.2325 4 15 4.76751 15 5.71429V13.2857C15 14.2325 14.2325 15 13.2857 15H8.71429C7.76751 15 7 14.2325 7 13.2857V12Z" fill="currentColor" fill-rule="evenodd">
          </path>
         </svg>
        </div>
       </button>
      </div>
     </div>
    </div>
   </div>
   <div class="leafygreen-ui-skkc39" tabindex="0">
    <table class="leafygreen-ui-hr8lsv">
     <colgroup>
      <col style="width:20%"/>
      <col style="width:80%"/>
     </colgroup>
     <thead class="leafygreen-ui-a9ho40">
      <tr data-testid="leafygreen-ui-header-row">
       <th class="leafygreen-ui-1trtg6r" role="columnheader" scope="col">
        <div class="leafygreen-ui-ui0te9">
         <div>
          Field
         </div>
        </div>
       </th>
       <th class="leafygreen-ui-13uteka" role="columnheader" scope="col">
        <div class="leafygreen-ui-ui0te9">
         <div>
          Description
         </div>
        </div>
       </th>
      </tr>
     </thead>
     <tbody>
      <tr class="">
       <td class="leafygreen-ui-1drjk7h">
        <div class="leafygreen-ui-1n4j8xf">
         <div>
          <code class="leafygreen-ui-1l06pbn">
           header
          </code>
         </div>
        </div>
       </td>
       <td class="leafygreen-ui-1drjk7h">
        <div class="leafygreen-ui-1n4j8xf">
         <div>
          Standard message header, as described in
          <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-wp-message-header" target="_self">
           <span>
            Standard Message Header
            <!-- -->
            .
           </span>
          </a>
         </div>
        </div>
       </td>
      </tr>
      <tr class="">
       <td class="leafygreen-ui-1drjk7h">
        <div class="leafygreen-ui-1n4j8xf">
         <div>
          <code class="leafygreen-ui-1l06pbn">
           flagBits
          </code>
         </div>
        </div>
       </td>
       <td class="leafygreen-ui-1drjk7h">
        <div class="leafygreen-ui-1n4j8xf">
         <div>
          An integer bitmask containing message flags, as described in
          <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-wire-msg-flags" target="_self">
           <span>
            Flag Bits
            <!-- -->
            .
           </span>
          </a>
         </div>
        </div>
       </td>
      </tr>
      <tr class="">
       <td class="leafygreen-ui-1drjk7h">
        <div class="leafygreen-ui-1n4j8xf">
         <div>
          <code class="leafygreen-ui-1l06pbn">
           sections
          </code>
         </div>
        </div>
       </td>
       <td class="leafygreen-ui-1drjk7h">
        <div class="leafygreen-ui-1n4j8xf">
         <div>
          Message body sections, as described in
          <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-wire-msg-sections" target="_self">
           <span>
            Sections
            <!-- -->
            .
           </span>
          </a>
         </div>
        </div>
       </td>
      </tr>
      <tr class="">
       <td class="leafygreen-ui-1drjk7h">
        <div class="leafygreen-ui-1n4j8xf">
         <div>
          <code class="leafygreen-ui-1l06pbn">
           checksum
          </code>
         </div>
        </div>
       </td>
       <td class="leafygreen-ui-1drjk7h">
        <div class="leafygreen-ui-1n4j8xf">
         <div>
          An optional CRC-32C checksum, as described in
          <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-wire-msg-checksum" target="_self">
           <span>
            Checksum
            <!-- -->
            .
           </span>
          </a>
         </div>
        </div>
       </td>
      </tr>
     </tbody>
    </table>
   </div>
   <span class="leafygreen-ui-1qnjd6d" id="std-label-wire-msg-flags">
   </span>
   <section>
    <h4 class="contains-headerlink leafygreen-ui-1vzlt5f">
     Flag Bits
     <a class="headerlink leafygreen-ui-1kepx47" href="#flag-bits" title="Permalink to this heading">
      <svg aria-label="Link Icon" class="leafygreen-ui-a30zj9" fill="none" height="12" role="img" viewbox="0 0 16 16" width="12" xmlns="http://www.w3.org/2000/svg">
       <path d="M6.039 9.953a3.596 3.596 0 0 1-.327-.38l1.45-1.445a1.553 1.553 0 0 0 2.496.423l2.885-2.87a1.57 1.57 0 0 0 .01-2.213 1.553 1.553 0 0 0-2.203-.01l-.379.377A.995.995 0 0 1 8.56 3.83a1.005 1.005 0 0 1 .006-1.418l.38-.377a3.542 3.542 0 0 1 5.024.023 3.58 3.58 0 0 1-.022 5.047l-2.884 2.871a3.542 3.542 0 0 1-5.025-.022Z" fill="currentColor">
       </path>
       <path d="M9.961 6.047c.12.12.228.248.327.38l-1.45 1.445a1.553 1.553 0 0 0-2.496-.423l-2.885 2.87a1.57 1.57 0 0 0-.01 2.213 1.553 1.553 0 0 0 2.203.01l.379-.377a.995.995 0 0 1 1.411.006 1.005 1.005 0 0 1-.006 1.418l-.38.377a3.542 3.542 0 0 1-5.024-.023 3.58 3.58 0 0 1 .022-5.047l2.884-2.871a3.542 3.542 0 0 1 5.025.022Z" fill="currentColor">
       </path>
      </svg>
      <div class="css-1btu0w3 evvkmar0" id="flag-bits">
      </div>
     </a>
    </h4>
    <p class="leafygreen-ui-1kp3ins">
     The
     <code class="leafygreen-ui-1l06pbn">
      flagBits
     </code>
     integer is a bitmask encoding flags that modify the
format and behavior of
     <code class="leafygreen-ui-1l06pbn">
      OP_MSG
     </code>
     .
    </p>
    <p class="leafygreen-ui-1kp3ins">
     The first 16 bits (0-15) are
     <em>
      required
     </em>
     and parsers
     <strong>
      MUST
     </strong>
     error if an unknown bit is set.
    </p>
    <p class="leafygreen-ui-1kp3ins">
     The last 16 bits (16-31) are
     <em>
      optional
     </em>
     , and parsers
     <strong>
      MUST
     </strong>
     ignore any unknown set bits. Proxies and other message forwarders
     <strong>
      MUST
     </strong>
     clear any unknown optional bits before forwarding messages.
    </p>
    <div class="header-buffer" id="ref-f1-id1">
    </div>
    <div class="leafygreen-ui-skkc39" tabindex="0">
     <table class="leafygreen-ui-hr8lsv">
      <colgroup>
       <col style="width:10%"/>
       <col style="width:20%"/>
       <col style="width:10%"/>
       <col style="width:10%"/>
       <col style="width:60%"/>
      </colgroup>
      <thead class="leafygreen-ui-a9ho40">
       <tr data-testid="leafygreen-ui-header-row">
        <th class="leafygreen-ui-1trtg6r" role="columnheader" scope="col">
         <div class="leafygreen-ui-ui0te9">
          <div>
           Bit
          </div>
         </div>
        </th>
        <th class="leafygreen-ui-13uteka" role="columnheader" scope="col">
         <div class="leafygreen-ui-ui0te9">
          <div>
           Name
          </div>
         </div>
        </th>
        <th class="leafygreen-ui-13uteka" role="columnheader" scope="col">
         <div class="leafygreen-ui-ui0te9">
          <div>
           Request
          </div>
         </div>
        </th>
        <th class="leafygreen-ui-13uteka" role="columnheader" scope="col">
         <div class="leafygreen-ui-ui0te9">
          <div>
           Response
          </div>
         </div>
        </th>
        <th class="leafygreen-ui-13uteka" role="columnheader" scope="col">
         <div class="leafygreen-ui-ui0te9">
          <div>
           Description
          </div>
         </div>
        </th>
       </tr>
      </thead>
      <tbody>
       <tr class="">
        <td class="leafygreen-ui-1drjk7h">
         <div class="leafygreen-ui-1n4j8xf">
          <div>
           0
          </div>
         </div>
        </td>
        <td class="leafygreen-ui-1drjk7h">
         <div class="leafygreen-ui-1n4j8xf">
          <div>
           <code class="leafygreen-ui-1l06pbn">
            checksumPresent
           </code>
          </div>
         </div>
        </td>
        <td class="leafygreen-ui-1drjk7h">
         <div class="leafygreen-ui-1n4j8xf">
          <div>
           <p class="leafygreen-ui-1kp3ins">
            ✓
           </p>
          </div>
         </div>
        </td>
        <td class="leafygreen-ui-1drjk7h">
         <div class="leafygreen-ui-1n4j8xf">
          <div>
           <p class="leafygreen-ui-1kp3ins">
            ✓
           </p>
          </div>
         </div>
        </td>
        <td class="leafygreen-ui-1drjk7h">
         <div class="leafygreen-ui-1n4j8xf">
          <div>
           The message ends with 4 bytes containing a CRC-32C
           <a class="footnote-reference header-buffer" href="#footnote-f1" id="ref-f1-id1">
            [
            <!-- -->
            2
            <!-- -->
            ]
           </a>
           checksum. See
           <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-wire-msg-checksum" target="_self">
            <span>
             Checksum
            </span>
           </a>
           for details.
          </div>
         </div>
        </td>
       </tr>
       <tr class="">
        <td class="leafygreen-ui-1drjk7h">
         <div class="leafygreen-ui-1n4j8xf">
          <div>
           1
          </div>
         </div>
        </td>
        <td class="leafygreen-ui-1drjk7h">
         <div class="leafygreen-ui-1n4j8xf">
          <div>
           <code class="leafygreen-ui-1l06pbn">
            moreToCome
           </code>
          </div>
         </div>
        </td>
        <td class="leafygreen-ui-1drjk7h">
         <div class="leafygreen-ui-1n4j8xf">
          <div>
           <p class="leafygreen-ui-1kp3ins">
            ✓
           </p>
          </div>
         </div>
        </td>
        <td class="leafygreen-ui-1drjk7h">
         <div class="leafygreen-ui-1n4j8xf">
          <div>
           <p class="leafygreen-ui-1kp3ins">
            ✓
           </p>
          </div>
         </div>
        </td>
        <td class="leafygreen-ui-1drjk7h">
         <div class="leafygreen-ui-1n4j8xf">
          <div>
           Another message will follow this one without further action from
the receiver. The receiver
           <strong>
            MUST NOT
           </strong>
           send another message until
receiving one with
           <code class="leafygreen-ui-1l06pbn">
            moreToCome
           </code>
           set to 0 as sends may block,
causing deadlock. Requests with the
           <code class="leafygreen-ui-1l06pbn">
            moreToCome
           </code>
           bit set will not receive a reply. Replies will only have this
set in response to requests with the
           <code class="leafygreen-ui-1l06pbn">
            exhaustAllowed
           </code>
           bit set.
          </div>
         </div>
        </td>
       </tr>
       <tr class="">
        <td class="leafygreen-ui-1drjk7h">
         <div class="leafygreen-ui-1n4j8xf">
          <div>
           16
          </div>
         </div>
        </td>
        <td class="leafygreen-ui-1drjk7h">
         <div class="leafygreen-ui-1n4j8xf">
          <div>
           <code class="leafygreen-ui-1l06pbn">
            exhaustAllowed
           </code>
          </div>
         </div>
        </td>
        <td class="leafygreen-ui-1drjk7h">
         <div class="leafygreen-ui-1n4j8xf">
          <div>
           <p class="leafygreen-ui-1kp3ins">
            ✓
           </p>
          </div>
         </div>
        </td>
        <td class="leafygreen-ui-1drjk7h">
         <div class="leafygreen-ui-1n4j8xf">
          <div>
          </div>
         </div>
        </td>
        <td class="leafygreen-ui-1drjk7h">
         <div class="leafygreen-ui-1n4j8xf">
          <div>
           <p class="leafygreen-ui-1kp3ins">
            The client is prepared for multiple replies to this request using
the
            <code class="leafygreen-ui-1l06pbn">
             moreToCome
            </code>
            bit. The server will never produce replies with
the
            <code class="leafygreen-ui-1l06pbn">
             moreToCome
            </code>
            bit set unless the request has this bit set.
           </p>
           <p class="leafygreen-ui-1kp3ins">
            This ensures that multiple replies are only sent when the network
layer of the requester is prepared for them.
           </p>
          </div>
         </div>
        </td>
       </tr>
      </tbody>
     </table>
    </div>
    <span class="leafygreen-ui-1qnjd6d" id="std-label-wire-msg-sections">
    </span>
   </section>
   <section>
    <h4 class="contains-headerlink leafygreen-ui-1vzlt5f">
     Sections
     <a class="headerlink leafygreen-ui-1kepx47" href="#sections" title="Permalink to this heading">
      <svg aria-label="Link Icon" class="leafygreen-ui-a30zj9" fill="none" height="12" role="img" viewbox="0 0 16 16" width="12" xmlns="http://www.w3.org/2000/svg">
       <path d="M6.039 9.953a3.596 3.596 0 0 1-.327-.38l1.45-1.445a1.553 1.553 0 0 0 2.496.423l2.885-2.87a1.57 1.57 0 0 0 .01-2.213 1.553 1.553 0 0 0-2.203-.01l-.379.377A.995.995 0 0 1 8.56 3.83a1.005 1.005 0 0 1 .006-1.418l.38-.377a3.542 3.542 0 0 1 5.024.023 3.58 3.58 0 0 1-.022 5.047l-2.884 2.871a3.542 3.542 0 0 1-5.025-.022Z" fill="currentColor">
       </path>
       <path d="M9.961 6.047c.12.12.228.248.327.38l-1.45 1.445a1.553 1.553 0 0 0-2.496-.423l-2.885 2.87a1.57 1.57 0 0 0-.01 2.213 1.553 1.553 0 0 0 2.203.01l.379-.377a.995.995 0 0 1 1.411.006 1.005 1.005 0 0 1-.006 1.418l-.38.377a3.542 3.542 0 0 1-5.024-.023 3.58 3.58 0 0 1 .022-5.047l2.884-2.871a3.542 3.542 0 0 1 5.025.022Z" fill="currentColor">
       </path>
      </svg>
      <div class="css-1btu0w3 evvkmar0" id="sections">
      </div>
     </a>
    </h4>
    <p class="leafygreen-ui-1kp3ins">
     An
     <code class="leafygreen-ui-1l06pbn">
      OP_MSG
     </code>
     message contains one or more sections. Each section starts
with a
     <code class="leafygreen-ui-1l06pbn">
      kind
     </code>
     byte indicating its type. Everything after the
     <code class="leafygreen-ui-1l06pbn">
      kind
     </code>
     byte constitutes the section's payload.
    </p>
    <p class="leafygreen-ui-1kp3ins">
     The available kinds of sections follow.
    </p>
   </section>
   <section>
    <h4 class="contains-headerlink leafygreen-ui-1vzlt5f">
     Kind 0: Body
     <a class="headerlink leafygreen-ui-1kepx47" href="#kind-0--body" title="Permalink to this heading">
      <svg aria-label="Link Icon" class="leafygreen-ui-a30zj9" fill="none" height="12" role="img" viewbox="0 0 16 16" width="12" xmlns="http://www.w3.org/2000/svg">
       <path d="M6.039 9.953a3.596 3.596 0 0 1-.327-.38l1.45-1.445a1.553 1.553 0 0 0 2.496.423l2.885-2.87a1.57 1.57 0 0 0 .01-2.213 1.553 1.553 0 0 0-2.203-.01l-.379.377A.995.995 0 0 1 8.56 3.83a1.005 1.005 0 0 1 .006-1.418l.38-.377a3.542 3.542 0 0 1 5.024.023 3.58 3.58 0 0 1-.022 5.047l-2.884 2.871a3.542 3.542 0 0 1-5.025-.022Z" fill="currentColor">
       </path>
       <path d="M9.961 6.047c.12.12.228.248.327.38l-1.45 1.445a1.553 1.553 0 0 0-2.496-.423l-2.885 2.87a1.57 1.57 0 0 0-.01 2.213 1.553 1.553 0 0 0 2.203.01l.379-.377a.995.995 0 0 1 1.411.006 1.005 1.005 0 0 1-.006 1.418l-.38.377a3.542 3.542 0 0 1-5.024-.023 3.58 3.58 0 0 1 .022-5.047l2.884-2.871a3.542 3.542 0 0 1 5.025.022Z" fill="currentColor">
       </path>
      </svg>
      <div class="css-1btu0w3 evvkmar0" id="kind-0--body">
      </div>
     </a>
    </h4>
    <p class="leafygreen-ui-1kp3ins">
     A body section is encoded as a
     <strong>
      single
     </strong>
     <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/bson-types/#std-label-bson-types">
      BSON object
     </a>
     .
The size in the BSON object also serves as the size of the section. This
section kind is the standard command request and reply body.
    </p>
    <p class="leafygreen-ui-1kp3ins">
     All top-level fields
     <strong>
      MUST
     </strong>
     have a unique name.
    </p>
   </section>
   <section>
    <h4 class="contains-headerlink leafygreen-ui-1vzlt5f">
     Kind 1: Document Sequence
     <a class="headerlink leafygreen-ui-1kepx47" href="#kind-1--document-sequence" title="Permalink to this heading">
      <svg aria-label="Link Icon" class="leafygreen-ui-a30zj9" fill="none" height="12" role="img" viewbox="0 0 16 16" width="12" xmlns="http://www.w3.org/2000/svg">
       <path d="M6.039 9.953a3.596 3.596 0 0 1-.327-.38l1.45-1.445a1.553 1.553 0 0 0 2.496.423l2.885-2.87a1.57 1.57 0 0 0 .01-2.213 1.553 1.553 0 0 0-2.203-.01l-.379.377A.995.995 0 0 1 8.56 3.83a1.005 1.005 0 0 1 .006-1.418l.38-.377a3.542 3.542 0 0 1 5.024.023 3.58 3.58 0 0 1-.022 5.047l-2.884 2.871a3.542 3.542 0 0 1-5.025-.022Z" fill="currentColor">
       </path>
       <path d="M9.961 6.047c.12.12.228.248.327.38l-1.45 1.445a1.553 1.553 0 0 0-2.496-.423l-2.885 2.87a1.57 1.57 0 0 0-.01 2.213 1.553 1.553 0 0 0 2.203.01l.379-.377a.995.995 0 0 1 1.411.006 1.005 1.005 0 0 1-.006 1.418l-.38.377a3.542 3.542 0 0 1-5.024-.023 3.58 3.58 0 0 1 .022-5.047l2.884-2.871a3.542 3.542 0 0 1 5.025.022Z" fill="currentColor">
       </path>
      </svg>
      <div class="css-1btu0w3 evvkmar0" id="kind-1--document-sequence">
      </div>
     </a>
    </h4>
    <div class="leafygreen-ui-skkc39" tabindex="0">
     <table class="leafygreen-ui-hr8lsv">
      <colgroup>
       <col style="width:30%"/>
       <col style="width:70%"/>
      </colgroup>
      <thead class="leafygreen-ui-a9ho40">
       <tr data-testid="leafygreen-ui-header-row">
        <th class="leafygreen-ui-1trtg6r" role="columnheader" scope="col">
         <div class="leafygreen-ui-ui0te9">
          <div>
           Type
          </div>
         </div>
        </th>
        <th class="leafygreen-ui-13uteka" role="columnheader" scope="col">
         <div class="leafygreen-ui-ui0te9">
          <div>
           Description
          </div>
         </div>
        </th>
       </tr>
      </thead>
      <tbody>
       <tr class="">
        <td class="leafygreen-ui-1drjk7h">
         <div class="leafygreen-ui-1n4j8xf">
          <div>
           int32
          </div>
         </div>
        </td>
        <td class="leafygreen-ui-1drjk7h">
         <div class="leafygreen-ui-1n4j8xf">
          <div>
           Size of the section in bytes.
          </div>
         </div>
        </td>
       </tr>
       <tr class="">
        <td class="leafygreen-ui-1drjk7h">
         <div class="leafygreen-ui-1n4j8xf">
          <div>
           C String
          </div>
         </div>
        </td>
        <td class="leafygreen-ui-1drjk7h">
         <div class="leafygreen-ui-1n4j8xf">
          <div>
           <p class="leafygreen-ui-1kp3ins">
            Document sequence identifier. In all current commands this field
is the (possibly nested) field that it is replacing from the body
section.
           </p>
           <p class="leafygreen-ui-1kp3ins">
            This field
            <strong>
             MUST NOT
            </strong>
            also exist in the body section.
           </p>
          </div>
         </div>
        </td>
       </tr>
       <tr class="">
        <td class="leafygreen-ui-1drjk7h">
         <div class="leafygreen-ui-1n4j8xf">
          <div>
           Zero or more BSON objects
          </div>
         </div>
        </td>
        <td class="leafygreen-ui-1drjk7h">
         <div class="leafygreen-ui-1n4j8xf">
          <div>
           <ul class="leafygreen-ui-rioki0">
            <li class="leafygreen-ui-d7p7b6">
             <p class="leafygreen-ui-1kp3ins">
              Objects are sequenced back to back with no separators.
             </p>
            </li>
            <li class="leafygreen-ui-d7p7b6">
             <p class="leafygreen-ui-1kp3ins">
              Each object is limited to the
              <code class="leafygreen-ui-1l06pbn">
               maxBSONObjectSize
              </code>
              of the
server. The combination of all objects is not limited to
              <code class="leafygreen-ui-1l06pbn">
               maxBSONObjSize
              </code>
              .
             </p>
            </li>
            <li class="leafygreen-ui-d7p7b6">
             <p class="leafygreen-ui-1kp3ins">
              The document sequence ends once
              <code class="leafygreen-ui-1l06pbn">
               size
              </code>
              bytes have been consumed.
             </p>
            </li>
            <li class="leafygreen-ui-d7p7b6">
             <p class="leafygreen-ui-1kp3ins">
              Parsers
              <strong>
               MAY
              </strong>
              choose to merge these objects into the body as
an array at the path specified by the sequence identifier when
converting to language-level objects.
             </p>
            </li>
           </ul>
          </div>
         </div>
        </td>
       </tr>
      </tbody>
     </table>
    </div>
   </section>
   <section>
    <h4 class="contains-headerlink leafygreen-ui-1vzlt5f">
     Kind 2
     <a class="headerlink leafygreen-ui-1kepx47" href="#kind-2" title="Permalink to this heading">
      <svg aria-label="Link Icon" class="leafygreen-ui-a30zj9" fill="none" height="12" role="img" viewbox="0 0 16 16" width="12" xmlns="http://www.w3.org/2000/svg">
       <path d="M6.039 9.953a3.596 3.596 0 0 1-.327-.38l1.45-1.445a1.553 1.553 0 0 0 2.496.423l2.885-2.87a1.57 1.57 0 0 0 .01-2.213 1.553 1.553 0 0 0-2.203-.01l-.379.377A.995.995 0 0 1 8.56 3.83a1.005 1.005 0 0 1 .006-1.418l.38-.377a3.542 3.542 0 0 1 5.024.023 3.58 3.58 0 0 1-.022 5.047l-2.884 2.871a3.542 3.542 0 0 1-5.025-.022Z" fill="currentColor">
       </path>
       <path d="M9.961 6.047c.12.12.228.248.327.38l-1.45 1.445a1.553 1.553 0 0 0-2.496-.423l-2.885 2.87a1.57 1.57 0 0 0-.01 2.213 1.553 1.553 0 0 0 2.203.01l.379-.377a.995.995 0 0 1 1.411.006 1.005 1.005 0 0 1-.006 1.418l-.38.377a3.542 3.542 0 0 1-5.024-.023 3.58 3.58 0 0 1 .022-5.047l2.884-2.871a3.542 3.542 0 0 1 5.025.022Z" fill="currentColor">
       </path>
      </svg>
      <div class="css-1btu0w3 evvkmar0" id="kind-2">
      </div>
     </a>
    </h4>
    <p class="leafygreen-ui-1kp3ins">
     This section is used for internal purposes.
    </p>
    <span class="leafygreen-ui-1qnjd6d" id="std-label-wire-msg-checksum">
    </span>
   </section>
   <section>
    <h4 class="contains-headerlink leafygreen-ui-1vzlt5f">
     Checksum
     <a class="headerlink leafygreen-ui-1kepx47" href="#checksum" title="Permalink to this heading">
      <svg aria-label="Link Icon" class="leafygreen-ui-a30zj9" fill="none" height="12" role="img" viewbox="0 0 16 16" width="12" xmlns="http://www.w3.org/2000/svg">
       <path d="M6.039 9.953a3.596 3.596 0 0 1-.327-.38l1.45-1.445a1.553 1.553 0 0 0 2.496.423l2.885-2.87a1.57 1.57 0 0 0 .01-2.213 1.553 1.553 0 0 0-2.203-.01l-.379.377A.995.995 0 0 1 8.56 3.83a1.005 1.005 0 0 1 .006-1.418l.38-.377a3.542 3.542 0 0 1 5.024.023 3.58 3.58 0 0 1-.022 5.047l-2.884 2.871a3.542 3.542 0 0 1-5.025-.022Z" fill="currentColor">
       </path>
       <path d="M9.961 6.047c.12.12.228.248.327.38l-1.45 1.445a1.553 1.553 0 0 0-2.496-.423l-2.885 2.87a1.57 1.57 0 0 0-.01 2.213 1.553 1.553 0 0 0 2.203.01l.379-.377a.995.995 0 0 1 1.411.006 1.005 1.005 0 0 1-.006 1.418l-.38.377a3.542 3.542 0 0 1-5.024-.023 3.58 3.58 0 0 1 .022-5.047l2.884-2.871a3.542 3.542 0 0 1 5.025.022Z" fill="currentColor">
       </path>
      </svg>
      <div class="css-1btu0w3 evvkmar0" id="checksum">
      </div>
     </a>
    </h4>
    <p class="leafygreen-ui-1kp3ins">
     Each message
     <strong>
      MAY
     </strong>
     end with a CRC-32C
     <a class="footnote-reference header-buffer" href="#footnote-f1" id="ref-f1-id2">
      [
      <!-- -->
      2
      <!-- -->
      ]
     </a>
     checksum that covers all
bytes in the message except for the checksum itself.
    </p>
    <p class="leafygreen-ui-1kp3ins">
     If you do not use TLS/SSL connections,
     <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod">
      <code class="leafygreen-ui-1l06pbn">
       mongod
      </code>
     </a>
     instances and
     <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongos/#mongodb-binary-bin.mongos">
      <code class="leafygreen-ui-1l06pbn">
       mongos
      </code>
     </a>
     instances exchange messages with checksums.
    </p>
    <p class="leafygreen-ui-1kp3ins">
     If you use TLS/SSL connections,
     <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod">
      <code class="leafygreen-ui-1l06pbn">
       mongod
      </code>
     </a>
     instances and
     <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongos/#mongodb-binary-bin.mongos">
      <code class="leafygreen-ui-1l06pbn">
       mongos
      </code>
     </a>
     instances skip the checksum.
    </p>
    <p class="leafygreen-ui-1kp3ins">
     Drivers and older binaries will ignore the checksum if presented with
messages with checksum.
    </p>
    <p class="leafygreen-ui-1kp3ins">
     The presence of a checksum is indicated by the
     <code class="leafygreen-ui-1l06pbn">
      checksumPresent
     </code>
     flag
bit.
    </p>
   </section>
  </section>
  <section>
   <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium">
    Legacy Opcodes
    <a class="headerlink leafygreen-ui-1kepx47" href="#legacy-opcodes" title="Permalink to this heading">
     <svg aria-label="Link Icon" class="leafygreen-ui-a30zj9" fill="none" height="12" role="img" viewbox="0 0 16 16" width="12" xmlns="http://www.w3.org/2000/svg">
      <path d="M6.039 9.953a3.596 3.596 0 0 1-.327-.38l1.45-1.445a1.553 1.553 0 0 0 2.496.423l2.885-2.87a1.57 1.57 0 0 0 .01-2.213 1.553 1.553 0 0 0-2.203-.01l-.379.377A.995.995 0 0 1 8.56 3.83a1.005 1.005 0 0 1 .006-1.418l.38-.377a3.542 3.542 0 0 1 5.024.023 3.58 3.58 0 0 1-.022 5.047l-2.884 2.871a3.542 3.542 0 0 1-5.025-.022Z" fill="currentColor">
      </path>
      <path d="M9.961 6.047c.12.12.228.248.327.38l-1.45 1.445a1.553 1.553 0 0 0-2.496-.423l-2.885 2.87a1.57 1.57 0 0 0-.01 2.213 1.553 1.553 0 0 0 2.203.01l.379-.377a.995.995 0 0 1 1.411.006 1.005 1.005 0 0 1-.006 1.418l-.38.377a3.542 3.542 0 0 1-5.024-.023 3.58 3.58 0 0 1 .022-5.047l2.884-2.871a3.542 3.542 0 0 1 5.025.022Z" fill="currentColor">
      </path>
     </svg>
     <div class="css-1btu0w3 evvkmar0" id="legacy-opcodes">
     </div>
    </a>
   </h3>
   <p class="leafygreen-ui-1kp3ins">
    Starting in MongoDB 5.1, these opcodes are removed in favor of
    <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-wire-op-msg" target="_self">
     <span>
      OP_MSG
      <!-- -->
      :
     </span>
    </a>
   </p>
   <ul class="leafygreen-ui-rioki0">
    <li class="leafygreen-ui-d7p7b6">
     <p class="leafygreen-ui-1kp3ins">
      <code class="leafygreen-ui-1l06pbn">
       OP_DELETE
      </code>
     </p>
    </li>
    <li class="leafygreen-ui-d7p7b6">
     <p class="leafygreen-ui-1kp3ins">
      <code class="leafygreen-ui-1l06pbn">
       OP_GET_MORE
      </code>
     </p>
    </li>
    <li class="leafygreen-ui-d7p7b6">
     <p class="leafygreen-ui-1kp3ins">
      <code class="leafygreen-ui-1l06pbn">
       OP_INSERT
      </code>
     </p>
    </li>
    <li class="leafygreen-ui-d7p7b6">
     <p class="leafygreen-ui-1kp3ins">
      <code class="leafygreen-ui-1l06pbn">
       OP_KILL_CURSORS
      </code>
     </p>
    </li>
    <li class="leafygreen-ui-d7p7b6">
     <p class="leafygreen-ui-1kp3ins">
      <code class="leafygreen-ui-1l06pbn">
       OP_QUERY
      </code>
      <a class="footnote-reference header-buffer" href="#footnote-op-query-footnote" id="ref-op-query-footnote-id3">
       [
       <!-- -->
       1
       <!-- -->
       ]
      </a>
     </p>
    </li>
    <li class="leafygreen-ui-d7p7b6">
     <p class="leafygreen-ui-1kp3ins">
      <code class="leafygreen-ui-1l06pbn">
       OP_REPLY
      </code>
     </p>
    </li>
    <li class="leafygreen-ui-d7p7b6">
     <p class="leafygreen-ui-1kp3ins">
      <code class="leafygreen-ui-1l06pbn">
       OP_UPDATE
      </code>
     </p>
    </li>
   </ul>
   <p class="leafygreen-ui-1kp3ins">
    If you are running an older version of MongoDB and need detailed
information on the previous opcodes, see
    <a class="leafygreen-ui-tqgtui" href="/docs/manual/legacy-opcodes/#std-label-wire-legacy-opcodes">
     Legacy Opcodes
     <!-- -->
     .
    </a>
   </p>
   <p class="css-1j389vi">
    Footnotes
   </p>
   <table class="header-buffer leafygreen-ui-rbqgrl" frame="void" id="footnote-op-query-footnote" rules="none">
    <colgroup>
     <col/>
    </colgroup>
    <tbody valign="top">
     <tr>
      <td class="leafygreen-ui-17r2xs0">
       [
       <a href="#ref-op-query-footnote-id3">
        1
       </a>
       ]
      </td>
      <td class="leafygreen-ui-17r2xs0">
       <!-- -->
       MongoDB 5.1 removes support for both
       <code class="leafygreen-ui-1l06pbn">
        OP_QUERY
       </code>
       find operations
and
       <code class="leafygreen-ui-1l06pbn">
        OP_QUERY
       </code>
       commands. As an exception,
       <code class="leafygreen-ui-1l06pbn">
        OP_QUERY
       </code>
       is still
supported for running the
       <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/command/hello/#mongodb-dbcommand-dbcmd.hello">
        <code class="leafygreen-ui-1l06pbn">
         hello
        </code>
       </a>
       and
       <code class="leafygreen-ui-1l06pbn">
        isMaster
       </code>
       commands as part of the connection handshake.
      </td>
     </tr>
    </tbody>
   </table>
   <table class="header-buffer leafygreen-ui-rbqgrl" frame="void" id="footnote-f1" rules="none">
    <colgroup>
     <col/>
    </colgroup>
    <tbody valign="top">
     <tr>
      <td class="leafygreen-ui-17r2xs0">
       [
       <!-- -->
       2
       <!-- -->
       ]
      </td>
      <td class="leafygreen-ui-17r2xs0">
       <em>
        (
        <a href="#ref-f1-id1">
         1
        </a>
        ,
        <a href="#ref-f1-id2">
         2
        </a>
        )
       </em>
       <!-- -->
       32-bit
       <span class="leafygreen-ui-vm4wms" tabindex="0">
        CRC
       </span>
       computed with the Castagnoli polynomial as
described by
       <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://tools.ietf.org/html/rfc4960#page-140" rel="noopener noreferrer">
        <span>
         https://tools.ietf.org/html/rfc4960#page-140
         <!-- -->
         .
        </span>
        <svg alt="" aria-hidden="true" class="leafygreen-ui-1ie5kuq" height="16" role="presentation" viewbox="0 0 16 16" width="16">
         <path d="M13.823 2.4491C13.8201 2.30008 13.6999 2.17994 13.5509 2.17704L9.5062 2.09836C9.25654 2.09351 9.12821 2.39519 9.30482 2.5718L10.3856 3.65257L7.93433 6.10383C7.87964 6.15852 7.83047 6.21665 7.78683 6.27752L5.99909 8.06525C5.46457 8.59977 5.46457 9.4664 5.99909 10.0009C6.53361 10.5354 7.40023 10.5354 7.93475 10.0009L9.72249 8.21317C9.78336 8.16953 9.84148 8.12037 9.89618 8.06567L12.3474 5.61441L13.4282 6.69518C13.6048 6.87179 13.9065 6.74347 13.9016 6.4938L13.823 2.4491Z" fill="currentColor">
         </path>
         <path d="M7.25 3.12893C7.66421 3.12893 8 3.46472 8 3.87893C8 4.29315 7.66421 4.62893 7.25 4.62893H4C3.72386 4.62893 3.5 4.85279 3.5 5.12893V11.9929C3.5 12.2691 3.72386 12.4929 4 12.4929H10.864C11.1401 12.4929 11.364 12.2691 11.364 11.9929V8.75C11.364 8.33579 11.6998 8 12.114 8C12.5282 8 12.864 8.33579 12.864 8.75V11.9929C12.864 13.0975 11.9686 13.9929 10.864 13.9929H4C2.89543 13.9929 2 13.0975 2 11.9929V5.12893C2 4.02436 2.89543 3.12893 4 3.12893H7.25Z" fill="currentColor">
         </path>
        </svg>
       </a>
      </td>
     </tr>
    </tbody>
   </table>
  </section>
 </section>
</section>
