Groupsock Overview (i)--live555 source reading (iv) network

Source: Internet
Author: User

Groupsock Overview (i)--live555 source reading (iv) network
    • Groupsock Overview (i)--live555 source reading (iv) network
      • Brief introduction
      • 1. Network Common data type definition
      • 2.Tunnel Tunnel Package

This article by Mob Lym fabricated, welcome reprintblog.cnblogs.net/oloroso
This article by Mob Lym fabricated, welcome reprintmy.oschina.net/oloroso

Brief introduction

Group is the meaning of groups/clusters, sockets are synonymous with network interfaces. This part is very large, mainly related to the network. Many of live555 's network modules involve the concept of multicast.
As a cross-platform streaming media service library, LIVE555 is a comprehensive package for the network and is worth seeing.

1. Network Common data type definition

Because of the live555 cross-platform feature, it is necessary to define some data types to accommodate each platform environment.
This writes the code in the live555sourcecontrol\groupsock\include\NetCommon.h file

#if defined (__win32__) | | Defined (_WIN32) | | Defined (_WIN32_WCE)/* Windows */#if defined (WINNT) | | Defined (_WINNT) | | Defined (__borlandc__) | | Defined (__mingw32__) | | Defined (_WIN32_WCE) #define _mswsock_#include <winsock2.h> #include <ws2tcpip.h> #endif # include <  windows.h> #include <string.h> #define Closesocket closesocket//Close socket function # define Ewouldblock wsaewouldblock 10035L may be blocked # define einprogress Wsaewouldblock//10035l operation is in progress # define Eagain Wsaewouldblock//10035l try again #defin E eintr wsaeintr//10004l Interrupt # If defined (_WIN32_WCE) #define No_strstream 1#endif/* Definitions of Size-specifi C types: Define a specific size type */typedef __int64 int64_t;typedef unsigned __int64 u_int64_t;typedef unsigned u_int32_t;typedef unsigned short u_int16_t;typedef unsigned char u_int8_t;//for "uintptr_t" and "intptr_t", we assume so if they ' re not a Lready defined, then this must be//"uintptr_t" and "intptr_t", we think if they are not already defined, then that must be//an old, 32-bit version of Windows: an older ,32-bit version of Windows: #if!defined (_msc_stdint_h_) &&!defined (_uintptr_t_defined) &&!defined (_uintptr_t_ Declared) &&!defined (_uintptr_t) typedef unsigned uintptr_t; #endif # if!defined (_msc_stdint_h_) &&! Defined (_intptr_t_defined) &&!defined (_intptr_t_declared) &&!defined (_intptr_t) typedef int INTPTR_ t; #endif #elif defined (VXWORKS)//VXWORKS */#include <time.h> #include <timers.h> #include <sys/times.h > #include <sockLib.h> #include 
2.Tunnel Tunnel Package

The code here is already well-commented. This first needs to understand what the following is Tunnel (tunneling). (Simply put, it's like a wolf in sheep's clothing)

Tunnel Chinese as a tunnel. Network tunneling (tunnelling) technology is a key technology. Network tunneling technology refers to the use of a network protocol to transmit another network protocol, which mainly uses the Network Tunneling Protocol to achieve this function. The network tunneling technology involves three kinds of network protocols, namely the Network Tunneling Protocol, the bearer Protocol under the Tunneling Protocol and the hosted protocol hosted by the Tunnel protocol.

The class implemented here TunnelEncapsulationTrailer is a very special class, and it should not be used to create objects.
For this part, here is not much to say, first look at the back.
It is defined in the live555sourcecontrol\groupsock\include\TunnelEncaps.hh file

typedef u_int16_t cookie;/* Cookies (data stored on the user's local terminal) cookies, and sometimes their plural forms, refer to certain websites in order to identify user identities, Data stored on the user's local terminal (usually encrypted) for session tracking. Defined in RFC2109 and 2965 are obsolete, the latest specification is RFC6265. *//*tunnel Chinese as a tunnel. Network tunneling (tunnelling) technology is a key technology. Network tunneling technology refers to the use of a network protocol to transmit another network protocol, which mainly uses the Network Tunneling Protocol to achieve this function. The network tunneling technology involves three kinds of network protocols, namely the Network Tunneling Protocol, the bearer Protocol under the Tunneling Protocol and the hosted protocol hosted by the Tunnel protocol. *///This class is interesting, it does not have data members internally, its function members are returned with this as the basis for the offset//, the address after the shift is the corresponding pointer type, and then the pointer to the contents of memory. So this class is not used to create objects, but to use them as a type. May be such as the following code//unsigned long long t= 0x1239874560864216l;//cout << ((tunnelencapsulationtrailer*) &t)  Address () << endl;//cout << 0x12398745 << endl;class Tunnelencapsulationtrailer {//the trailer is Layed out as follows://bytes 0-1: Source ' Cookie ' origin cookie//bytes 2-3: Destination ' cookie ' purpose COO                     Kie//bytes 4-7: Address addresses//bytes 8-9: Port ports//byte 10:ttl TTL//Byte 11:command command//Optionally, there may also be a 4-byte' Auxilliary address '//optional, there may also be a 4-byte "secondary location"//(e.g., for ' source-specific multicast ' preceding this) (for example, "specific source multicast" before this)//bytes-4 through-1: Auxilliary address//-4 to 1 bytes (this before 4 bytes), Secondary addresses Public:co    okie& Srccookie () {return * (cookie*) byteoffset (0);}    cookie& Dstcookie () {return * (cookie*) Byteoffset (2);}    u_int32_t& address () {return * (u_int32_t*) Byteoffset (4);}    port& Port () {return * (port*) Byteoffset (8);}    u_int8_t& ttl () {return * (u_int8_t*) Byteoffset (10);}        u_int8_t& command () {return * (u_int8_t*) Byteoffset (11);}    u_int32_t& auxaddress () {return * (u_int32_t*) Byteoffset (-4);} Private://Take this offset CharIndex inline char* byteoffset (int charIndex) {return ((char*) this) + CharIndex;} };const unsigned tunnelencapsulationtrailersize = 12; Bytes Tunnel package Trailer Size const unsigned tunnelencapsulationtrailerauxsize = 4; BytES auxiliary Dimensions const unsigned tunnelencapsulationtrailermaxsize//MAX size = tunnelencapsulationtrailersize + tunnelencapsulatio           ntrailerauxsize;//Command codes: Order code//0:unusedconst u_int8_t tunneldatacmd = 1;      Data command for the tunnel const u_int8_t Tunneljoingroupcmd = 2;     Tunnel Connection Group Command const u_int8_t tunnelleavegroupcmd = 3;       Tunnel Leave Group Command const u_int8_t tunnelteardowncmd = 4;          Tunnel Demolition Command Const u_int8_t tunnelprobecmd = 5;       Tunnel probe Command const u_int8_t tunnelprobeackcmd = 6;      Tunnel Probe ack Command const u_int8_t tunnelprobenackcmd = 7;   Tunnel probe nack Command const u_int8_t tunneljoinrtpgroupcmd = 8;  The tunnel joins the RTP Group Command const u_int8_t Tunnelleavertpgroupcmd = 9; Tunnel left RTP Group command//0x0A through 0x10:currently unused.0x0a to 0x10: not currently used//a flag, not a CMD code an identity, not a command code.  Tunnel extension Identifier const u_int8_t Tunnelextensionflag = 0x80; bits:1000 0000const u_int8_t tunneldataauxcmd//Tunnel Data Auxiliary command = (tunnelextensionflag| TUNNELDATACMD); const u_int8_t TUNNELJOINGROUPAUXCMD//Tunnel Connection Group Auxiliary command = (tunnelextensionflag| Tunneljoingroupcmd); const u_int8_t Tunnelleavegroupauxcmd//Tunnel Leave Group Auxiliary command = (tunnelextensionflag| TUNNELLEAVEGROUPCMD);//Note:the TearDown, Probe, Probeack, Probenack Cmds have no Aux version//Note: TearDown (demolition), Probe (probe ), Probeack (Ack probe), Probenack (Nack probe) no auxiliary version command//0x84 through 0x87:currently unused.const u_int8_t Tunneljoinrtpgroupauxcmd//Tunnel join RTP Group Auxiliary command = (tunnelextensionflag| TUNNELJOINRTPGROUPCMD); const u_int8_t tunnelleavertpgroupauxcmd//Tunnel leave RTP Group Auxiliary command = (tunnelextensionflag| TUNNELLEAVERTPGROUPCMD);//0x8A through 0xff:currently unused//Determine if the parameter cmd is an auxiliary command inline Boolean tunnelisauxcmd (u_int8_t C MD) {return (cmd&tunnelextensionflag)! = 0;}

Groupsock Overview (i)--live555 source read (iv) network

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.