Multicast Video Streaming with VLC (IT Tutorial)

avatar
(Edited)

Good afternoon POB community

It's @trippymane again with a crazy IT tech tutorial 😁



This guide was started 5 months ago when we were carrying a lot of different types of test on a newly installed network in my workplace, I then had some busy times in life and switched my focus over other things and other types of posts, you may have noticed that I stopped posting altogether (except for my Graffiti Lettering Contest) as I've been a bit blue lately, now I am trying to get back to post more often so I thought it could be a good idea to finish first my posts in progress, clear all the past clutter and then start fresh with nothing left behind! Thanks for reading and have fun with some IT madness! Cheers



If you read my last IT post you know that I do work in IT and I like to write down the stuff that I learn to memorise it better and since I joined Hive I decided to blog these entries here! Enjoy! 🀣

I will try to keep this entry shorter than the previous one.


Multicast Video Streaming with VLC over LAN

Today I will show you how to setup a streaming with VLC over a Multicast address (a particular class D address used to enable multiple addresses to connect to the same host at the same time *) in the same LAN (your home connection for example) . At work we use this tool that I'll show today to push Multicast streams over the whole network to check if certain security and QoS (quality of service) policies are configured correctly, if certain connections are allowed, etc...

* Imagine when you connect to an online stream of a youtuber of gamer on twitch, most likely your PC like the PCs of many other watchers will connect to the server streaming the video through a multicast address over the internet, over a specific port using a specific protocol


And in this guide I will show you a little bug/error that we found in the VLC software, we couldn't make it work and had to spend a bit of time around it to find the fixt eventually, I will make sure to highlight that part in the guide!


Lab Scenario

For today's tutorial I will set up a home lab with 2 devices, Windows and Linux, I will setup one as the server pushing the stream and use the other to connect to the server and receive the stream in real time. I will also try to connect to the same stream with my Android device to test the multi-connectivity.

I will set this up over my LAN connection at home so all machines will have a local address in range 192.168.1.x /24.

Quickly at the end I will recreate the same stream but this time with 2 devices connected to a LAN on a dumb subnet (no internet) and will also capture some packets with Wireshark to show what happens between the devices when a Multicast stream takes place!


What we need

  • 2-3 devices (any OS) in the same LAN
  • VLC installed on all the devices (can be found on their official website)
  • LAN connection (In this case I'll use my existing LAN connecting from my router, but we can create our own LAN with a switch+router setup or directly connecting the devices to a router)
  • A video for the test
    (I just downloaded one from herequicky, this one first download link on the page)

Let's start the test

Server device - Windows Machine

Because we will setup the stream over a Class D Multicast Address (224.0.0.0 - 239.255.255.255) (a special range of address reserved for multicast purposes) we don't really need to know the IP address of the server, we only need the Multicast address and the Port over which we want to send the stream. Let's start setting up the stream.

For this test I will stream the video over Multicast address 228.0.0.1, you can use any within the 224.0.0.0-239.255.255.255 range)



First we need to open VLC and go to Media and then Stream (or simply Ctrl+S):

stream.png



This will open the Stream settings:

stream2.png



Click on Add and select the Video source to stream:

stream3.png



Click on Stream at the bottom and this new window will pop up, here click Next:

stream4.png



In the next window we need to do a very important step!
At the bottom in New destination we need to select RTP/MPEG Transport Stream and click Add:

screenshot_7_.png



After clicking Add this windows will pop up:

stream5.png



At this stage we need to input our Multicast address and the Port over which we want to stream!
As we said previously we'll use 228.0.0.1 and I'll leave the default port 5004*, then click Next:

stream6.png * It could be necessary for the test to work to disable the Firewall or allow the Port used for the stream on both devices



In the next window make sure to tick Active Transcoding and select the right profile for your file, in my case I used the MP4 standard - Video H.264+ MP3 (MP4), then click Next:

screenshot_9_.png


Previously I mentioned an error/bug, at this point is where we need to APPLY THE FIX in order for the Stream to work!
Check out the Next Step!



Make sure to tick Stream all elementary streams at this stage, this will change the config file (Generated stream output string)!

The bug is in the way the software creates the final configuration file (or Generated stream output string), it fails to define an important value: TTL (time to live), let me try to explain with the help of some pictures.
Basically VLC will take all the options we just defined and will make a config string out of it, let's have a look at what that means:

stream61.png



We can see within the string some of the options we defined such as the dst=228.0.0.1 value and the port=5004 value.

The error is in the fact that we have a value that is missing! TTL (Time to live) is not defined in the config, so in order to fix the issue we can simply add it ourselves manually, like I did here (you can see I added manually the value ttl=10 to the string, you can use any number really as long as it's higher than 1):

stream8.png



Now that the string is correct we can finally click on Stream and this will start our stream!

The server is now streaming and pushing the video to the network over Port 5004 and Multicast address 228.0.0.1 (I will capture some packets with Wireshark to show you this later!):

stream9.png

We can also see at the top it says "converting file:///................"
I selected also Repeat 1 always so the stream will keep looping itself.

We can move on to the client devices!



Client devices - Linux & Android

Linux

Now we can jump over the other machines and try to connect to the Stream we created. Let's start with Linux. In the VLC software we need to go to Media and select Open Network Stream:

In the next window we'll need to input the network address of our stream:

If you remember our Stream is an RTP stream, in order to connect to the Stream we need to input the following string in VLC:

rtp://@228.0.0.1:5004


This will tell VLC to which address connect over port 5004 using RTP as a protocol:

t1.png



Next click on play and we should be able to see our stream on the screen:

And here it is!

t2.png



Android

For the Android part the app is a bit more intuitive to use and on the home screen we can see a huge + NEW STREAM button which we can use to connect to a streaming address:

screenshot_20211120_122016_vlc.jpg



After clicking it it will prompt us to enter the address to where we want to connect (same as before):

rtp://@228.0.0.1:5004

screenshot_20211120_122042_vlc.jpg



And here is the stream working on our Android phone:

screenshot_20211120_122101_vlc.jpg



If you are wondering how I did manage to connect my Android to this LAN, I used a type C Ethernet Adapter, I recently found out that it works on Android and I use it with an app called WifiMan to get info about the connection, this is a game changer, now at work I test Ethernet lines with my phone and no need to bring a heavy laptop (LOL IT and Laziness... You know it ahahaha!)

And Andoid being based on Linux is just next level, I can pull out a terminal (like CMD for Windows we have bash for Linux and it works on Android, the app i use is called Termux) and ping stuff! Lovely 😎

In my next IT post maybe I can do a quick overview of how I use these particular tools with my Android phone and what I use them for!


Wireshark captures

I will hide my MAC address for security reasons!

As I previously mentioned now I want to quickly set up a LAN between the two devices and sniff some packets with Wireshark to show you the stream using the Multicast address 228.0.0.1 and port 5004.

To set up a LAN I will use a Router and a Switch, router will be set in range 192.168.2.x so we should see devices in that IP range connecting to multicast address 228.0.0.1 through port 5004 while streaming and connecting to the stream.

As always I want first to check the devices have all IP addresses and ping between them, Windows PC has 192.168.2.5 and Linux has 192.168.2.6

Here's the screen of my Linux machine getting IP address 192.168.2.6 able to ping Windows 192.168.2.5, this is enough to make sure we have connectivity.

t44.png



Here are some captures from the Windows (SENDING STREAM) and you can see our Windows machine (192.168.2.5) as the source, the 228.0.0.1 Multicast address as the destination and port 5004 being used as the destination port:

vl1.jpg



If we look into the UDP field we can see more clearly port 5004 as the destination port:

vl2.jpg



And if we check the IPv4 field we can see more clearly our source and destination addresses, as well as the TTL=10 field we added manually when setting up the stream, remember?

vl3.jpg



For the last screenshot I wanted to show you the Linux packet capture (receiving machine):

vl66.png

As you can see we see pretty much the same thing as on the Windows machine, if you think about it we are sending a stream over 228.0.0.1 and not directly to 192.168.2.6 (Linux) and that's why we do not see any activity from our Linux machine in the capture, the machine is just listening and not sending anything over the network, the only machine that is sending packets over the network is 192.168.2.5 (Windows).

In both captures we can see that the stream is being sent over Multicast address 228.0.0.1 (and MAC address 01:00:5e:00:00:01 which is a multicast mac address) and this is exactly what I was expecting from this test!
If the test were carried over a live network and not just an empty LAN (no internet) we would have seen so much more stuff going on, also for clarity the multicast stream was the only process running on the PCs in order to have less clutter in our capture.

That's it for today, I hope you enjoyed my quick guide and learned a thing or two, are you ready to get some testing done? 😜

This particular kind of test was useful for us when we were setting up the new enterprise network and wanted to check if multicast streams were working over particular subnets and if the PPS policies were right and so on and so forth, IT gibberish LOL


If you have any question or need some help with anything related to this tutorial feel free to drop a comment and I will try to reply and help as soon as I can! Cheers


Trippy

IT nerd πŸ˜†

Peace!


trippymanelogo.png



0
0
0.000
4 comments
avatar

Congratulations @trippymane! You have completed the following achievement on the Hive blockchain and have been rewarded with new badge(s):

You received more than 4500 upvotes.
Your next target is to reach 4750 upvotes.

You can view your badges on your board and compare yourself to others in the Ranking
If you no longer want to receive notifications, reply to this comment with the word STOP

Check out the last post from @hivebuzz:

Hive Power Up Month - Feedback from Day 18
0
0
0.000
avatar

If I would try this nowadays, then the whole stream would lag, because nowadays I am using mobile internet in a dead end village. Sometimes I do not even have 3G connection, let alone 4G. But good luck to those, who are streaming.

0
0
0.000
avatar

Oh yeah it would lag a lot and eat up your bandwidth in a second, this is tested on a live network with a stable 100-300 Mbps speed and then on a empty network without any internet, the router handles everything.

Thanks for dropping by :)

Have a great week!

0
0
0.000