The following script Written by nabe@abk (Credit to author) displays the UPNP Simple Service Discovery Protocol (SSDP) packets from your network.
$ vim ssdp-test.pl
#!/usr/bin/perl
################################################################################
# SSDP discover Written by nabe@abk / This is PDS
################################################################################
use strict;
use Socket;
my $CAST = '239.255.255.250';
my $PORT = 1900;
################################################################################
my $msg =<<SSDP;
M-SEARCH * HTTP/1.1
HOST: 239.255.255.250:1900
MAN: "ssdp:discover"
MX: 3
ST: ssdp:all
SSDP
# ST: ssdp:all
# ST: urn:schemas-upnp-org:device:MediaServer:1
# ST: urn:schemas-upnp-org:device:MediaRenderer:1
$msg =~ s/\r?\n/\r\n/g;
################################################################################
my $sock;
my $addr = pack_sockaddr_in($PORT, inet_aton($CAST));
socket($sock, AF_INET, SOCK_DGRAM, 0);
setsockopt($sock, SOL_SOCKET, SO_BROADCAST, 1);
bind($sock, pack_sockaddr_in(0, INADDR_ANY));
send($sock, $msg, 0, $addr);
while (1){
my $buf;
recv($sock, $buf, 65536, 0);
print "$buf\n";
}
Now, run this script as,
$ perl ssdp-test.pl
$ perl ssdp-test.pl
HTTP/1.1 200 OK
CACHE-CONTROL: max-age=1800
DATE: Mon, 04 May 2020 18:58:58 GMT
ST: uuid:4d696e69-444c-164e-9d41-544810cf4812
USN: uuid:4d696e69-444c-164e-9d41-544810cf4812
EXT:
SERVER: Ubuntu DLNADOC/1.50 UPnP/1.0 MiniDLNA/1.2.1
LOCATION: http://192.168.0.104:8200/rootDesc.xml
Content-Length: 0
HTTP/1.1 200 OK
CACHE-CONTROL: max-age=1800
DATE: Mon, 04 May 2020 18:58:58 GMT
ST: upnp:rootdevice
USN: uuid:4d696e69-444c-164e-9d41-544810cf4812::upnp:rootdevice
EXT:
SERVER: Ubuntu DLNADOC/1.50 UPnP/1.0 MiniDLNA/1.2.1
LOCATION: http://192.168.0.104:8200/rootDesc.xml
Content-Length: 0
HTTP/1.1 200 OK
CACHE-CONTROL: max-age=1800
DATE: Mon, 04 May 2020 18:58:58 GMT
ST: urn:schemas-upnp-org:device:MediaServer:1
USN: uuid:4d696e69-444c-164e-9d41-544810cf4812::urn:schemas-upnp-org:device:MediaServer:1
EXT:
SERVER: Ubuntu DLNADOC/1.50 UPnP/1.0 MiniDLNA/1.2.1
LOCATION: http://192.168.0.104:8200/rootDesc.xml
Content-Length: 0
You can also refer to C program – UDP Server to print UPNP Packets
1 thought on “Identify UPNP SSDP packets from your network”