[Reprint] multicast explained in Flash 10.1 P2P

Source: Internet
Author: User
ArticleDirectory
    • Difference between unicast and Multicast
    • Developing multicast in Flash
    • Packet distribution in Multicast
    • Conclusion

Original article: Workshop

Multicast is one of the features of Flash Player 10.1 and it enables you to distribute netstreams into ss the peer-to-peer mesh. it can be audio, video or even pure data stream (amf3)-the data stream can be very handy for games, it's much better for such purpose (like sending realtime positions, directions) than using posting as posting is more optimized for large number of senders to send something-like chat, status change and so on.

Difference between unicast and Multicast

Unicast
Unicast simply delivers streams from a serverNClients. for this purpose you can use Flash Media Server and TCP protocols such as rtmp/t/s/E or http protocol. unicast also costs you a lot of resources-> 1 Mbps stream delivered to 1000 clients means 1 GB upstream from server-which is CPU demanding and network transit is also huge.

Application level multicast
Sometimes called P2P multicast is an optimized Stream Distribution among peers. it's very cost valid tive as the stream is distributed among peers. you can either distribute stream from a client or FMS (with the future release ).

Native IP Multicast
This one is distributed over the network not using P2P connection, but using network routing capabilities. it mostly works in internal, enterprise, VPN or LAN networks-basically in closed networks, which supports that. you can combine native IP Multicast with application level multicast to deliver combined solution called multicast fusion. this feature need Flash Media Server (next generation version ). we will cover this feature once the new FMS is available.

Developing multicast in Flash

We are going to build two applications, one is going to be a runner er and one broadcaster.

Once you get connected to Cirrus or FMS. You need to setup the netstream-Same way like netgroup (check Simple Chat using netgroup tutorial ).

My group is called "mygroup/multicastone" and I am streaming stream "multicast". You can define whatever names you want.

Broadcaster app (see whole source-code broadcaster. mxml ):

 
Private FunctionSetupstream():Void{
 
VaRGroupspec: groupspecifier =NewGroupspecifier("Mygroup/multicastone");
 
Groupspec.Serverchannelenabled=True;
Groupspec.Multicastenabled=True;
 
Stream =New Netstream(NC, groupspec.Groupspecwithauthorizations());
 
Stream.Addeventlistener(Netstatusevent.Net_status, Netstatus);
VaRCam:Camera=Camera.Getcamera();
 
Video.Attachcamera(Cam);
 
Stream.Attachcamera(Cam);
 
Stream.Publish("Multicast");
}

Receiver app (see whole source-code receiver. mxml ):

 
Private FunctionSetupstream():Void{
 
VaRGroupspec: groupspecifier =NewGroupspecifier("Mygroup/multicastone");
 
Groupspec.Serverchannelenabled=True;
Groupspec.Multicastenabled=True;
 
Stream =New Netstream(NC, groupspec.Groupspecwithauthorizations());
 
Stream.Addeventlistener(Netstatusevent.Net_status, Netstatus);
Stream.Play("Multicast");
 
Video.Attachnetstream(Stream);
 
}

Watch: Developing multicast streaming in Flash Player 10.1 (videotutorial)

Okay, but how can I stream from Flash Media live encoder. for this purpose you will need to get next generation of Flash Media Server. once it's available-I will write a tutorial how you can use it.

Packet distribution in Multicast

Multicast in Flash is optimized to be efficient. it works the way that you don't upstream whole stream you have Ed-You cocould do that-but you rather upstream only couple chunks that fits your network possibilities. most of the normal DSL lines have around 8 Mbps download and 1 Mbps upload or more-so are able to receive 2 Mbps, but distribute only 1 Mbps (in optimal situation ), so you wowould need more peers for further distribution, which wowould combine packets together.

Multicast in Flash is a pull/push system. pull ensures to deliver the data to the peers. push optimize the mesh, reduce latency and create multiple spanning trees. if there were only pull, the latency of the live stream on the furthest peer wocould be too big. push solves that.

Pull

There are these steps:

    1. Once you start distributing stream you send a map of blocks to one (or all) neighbor (s)
    2. Neighbor waits a short time to see who can source each block
    3. Neighbor picks you to send some of the blocks and sends request
    4. Send requested blocks to neighbor
    5. All transmissions are partially-reliable
    6. Neighbor will ask someone else if requestgoes unfulfilled
    7.  

Pull then works this way:

Push

    1. Send map of what blocks you have to one (or all) neighbor (s)
    2. Neighbor notices that data is flowing
    3. Neighbor picks candidate sources for each sequence number slice
    4. Neighbor sends mask describing which sequence numbers to push
    5. Modulo size of mask (in this example every 3rd, 5th, and 6th)
    6. Periodically tests other neighbors to check for lower latency
    7. For each sequence number slice, keeps just quickest Source
    8. Data is pushed immediately as it arrives for requested slices
    9. For each slice, there is a limit to the number of push clients served

Push then works this way

Push/pull
By combining two abve, you get optimized tive/Optimized multicast distribution, which can be converted strated like this:

Conclusion

For multicast in Flash we use netstream class together with groupspecifier and netconnection. multicast is the most complicated thing in Flash P2P implementation and it's very intelligent in optimizing the delivery, Chunk distribution and mesh reforming. we have three types of Multicast: P2P, IP and fusion (P2P + IP ). multicast is available with Adobe cirrus and more will be available with new FMS.

Adobe TV resources:
-Watch the session about P2P from Max 2009 explaining multicast by Matthew Kaufman(Seek to 36: 28)
-Videotutorial: Developing multicast streaming in Flash Player 10.1

In the next tutorial I will explain how QoS and monitoring with multicast works.

Stay tuned for more!

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.