📜 ⬆️ ⬇️

Forwarding DLNA to a remote network

Background :

So, there was a need to give the opportunity to watch movies from my server on the TV. Well, it would seem, we are raising DLNA, for example miniDLNA, and the problem has been solved. So it was, until there was a need to give the same opportunity to parents who live in a different place, and there was no wish to place a server or a simple nas for them there. It was decided to merge our networks by tunneling traffic and give access to my film library.

Preparation :

I have already put a great router with my parents for a long time, with whom I have been working and trusting for a long time - Mikrotik 951Ui 12HnD. Who is not familiar with this great router, I advise you to get acquainted. Pricing allows you to choose solutions for both home and office. At the same time we get the functionality, as in expensive enterprise solutions.
')
I had Mikrotik in my apartment as well, with only one difference, I had all the gigabit ports. I without hesitation picked up the pptp tunnel and then it began ...

First problems :

In contrast to the classical way of transmitting streaming audio and video data segment DLNA is slightly different. And it immediately became clear after I sniffed traffic.

  1. All communication between the media server and the TV takes place via HTTP
  2. The TV makes a multicast distribution of SSDP packets to the address 239.255.255.255.250, in which it registers itself as a service in the face of media servers.
  3. DLNA servers, when they see a new service, start to access the TV directly, after a couple of packages send their information inside

    XML
    <?xml version="1.0" encoding="utf-8"?> <root xmlns="urn:schemas-upnp-org:device-1-0" xmlns:dlna="urn:schemas-dlna-org:device-1-0" xmlns:sec="http://www.sec.co.kr/dlna"> <specVersion> <major>1</major> <minor>0</minor> </specVersion> <device> <dlna:X_DLNADOC xmlns:dlna="urn:schemas-dlna-org:device-1-0">DMS-1.50</dlna:X_DLNADOC> <dlna:X_DLNADOC xmlns:dlna="urn:schemas-dlna-org:device-1-0">M-DMS-1.50</dlna:X_DLNADOC> <dlna:X_DLNACAP xmlns:dlna="urn:schemas-dlna-org:device-1-0">av-upload,image-upload,audio-upload</dlna:X_DLNACAP> <sec:ProductCap>smi,DCM10,getMediaInfo.sec,getCaptionInfo.sec</sec:ProductCap> <sec:X_ProductCap>smi,DCM10,getMediaInfo.sec,getCaptionInfo.sec</sec:X_ProductCap> <deviceType>urn:schemas-upnp-org:device:MediaServer:1</deviceType> <friendlyName>[PC]DESKTOP-SBP6BH3</friendlyName> <manufacturer>Samsung Electronics</manufacturer> <manufacturerURL>http://www.samsung.com/sec</manufacturerURL> <modelDescription>Samsung PC DMS</modelDescription> <modelName>PC</modelName> <modelNumber>AllShare1.0</modelNumber> <modelURL>http://www.samsung.com/sec</modelURL> <UDN>uuid:0d1cef00-0032-1000-8823-f46d043e5ae2</UDN> <sec:deviceID>H3CJEO6BEFKMU</sec:deviceID> <iconList> <icon> <mimetype>image/jpeg</mimetype> <width>48</width> <height>48</height> <depth>24</depth> <url>/smp_2_</url> </icon> <icon> <mimetype>image/jpeg</mimetype> <width>120</width> <height>120</height> <depth>24</depth> <url>/smp_3_</url> </icon> <icon> <mimetype>image/png</mimetype> <width>120</width> <height>120</height> <depth>24</depth> <url>/smp_4_</url> </icon> <icon> <mimetype>image/png</mimetype> <width>48</width> <height>48</height> <depth>24</depth> <url>/smp_5_</url> </icon> </iconList> <serviceList> <service> <serviceType>urn:schemas-upnp-org:service:ConnectionManager:1</serviceType> <serviceId>urn:upnp-org:serviceId:ConnectionManager</serviceId> <SCPDURL>/smp_7_</SCPDURL> <controlURL>/smp_8_</controlURL> <eventSubURL>/smp_9_</eventSubURL> </service> <service> <serviceType>urn:schemas-upnp-org:service:ContentDirectory:1</serviceType> <serviceId>urn:upnp-org:serviceId:ContentDirectory</serviceId> <SCPDURL>/smp_10_</SCPDURL> <controlURL>/smp_11_</controlURL> <eventSubURL>/smp_12_</eventSubURL> </service> </serviceList> </device> </root> 


  4. After you select the media file that you want to listen to / watch the exchange on TCP begins, as I understand the TV starts to cache the media file.



Some of these requests ran through PPTP, some did not. After I studied the traffic dump, I came to the following conclusions:


It would seem that everything was provided for, I saw my DLNA server on my parents' TV, connected to it, opened the movie, and then I managed to see 2 frames and that was all. He just disconnected from the server. I started anew, ran through the entire configuration on both routers, sinned on the firewall. Then again I looked at the traffic dump and saw the same ..
don't fragment

And then it dawned on me! The packet size exceeds the MTU that PPTP provides to us, but you cannot fragment it! Unfortunately, in the miniDLNA server settings, I could not find an opportunity to limit the packet length.

Winning decision :

As a result, the simplest IP-IP tunnel provides us with the necessary MTU, MRU, and MSS, but we are faced with the problem of dynamic addressing from the provider, if you have static at both ends, you are lucky!

You can also try to limit mtu on the interface to which the NAS is connected. In this case, the packets will obviously be with a small MTU, which will crawl into any tunnel, but this can significantly load the CPU.

Addition :

Do not forget that watching movies is not a heavy load on the network in terms of channel width. When within the local network, it is not scary, but between networks, when the channel width is controlled by the provider ... In general, I advise everyone to turn on QoS, give priority to their server, and any connections to it, and we can wait an additional 30 ms to open the page.

If there are wishes, I will describe in detail how to configure Mikrotik.

Articles I used:
ru.wikipedia.org/wiki/DLNA
ru.wikipedia.org/wiki/Maximum_transmission_unit
wiki.mikrotik.com/wiki/Manual : Routing / Multicast

Dear! If you are minus the article, please write in the comments why, and I will improve it!
I will be glad to criticism and comments!

Source: https://habr.com/ru/post/267149/


All Articles