Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 7 Next »

CDN based on WCS servers can be organized in two ways:

  1. Static CDN with pre-configured nodes. Changing CDN configuration requires restarting the server(s), because in this scheme the server(s) are the source of streams in the network. Such CDN 1.0 can be organized based on the load balancing function.
  2. Dynamic CDN with dynamically changing nodes. To include/exclude a node to/from such CDN, restarting of this node only is required.

In this section we describe dynamic CDN based on Web Call Server 5.1.

Overview

Dynamic CDN operation principle

Distributed dynamic content delivery network (CDN) based on WCS 5.1 operates as follows:
Upon startup of the server, a special CDN module starts. The module sends a request to the server specified as the CDN entry point to retrieve from it the list of other servers in the CDN and the list of available streams. If the entry point is not specified or if the specified server is not available, the module waits for a notification from another server in the CDN (for example, if that server was already added to the list of CDN servers on another server, or if it was specified as the entry point). As a result, each active CDN server at any given moment has the up-to-date list of all other CDN servers.
All interaction between nodes of CDN is performed via Websocket.

Server roles in CDN

A server can perform one of two roles

  1. Origin: works as a source of streams for other servers in CDN. Can distribute both streams published on it and streams fetched from other servers.
  2. Edge: can fetch streams from Origin servers, but do not distribute its own (local) streams to other servers.

Streams are not distributed by force. An Edge server fetches a specific stream from Origin only upon user request from a browser or a mobile application.

Operation flowchart

  1. The browser connects to the Origin server via the Websocket protocol and sends the publish command.
  2. The browser captures the microphone and the camera and sends the WebRTC stream to the server.
  3. The second browser establishes a connection to the Edge3 server via Websocket and sends the play command.
  4. The Edge3 server requests the stream from the Origin server.
  5. The Edge3 server receives the WebRTC stream.
  6. The second browser receives the WebRTC stream and plays this stream on the page.

Stream identification principles in CDN

A stream name is unique for every WCS server (and identifies the stream unambiguously), but not for the CDN in a whole. Hence, there are two limitations:

  1. If a stream is published on the server, and there is another stream with the same name on some other Origin server, the local (non-CDN) stream will be played on that server.
  2. When a CDN stream is played on the server, a stream with the same name cannot be published on that server. The same name can be used for publishing only when the playback stops and the pull agent is deleted after the activity checking timeout expires (by default it is 1 minute).

Configuration

Parameters of the settings file

To configure CDN, the following main settings in the flashphoner.properties file are used (see the complete list in the settings file description):

Parameter

Default value

Type

Description

cdn_enabled

false

Boolean

Enable/disable CDN

cdn_ip

Empty

String

Server address in CDN

cdn_nodes_resolve_ip

false

Boolean

Resolve server names to IP addresses

cdn_point_of_enry

Empty

String

Address of the server, the entry point to CDN for the given server

cdn_port

8084

Int

Port number for CDN

cdn_role

edge

String

Role of the server in CDN:

origin - source of streams for other servers in CDN

edge - can receive streams from other servers

Configuration examples

Minimum configuration example

Two servers: Origin (origin.flasphoner.com) and Edge (edge.flasphoner.com)

Origin settings:

cdn_enabled=true
cdn_ip=origin.flashponer.com
cdn_nodes_resolve_ip=true
cdn_role=origin

Edge settings:

cdn_enabled=true
cdn_ip=edge.flashphoner.com
cdn_nodes_resolve_ip=true
cdn_point_of_entry=origin.flashponer.com
cdn_role=edge

Two Origin servers configuration example

Four servers: Origin1 (origin1.flasphoner.com), Origin2 (origin2.flasphoner.com) and Edge1 (edge1.flasphoner.com), Edge2 (edge2.flasphoner.com)

Origin1 settings:

cdn_enabled=true
cdn_ip=origin1.flashponer.com
cdn_nodes_resolve_ip=true
cdn_role=origin

Origin2 settings:

cdn_enabled=true
cdn_ip=origin2.flashponer.com
cdn_point_of_entry=origin1.flashponer.com
cdn_nodes_resolve_ip=true
cdn_role=origin

Edge1 settings:

cdn_enabled=true
cdn_ip=edge1.flashphoner.com
cdn_point_of_entry=origin1.flashponer.com
cdn_nodes_resolve_ip=true
cdn_role=edge

Edge2 settings:

cdn_enabled=true
cdn_ip=edge2.flashphoner.com
cdn_point_of_entry=origin1.flashponer.com
cdn_nodes_resolve_ip=true
cdn_role=edge

Using CLI

Obtaining information about the current status of CDN from the WCS command line is performed with these commands:

Command

Description

Example result

show cdn-nodes

Displays the list of node servers in CDN:

ACTIVE - the server is running, responds to queries and/or sends notifications

PASSIVE - the server is stopped or unavailable

IIp                       State        
---------------------------------
edge1.flashphoner.com    ACTIVE   
edge2.flashphoner.com    ACTIVE   
origin2.flashphoner.com  PASSIVE

show cdn-routes

Shows the list of active streams in CDN

Route                       Stream     
------------------------------------
1-origin2.flashphoner.com-2 stream1
0-origin2.flashphoner.com-0 stream2
2-origin1.flashphoner.com-1 stream1

Removing stopped servers from CDN nodes list

By default, when server is stopped or unavailable, it will be displayed in CDN nodes list in PASSIVE state until it will be started again or all the CDN will be stopped. The time interval may be set if necessary to remove inactive node from nodes list. This interval should be set in seconds using the following parameter in flashphoner.properties file, for example

cdn_nodes_timeout=60

In this case inactive nodes will be removed from CDN nodes list after 60 seconds of inactivity.

Coordination of codecs on Origin and Edge servers

In order to avoid excessive transcoding when distributing streams, you need to coordinate codec settings on Origin and Edge servers. Let's take a look at three possible sound encoding configurations in the CDN intended to distribute a stream from the web camera and the RTMP encoder.

Using Opus or AAC

1. Distributing a stream captured from browser Chrome

1.1. Origin captures H.264+Opus stream from Chrome.
1.2. Edge pulls stream from Origin via WebRTС using H.264+Opus, there's no transcoding on Origin.
1.3. Subscriber pulls stream from Edge:
1.3.1. using H.264+Opus, there's no transcoding on Origin;
1.3.2. using H.264+AAC, there is transcoding Opus > AAC on Edge.

2. Distributing a stream captured from RTMP encoder

2.1. Origin captures H.264 stream from RTMP encoder:
2.1.1 AAC sound without transcoding:
2.1.2 Speex soind with transcoding to AAC.
2.2. Edge pulls stream from Origin via WebRTС using H.264+AAC.
2.3. Subscriber pulls stream from Edge:
2.3.1. using H.264+Opus, there is transcoding AAC > Opus Edge;
2.3.2. using H.264+AAC, there's no transcoding on Edge.

For this CDN to work, codecs should be configures as follows:

on Origin server

flash_handler_publish.sdp file should be created

v=0
o=- 1988962254 1988962254 IN IP4 0.0.0.0
c=IN IP4 0.0.0.0
t=0 0
a=sdplang:en
m=video 0 RTP/AVP 96
a=rtpmap:96 H264/90000
a=fmtp:96 profile-level-id=42e01f;packetization-mode=1
a=sendonly
m=audio 0 RTP/AVP 108
a=rtpmap:108 mpeg4-generic/48000/1
a=sendonly

on Edge server

this parameter shuold be set in flashphoner.properties file

codecs_exclude_cdn=alaw,ulaw,g729,speex16,g722,telephone-event,flv

and flash_handler_play.sdp file should be created

v=0
o=- 1988962254 1988962254 IN IP4 0.0.0.0
c=IN IP4 0.0.0.0
t=0 0
a=sdplang:en
m=video 0 RTP/AVP 96
a=rtpmap:96 H264/90000
a=fmtp:96 profile-level-id=42e01f;packetization-mode=1
a=recvonly
m=audio 0 RTP/AVP 108
a=rtpmap:108 mpeg4-generic/48000/1
a=recvonly

Using Opus only

1. Distributing a stream captured from browser Chrome

1.1. Origin captures H.264+Opus stream from Chrome.
1.2. Edge pulls H.264+Opus stream from Origin via WebRTC, there's no transcoding on Origin.
1.3. Subscriber pulls H.264+Opus stream from Edge, there's no transcoding on Edge.

2. Distributing a stream captured from RTMP encoder

2.1. Origin captures H.264 stream from RTMP encoder:
2.1.1 AAC sound with transcoding to Opus:
2.1.2 Speex sound with transcoding to Opus.
2.2. Edge pulls H.264+Opus stream from Origin via WebRTC.
2.3. Subscriber pulls H.264+Opus stream from Edge, there's no transcoding on Edge.

For this CDN to work, codecs should be configures as follows:

on Origin server

codecs setting should be default

on Edge server

this parameter shuold be set in flashphoner.properties file

codecs_exclude_cdn=alaw,ulaw,g729,speex16,g722,mpeg4-generic,telephone-event,flv

Using AAC only

1. Distributing a stream captured from browser Chrome

1.1. Origin captures H.264+Opus stream from Chrome with transcoding Opus > AAC.
1.2. Edge pulls H.264+AAC stream from Origin via WebRTС.
1.3. Subscriber pulls H.264+AAC stream from Edge, there's no transcoding on Edge.

2. Distributing a stream captured from RTMP encoder

2.1. Origin captures H.264 stream from RTMP encoder:
2.1.1 AAC sound without transcoding:
2.1.2 Speex sound with transcoding to AAC.
2.2. Edge pulls H.264+AAC stream from Origin via WebRTС.
2.3. Subscriber pulls H.264+AAC stream from Edge, there's no transcoding on Edge.

For this CDN to work, codecs should be configures as follows:

on Origin server

flash_handler_publish.sdp file should be created

v=0
o=- 1988962254 1988962254 IN IP4 0.0.0.0
c=IN IP4 0.0.0.0
t=0 0
a=sdplang:en
m=video 0 RTP/AVP 96
a=rtpmap:96 H264/90000
a=fmtp:96 profile-level-id=42e01f;packetization-mode=1
a=sendonly
m=audio 0 RTP/AVP 108
a=rtpmap:108 mpeg4-generic/48000/1
a=sendonly

on Edge server

this parameter shuold be set in flashphoner.properties file

codecs_exclude_cdn=opus,alaw,ulaw,g729,speex16,g722,telephone-event,flv

Quick manual on testing

1. For testing we use:

  • two WCS servers;
  • the Two Way Streaming web application to publish the stream;
  • the Player web application to play the stream.

Configuring WCS

2. For the test, configure CDN in the minimum configuration: one Origin and one Edge server

Origin settings:

cdn_enabled=true
cdn_nodes_resolve_ip=true
cdn_ip=origin.flashphoner.com
cdn_role=origin

Edge settings:

cdn_enabled=true
cdn_nodes_resolve_ip=true
cdn_point_of_entry=origin.flashphoner.com
cdn_ip=edge.flashphoner.com
cdn_role=edge

Here origin.flashphoner.com and edge.flashphoner.com - are examples names of the WCS servers.

Restart Origin and Edge servers. Enter the command line interface of the Edge server, authorize and enter this command

show cdn-nodes

The result of the command is as follows:

> show cdn-nodes
Ip                  State
---------------------------
origin.flashphoner.com ACTIVE

Running a broadcast form a web camera to the Origin server

3. Open the Two Way Streaming web application on the Origin server. Click the Connect button and specify the name of the broadcast stream testCDN:


4. Click the Publish button. The stream is published from the web camera:

Playing the stream on the Edge server

5. Open the Player web application on the Edge server. Specify the name of the stream broadcast to the Origin server, testCDN:


6. Click the Start button. Playing of the testCDN stream starts.


7. In the command line interface of the Edge server enter the command

show cdn-routes

The result of executing the command is:

> show cdn-routes
Route                   Stream
--------------------------------
0-origin.flashphoner.com-0 testCDN

Stopping broadcasting from the web camera to the Origin server

8. Click the Stop button on the stream publishing page. Publishing stops:


On the play page of the Edge server playing of the stream also stops and the message "Stopped by publisher stop" displays.

Known issues

1) Changing codec settings on the Edge server can lead to increased load on the server as a result of enabled transcoding.

Symptoms: when a large number of streams are broadcast, the load on the CPU of the Edge server increases
Solution: configure codec settings on Origin and Edge servers so to reduce excessive transcoding.

For instance, if the codec setting on the Origin server specifies the following set of codecs:

codecs=opus,mpeg4-generic,alaw,ulaw,g729,g722,telephone-event,h264,vp8

and the setting on the Edge server is

codecs=opus,speex16,mpeg4-generic,g729,g722,h264,vp8

then, when a stream is broadcast through the Edge server, audio transcoding from Speex16 or AAC is activated. With a large number of streams, the load to the CPU of the server can greatly increase.

  • No labels