> Agent-readable docs index: /llms.txt. Download /docs.zip to grep all markdown files locally.

---
title: Network Channel
icon: arrow-down-up
---

# <ApiPageIcon icon="arrow-down-up" />Network Channel

## netchan<ApiTag label="global table" />

Statistics for the current network connection to the game server. All fields are read-only.

Each field is read from the engine's net channel at the moment you access it. When the game is
not connected to a server, every field is **nil**.

<ApiMembers>
  <ApiMember kind="prop" name="netchan.address" summary="The address of the server." ret="[[{&#x22;s&#x22;:&#x22;string&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/base#string&#x22;},{&#x22;s&#x22;:&#x22;?&#x22;}]]" />

  <ApiMember kind="prop" name="netchan.avg_data" summary="The average amount of data in bytes per second, for each direction." ret="[[{&#x22;s&#x22;:&#x22;netchan.FLOW.Value&#x22;,&#x22;k&#x22;:&#x22;class&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/networking/netchan#netchan-FLOW-Value&#x22;},{&#x22;s&#x22;:&#x22;?&#x22;}]]" />

  <ApiMember kind="prop" name="netchan.avg_latency" summary="The average network ping, in seconds." ret="[[{&#x22;s&#x22;:&#x22;number&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/base#number&#x22;},{&#x22;s&#x22;:&#x22;?&#x22;}]]" />

  <ApiMember kind="prop" name="netchan.avg_packets" summary="The average number of packets per second, for each direction." ret="[[{&#x22;s&#x22;:&#x22;netchan.FLOW.Value&#x22;,&#x22;k&#x22;:&#x22;class&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/networking/netchan#netchan-FLOW-Value&#x22;},{&#x22;s&#x22;:&#x22;?&#x22;}]]" />

  <ApiMember kind="prop" name="netchan.data_rate" summary="The data rate set for the connection, in bytes per second." ret="[[{&#x22;s&#x22;:&#x22;number&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/base#number&#x22;},{&#x22;s&#x22;:&#x22;?&#x22;}]]" />

  <ApiMember kind="prop" name="netchan.dropped" summary="The fraction of packets that were dropped, for each direction." ret="[[{&#x22;s&#x22;:&#x22;netchan.FLOW.Value&#x22;,&#x22;k&#x22;:&#x22;class&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/networking/netchan#netchan-FLOW-Value&#x22;},{&#x22;s&#x22;:&#x22;?&#x22;}]]" />

  <ApiMember kind="prop" name="netchan.engine_latency" summary="The outgoing ping that the engine measures, in seconds." ret="[[{&#x22;s&#x22;:&#x22;number&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/base#number&#x22;},{&#x22;s&#x22;:&#x22;?&#x22;}]]" />

  <ApiMember kind="prop" name="netchan.is_localhost" summary="Whether the server runs on the local computer." ret="[[{&#x22;s&#x22;:&#x22;boolean&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/base#boolean&#x22;},{&#x22;s&#x22;:&#x22;?&#x22;}]]" />

  <ApiMember kind="prop" name="netchan.is_loopback" summary="Whether the connection is a loopback connection." ret="[[{&#x22;s&#x22;:&#x22;boolean&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/base#boolean&#x22;},{&#x22;s&#x22;:&#x22;?&#x22;}]]" />

  <ApiMember kind="prop" name="netchan.is_playback" summary="Whether a demo is playing. This is `false` for a live connection." ret="[[{&#x22;s&#x22;:&#x22;boolean&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/base#boolean&#x22;},{&#x22;s&#x22;:&#x22;?&#x22;}]]" />

  <ApiMember kind="prop" name="netchan.is_timing_out" summary="Whether the connection is timing out at the moment." ret="[[{&#x22;s&#x22;:&#x22;boolean&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/base#boolean&#x22;},{&#x22;s&#x22;:&#x22;?&#x22;}]]" />

  <ApiMember kind="prop" name="netchan.late" summary="The fraction of packets that arrived too late, for each direction." ret="[[{&#x22;s&#x22;:&#x22;netchan.FLOW.Value&#x22;,&#x22;k&#x22;:&#x22;class&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/networking/netchan#netchan-FLOW-Value&#x22;},{&#x22;s&#x22;:&#x22;?&#x22;}]]" />

  <ApiMember kind="prop" name="netchan.name" summary="The name of the connection." ret="[[{&#x22;s&#x22;:&#x22;string&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/base#string&#x22;},{&#x22;s&#x22;:&#x22;?&#x22;}]]" />

  <ApiMember kind="prop" name="netchan.peak_jitter" summary="The highest delivery jitter in milliseconds, for each direction." ret="[[{&#x22;s&#x22;:&#x22;netchan.FLOW.Value&#x22;,&#x22;k&#x22;:&#x22;class&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/networking/netchan#netchan-FLOW-Value&#x22;},{&#x22;s&#x22;:&#x22;?&#x22;}]]" />

  <ApiMember kind="prop" name="netchan.sequence_nr" summary="The current packet sequence number, for each direction." ret="[[{&#x22;s&#x22;:&#x22;netchan.FLOW.Value&#x22;,&#x22;k&#x22;:&#x22;class&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/networking/netchan#netchan-FLOW-Value&#x22;},{&#x22;s&#x22;:&#x22;?&#x22;}]]" />

  <ApiMember kind="prop" name="netchan.time" summary="The current time of the net channel, in seconds." ret="[[{&#x22;s&#x22;:&#x22;number&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/base#number&#x22;},{&#x22;s&#x22;:&#x22;?&#x22;}]]" />

  <ApiMember kind="prop" name="netchan.time_connected" summary="The number of seconds since the connection was made." ret="[[{&#x22;s&#x22;:&#x22;number&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/base#number&#x22;},{&#x22;s&#x22;:&#x22;?&#x22;}]]" />

  <ApiMember kind="prop" name="netchan.time_since_last_received" summary="The number of seconds since the last packet was received." ret="[[{&#x22;s&#x22;:&#x22;number&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/base#number&#x22;},{&#x22;s&#x22;:&#x22;?&#x22;}]]" />

  <ApiMember kind="prop" name="netchan.time_until_timeout" summary="The number of seconds that are left before the connection times out." ret="[[{&#x22;s&#x22;:&#x22;number&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/base#number&#x22;},{&#x22;s&#x22;:&#x22;?&#x22;}]]" />

  <ApiMember kind="prop" name="netchan.timeout" summary="The connection timeout in seconds." ret="[[{&#x22;s&#x22;:&#x22;number&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/base#number&#x22;},{&#x22;s&#x22;:&#x22;?&#x22;}]]" />

  <ApiMember kind="prop" name="netchan.total_data" summary="The total number of bytes sent or received, for each direction." ret="[[{&#x22;s&#x22;:&#x22;netchan.FLOW.Value&#x22;,&#x22;k&#x22;:&#x22;class&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/networking/netchan#netchan-FLOW-Value&#x22;},{&#x22;s&#x22;:&#x22;?&#x22;}]]" />

  <ApiMember kind="prop" name="netchan.total_packets" summary="The total number of packets sent or received, for each direction." ret="[[{&#x22;s&#x22;:&#x22;netchan.FLOW.Value&#x22;,&#x22;k&#x22;:&#x22;class&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/networking/netchan#netchan-FLOW-Value&#x22;},{&#x22;s&#x22;:&#x22;?&#x22;}]]" />

  <ApiMember kind="fn" name="netchan.RemoteFrametime" summary="Returns the frame timing of the server, in seconds. The three values are the frame time, the standard deviation of the frame time, and the standard deviation of the frame start time." args="" sig="[{&#x22;s&#x22;:&#x22;netchan.RemoteFrametime&#x22;},{&#x22;s&#x22;:&#x22;(&#x22;},{&#x22;s&#x22;:&#x22;)&#x22;},{&#x22;s&#x22;:&#x22;: &#x22;},{&#x22;s&#x22;:&#x22;number&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/base#number&#x22;},{&#x22;s&#x22;:&#x22;?&#x22;},{&#x22;s&#x22;:&#x22;, &#x22;},{&#x22;s&#x22;:&#x22;number&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/base#number&#x22;},{&#x22;s&#x22;:&#x22;?&#x22;},{&#x22;s&#x22;:&#x22;, &#x22;},{&#x22;s&#x22;:&#x22;number&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/base#number&#x22;},{&#x22;s&#x22;:&#x22;?&#x22;}]" ret="[[{&#x22;s&#x22;:&#x22;number&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/base#number&#x22;},{&#x22;s&#x22;:&#x22;?&#x22;}],[{&#x22;s&#x22;:&#x22;number&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/base#number&#x22;},{&#x22;s&#x22;:&#x22;?&#x22;}],[{&#x22;s&#x22;:&#x22;number&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/base#number&#x22;},{&#x22;s&#x22;:&#x22;?&#x22;}]]" returns="[{&#x22;n&#x22;:&#x22;frametime&#x22;,&#x22;t&#x22;:[{&#x22;s&#x22;:&#x22;number&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/base#number&#x22;},{&#x22;s&#x22;:&#x22;?&#x22;}]},{&#x22;n&#x22;:&#x22;frametime_stddev&#x22;,&#x22;t&#x22;:[{&#x22;s&#x22;:&#x22;number&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/base#number&#x22;},{&#x22;s&#x22;:&#x22;?&#x22;}]},{&#x22;n&#x22;:&#x22;framestarttime_stddev&#x22;,&#x22;t&#x22;:[{&#x22;s&#x22;:&#x22;number&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/base#number&#x22;},{&#x22;s&#x22;:&#x22;?&#x22;}]}]" nodiscard>
    <ApiNotes>
      When the game is not connected to a server, all three values are **nil**.
    </ApiNotes>
  </ApiMember>

  <ApiMember kind="fn" name="netchan.GetInstance" summary="Returns a pointer to the net channel." args="" sig="[{&#x22;s&#x22;:&#x22;netchan.GetInstance&#x22;},{&#x22;s&#x22;:&#x22;(&#x22;},{&#x22;s&#x22;:&#x22;)&#x22;},{&#x22;s&#x22;:&#x22;: &#x22;},{&#x22;s&#x22;:&#x22;userdata&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/base#userdata&#x22;},{&#x22;s&#x22;:&#x22;?&#x22;}]" ret="[[{&#x22;s&#x22;:&#x22;userdata&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/base#userdata&#x22;},{&#x22;s&#x22;:&#x22;?&#x22;}]]" nodiscard>
    <ApiNotes>
      <Warning>
        Use this pointer only with FFI. The pointer is owned by the connection. Do not keep it after the
        game disconnects from the server.
      </Warning>
    </ApiNotes>
  </ApiMember>

  <ApiMember kind="type" name="netchan.FLOW.Value" summary="A table with one value for each direction of traffic. Use `netchan.FLOW` as the index. `[0]` is the value for outgoing traffic and `[1]` is the value for incoming traffic." ret="[[{&#x22;s&#x22;:&#x22;table&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/table#table-1&#x22;}]]" />

  <ApiMember kind="type" name="netchan.FLOW" summary="The direction of traffic. Use it as the index of a `netchan.FLOW.Value`." ret="[[{&#x22;s&#x22;:&#x22;integer&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/base#integer&#x22;}]]">
    <ApiEnum name="netchan.FLOW" values="[[&#x22;OUTGOING&#x22;,&#x22;0&#x22;,&#x22;&#x22;],[&#x22;INCOMING&#x22;,&#x22;1&#x22;,&#x22;&#x22;]]" />
  </ApiMember>
</ApiMembers>
