WebSocket ============ .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow **What is WebSocket?** WebSocket is a communication protocol that provides full-duplex, bidirectional communication channels over a single TCP connection. It is designed to allow real-time interaction between a client (like a browser) and a server with minimal overhead. .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow **Why is WebSocket useful?** * Real-time communication – Enables low-latency, two-way data exchange * Reduced overhead – Unlike HTTP, headers are sent only once during the initial handshake * Persistent connection – Keeps a single connection open for ongoing interaction * Ideal for live updates – Great for chat, gaming, and real-time dashboards .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow **How it works?** * **Handshake** – Starts with an HTTP request to establish a WebSocket connection * **Upgrade** – If accepted, the protocol upgrades to WebSocket * **Open connection** – A persistent connection remains open * **Data exchange** – Messages can be sent in both directions at any time * **Close** – Either side can close the connection when done .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow **Where is WebSocket used?** * Online gaming – For real-time multiplayer synchronization * Chat applications – Enables instant messaging * Live sports and stock tickers – For pushing real-time data updates * Collaborative tools – Like whiteboards or shared editing platforms .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow **Which OSI layer does WebSocket belong to?** * WebSocket defines message formats and communication logic for applications * It builds on top of TCP (via HTTP) but operates at the application level * It belongs to the **Application Layer (Layer 7)** of the OSI model .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow Topics in this section, * :ref:`Learnings in this section ` * :ref:`Terminology ` * :ref:`Version Info ` * :ref:`WebSocket Version&RFC Details ` * :ref:`WebSocket Basic Setup on Ubuntu using IPv4 ` * :ref:`WebSocket Basic Setup on Ubuntu using IPv6 ` * :ref:`WebSocket Protocol Packet Details ` * :ref:`WebSocket Usecases ` * :ref:`WebSocket Basic Features ` * :ref:`WebSocket Feature : Full Duplex Communication ` * :ref:`WebSocket Feature : Persistent Connection ` * :ref:`WebSocket Feature : Low Latency ` * :ref:`WebSocket Feature : Light weight Protocol ` * :ref:`WebSocket Feature : Real Time Data Transfer ` * :ref:`WebSocket Feature : Cross Platform Support ` * :ref:`WebSocket Feature : Firewall Friendly ` * :ref:`WebSocket Feature : Binary and Text Support ` * :ref:`WebSocket Feature : Built in Ping Pong Frames ` * :ref:`WebSocket Feature : Protocol Upgrade from HTTP ` * :ref:`Reference links ` .. _WebSocket_step1: .. tab-set:: .. tab-item:: Learnings in this section * In this section, you are going to learn .. _WebSocket_step2: .. tab-set:: .. tab-item:: Terminology * Terminology .. _WebSocket_step3: .. tab-set:: .. tab-item:: Version Info * Version Info .. _WebSocket_step5: .. tab-set:: .. tab-item:: WebSocket Version&RFC Details .. csv-table:: :file: ./WebSocket/WebSocket_rfcdetails.csv :widths: 10,10,10,30 :header-rows: 1 .. _WebSocket_step19: .. tab-set:: .. tab-item:: WebSocket Basic Setup on Ubuntu using IPv4 * setup .. _WebSocket_step20: .. tab-set:: .. tab-item:: WebSocket Basic Setup on Ubuntu using IPv6 * setup .. _WebSocket_step6: .. tab-set:: .. tab-item:: WebSocket Protocol Packet Details **Client Handshake Request Packet** .. csv-table:: :file: ./WebSocket/WebSocket_packetdetails1.csv :widths: 10,20,30,10 :header-rows: 1 **Server Handshake Response Packet** .. csv-table:: :file: ./WebSocket/WebSocket_packetdetails2.csv :widths: 10,20,30,10 :header-rows: 1 **Data Frame Packet** .. csv-table:: :file: ./WebSocket/WebSocket_packetdetails3.csv :widths: 10,20,30,10 :header-rows: 1 **Control Frame Packet** .. csv-table:: :file: ./WebSocket/WebSocket_packetdetails4.csv :widths: 10,20,30,10 :header-rows: 1 .. _WebSocket_step7: .. tab-set:: .. tab-item:: WebSocket Usecases .. csv-table:: :file: ./WebSocket/WebSocket_usecases.csv :widths: 10,20,30 :header-rows: 1 .. _WebSocket_step8: .. tab-set:: .. tab-item:: WebSocket Basic Features .. csv-table:: :file: ./WebSocket/WebSocket_basicfeatures.csv :widths: 10,10,30 :header-rows: 1 .. _WebSocket_step9: .. tab-set:: .. tab-item:: WebSocket Feature : Full Duplex Communication **Full Duplex Communication - Testcases** .. csv-table:: :file: ./WebSocket/WebSocket_feature1_Full_Duplex_Communication_testcases.csv :widths: 10,10,30,20 :header-rows: 1 .. _WebSocket_step10: .. tab-set:: .. tab-item:: WebSocket Feature : Persistent Connection **Persistent Connection - Testcases** .. csv-table:: :file: ./WebSocket/WebSocket_feature2_Persistent_Connection_testcases.csv :widths: 10,10,30,20 :header-rows: 1 .. _WebSocket_step11: .. tab-set:: .. tab-item:: WebSocket Feature : Low Latency **Low Latency - Testcases** .. csv-table:: :file: ./WebSocket/WebSocket_feature3_Low_Latency_testcases.csv :widths: 10,10,30,20 :header-rows: 1 .. _WebSocket_step12: .. tab-set:: .. tab-item:: WebSocket Feature : Light weight Protocol **Light weight Protocol - Testcases** .. csv-table:: :file: ./WebSocket/WebSocket_feature4_Light_weight_Protocol_testcases.csv :widths: 10,10,30,20 :header-rows: 1 .. _WebSocket_step13: .. tab-set:: .. tab-item:: WebSocket Feature : Real Time Data Transfer **Real Time Data Transfer - Testcases** .. csv-table:: :file: ./WebSocket/WebSocket_feature5_Real_Time_Data_Transfer_testcases.csv :widths: 10,10,30,20 :header-rows: 1 .. _WebSocket_step14: .. tab-set:: .. tab-item:: WebSocket Feature : Cross Platform Support **Cross Platform Support - Testcases** .. csv-table:: :file: ./WebSocket/WebSocket_feature6_Cross_Platform_Support_testcases.csv :widths: 10,10,30,20 :header-rows: 1 .. _WebSocket_step15: .. tab-set:: .. tab-item:: WebSocket Feature : Firewall Friendly **Firewall Friendly - Testcases** .. csv-table:: :file: ./WebSocket/WebSocket_feature7_Firewall_Friendly_testcases.csv :widths: 10,10,30,20 :header-rows: 1 .. _WebSocket_step16: .. tab-set:: .. tab-item:: WebSocket Feature : Binary and Text Support **Binary and Text Support - Testcases** .. csv-table:: :file: ./WebSocket/WebSocket_feature8_Binary_and_Text_Support_testcases.csv :widths: 10,10,30,20 :header-rows: 1 .. _WebSocket_step17: .. tab-set:: .. tab-item:: WebSocket Feature : Built in Ping Pong Frames **Built in Ping Pong Frames - Testcases** .. csv-table:: :file: ./WebSocket/WebSocket_feature9_Built_in_Ping_Pong_Frames_testcases.csv :widths: 10,10,30,20 :header-rows: 1 .. _WebSocket_step21: .. tab-set:: .. tab-item:: WebSocket Feature : Protocol Upgrade from HTTP **Protocol Upgrade from HTTP - Testcases** .. csv-table:: :file: ./WebSocket/WebSocket_feature10_Protocol_Upgrade_from_HTTP_testcases.csv :widths: 10,10,30,20 :header-rows: 1 .. _WebSocket_step18: .. tab-set:: .. tab-item:: Reference links * Reference links