UPnP - Universal Plug and Play =============================== .. 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 UPnP?** UPnP (Universal Plug and Play) is a set of networking protocols that allows devices on a network to discover each other and establish functional network services automatically, without manual configuration. .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow **Why is UPnP useful?** * Automatically discovering devices (smart TVs, printers, routers) * Enabling seamless communication between devices * Reducing manual setup for port forwarding, media sharing, and device control .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow **How it works** * Device joins network: A UPnP-enabled device connects to the local network * Discovery via SSDP: Sends multicast messages announcing presence * Description exchange: Other devices retrieve device capabilities (usually XML) * Control: Devices send commands using SOAP over HTTP * Eventing: Devices subscribe and receive state change notifications * Presentation: Optional web interface for user interaction .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow **Where is UPnP used?** * Home networks (smart TVs, gaming consoles, media servers) * IoT devices (smart lights, thermostats, cameras) * Printers and scanners * Routers (automatic port forwarding) * Streaming and file sharing applications .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow **Which OSI layer does this protocol belong to?** * UPnP uses HTTP, SOAP, and XML—all application-layer protocols * Manages device discovery, service description, control commands, event notifications * High-level functions performed by applications .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow **What is SSDP’s role in UPnP?** * SSDP is the discovery protocol within UPnP * Devices advertise themselves using NOTIFY messages * Control points (clients) search for devices using M-SEARCH .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow **What devices typically support UPnP?** * Smart TVs and media players * Network printers * Game consoles (PlayStation, Xbox) * IP cameras * Routers * Home automation hubs * Streaming servers (e.g., Plex, DLNA) .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow **Can UPnP work across subnets or VLANs?** No, UPnP is designed for local LANs only. SSDP uses multicast, which generally does not cross routers unless special relay/proxy setups are in place. .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow **What are the main components of UPnP architecture?** * Devices – Provide services (e.g., media server, printer) * Control Points – Clients that discover and control devices * Services – XML-defined interfaces describing functionality * Description – Device metadata in XML format * Control – Clients send SOAP commands * Eventing – Devices notify clients about state changes (optional) * Presentation – Optional web UI for user interaction .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow **What happens if two devices provide the same UPnP service?** Clients differentiate them by: * Unique UUIDs * USN field * Different service description URLs .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow **Is UPnP only for home networks?** Mostly yes. UPnP is designed for LAN environments and does not scale well in: * WAN environments * Segmented networks without multicast forwarding .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow **Is UPnP Windows specific?** No. * UPnP is a cross-platform set of networking protocols. * Widely supported on Windows, Linux, macOS, and embedded devices. .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow **Is UPnP Linux specific?** No. * UPnP is not Linux specific. * Linux supports UPnP through various libraries and tools (e.g., MiniUPnP). .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow **Which Transport Protocol is used by UPnP?** * UPnP primarily uses UDP for discovery (SSDP). * TCP is used for control and eventing. .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow **Which Port is used by UPnP?** * UDP port 1900 (for SSDP discovery). * TCP ports are dynamically assigned for control and communication. .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow **Is UPnP using Client server model?** Yes. * UPnP uses a client-server architecture. * Devices (servers) advertise services and clients discover and control them. .. 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:`UPNP Version&IEEE Details ` * :ref:`UPNP Basic Setup on Ubuntu using IPv4 ` * :ref:`UPNP Basic Setup on Ubuntu using IPv6 ` * :ref:`UPNP Protocol Packet Details ` * :ref:`UPNP Usecases ` * :ref:`UPNP Basic Features ` * :ref:`UPNP Feature : Zero Configuration ` * :ref:`UPNP Feature : Auto Discovery ` * :ref:`UPNP Feature : Device Control ` * :ref:`UPNP Feature : Service Advertisement ` * :ref:`UPNP Feature : Event Notification ` * :ref:`UPNP Feature : Content Sharing ` * :ref:`UPNP Feature : Port Mapping ` * :ref:`UPNP Feature : Standardized Architecture ` * :ref:`UPNP Feature : Extensibility ` * :ref:`UPNP Feature : Cross Platform Support ` * :ref:`Reference links ` .. _UPNP_step1: .. tab-set:: .. tab-item:: Learnings in this section * In this section, you are going to learn .. _UPNP_step2: .. tab-set:: .. tab-item:: Terminology * Terminology .. _UPNP_step3: .. tab-set:: .. tab-item:: Version Info * Version Info .. _UPNP_step5: .. tab-set:: .. tab-item:: UPNP Version&RFC Details .. csv-table:: :file: ./UPNP/UPNP_RFCdetails.csv :widths: 10,10,10,30,30 :header-rows: 1 .. _UPNP_step20: .. tab-set:: .. tab-item:: UPNP Basic Setup on Ubuntu using IPv4 * This guide explains how to set up a basic UPnP test environment using GNS3, a physical router, and two VMs (server + client). * Step 1: creating the Network Topology * Cloud Node in GNS3 - Connect to host NIC that has access to the physical router (Wi-Fi or Ethernet). * VM1 (Server, miniupnpd)- Connected to the same Cloud/bridge. * VM2 (Client, miniupnpc) - Connected to the same Cloud/bridge. * Ensure all devices are in the same subnet (example:192.168.1.0/24). * Step 2: Enable Multicast Traffic .. code-block:: shell test:~$ sudo ip link set dev enp0s8 multicast on * Step 3: Install UPnP Tools on the both server and client VMs .. code-block:: shell test:~$ sudo apt update test:~$ sudo apt install miniupnpd miniupnpc tcpdump * Step 4: Configure UPnP Server (VM1/Router) * If using **miniupnpd** on VM1, edit the configuration file: .. code-block:: shell test:~$ sudo nano /etc/miniupnpd/miniupnpd.conf * Example Configuration .. code-block:: shell test:~$ ext_ifname=enp0s8 # WAN interface towards router. listening_ip=enp0s3 # LAN interface towards client. * Step 5: Now restart the services and get status of miniupnpd .. code-block:: shell test:~$ sudo systemctl enable miniupnpd test:~$ sudo systemctl restart miniupnpd test:~$ sudo systemctl status miniupnpd * Step 6: On VM2 (client), test discovery .. code-block:: shell test:~$ upnpc -s test:~$ upnpc -l * These commands send **M-SEARCH (SSDP discovery)** and fetch device descriptions. * Step 7: on VM2 capture the UPNP packets .. code-block:: shell test:~$ sudo tcpdump -i -nn port 1900 or port 5000 * You should see the following packet types: - **SSDP (UDP 1900)** - M-SEARCH, NOTIFY - **HTTP/SOAP (TCP, dynamic ports)** - POST /upnp/control/... * Notes: * Ensure all nodes are in the same subnet. * Check multicast traffic is not filtered. * Router/VM1 (server) should reply to client discovery requests. * Step 8: Wireshark Capture :download:`Download wireshark capture ` .. _UPNP_step21: .. tab-set:: .. tab-item:: UPNP Basic Setup on Ubuntu using IPv6 * This guide explains how to set up a basic UPnP test environment using GNS3, a physical router, and two VMs (server + client) with **IPv6 enabled**. * Step 1: creating the Network Topology * Cloud Node in GNS3 - Connect to host NIC that has access to the physical router (Wi-Fi or Ethernet). * VM1 (Server, miniupnpd)- Connected to the same Cloud/bridge. * VM2 (Client, miniupnpc) - Connected to the same Cloud/bridge. * Ensure all devices are in the same subnet (example:192.168.1.0/24). * Step 2: Assign IPv6 addresses * On VM(server) .. code-block:: shell test:~$ sudo ip -6 addr add fd00::1/64 dev test:~$ sudo ip -6 link set up * On VM(client) .. code-block:: shell test:~$ sudo ip -6 addr add fd00::2/64 dev test:~$ sudo ip -6 link set up * Verify the ping .. code-block:: shell test:~$ ping6 fd00::1 # from client test:~$ ping6 fd00::2 # from Server * Step 3: Install UPnP packages .. code-block:: shell * On both VMs test:~$ sudo apt update test:~$ sudo apt install -y miniupnpd miniupnpc * Step 4: Configure miniupnpd (server) .. code-block:: shell test:~$ sudo nnao /etc/miniupnpd/moniupnpd.conf * Example Configuration .. code-block:: shell test:~$ ext_ifname=enp0s8 #IP Interface * Step 5: Now restart the services and get status of miniupnpd .. code-block:: shell test:~$ sudo systemctl enable miniupnpd test:~$ sudo systemctl restart miniupnpd test:~$ sudo systemctl status miniupnpd * Step 6: Run UPnP client * Discover devices .. code-block:: shell test:~$ upnpc -6 -s test:~$ upnpc -6 -l * Step 7: on any VM capture the UPNP packets .. code-block:: shell test:~$ sudo tcpdump -i ip6 and udp port 1900 -w upnp-ipv6.pcap * You should see the following packet types: - **SSDP (UDP 1900)** - M-SEARCH, NOTIFY - **HTTP/SOAP (TCP, dynamic ports)** - POST /upnp/control/... * Step 8: Wireshark Capture :download:`Download wireshark capture ` .. _UPNP_step6: .. tab-set:: .. tab-item:: UPNP Protocol Packet Details **UPNP M SEARCH Packet** .. csv-table:: :file: ./UPNP/UPNP_M_Search_Packet.csv :widths: 10,20,30,40 :header-rows: 1 **UPNP NOTIFY Packet** .. csv-table:: :file: ./UPNP/UPNP_NOTIFY_Packet.csv :widths: 10,20,30,40 :header-rows: 1 **UPNP HTTP RESPONSE Packet** .. csv-table:: :file: ./UPNP/UPNP_HTTP_Response_Packet.csv :widths: 10,20,30,40 :header-rows: 1 .. _UPNP_step7: .. tab-set:: .. tab-item:: UPNP Usecases .. csv-table:: :file: ./UPNP/UPNP_Use_Cases.csv :widths: 10,20,30 :header-rows: 1 .. _UPNP_step8: .. tab-set:: .. tab-item:: UPNP Basic Features .. csv-table:: :file: ./UPNP/UPNP_Features.csv :widths: 10,10,30 :header-rows: 1 .. _UPNP_step9: .. tab-set:: .. tab-item:: UPNP Feature : Zero Configuration **Zero Configuration - Testcases** .. csv-table:: :file: ./UPNP/UPNP_Feature1_zero_configuration_Test_Cases.csv :widths: 10,10,30,20 :header-rows: 1 .. _UPNP_step10: .. tab-set:: .. tab-item:: UPNP Feature : Auto Discovery **Auto Discovery - Testcases** .. csv-table:: :file: ./UPNP/UPNP_Feature2_Auto_discovery_Test_Cases.csv :widths: 10,10,30,20 :header-rows: 1 .. _UPNP_step11: .. tab-set:: .. tab-item:: UPNP Feature : Device Control **Device Control - Testcases** .. csv-table:: :file: ./UPNP/UPNP_Feature3_Device_control_Test_Cases.csv :widths: 10,10,30,20 :header-rows: 1 .. _UPNP_step12: .. tab-set:: .. tab-item:: UPNP Feature : Service Advertisement **Service Advertisement - Testcases** .. csv-table:: :file: ./UPNP/UPNP_Feature4_Service_advertisement_Test_Cases.csv :widths: 10,10,30,20 :header-rows: 1 .. _UPNP_step13: .. tab-set:: .. tab-item:: UPNP Feature : Event Notification **Event Notification - Testcases** .. csv-table:: :file: ./UPNP/UPNP_Feature5_event_notification_Test_Cases.csv :widths: 10,10,30,20 :header-rows: 1 .. _UPNP_step14: .. tab-set:: .. tab-item:: UPNP Feature : Content Sharing **Content Sharing - Testcases** .. csv-table:: :file: ./UPNP/UPNP_Feature6_Content_sharing_Test_Cases.csv :widths: 10,10,30,20 :header-rows: 1 .. _UPNP_step15: .. tab-set:: .. tab-item:: UPNP Feature : Port Mapping **Port Mapping - Testcases** .. csv-table:: :file: ./UPNP/UPNP_Feature7_Port_Mapping_Test_Cases.csv :widths: 10,10,30,20 :header-rows: 1 .. _UPNP_step16: .. tab-set:: .. tab-item:: UPNP Feature : Standardized Architecture **Standardized Architecture - Testcases** .. csv-table:: :file: ./UPNP/UPNP_Feature8_standardized_architecture_Test_Cases.csv :widths: 10,10,30,20 :header-rows: 1 .. _UPNP_step17: .. tab-set:: .. tab-item:: UPNP Feature : Extensibility **Extensibility - Testcases** .. csv-table:: :file: ./UPNP/UPNP_Feature9_Extensibility_Test_Cases.csv :widths: 10,10,30,20 :header-rows: 1 .. _UPNP_step18: .. tab-set:: .. tab-item:: UPNP Feature : Cross Platform Support **Cross Platform Support - Testcases** .. csv-table:: :file: ./UPNP/UPNP_Feature10_Cross_platform_support_Test_Cases.csv :widths: 10,10,30,20 :header-rows: 1 .. _UPNP_step19: .. tab-set:: .. tab-item:: Reference links * Reference links