NetGear API Parameters¶
 
address¶
This parameter sets the valid Network IP address for Server/Client. Network addresses are unique identifiers across the network.
In every messaging pattern, the receiver (Client) binds and the sender (Server) connects. Hence, this parameter MUST always be the IP address of the receiver (Client) machine at both ends (or '*' at the Client end to bind on all interfaces).
With protocol="ipc", this parameter is instead a filesystem path (e.g. /tmp/netgear.ipc), and MUST be same at both ends. Its default path is <tempdir>/vidgear-<port>.ipc at both ends. In Multi-Servers/Multi-Clients Mode, -<port> is appended to an explicit path for each port.
Data-Type: String
Default Value: Its default value is based on selected primary mode, i.e 'localhost' for Send Mode and '*' for Receive Mode on a local machine.
Usage:
Â
port¶
This parameter sets the valid Network Port for Server/Client. Network port is a number that identifies one side of a connection between two devices on the network and is used determine to which process or application a message should be delivered.
Exception for Exclusive Modes
- A unique port number MUST be assigned to each Server on the network using this parameter.
- At Client end, a List/Tuple of all available Server(s) ports MUST be assigned using this same parameter.
- See its usage example here âž¶.
- A unique port number MUST be assigned to each Client on the network using this parameter.
- At Server end, a List/Tuple of all available Client(s) ports MUST be assigned using this same parameter.
- See its usage example here âž¶.
Data-Type: String or List/Tuple
Default Value: Its default value is '5555'
Usage:
Â
protocol¶
This parameter sets the valid messaging protocol between server and client. A network protocol is a set of established rules that dictates how to format, transmit and receive data so computer network devices - from servers and routers to endpoints - can communicate regardless of the differences in their underlying infrastructures, designs or standards. Supported protocol are: 'tcp' and 'ipc'. Any other value is skipped with a warning, and NetGear falls back to 'tcp'.
ipc protocol needs UNIX domain sockets, and works only between processes on the same machine. Its address is a filesystem path. Also, SSH Tunneling Mode only supports tcp (raises ValueError otherwise).
Data-Type: String
Default Value: Its default value is 'tcp'
Usage:
Â
pattern¶
This parameter sets the supported messaging pattern(flow of communication) between server and client. Messaging patterns are the network-oriented architectural pattern that describes the flow of communication between interconnecting systems. NetGear provides access to ZeroMQ's pre-optimized sockets which enables you to take advantage of these patterns.
Data-Type: Integer
Default Value: Its default value is 0 (i.e zmq.PAIR). Any invalid value is skipped with a warning, and NetGear falls back to 0.
Supported ZMQ patterns
All supported ZMQ patterns for NetGear are:
0(.i.e. zmq.PAIR): In this pattern, the communication is bidirectional. There is no specific state stored within the socket. There can only be one connected peer. The client (receiver) binds on a certain port and the server (sender) connects to it.1(.i.e. zmq.REQ/zmq.REP): In this pattern, it employsZMQ REQsockets that can connect to many peers. The requests will be interleaved or distributed (round-robin) between them. socketzmq.REQwill block send unless it has successfully received a reply back and socketzmq.REPwill block on recv() unless it has received a request.2(.i.e. zmq.PUB/zmq.SUB): It is an another classic pattern where senders of messages, called publishers, do not program the messages to be sent directly to specific receivers, called subscribers. Messages are published without the knowledge of what or if any subscriber of that knowledge exists. AZMQ.SUBcan receive from multipleZMQ.PUB(publishers). No single publisher overwhelms the subscriber. The messages from both publishers are interleaved. Frames are dropped while no subscriber is connected.3(.i.e. zmq.PUSH/zmq.PULL): In this one-way pipeline pattern, theZMQ.PUSHsender distributes frames to its connectedZMQ.PULLreceivers in round-robin (load-balancing, not broadcast), and aZMQ.PULLreceiver fair-queues frames from all its senders. Frame order is preserved per-sender only. The sender buffers up tosend_hwmframes, and itssend()raisesRuntimeErrorafterrequest_timeoutif no client takes them. Bidirectional Mode is not supported.
In every pattern, the receiver (Client) binds and the sender (Server) connects. Multi-Servers and Multi-Clients Modes need pattern 1, 2 or 3, whereas Bidirectional Mode needs pattern 0 or 1.
Usage:
Â
receive_mode¶
This parameter select the Netgear's Mode of operation. It basically activates Receive Mode(if True) and Send Mode(if False). Furthermore, recv() method will only work when this flag is enabled(i.e. Receive Mode), whereas send() method will only work when this flag is disabled(i.e.Send Mode).
Data-Type: Boolean
Default Value: Its default value is False(i.e. Send Mode is activated by default).
Usage:
Â
options¶
This parameter provides the flexibility to alter various NetGear API's internal properties, modes, and some PyZMQ flags.
Data-Type: Dictionary
Default Value: Its default value is {}
Usage:
Supported dictionary attributes for NetGear API
-
multiserver_mode(boolean) : This internal attribute activates the exclusive Multi-Servers Mode, if enabled(True). -
multiclient_mode(boolean) : This internal attribute activates the exclusive Multi-Clients Mode, if enabled(True). -
secure_mode(integer) : This internal attribute selects the exclusive Secure Mode. Its possible values are:0(i.e. Grassland(no security)) or1(i.e. StoneHouse) or2(i.e. IronHouse). -
bidirectional_mode(boolean) : This internal attribute activates the exclusive Bidirectional Mode, if enabled(True). -
ssh_tunnel_mode(string) : This internal attribute activates the exclusive SSH Tunneling Mode at the Server-end only, and sets the SSH server to tunnel through (formatted asuser@server:port, default port22). -
ssh_tunnel_pwd(string): In SSH Tunneling Mode, This internal attribute sets the password required to authorize Host for SSH Connection at the Server-end only. More information can be found here âž¶ -
ssh_tunnel_keyfile(string): In SSH Tunneling Mode, This internal attribute sets path to the user's SSH private key (similar tossh -i) that provide another way to authenticate with the SSH server at the Server-end only. An invalid path is discarded with a warning. More information can be found here âž¶ -
custom_cert_location(string) : In Secure Mode, This internal attribute assigns user-defined location/path to directory for generating/storing Public+Secret Keypair necessary for encryption. This directory MUST already exist and be writable, otherwiseAssertionErroris raised. More information can be found here âž¶ -
overwrite_cert(boolean) : In Secure Mode, This internal attribute decides whether to overwrite existing Public+Secret Keypair/Certificates or not, at the Server-end only. More information can be found here âž¶ -
allowed_ips(list of strings) : In Secure Mode, This optional internal attribute whitelists IP addresses of the Server(s) (senders) allowed to connect, at the Client-end only. By default, there's no IP whitelist, and any peer with valid CURVE credentials is accepted. More information can be found here âž¶ -
jpeg_compression(bool/str): This internal attribute is used to activate(ifTrue)/deactivate(ifFalse) JPEG Frame Compression as well as to specify incoming frames colorspace with compression. By default colorspace isBGRand compression is enabled(True), but only if simplejpeg is installed (otherwise this attribute is silently ignored, and frames are sent uncompressed). Invalid values are skipped with a warning. More information can be found here âž¶ -
jpeg_compression_quality(int/float): This internal attribute controls the JPEG quantization factor in JPEG Frame Compression. Its value varies from10to100(the higher is the better quality but performance will be lower). Its default value is90. More information can be found here âž¶ -
jpeg_compression_fastdct(bool): This internal attributee if True, use fastest DCT method that speeds up encoding/decoding by 4-5% for a minor loss in quality in JPEG Frame Compression. It affects each end independently (i.e. encoding at the Server, and decoding at the Client). Its default value is alsoTrue. More information can be found here âž¶ -
jpeg_compression_fastupsample(bool): This internal attribute if True, use fastest color upsampling method while decoding at the end it is set on. Its default value isFalse. More information can be found here âž¶ -
jpeg_compression_colorsubsampling(str): This internal attribute sets the chroma subsampling used while encoding at the Server end. Its possible values are:"444","422","420","440"and"411", and its default value is"422". More information can be found here âž¶ -
max_retries(integer): This internal attribute controls the maximum consecutive reconnection attempts before Server/Client exit itself, if it's unable to get any response/reply from the socket before a certain amount of time, when synchronous messaging patterns like (zmq.PAIR&zmq.REQ/zmq.REP) are being used. This counter is reset after every successful exchange. The Server raisesRuntimeErroronce all retries fail. It's value can be any integer greater than or equal to1, and its default value is3. -
request_timeout(int/float): This internal attribute controls the timeout value (in seconds) for getting a response/reply from the socket, when synchronous messaging patterns like (zmq.PAIR&zmq.REQ/zmq.REP) are being used. The Client waits 3× this value before reconnecting, whereas the Server reconnects after this value and raisesRuntimeErroraftermax_retriesfailed attempts. Inzmq.PUSH/zmq.PULLpattern, it is also thesend()timeout at the Server end. It's value can be any number greater than or equal to4, and its default value is4seconds. -
receive_timeout(int/float): Similar torequest_timeout, this internal attribute also controls the timeout value (in seconds) but for non-synchronouszmq.PUB/zmq.SUBandzmq.PUSH/zmq.PULLpatterns at the Client end only, after which the Client exits itself (i.e.recv()returnsNone) if nothing arrives from the socket for that long. It's value can be any number greater than0, and its disabled by default (meaning the client will wait forever for response). Recommended for these patterns, since their termination signal is best-effort. Its older namesubscriber_timeoutis also accepted as an alias. -
send_hwm(integer): This internal attribute sets the maximum number of frames buffered at the Server end inzmq.PUSH/zmq.PULLpattern, while no Client takes them. Once full,send()waits up torequest_timeoutand then raisesRuntimeError. It's value can be any integer greater than or equal to1, and its default value is4. -
flag(integer): This PyZMQ attribute value can be either0orzmq.NOBLOCK( i.e. 1), and applies to both sending and receiving. Its default value is0. More information can be found here âž¶.
With flags=1 (i.e. NOBLOCK), send() may raise zmq.Again if the message cannot be queued right away, and NetGear might not terminate gracefully.
copy(boolean): This PyZMQ attribute selects if message be sent/received in a copying or non-copying (zero-copy) manner. Its default value isFalse(i.e. zero-copy).
With copy=False, do not modify a raw frame's buffer that you've passed to send() until it is sent. JPEG compressed frames are always encoded into fresh buffers, so they're safe.
track(boolean): This PyZMQ attribute check if the message is tracked for notification that ZMQ has finished with it (ignored ifcopy=True). Its default value isFalse.
The desired attributes can be passed to NetGear API as follows:
# formatting parameters as dictionary attributes
options = {
"secure_mode": 2,
"custom_cert_location": "/home/foo/foo1/foo2", # must be an existing writable directory
"overwrite_cert": True,
"flag": 0,
"copy": True,
"track": False
}
# assigning it
NetGear(logging=True, **options)
Â
logging¶
This parameter enables logging (if True), essential for debugging.
Data-Type: Boolean
Default Value: Its default value is False.
Usage:
Â