ICE STUN and TURN


Assuming host A B both behind NAT on the internet.
STUN: Session Traversal Utilities for NAT
A B talk to STUN server to know each other’s external IP and port state for hole punching.
The goal is to let A B directly talk to each other on UCP and sometimes TCP, if NAT is not symmetric.
This public IP is also needed in RTSP SDP when RTP over UDP.
STUN server itself communicates over UDP by default.
TURN: Traversal Using Relays around NAT
A first asks TURN server a permission, and then A sends all data to TURN, which is relayed to B.
Used for some NAT TCP, when hole punching doesn’t work.
ICE: Interactive Connectivity Establishment
Just a combination of STUN and TURN, and automatically switches between the two.

Advertisements

Special Years


I notice 1900 1970 and 1601 are used in time presentation.
1900: ts.tm_year is number of year since 1900.
ts is a struct, returned by localtime and gmtime, and get converted to string by asctime
1970: time_t is the number of seconds since start of this year UTC. returned by time and mktime(tm)
This is called Epoch AKA Unix timestamps and POSIX time. converted to string by ctime.
1601: FILETIME on Windows, 64bit, is the number of 0.1ms since start of this year in UTC
This year is the start of a 400-year cycle in Gregorian calendar.

Decorator Pattern


Goal: adding feature to a class, e.g. CPerson.
How: instead of subclassing, we use Person as a data member of the new class, e.g. Son.
By doing so, 1. no change to CPerson, 2. no calling the existing class’s constructor.
In this example below, we decorate CPerson so that it becomes a CSon, and 20 years later, we decorate the same person so that he becomes a CDad. CPerson’s constructor is only called once, at birth.
——————– code ——————–

class IPerson
{
public:
virtual void Talk() = 0;
};
class CPerson
{
public:
void Talk()
{
printf(” Person is constructed\n”);
};
};
class CSon: public IPerson
{
CPerson &mPerson;
public:
CSon(CPerson &person): mPerson(person)
{
};
void Talk()
{
printf(” I am a son\n”);
};
};
class CDad : public IPerson
{
CPerson &mPerson;
public:
CDad(CPerson &person) : mPerson(person)
{
};
void Talk()
{
printf(” I am a dady\n”);
};
};

int main()
{
const char* const msg = “person has been decorated into a”;
CPerson person;
person.Talk();
printf(“%s son\n”, msg);
CSon son(person);
son.Talk();
printf(“%s dady\n”, msg);
CDad dad(person);
dad.Talk();
return 0;
}
/*output
Person is constructed
person has been decorated into a son
I am a son
person has been decorated into a dady
I am a dady
*/

Live Streaming: THSCA Convention and Coaching School, 2018


MaxxSports is live streaming this three day events, from July 22nd to 24th
at https://www.tsrnsports.com/watch-live
from Henry B. Gonzalez Convention Center, San Antonio, TX

CoachShow