Manuals en PDF
Manuals en PDF
Manuals en PDF
NAME
Gigapxy - an inter-protocol data stream relay and proxy.
DESCRIPTION
Gigapxy pipes data channels to corresponding clients; either of the two endpoints may be a network socket
or a file.
Gigapxy is designed to serve many clients per channel, efficiently and economically. A built-in caching
mechanism allows new clients to start reading cached (channel) data at once, minimizing the delay associ-
ated with making a new connection or a multicast group subscription. For the end user that means that
changing IPTV channels becomes very fast.
Application modules
Gigapxy is a server application; its services include relaying data to to clients and performing administra-
tive tasks, such as reporting application statistics in various formats.
The two modules run as separate processes, a single instance of gws(1) controls a number (N >= 1) of
gng(1) processes.
gws(1) processes and validates a user request for data, sets up input and output ends of associated data
streams, then dispatches the request to the appropriate gng(1) instance to handle data transfer. If gws
receives an administrative request, it may service it locally or relay to an appropriate gng.
A gng(1) , on its end, is fully dedicated to channel-to-client data transfer; it is not to be affected by delays
associated with HTTP request processing or even a crash of the controlling gws(1) instance.
gng reports to gws the events for the clients and channels that it is handling; the reports let gws track the
data streams and load-balance requests between multiple gng instances.
gng also (if configured) regularly updates traffic performance statistics (TPS) that gws needs to produce
traffic reports.
SETTING UP
Gigapxy is built as a single executable binary (named gigapxy), with two soft links to it set up by the instal-
lation process, the links denote the modules: gws and gng.
To see an overview of command-line parameters accepted by a module, run it with one of the following
As one might expect, a command-line parameter always overrides the corresponding setting in the configu-
ration.
Please note that running a module without any option is NOT equivalent to requesting help summary; it
will just run the module in default configuration.
Most of Gigapxy’s parameters should be specified in module-designated config files. The following are the
default locations for configuration files: Gigapxy will look for either gws.conf or gng.conf (depending on
the module being launched) and then (if neither could be opened) for gigapxy.conf in each of those loca-
tions unless a full path is specified at command line.
(current directory)
/etc
/usr/local/etc
If configuration file path is specified at command line, the module will only try to open that a file at that
particular path.
The installation provides ’/etc/gigapxy.conf’ as the default configuration file containing sections for both
gws and gng. However, each module’s section could be put into a separate file and passed to the module via
the ’-C|--config’ command-line parameter.
The documentation includes a fully annotated configuration file, with every possible option specified and
commented on, at:
PREPARING TO RUN
Gigapxy can run in a terminal or as a daemon. To run as a daemon, it must be started with root privileges.
Root privileges are not required after a short period of initialization; therefore it is suggested that the mod-
ule run in a non-privileged mode, under a non-root user. The default configuration has application mod-
ules (started as root) switch to non-privileged gigapxy account, which is automatically created at installa-
tion point with the home directory of /var/run/gigapxy. The user is not removed at de-installation for
safety reasons.
Log-file directory /var/log/gigapxy is automatically created at the installation point. No module will start
without being able to write into a log file.
NB: It makes sense to have your logs reside in a designated partition that is not shared with your system’s
root directory. Setting up for log-rotation and archival are two related tasks that must not be overlooked.
It is suggested that all module instances write their own log, although writing into a shared log is also pos-
sible.
RUNNING
The very base topology of Gigapxy is running one controlling gws hooked up with a single gng. This
would utilize only two CPUs/cores, so you might want to add more gng instances to spread channels across
available cores. Mind that all clients of a single channel go to the one designated (by their controlling gws)
gng. If you want to balance clients of the same channel across multiple gng’s, you would have to introduce
more gws instances, each of them handling its portion of the channel’s load.
The only rule to follow starting up modules is that a gws process should always start before any gng
instances it controls. (You could test-run your topology in separate terminal windows to see how it works.)
An example control script has been provided at:
Before the configuration is finalized and the process is not (yet) fully automated, the two command-line
options: -T and -v may be quite helpful. (See command-line options.)
The -v option works cummulatively: it allows for up to -vvvv to specify the deepest (debug) level of ver-
bosity in the log output. If you are testing a particular feature or trying to reproduce a bug, this is the way to
run for the log to be most helpful to the support team.
NB: Debug logs grow VERY large very fast so please make sure you have enough space in your dedi-
cated log partition and log rotation set up. gng is especially verbose in its debug output so take extra cau-
tion there: provide both the space and the log storage fast enbough to handle a lot of writing without serious
performance degradation.
For the -T option, bear in mind, that invoking it will disable switching to an alternate (non-privileged) user
from root.
Running Gigapxy is trivial once the configuration has been properly set up: launch the modules individu-
ally or via a control script.
Gigapxy can be considered running and fully functional when a gws(1) is running with at least one gng(1)
controlled by it. A gws(1) may run on its own without a single gng(1) attached but it will not be fully func-
tional: it will NOT be accepting user requests for data until a gng connects. You could still check on it by
requesting a status report via admin port.
A gws(1) shutting down gracefully (after one of the quitP signals: TERM, QUIT or INT will also shut
down all its engines. This behavior could be overridden in the configuration to safeguard against abnormal
situations or bugs causing a graceful exit(3) instead of a crash. Please refer to the gws.conf(5) for details.
If a gws(1) crashes, the subservient engines will not shut down at once but after N attempts to re-connect
with a gws(1) at the same (socket) path. The associated parameters are also configurable.
a) http://{addr}:{gws_port}/{cmd}/{mcast-addr}:{mcast-port} OR
http://{addr}:{gws_port}/{cmd}/{src-addr}@{mcast-addr}:{mcast-port}
WHERE
{addr}:{gws_port} ::= IPv4/6 address of the user-request listener;
{cmd} ::= udp;
{mcast-addr}:{mcast-port} ::= IPv4/6 address of the mulitcast group;
{src-addr} ::= source address for (SSM).
This (udpxy-style) type of request specifies multicast group as the data source and the requesting HTTP
connection as the destination.
b) http://{addr}:{gws_port}/src/{channel-uri}/dst/{client-uri}
WHERE
{addr}:{gws_port} ::= IPv4/6 address of the user-request listener;
{channel-uri} ::= URI for the channel (see format below);
{client-uri} ::= URI for the client (see format below);
URI format: {protocol}://{path}?{query}
c) http://{addr}:{gws_port}/${alias}
This type of request uses a channel alias: a dollar-sign prefixed name that resolves to a URL for a channel
within a group. Refer to channels.conf(5) for details on configuring channels using aliased groups.
Supported protocols are: FILE, TCP, UDP, HTTP. Below are a few examples of requests using different
protocols and formats:
a) http://acme.com:8080/src/file:///opt/data/somefile.dat/dst/?a=bb&c=dd
The request has an associated query ’a=bb&c=dd’ which could be used to specify additional
parameters for the session.
Client (dst) is not specified, which defaults to the connection of the HTTP request.
The contents of /opt/data/somefile.dat will be sent to the client; at EOF point the engine will wait
(in a non-blocking manner) for the file to expand (be appended with more data) and, if the file
gets expanded, will send the new data to the client. If the file does not expand within a certain
(configurable) time period, the channel will time out and the clients’ sessions will be terminated.
b) http://acme.com:8080/src/udp://[ff18::1]:5056/dst/file:///opt/data/somefile.dat
The engine will write any data arriving for the channel (multicast group) into the named file. The
channel may time out if no data arrive within a certain time period, in which case the session will
be closed. If there’s an error writing to the destination file, the session will also end.
c) http://acme.com:8080/src/udp://[ff18::1]:5056/dst/
d) http://acme.com:8080/udp/[ff18:1]:5056
The two requests above are equivalent (just stated in two different formats).
Both specify channel as the multicast group [ff18:1]:5056 and the (requesting) HTTP connection
as the client. A timeout may occur on either of the network connections here, either of the two
connections could also be broken by the peer, thus terminating the session.
e)
http://acme.com:8080/src/http://10.0.1.12:4056/udp/224.0.2.26:4033?kk=yy/dst/tcp://192.168.12.10:5051?mm=ff
specifies that channel data comes as a response to the HTTP GET /udp/224.0.2.26:4033?kk=yy
request sent to http://10.0.1.12:4056. Whatever application handles HTTP requests at that
address is expected to reply with a data stream destined to a TCP socket connected to the address:
192.168.12.10:5051. This session also has an associated query: ´mm=ff´, which could have a
meaning in the context of the given session.
This request underlines Gigapxy’s capability to cascade or ’daisy-chain’ requests, and, therefore,
link its instances or itself up with other applications compliant with either of the two request for-
mats (’udp-channel’ and ’src-dst pair’). A chain, such as, for instance, udpxy -> gigapxy ->
udpxy -> media player, is made possible by this functionality.
f) http://acme.com:8080/$TV9
requests to use an aliased channel TV9 as the source, the destination defaulting to the requesting
connection.
g) http://acme.com:8080/src/$TV9?key=BF094744c5/dst
requests the same aliased channel in gigapxy format and appends the key parameter to the URL
the alias resolves to.
h) http://acme.com:8080/udp/[email protected]:5050 OR
http://acme.com:8080/src/udp://[email protected]:5050/dst/
request (via SSM) a multicast channel at 224.0.2.26:5050 coming from 10.0.11.26, taking advan-
tage of IGMPv3.
Administrative requests
Gigapxy listens on a dedicated TCP port for administrative requests. The request types are as below:
a) reports: http://{addr}:{port}/report?type={type}&format={format}&cached={0|1}
WHERE:
{type} ::= traffic|tps
{format} ::= html|web|xml
Other popular formats, such as json are also planned for the future.
Note: generation of throughput statistics should be enabled in appropriate config settings for TPS reports to
work.
Caching: gws(1) may cache its reports for a certain time period, defined as ws.report.cache_timeout_ms
in gws.conf(5) The request URL may request invalidation of the cache by using cached=0 parameter. NB:
this is to be used when getting the most actual data is critical. In all other cases, using cached reports would
be a wiser choice, saving CPU resources when many report requests come in close proximity.
WHERE:
{channel_tag} is the name tag for the channel;
{client_tag} is the name tag for the client (within the given channel). If client parameter is missing, then
channel={channel_tag} with all its clients will be disconnected.
Both channel and client must be specified exactly as TPS reports display them. For instance, for a multicast
channel tagged as UDP://224.0.12.15:7010 (please do mind that URI parameters, such as authorization cre-
dentials etc., are not included) and a client tagged as TCP://192.168.10.15:50905, with gws listening for
admin requests on 127.0.0.1:4047, the request:
http://127.0.0.1:4047/drop?channel=UDP://224.0.2.15:7010&client=TCP://192.168.10.15:50905 will
drop (disconnect) only the client, leaving the channel up and running, whereas
gws, upon receiving a ’drop’ request, looks up the channel record (but not the client), locates the appropri-
ate gng and relays the request to it. It is not the responsibility of gws to fulfill the request (since gng han-
dles it from there), so gws would report success (HTTP 200 OK) as soon as the request is sent to gng. If the
client in the request is invalid, the error will only be discovered by gng which sends no feedback to the
request’s origin. Should the request be successfully fulfilled by gng, it will report client/channel drops to
gws, resulting in appropriate entries added to the access log (see gws.conf(5) for more info on gws logs).
d) disconnect all clients and channels: http://{addr}:{port}/reset - this will have gws send SIGUSR2 to all
attached gng instances. SIGUSR2 directs a gng to drop all its channels and clients.
AUTHORIZATION
Gigapxy utilizes authorization helpers - user-supplied components - communicating with gws(1) via
STDIN and STDOUT. With authorization enabled (via config), each user request results in an authoriza-
tion request sent to a vacant auth helper. An illustrative example of a helper is prodvided at:
/usr/share/gigapxy/scripts/gauth.sh
An authorization request is a text string terminated by CR/LF, with the following fields separated by white-
space:
[ID] is A{num}, where {num} is a sequence number generated by gws; Example: A3404;
[peer] is combined IP address and port of the remote host requesting access; Example:
104.12.33.67:12301;
[source]: URI of the channel being requested and the authorization token; $Example:
udp://224.0.2.12:5011?auth=ef031204ba0c.
NB: The format of the authorization token is not dictated in any way by gws: it’s a mere convention
between the client requesting access and the (user-defined) authorization logic embedded in the helper. gws
passes what it recognizes as source to auth helper as is.
[destination] is URI for the destination or ’-’ for destination being the requesting TCP connection; Exam-
ple: -;
[CRLF] is a sequence of two symbols with ASCII codes 0x0d and 0x0a.
The helper validates the request and responds in the following format:
NB: A denial code could be arbitrary as long as it is non-zero; gws logic recognizes no difference between
1 and 210045, they both indicate denial of access and result in the 403 Forbidden HTTP response being
forwarded to the client; then the client session ends.
Since gws does not have any guarantee that a helper would not block on a request, it times out auth
requests using the applicable settings for user requests (please see gws.conf(5) for the particular settings). If
a client/user request times out on handling an authorization task, the engaged auth helper gets kill(2) -ed.
Do make sure your time-out settings for user requests are well-balanced to allow ample time for auth
requests to complete gracefully. Also, ensure that enough auth helpers are running to distribute requests to.
gws(1) issues warnings about a slow auth helper when it detects one (at a time-out), a sequence of such
warnings would indicate a mis-comfiguration issue.
AUTHORS
Pavel V. Cherenkov
SEE ALSO
gws(1),gng(1),gws.conf(5),gng.conf(5),channels.conf(5),gigapxy.auth(5)
NAME
gws - Gigapxy web service daemon.
SYNOPSIS
gws [-h?TvVqkU] [-C config_file] [-l logfile}] [-p pidfile]
DESCRIPTION
gws is the front-end module of Gigapxy. It handles user and administrative requests submitted via HTTP
protocol. The format of requests is described in the gigapxy(1) manpage.
gws dispatches user requests to Gigapxy engines, instances of a gng(1) daemon. At least one gng should
be running for Gigapxy to accept requests for data. A gws can control up to 64 engines.
gws takes its parameters from a configuration file, which is either gws.conf or gigapxy.conf by default and
can contain sections for any or all gigapxy modules. gws will look for the default configuration in a) cur-
rent directory; b) /etc; c) /usr/local/etc. Path to a specific configuration file could be given at com-
mand-line (see OPTIONS). Configuration options for gws are described in detail in gws.conf(5) man-
page.
gws rereads its configuration in response to SIGHUP. gws will force-rotate its log in response to
SIGUSR1.
OPTIONS
gws accepts the following options:
-h, --help, -?, --options
output brief option guide. This is NOT the behavior when run without parameters.
-C, --config path
specify configuration file.
-l, --logfile path
specify log file.
-p, --pidfile path
specify pid file.
-T, --term
run as a terminal (non-daemon) application. This is the default behavior when gws is run by a
non-privileged user. -T could be specified when run as root in order NOT to become a daemon,
for instance, for debugging purposes.
-v, --verbose
set the level of verbosity in the output. This option could be repeated to get to the desired level,
which is 0, unless the option is used at least once. Level 0 will reduce output to the very essential
log entries of NRM (normal) priority; level 1 will set verbosity to output to INF (info): suitable
for monitoring but not debugging; level 2 will enable DBG (debug) level for most (but not all)
application modules; level 3 will set DBG (debug) for all modules. This switch has a rather
inflexible nature, for more precise setting of log levels please use config settings alone.
-V, --version
output application’s version and quit.
-q,--quiet
send no output to terminal. This is to supress any output normally sent to standard output or error
streams. Unless specified, when run from a non-privileged account, gws will mirror diagnostic
messages sent to the log (as specified with the -l option) to standard output.
-k,--oldmcast
use legacy multicast API. gws uses newer protocol-agnostic API by default, some (older) sys-
tems may not fully support it or exhibit erroneous behavior when using it. Enabling this option
will have gws use the older protocol-specific multicast API.
-U,--unauth
Disable authorization (if configured). This option allows a quick command-line override to dis-
able whatever authorization method has been configured.
AUTHORS
Pavel V. Cherenkov
SEE ALSO
gigapxy(1),gng(1),gws.conf(5),gng.conf(5)
NAME
gws.conf - Gigapxy web service daemon configuration file.
DESCRIPTION
gws(1) is the gigapxy(1) web service daemon, responsible for processing incoming requests. The configu-
ration file contains the parameters read by the daemon at launch. The config file is human-readable and is
in libconfig format. An example of a gws.conf is provided with the installation; please refer to it or the lib-
config manual.
Once the parameters are read by gws, the daemon operates with those values util the configuration is
re-loaded in response to SIGHUP.
All gws(1) settings beginning with the ws. prefix, as in ws.section.param. A configuration file could contain
other (non-gws) settings too; gws will simply disregard those.
The configuration settings are given below. The default value for a setting is given in square brackets as
[default]. Parameters without default values are mandatory.
ws.log.*
Below are the settings pertaining to different modules within gws(1). Setting verbosity for one of those
allows to variate debug log detailization for specific modules within the program. Not every module though
has a specific level attributed to it; most default to the non-specific common level.
The follow settings are for the application (debug) log. Application log captures various actions as they
happen without any specific focus.
ws.log.file = path
Full path to debug log.
ws.access_log.*
The following settings are for gws access log, serving a specific purpose of capturing channel and client
session statistics. Access log is updated every time a new data stream is opened or closed. The entry types
are:
OPEN_CHANNEL channel_address
gws opens a connection to the given channel. Data starts flowing from the channel (specified by chan-
nel_address) into internal storage and on to channel subscribers.
AUTH_START/EXIT pid
Authorization helper started/exited. Shown is the helper’s pid.
ws.access_log.file = path
Full path to access log.
ws.channel_groups = path []
Full path to aliased channel-group configuration file (if any). If empty, no channel groups will be defined.
See details on aliased channel groups in channels.conf(5)
ws.channel_group_refresh = um [0]
Check every N seconds if channel-group config file changed, re-load and apply new channel-group settings
if it did.
ws.listener.*
The following are the settings equally applying to listeners of the two types of requests (admin and user)
handled by the application. You can define up to 32 user and 4 admin listeners. See gigapxy-com-
mented.conf for an example of multiple-listener config.
ws.listener.*.port = number
Port number for the listener.
ws.run_as_user = username []
Run as this user when running as a daemon (if empty, do not switch).
ws.process_limits.*
This section allows to impose limits on the running process via setrlimit(2) syscall. Memory limits are
specified as strings containing numerals and an optional denominator suffix, such as Kb, Mb or Gb. The
number can have a fraction, so "1.5Kb" evaluates to 1024 + 512 = 1536 - the value to be submitted as a
limit. "0" value or omission of a limit parameter leaves current (system-imposed) limit unchanged.
ws.tput_stats.*
The following section specifies the parameters needed for engines to report traffic throughput statistics,
queried using report admin request. See gigapxy(1) for details on reports and admin request particulars.
ws.report.*
The following section specifies the parameters needed to support generation of various reports.
ws.report.backup_file = filepath []
File to save each report into (overwriting the previous one). If empty, do NOT save.
ws.sync.regular_timeout_ms = ms [500]
After a GNG attaches, synchronize (retrieve) channel/client stats from TPS cache in N ms after the attach.
Enabled only if TPS (ws.tput_stats.enabled is true).
ws.sync.forced_timeout_ms = ms [10000]
If at least one GNG is attached, synchronize (retrieve) channel/client stats from TPS cache every N ms.
Enabled only if TPS (ws.tput_stats.enabled is true).
ws.redirect.err_channel = channel_URL []
Redirect client (via HTTP 302) to channel_address if requested channel is unavailable (for any reason
other than an error in an internal component of gigapxy). Channel URL must be a full HTTP URL that will
be returned to client via HTTP 302 response.
ws.redirect.no_access = channel_URL []
Redirect client (via HTTP 302) to channel_address if access to the requested channel has been denied (by
an authorization helper). Channel URL must be a full HTTP URL that will be returned to client via HTTP
302 response.
ws.psensors.*
Performance sensors allow to measure resource utilization between two specific points within the applica-
tion, using the metrics provided by utime(2) utime(2) call at each end of the sensor. All sensor data will be
printed out at the application exit in the format similar to the output of time(1) utility.
Performance sensors are a debugging/profiling facility and incur additional load on the system.
USE WITH DISCRETION.
Defined sensors:
app = application runtime; ev_loop = event processing (all events); ev_read = reading/processing inbound
data; ev_write = writing/processing outbound data; ev_err = processing error events; ev_pp = post-pro-
cessing events; ws_userq = processing user requests; ws_admrq = processing administrative requests
(reports, etc.).
ws.psensors.except = sensor_list []
Enables sensors in the list if ws.psensors.enable_all is true, or disables those sensors if false. This way
enable_all is used to initialize the set of sensors while except narrows it down by enabling/disabling its spe-
cific elements.
EXAMPLE A:
EXAMPLE B:
ws.auth.*
Authorization helpers are user-defined applications (plug-ins) used by gws to screen user requests, based
on request-specific data, such as user address, request URI, etc. gws starts one or several helpers and com-
municates with them via pipes connected to helpers’ STDIN and STDOUT streams. Example helper scripts
(a1p-auth.sh, b2p-auth.sh) for two supported protocols are provided in /usr/share/gigapxy/scrpts under
Linux (/usr/local/share/.. under FreeBSD).
ws.auth.exec = exec_path_with_params []
Specify full path to the helper executable with all command-line parameters. This constitutes a complete
absolute-path to the helper binary with all required command-line options and parameters. NB: all helpers
will be launched under user/group specified in ws.run_as* settings.
ws.auth.no_spawn_tmout = ms [5000]
Maximum time (ms) to disallow launching helpers after suspected cascading crashes. When a helper
crashes shortly after being launched, gws disables further helper launches for the configured time period.
ws.auth.aux_params = list_of_params []
Additional A1P-specific parameters passed to auth helpers. The available parameters are:
listener-alias = alias for the originating listener
ws.auth.cache.*
Negative authentication responses can be cached by gws. This allows for much faster response when
helpers’ time is at the premium and may better chances in case of a DOS attack. The cache’s eviction
method is LRU (least recently used) and each entry (source URL) has a time-out.
AUTHORS
Pavel V. Cherenkov
SEE ALSO
gigapxy(1),gws(1),gng(1),gng.conf(5),channels.conf(5),gigapxy.auth(5)
NAME
channels.conf - Gigapxy channel-group configuration file.
DESCRIPTION
gws(1) uses channel-group configuration to define channel sources that could be referenced not by absolute
address but via an alias. An alias is a name prepended by a dollar-sign character. gws, as it processes a
URL, recognizes an alias and translates it to an absolute-address URL to be used as a source.
alias
This is the name to be used in URLs with the dollar-sign prefix. The name/alias will be translated into one
of the URLs from the set defined for the given group.
urls
The URL to resolve the alias to. A URL may contain an alias but only to be resolved remotely (by the
gigapxy daisy-chained to the current one). In the future, more than one URL (with a load-balancing
option) may be supported for this setting.
EXAMPLE
This is what contents of a channels.conf file may look like:
channels = (
{ alias = "TV5"; urls = ["file:///opt/prog/tv5/channel-down.ts"]; },
{ alias = "NightLife"; urls = ["udp://10.0.24.16:5054"]; } );
Aliases are used with a dollar-sign prefix. A request to TV5 channel thus may look as:
a) http://acme.com:8080/$TV9
Or, in src/dst format, with a custom key parameter:
b) http://acme.com:8080/src/$TV9?key=BF094744c5/dst
AUTHORS
Pavel V. Cherenkov
SEE ALSO
gigapxy(1),gws(1),gws.conf(5)
NAME
gigapxy.auth - Gigapxy authentication manual.
DESCRIPTION
gws employs helpers - custom scripts - to authenticate and authorize incoming user requests. Any appli-
cation reading from STDIN and responding via STDOUT could serve as a helper as long as it ’speaks’ one
of the two communication protocols: A1P or B2P. This page is dedicated to giving the insight into auth
helpers, employed protocols and associated capabilities.
Common features:
Both protocols have things in common. Firstly, they are textual and line-oriented: a message is a text string
ending with CRLF ASCII sequence (single LF symbol under Linux and FreeBSD). gws writes mes-
sages/lines to helpers via unnamed pipes connecting to the helpers’ STDIN.
Messages contain fields separated by whitespace. An empty (blank) value is always specified as - (dash).
Some fields are common for both protocols, the first field is always the same: Session ID.
A1P request:
A1P uses pre-defined sequence of mandatory and optional fields in each request/response message.
The request fields are: Session-ID Peer Source Destination [Listener] (the last field is optional and is added
only if ws.auth.aux_params value contains listener-alias).
Peer = address:port
Address/port of the client (that sent the original request to gws)
Listener = alias
Alias of the listener that accepted the request. Do mind that when using this option, alias must be specified
for each listener in gws.conf.
A1P response:
A1P response example: A102 0
B2P protocol
B2P is an extension of A1P protocol that mainly addresses the inflexibility of A1P (fixed number of fields
come in and come out). The core features that drove towards creating a new protocol were: a) custom URLs
and b) endpoint (source/destination) re-write capability. B2P accommodates both of these features and pro-
vides future expansion of functionality. B2P adds one mandatory field to Session-ID, the Field-Mask.
Field identifiers:
U = Request-URL - the B2P field that holds URL for the HTTP request, the way it was in the header.
Example: /udp/224.0.4.56:4504
S = Source
D = Destination
P = Peer
A = User-Agent
L = Listener
r = Result-Code
Field-Mask ’USDP’ means that the message, besides the mandatory two fields, must have four fields of the
corresponding types. gws.conf provides ws.auth.b_fields setting to specify what information gws will send
to auth helpers with every B2P message.
B2P request:
Example B2P request: B102 UPL /udp/224.0.2.26:5034?auth=0x93fb0ad 10.0.3.14:40987 bb1
Some fields (r) don’t make much sense in the request and will be rejected by gws if specified.
B2P response:
It’s up to the helper implementation what set of fields would be returned, but at least one field should be.
Absense of Result-Code is assumed as APPROVE as long as other fields are present in the response. With
all the flexibility, only certain fields will be accepted in by gws in the response message.
Response-approved fields:
S = source will be re-written to the returned value
D = destination will be re-written to the returned value
r = APPROVE if 0, DENY otherwise.
A typical B2P denial response would be: B102 r 111 (Don’t you worry about 111, any non-zero number
would do).
allows to reply with the appropriate Source (and Destination is needed) and let gws know what the end-
points are.
allow_custom_urls lets gws ignore that the URL could not be parsed into gigapxy endpoints, so both
Source and Destination remain empty after request has been parsed.
B1 S udp://226.0.3.14:6060
gws reads the response and assumes the request is APPROVED (no r field but another field present). It
then takes udp://226.0.3.14:6060 as the source endpoint, directing to read from the given multicast chan-
nel.
Where do I begin?
Having decided which features you’d need and thus which protocol to select, make a copy of the corre-
sponding example helper in /usr/share/gigapxy/scrpts under Linux (/usr/local/share/.. under FreeBSD).
If you understand the logic, but dislike /bin/sh, use any other language. Once your helper (kind of) works,
make a text file (requests.txt) with sample requests (the kind you’d be most likely processing) and run:
The output will be the response messages. If somethig does not quite work, the log (where your script
writes) should help.
AUTHORS
Pavel V. Cherenkov
SEE ALSO
gigapxy(1),gws(1),gng(1),gng.conf(5),gws.conf(5)
NAME
gng - Gigapxy engine daemon.
SYNOPSIS
gng [-h?TvVq] [-C config_file] [-l logfile}] [-p pidfile] [-w path] [-P cpunum]
DESCRIPTION
gng is the Gigapxy engine module performing I/O on behalf of data requests submitted to gws. The format
of gws requests is described in the gigapxy(1) manpage.
gng attaches to the specified gws upon start-up; up to 64 engines may attach to a single gws. The control-
ling gws relays (pre-processed) data requests to the attached engines for execution.
gng takes its parameters from a configuration file, which is either gng.conf or gigapxy.conf by default and
can contain sections for any or all gigapxy modules. gng will look for the default configuration in a) current
directory; b) /etc; c) /usr/local/etc. Path to a specific configuration file could be given at command-line
(see OPTIONS). Configuration options for gws are described in detail in gng.conf(5) manpage.
gng re-reads its configuration in response to SIGHUP. gng will force-rotate its log in response to
SIGUSR1.
OPTIONS
gng accepts the following options:
-h, --help, -?, --options
output brief option guide. This is NOT the behavior when run without parameters.
-C, --config path
specify configuration file.
-l, --logfile path
specify log file.
-p, --pidfile path
specify pid file.
-w, --gws path
specify path to the controlling gws (domain socket).
-T, --term
run as a terminal (non-daemon) application. This is the default behavior when gws is run by a
non-privileged user. -T could be specified when run as root in order NOT to become a daemon,
for instance, for debugging purposes.
-v, --verbose
set the level of verbosity in the output. This option could be repeated to get to the desired level,
which is 0, unless the option is used at least once. Level 0 will reduce output to the very essential
log entries of NRM (normal) priority; level 1 will set verbosity to output to INF (info): suitable
for monitoring but not debugging; level 2 will enable DBG (debug) level for most (but not all)
application modules (please mind that bufd is NOT at debug at level 2); level 3 will set DBG
(debug) for additional modules, including bufd; level 4 will set all modules to debug. This switch
has a rather inflexible nature, for more precise setting of log levels please use config settings
alone.
-V, --version
output application’s version and quit.
-q,--quiet
send no output to terminal. This is to supress any output normally sent to standard output or error
streams. Unless specified, when run from a non-privileged account, gws will mirror diagnostic
messages sent to the log (as specified with the -l option) to standard output.
-P,--cpu
Set CPU affinity for the main process. This option allows to restrict the main gng process to the
given CPU/core (numbered from 0 to N-1).
AUTHORS
Pavel V. Cherenkov
SEE ALSO
gigapxy(1),gws(1),gws.conf(5),gng.conf(5)
NAME
gng.conf - Gigapxy engine configuration file.
gng(1) is the gigapxy(1) data processing daemon, responsible for the I/O on behalf of user requests relayed
to it by gws(1). The configuration file contains the parameters read by the daemon at the launch. The file is
in easy-to-read libconfig format. An example of a gng.conf is provided with the installation.
Once the parameters are read by gng, the daemon operates with those values util the configuration is
re-loaded in response to SIGHUP.
All gng(1) settings begin with the ng. prefix, as in ng.section.param. A configuration file may also contain
settings intended for other modules; gng would ignore all non-gng settings.
The configuration settings are listed below. The default value for a setting is given in square brackets as
[default]. Parameters without default values are mandatory.
ng.log.file = path
Full path to log.
ng.run_as_user = username []
Run as this user when running as a daemon (if empty, do not switch).
ng.cpunum = -1 | 0 .. N [-1]
Set affinity to CPU #N (zero-based) for this process, unless -1 (or <0).
(virtual memory cap). If both RSS and VMEM are to be limited under Linux, the smaller value is used with
RLIMIT_AS. Under FreeBSD, RSS limit is fully supported.
ng.tput_stats.*
The following section specifies the parameters needed for engines to report traffic throughput statistics,
queried using report admin request. See gigapxy(1) for details on reports and admin request particulars.
ng.bufd.*
The following section specifies the parameters for the internal cache used by gng to multiplex access to
channel data. For each channel (that needs to be cached) gng maintains a chain of buffers, representing con-
secutive segments for traffic data.
The following three settings affect the way gng caches data. There is a certain amount that can be kept per
channel to ensure that new clients can start receiving data without delay. The settings below regulate that
amount and set the point (in the cache) from which data gets served to a new client.
The two settings above work in tandem, each of them setting a threshold. gng will consider that enough
data has been cached as soon as either or both of those thresholds have been reached: if, for instance, the
first setting is 5 seconds and the second one is 10485760 bytes (10 Mb), then enough is as soon as we’ve
cached 10Mb or accumulated more than 5 seconds worth of data (if the channel is slow, it may be less than
10Mb).
Channel data is stored as a sequence of buffers, from the most-recently-received one - the HEAD, to the
oldest one - the TAIL.
A newly-joined client/subscriber needs the first data buffer to start with. The setting below defines the
algorithm gng would use to pick one.
ng.bufd.start_mode = 0 | 1 | -1 | 2 [1]
Defines the method to pick the initial buffer for a client:
0 (HEAD) picks the most-recently-received buffer, offset: 0 (cached: all of the most recent buf-
fer).
2 (EDGE) picks the most-recently-received buffer, offset: END-OF-DATA (no data cached).
1 (MIN_CACHED) picks the buffer that allows to transfer N seconds or M bytes of data, offset: 0
(cached: N seconds/M bytes).
-1 (TAIL) picks the oldest buffer in cache, offset: 0 (cached: all current data for the channel).
All the above methods, except EDGE (2) position a new client at zero offset in the selected buffer. This
way there is always some data to send to the client right away, without I/O wait. EDGE ensures a no-cache
policy: only the data received during the client’s lifespan gets relayed to the destination.
ng.bufd.client_catch_up_ms = ms [0]
Advance to the most recent buffer if no data gets sent out within the given time period. Once a client times
out, its output marker is shifted to ’catch up’ with the source data flow. For start_mode = EDGE (2), the
offset would be at the end of the head buffer (edge), for other modes - byte 0 of the head buffer.
associated with a channel to track incoming datagrams. Certain features rely heavily on such tracking. A
datagram index holds a number of datagram sequences. Each sequence accounts for a number of consecu-
tive datagrams of the same size.
ng.bufd.stale_dgram_ms = ms [0]
If non-zero, the value sets expiry period for inbound data in UDP channels. If a client finds itself at the
point of needing to transmit a stale datagram, its output offset gets shifted to byte 0 of the
most-recently-received datagram.
ng.bufd.max_dseq_ms = ms [8 * stale_dgram_ms]
Maximum time in milliseconds (worth of data) to aggregate in a single datagram sequence. This setting
could be made smaller to increase precision of time measurement for stale_dgram_ms or made larger to
aggregate more datagrams in a single sequence (in order to save space).
ng.cli_write_delay.*
This section regulates delaying data output to reduce the number of write(2) syscalls. Data is accumulated
until the saved portion is large enough.
ng.psensors.*
Performance sensors allow to measure resource utilization between two specific points within the applica-
tion, using the metrics provided by utime(2) utime(2) call at each end of the sensor. All sensor data will be
printed out at the application exit in the format similar to the output of time(1) utility.
Performance sensors are a debugging/profiling facility and incur additional load on the system.
USE WITH DISCRETION.
Defined sensors:
app = application runtime; ev_loop = event processing (all events); ev_read = reading/processing inbound
data; ev_write = writing/processing outbound data; ev_err = processing error events; ev_pp = post-pro-
cessing events; ng_chaio = channel data I/O; ng_clio = client data I/O.
ng.psensors.except = sensor_list []
Enables sensors in the list if ng.psensors.enable_all is true, or disables those sensors if false. This way
enable_all is used to initialize the set of sensors while except narrows it down by enabling/disabling its spe-
cific elements.
EXAMPLE A:
EXAMPLE B:
AUTHORS
Pavel V. Cherenkov
SEE ALSO
gigapxy(1),gws(1),gng(1),gws.conf(5),channels.conf(5),gigapxy.auth(5),mlockall(2)