Tuesday, October 20, 2015

Real-time Transport Protocol

The Real-time Transport Protocol (RTP) is a network protocol for delivering audio and video over IP networks. RTP is used extensively in communication and entertainment systems that involve streaming media, such as telephony, video teleconference applications, television services and web-based push-to-talk features.
RTP is used in conjunction with the RTP Control Protocol (RTCP). While RTP carries the media streams (e.g., audio and video), RTCP is used to monitor transmission statistics and quality of service (QoS) and aids synchronization of multiple streams. RTP is one of the technical foundations of Voice over IP and in this context is often used in conjunction with a signaling protocol such as the Session Initiation Protocol (SIP) which establishes connections across the network.
RTP was developed by the Audio-Video Transport Working Group of the Internet Engineering Task Force (IETF) and first published in 1996 as RFC 1889, superseded by RFC 3550 in 2003.
RTP combines its data transport with a control protocol (RTCP), which makes it possible to monitor data delivery for large multicast networks. Typically, RTP runs on top of the UDP protocol, although the specification is general enough to support other transport protocols. An RTP session is established for each multimedia stream. A session consists of an IP address with a pair of ports for RTP and RTCP. For example, audio and video streams use separate RTP sessions, enabling a receiver to deselect a particular stream.

Monday, October 5, 2015

Node.js Module

A module encapsulates related code into a single unit of code. When creating a module, this can be interpreted as moving all related functions into a file. Node.js has a simple module loading system. In Node.js, files and modules are in one-to-one correspondence. As an example, foo.js loads the module circle.js in the same directory.
The semantics of Node.js's require() function were designed to be general enough to support a number of reasonable directory structures. Package manager programs such as dpkg, rpm, and npm will hopefully find it possible to build native packages from Node.js modules without modification.
Core Modules
Node.js has several modules compiled into the binary. The core modules are defined within Node.js's source and are located in the lib/ folder. Core modules are always preferentially loaded if their identifier is passed to require(). For instance, require('http') will always return the built in HTTP module, even if there is a file by that name.
exports VS. module.exports
  • exports is an alias to module.exports.
  • node automatically creates it as a convenient shortcut.
  • For assigning named properties, use either one.
     > module.exports.fiz = "fiz";
     > exports.buz = "buz";
     > module.exports === exports;

  • Assigning anything to exports directly (instead of exports.something) will overwrite the exports alias.
Named exports - one module, many exported things
Anonymous exports - simpler client interface