Summary of the invention
It is an object of the invention to provide a kind of streaming media data stream method of sending and receiving, aim to solve the problem that and existing realize cross-network segment multicast by configuring IGMP agreement on the router, owing to IGMP agreement sends out complexity, in practical engineering application to on-the-spot workmen with there being higher problem per family.
The present invention is achieved in that a kind of streaming media data stream method of sending and receiving, and this streaming media data stream method of sending and receiving comprises the following steps:
Step one, is fixedly installed the IP address of server on service node, after service node starts, directly sends heartbeat message to multicast source;
Step 2, multicast source generates equipment according to subnet information and searches the multicast forward table of message, and the equipment that sends searches message, comprises the IP address of server in message, and service node determines the IP address in current multicast source after receiving this message;
Step 3, multicast source, when the equipment of transmission searches message, is not yet included in the service node of line in subnet, then with the acquiescence forward node of this subnet for forward node, after having node to reach the standard grade, then adopt the mode of dynamic dispatching, forward with the node of final updating state all the time;
Step 4, after multicast source receives the heartbeat message of service node, being designated this node is upper line states, and the subnet number of this equipment is determined according to IP address, after node is reached the standard grade, multicast source starts overtime timer, time-out does not receive new heartbeat message, then identify this node and roll off the production line;
Step 5, when multicast source initiates a road multicast service, the mode first passing through clean culture sends broadcast startup order to the service node of all these business of reception, contains the multicast address for receiving this road stream medium data and port in this order;
Step 6, after service node receives broadcast startup order, the UDP opening destination interface receives socket, and add reception purpose multicast address, now, service node receives the identical multicast of destination interface and unicast message simultaneously, then, send state to multicast source immediately and update message;
Step 7, multicast source connects and receives heartbeat message every time, checks that the state of current business node is whether correct, incorrect, retransmits broadcast and starts order, and the state of broadcast reception node is correct, then by this node city head of the queue to multicast forward table correspondence subnet;
Step 8, multicast source proceeds by the transmission of stream medium data after starting broadcast session immediately; When multicast source carries out stream medium data forwarding, all send according to the requirement timing of timestamp;
Step 9, service node is opened the SOCKET of corresponding udp port, and is added the multicast address of this group business stream after receiving broadcast startup order;
Step 10, service node is after receiving business datum with multicast mode, only carries out the decoding playback of audio frequency or video flowing; It is in the way of clean culture, receive data, while being decoded playback, these data is carried out multicast forwarding in this subnet;
Step 11, the different service node in same subnet can receive different broadcasting service stream simultaneously, and the node by participating in this Business Stream that forwards of Business Stream completes.
Further, in step 2, what when transmission equipment lookup message and step 8 multicast source carry out stream medium data forwarding, timing sent specifically comprises the following steps that
First read first subnet array, then judge whether subnet array is empty, then terminate for sky; Subnet array is not empty, then judge whether array member is empty, for sky, then reading next array, array member is not empty, then judge whether multicast source is local subnet, it it is not local subnet, then clean culture is sent to the first node of queue, reading next queue, re-reads first subnet array; For local subnet, then multicast is sent to local subnet, reading next queue, re-reads first subnet array.
Further, in step 10, service node receives specifically comprising the following steps that of business datum with multicast mode
It is first turned on order and receives socket, wait server data to be received, judge data type afterwards, data type starts order for broadcast, then open Business Stream and receive socket, add multicast address, to send state renewal message, return and open order reception socket; Data type is that broadcast is ceased and desisted order, then close Business Stream and receive socket, then exit multicast address, to send state renewal message, returns and opens order reception socket; Data type is Business Stream, then determine whether multicast message, is multicast message, then carry out audio/video decoding playback, returns to waiting for receiving server data; It is unicast message, then E-Packets to purpose multicast address and port, then carry out audio/video decoding playback, return to waiting for receiving server data.
Further, in step 11, when multicast source carries out Business Stream transmission, choose the service node of the final updating state participating in this business in each network segment all the time as forward node, when service node exits this Business Stream, multicast source will be immediately switched in queue next node as forward node;
Carrying out forwarding service node because, after a variety of causes inefficacy, heartbeat message will not be retransmited, when multicast source receives the heartbeat message of other node participating in identical services, automatically switching to this node and forward.
Streaming media data stream method of sending and receiving provided by the invention, adopt C/S model, with Streaming Media transmission source for server end, equipment is received for client with Streaming Media, multicast packet can be enable without the help of switch or router to cross over each different segment in large, medium and small LAN under the support and configuration of IGMP agreement, thus realizing the application of Streaming Media IP multicasting technology. The present invention is under the environment of cross-network segment, it is not necessary under the environment of amendment configuration of routers and multicast routing protocol, it is achieved that the one-way transmission of group business stream, is highly suitable in the application system of the unidirectional propelling movement of audio frequency and video group business stream and implements.
The present invention is compared with prior art:
1. Practical Project should in, it is not necessary to change router is arranged, it is possible to quickly, disposes cross-network segment multicast simply.
2. in the process carrying out multicast service forwarding, dynamically adjust the strategy of business forward node in each subnet owing to have employed, it is to avoid individual node lost efficacy and causes the situation of large area service disconnection, strengthened the vigorousness of cross-network segment multicast transmission system.
3., owing to multicast service forwards the service node by participating in Business Stream to complete, the load being effectively realized cross-network segment multicast transmission is all carried on a shoulder pole and flow equilibrium, improves the concurrency of multicast service system.
Detailed description of the invention
In order to make the purpose of the present invention, technical scheme and advantage clearly understand, below in conjunction with embodiment, the present invention is further elaborated. Should be appreciated that specific embodiment described herein is only in order to explain the present invention, is not intended to limit the present invention.
Below in conjunction with drawings and the specific embodiments, the application principle of the present invention is further described.
As it is shown in figure 1, the streaming media data stream method of sending and receiving of the embodiment of the present invention comprises the following steps:
S101: be fixedly installed the IP address of server on service node, service node directly can send out " sending heartbeat message " to multicast source after starting;
S102: multicast source generates the multicast forward table of " equipment lookup message " according to subnet information, and sends " equipment lookup message ", comprises the IP address of server in this message, and service node can determine that the IP address in current multicast source after receiving this message;
S103: multicast source is when sending " equipment lookup message ", if being not yet included in the service node of line in subnet, then with the acquiescence forward node of this subnet for forward node, once after having node to reach the standard grade, then adopt the mode of dynamic dispatching, forward with the node of final updating state all the time;
S104: after multicast source receives " heartbeat message " of service node, being designated this node is upper line states, and determines the subnet number of this equipment according to IP address, after node is reached the standard grade, multicast source starts overtime timer, if time-out does not receive new heartbeat message, then identifies this node and rolls off the production line;
S105: when multicast source initiates a road multicast service, the mode first passing through clean culture sends " broadcast starts order " to the service node of all these business of reception, contains the multicast address for receiving this road stream medium data and port in this order;
S106: after service node receives broadcast startup order, the UDP opening destination interface receives socket, and adds reception purpose multicast address. Now, service node can receive the identical multicast of destination interface and unicast message simultaneously. Then, send state to multicast source immediately and update message;
Whether S107: multicast source connects and receives " heartbeat message " every time, all need the state checking current business node correct, if incorrect, needs to retransmit " broadcast starts order ". If the state of broadcast reception node is correct, then by this node city head of the queue to multicast forward table correspondence subnet;
S108: multicast source proceeds by the transmission of stream medium data after starting broadcast session immediately. Data source of stream media can be the audio-video document uploaded in advance, it is also possible to be the real time data that sended over by clean culture of other collecting device; When multicast source carries out stream medium data forwarding, all send according to the requirement timing of timestamp;
S109: service node is opened the SOCKET of corresponding udp port, and added the multicast address of this group business stream after receiving " broadcast starts order ";
S110: service node, if after receiving business datum with multicast mode, only carries out the decoding playback of audio frequency or video flowing; If receiving data in the way of clean culture, while being decoded playback, also need in this subnet, these data are carried out multicast forwarding;
S111: the different service node in same subnet can receive different broadcasting service stream simultaneously, the node by participating in this Business Stream that forwards of Business Stream completes.
In step s 102, what when transmission " equipment lookup message " and step S108 multicast source carry out stream medium data forwarding, timing sent specifically comprises the following steps that
First read first subnet array, then judge whether subnet array is empty, then terminate if it is empty; If subnet array is not empty, then judge whether array member is empty, if it is empty, then reading next array, array member is not empty, then judge whether multicast source is local subnet, it it is not local subnet, then clean culture is sent to the first node of queue, reading next queue, re-reads first subnet array; If local subnet, then multicast is sent to local subnet, reading next queue, re-reads first subnet array;
In step s 110, service node receives specifically comprising the following steps that of business datum with multicast mode
It is first turned on order and receives socket, wait server data to be received, judge data type afterwards, data type starts order for broadcast, then open Business Stream and receive socket, add multicast address, to send state renewal message, return and open order reception socket; Cease and desist order if data type is broadcast, then close Business Stream and receive socket, then exit multicast address, to send state renewal message, return and open order reception socket; If data type is Business Stream, then determine whether multicast message, be multicast message, then carry out audio/video decoding playback, return to waiting for receiving server data; It is unicast message, then E-Packets to purpose multicast address and port, then carry out audio/video decoding playback, return to waiting for receiving server data.
In step S111, once service node exits this Business Stream, the forwarding of this Business Stream will be no longer participate in. When multicast source carries out Business Stream transmission, choose the service node of the final updating state participating in this business in each network segment all the time as forward node. When service node exits this Business Stream, multicast source will be immediately switched in queue next node as forward node.
If carrying out forwarding service node because, after a variety of causes inefficacy, " heartbeat message " will not be retransmited. When multicast source receives " heartbeat message " of other node participating in identical services, automatically switch to this node and forward, thus realizing the fast quick-recovery of business.
The concrete steps of the present invention:
1, equipment finds:
Static configuration mode, is namely fixedly installed the IP address of server on service node, and service node directly can send out " sending heartbeat message " to multicast source after starting.
Dynamic Discovery mode, multicast source generates the multicast forward table of " equipment lookup message " according to subnet information, and the flow process shown in Fig. 4 sends " equipment lookup message ", comprising the IP address of server in this message, service node can determine that the IP address in current multicast source after receiving this message.
Multicast source is when sending " equipment lookup message ", if being not yet included in the service node of line in subnet, then with the acquiescence forward node of this subnet for forward node, once after having node to reach the standard grade, then adopt the mode of dynamic dispatching, forward with the node of final updating state all the time.
After multicast source receives " heartbeat message " of service node, being designated this node is upper line states, and determines the subnet number of this equipment according to IP address. After node is reached the standard grade, multicast source starts overtime timer, if time-out does not receive new heartbeat message, then identifies this node and rolls off the production line.
2, multicast service flow process (audio-video-frequency broadcast):
When multicast source initiates a road multicast service, the mode first passing through clean culture sends " broadcast starts order " to the service node of all these business of reception, contains the multicast address for receiving this road stream medium data and port in this order.
After service node receives broadcast startup order, the UDP opening destination interface receives socket, and adds reception purpose multicast address. Now, service node can receive the identical multicast of destination interface and unicast message simultaneously. Then, send state to multicast source immediately and update message.
Owing to " broadcast starts order " is UDP message, for ensureing the vigorousness of system, service node also needs regularly current to multicast source report service condition. Whether multicast source connects and receives " heartbeat message " every time, all need the state checking current business node correct, if incorrect, needs to retransmit " broadcast starts order ". If the state of broadcast reception node is correct, then by this node city head of the queue to multicast forward table correspondence subnet.
Multicast source proceeds by the transmission of stream medium data after starting broadcast session immediately. Data source of stream media can be the audio-video document uploaded in advance, it is also possible to be the real time data that sended over by clean culture of other collecting device.
When multicast source carries out stream medium data forwarding, all send according to the requirement timing of timestamp. Transmission mode adopts the flow process shown in Fig. 4 to be transmitted.
Service node is opened the SOCKET of corresponding udp port, and is added the multicast address of this group business stream after receiving " broadcast starts order ".
Service node, if after receiving business datum with multicast mode, only carries out the decoding playback of audio frequency or video flowing; If receiving data in the way of clean culture, while being decoded playback, also need in this subnet, these data are carried out multicast forwarding. Idiographic flow is as shown in Figure 5.
3, load balancing and fault-tolerant:
Different service node in same subnet can receive different broadcasting service stream simultaneously, and the node by participating in this Business Stream that forwards of Business Stream completes.
Once service node exits this Business Stream, the forwarding of this Business Stream will be no longer participate in. When multicast source carries out Business Stream transmission, choose the service node of the final updating state participating in this business in each network segment all the time as forward node. When service node exits this Business Stream, multicast source will be immediately switched in queue next node as forward node.
If carrying out forwarding service node because, after a variety of causes inefficacy, " heartbeat message " will not be retransmited. When multicast source receives " heartbeat message " of other node participating in identical services, automatically switch to this node and forward, thus realizing the fast quick-recovery of business.
The operation principle of the present invention:
It is an object of the invention to provide a kind of Streaming Media cross-network segment IP multicast support technology based on C/S model. Streaming Media multicast packet can be carried out passing through and distributing in each subnet section of LAN in the support not relying on router and switch.
In the multimedia audio-video addressable multicasting system applying this technology, streaming media server achieves the function of multicast source, and service node is the audio-video-frequency broadcast receiving node that each is independent.
Multicast source adopt static mode configuration dispose the subnet information (subnet number and subnet mask) of service node, and for each subnet arranges the service node of " the forwarding unit lookup message " of an acquiescence.
Specific embodiments of the invention:
The present invention is adapted in the application system of the unidirectional propelling movement of audio frequency and video group business stream to implement;
Application system is made up of multicast source and service node, and network topology is as shown in Figure 2; Service node can be deployed in the same network segment of multicast source, it is also possible to is distributed in each different subnet;
The technical characteristic of multicast source is:
It is responsible for structure, network topology structure in maintenance system and the presence of all nodes;
It is the multicast service of audio-video-frequency broadcast that multicast source actively can initiate multichannel content parallel, and receives state by the service node entrance business that clean culture order is relevant, adopts UDP mode to send multicast service subsequently and flow to relevant service node;
Multicast source is the data source of the promoter of the multicast service (audio-video-frequency broadcast) of system and group business stream. group business stream is generally real-time audio frequency or video data stream, adopts UDP multicast mode transmission in the present system;
Multicast source is by receiving the presence of " heartbeat message " and " state renewal message " current all service nodes of real-time update of service node and current Business Stream state, and the multicast forward table of all group business streams of Dynamic Maintenance;
The logical structure of multicast forward table is as shown in Figure 3; The multicast forward table of each Business Stream is made up of multiple subnet queues, and each subnet queue contains the service node of all these group business streams of reception in current sub network; Multicast source dynamically updates forward table according to the state reporting information of service node, and each subnet queue was ranked up by the state renewal time of service node, and namely the node of last uploaded state comes the first place of queue all the time;
Multicast source is when sending group business stream, the subnet queue of current multicast business forward table need to be traveled through not for empty queue, if subnet residing for multicast source, in the way of multicast, then send message, otherwise, the service node ranked the first in subnet queue sends traffic data in the way of clean culture, and idiographic flow is as shown in Figure 4;
Large area service disconnection is caused for avoiding service node to lose efficacy, multicast source is also the timeout mechanism that each service node is arranged, if not receiving " heartbeat message " or " state renewal message " of service node for a long time, then judge this node failure, and from forward table, delete this node;
The technical characteristic of service node:
The state of the machine regularly (5 seconds, interval) will be reported multicast source by " heartbeat message " by service node in the way of clean culture UDP;
The IP address of multicast source can be obtained by the mode of static configuration or dynamic lookup;
After receiving multicast service (audio-video-frequency broadcast) startup order, open the SOCKET of corresponding udp port, and add the multicast address of this group business stream;
Receive after multicast service (audio-video-frequency broadcast) ceases and desist order, close the SOCKET of corresponding udp port, and exit the multicast address of this group business stream;
Service node, if after receiving traffic data with multicast mode, only carries out the decoding playback of audio frequency or video flowing; If receiving data message in the way of clean culture, while being decoded playback, also need in this subnet, this data message is carried out multicast forwarding;
Service node dynamically adds or exits certain multicast service, stops receiving this group business stream after exiting multicast service;
After the reception state of service node changes, need to by " state renewal message " immediately to multicast source uploaded state;
The reception of the group business stream of service node and forwarding process are as shown in Figure 5.
The present invention adopts C/S model, with Streaming Media transmission source for server end, equipment is received for client with Streaming Media, multicast packet can be enable without the help of switch or router to cross over each different segment in large, medium and small LAN under the support and configuration of IGMP agreement, thus realizing the application of Streaming Media IP multicasting technology.
The foregoing is only presently preferred embodiments of the present invention, not in order to limit the present invention, all any amendment, equivalent replacement and improvement etc. made within the spirit and principles in the present invention, should be included within protection scope of the present invention.