Monday, February 21, 2011

Digging into Tibco Rendezvous network details - II

Daemon Parameter -
The daemon parameter instructs the transport creation function about how and where to find the Rendezvous daemon and establish communication. Each Rendezvous transport establishes a communication conduit with theRendezvous daemon, as the following steps describe:
  1. The daemon process opens a (TCP) client socket, and waits for a client to request a connection.The -listen option of the Rendezvous daemon (rvd) specifies the socketwhere the Rendezvous daemon should listen for new client programconnections.
  2. The program calls the transport creation function, which contacts the daemon at the client socket specified in its daemon parameter. The daemon parameter of the transport creation function must correspond tothe -listen option of daemon process; that is, they must specify the same communication type and socket number.If no daemon process is listening on the specified client socket, then thetransport creation call automatically starts a new daemon process (which listens on the specified client socket), and then attempts to connect to it.
  3. The daemon process opens a conduit for private communication with the newtransport object in the program. All future communication uses that conduit.The request socket is now free for additional requests from other clienttransports.
  • Specifying a Local Daemon - For local daemons, specify the transport creation function‘s daemon parameter andthe -listen option to the daemon process as a (TCP) socket number; for example:"6555".To use the default client socket, supply NULL as the daemon argument to thetransport creation function, and omit the -listen option to the daemon process.
  • Remote Daemon - In most cases, programs connect to a local daemon, running on the same host asthe program. Certain situations require a remote daemon, for example: The program runs on a laptop computer that is not directly connected to thenetwork. Instead, the laptop connects to a workstation on the network, andthe daemon runs on that workstation. Another example could be that the program connects to a network at a remote site.

For remote daemons, specify two parts (introducing the remote host name as thefirst part): Remote host name: Port number. For example:"purple_host:6555"

Network Parameter -

Every network transport object communicates with other transport objects over anetwork. On computers with only one network interface, the Rendezvous daemon communicates on that network without further instruction from the program. On computers with more than one network interface, the network parameter instructs the Rendezvous daemon to use a particular network for all communications involving this transport. To communicate over more than one network, a program must create a separate transport object for each network. The network parameter also specifies multicast addressing details
The network parameter consists of up to three parts, separated by semicolons—network, multicast groups, send address—as in these examples:

lan0 -- > network only

lan0; --> one multicast group

lan0;,; --> two multicast groups, send address

lan0;; -->no multicast group, send address

  1. Part one identifies the network, which you can specify in several ways: - Host name, Host IP address, Network name, Network IP number, Interface name, Default TRDP daemons use the network interface which corresponds to the hostname of the system as determined by the C function gethostname(). PGM daemons use the default PGM multicast interface,
  2. Part Two—Multicast Groups - Part two is a list of zero or more multicast groups to join, specified as IP addresses, separated by commas. Each address in part two must denote a valid multicast address. Joining a multicast group enables listeners on the resulting transport to receive data sent to that multicast group.
  3. Part Three—Send Address, Part three is a single send address. When a program sends multicast data on the resulting transport, it is sent to this address. (Point-to-point data is not affected.) If present, this item must be an IP address—not a host name or network name. The send address need not be among the list of multicast groups joined in part two. If you join one or more multicast groups in part two, but do not specify a send address in part three, the send address defaults to the first multicast group listed in part two.

Digging into Tibco Rendezvous network details - I

Tibco RV is is one of the most used messaging systems. Athough lot of people use RV but there are some concepts which are known mainly to admins. These are some concepts which are better to be known by developers also for better programming.

Rendezvous Daemon -

The Rendezvous daemon is a background process that supports all Rendezvous communications. Distributed processes depend on it for reliable and efficient network communication. All information that travels between processes passes through a Rendezvous daemon as it enters a host computer or exits a sending process. Its functions are as following :-

• Transmits outbound messages from program processes to the network.
• Delivers inbound messages from the network to program processes.
• Filters subject-addressed messages.
• Shields programs from operating system idiosyncrasies, such as low-level sockets.

The Rendezvous daemon process, rvd, starts automatically when needed, runs continuously and may exit after a period of inactivity. We can run the deamon on our local machine or can even connect to another daemon running on some remote machine.

Transport -

Programs use transport objects to send messages and listen for messages. A transport determines three aspects of message delivery:
  1. Delivery scope—the potential range of its messages
  2. Delivery mechanism—the path (including software, hardware and networkaspects) that its messages travel
  3. Delivery protocol—the ways in which programs cooperate and shareinformation concerning message delivery. Various types of transport object combine these aspects to yield different qualities of service—for example, intra-process delivery, network delivery, reliabledelivery, virtual circuit, certified delivery, and distributed queue delivery.
Rendezvous software distinguishes between two broad classes of transports.

• Network transports - A network transport delivers messages across a network, to processes on one ormore hosts. It also can deliver messages to several processes on a single host. All messages pass through a Rendezvous daemon process.The service, network and daemon parameters of a network transport specifyits scope within the network

• Intra Process Transport - An intra-process transport delivers messages between program threads within asingle process.Intra-process messages do not pass through a Rendezvous daemon process;instead, they remain local within the program process. Intra-process messagesare significantly faster than network messages.Each program contains exactly one intra-process transport; the Rendezvousopen call creates it automatically. Its scope is the program process. Any threadcan dispatch intra-process events from an appropriate queue.

Service parameter -

The service parameter instructs the Rendezvous daemon to use this servicewhenever it conveys messages on the transport. As a direct result, services divide the network into logical partitions. Eachtransport communicates on a single service; a transport can communicate onlywith other transports on the same service. To communicate on more than oneservice, a program must create a separate transport object for each service. Within each rvd process, all the transports that specify a given service mustspecify the same network parameter. That is, if the service parameters resolve tothe same UDP or PGM port, then the network parameters must also be identical.(This restriction extends also to routing daemons.)

For example, suppose that the program foo, on the computer named orange, hasa transport that communicates on the service svc1 over the network lan1. It isillegal for any program to subsequently create a transport (connecting to the samedaemon process on orange) to communicate on svc1 over any other network—such as lan2. Once rvd binds svc1 to lan1, that service cannot send outboundbroadcast messages to any other network. Attempting to illegally rebind a serviceto a new network fails; transport creation calls produce an error status(TIBRV_INIT_FAILURE).

The limitation is not as severe as it might seem at first, because it only affectsoutbound broadcast messages:

--> Point-to-point messages on the transport’s service travel on the appropriatenetwork (as determined by the operating system) irrespective of thetransport’s network parameter.

--> Inbound broadcast messages on the transport’s service can arrive from anynetwork, irrespective of the transport’s network parameter.

Rendezvous programs specify services in one of three ways, shown below inorder of preference:

  1. Service name - When you specify a service name, the transport creation function callsgetservbyname(), which searches a network database (such as NIS) or a flat file(such as services in the system directory).
  2. Port number - When you specify a port number, it must be a string representing a decimalinteger (for example, "7890").
  3. Default - If you specify null, the transport creation function searches for the service namerendezvous. If getservbyname() does not find rendezvous, the Rendezvous daemoninstructs the transport creation function to use a hard default:

The TRDP daemon offers the default service 7500.The PGM daemon offers the default service 7550.

Monday, January 10, 2011

Software/Package Management in Ubuntu/debian

Ubuntu's package management system is derived from the same system used by the Debian GNU/Linux distribution. The package files contain all of the necessary files, meta-data, and instructions to implement a particular functionality or software application on your Ubuntu computer.
Debian package files typically have the extension '.deb', and typically exist in repositories which are collections of packages found on various media, such as CD-ROM discs, or online. Packages are normally of the pre-compiled binary format; thus installation is quick and requires no compiling of software.

dpkg - dpkg is a package manager for Debian based systems. It can install, remove, and build packages, but unlike other package management system's, it can not automatically download and install packages or their dependencies. I shall show examples of dpkg to manage locally installed packages:

To list all packages installed ==> dpkg -l
To list all files installed by package specified as argument ==> dpkg -L {package-name}
To install local package ==> sudo dpkg -i {package-name}
To unistall a package ==> sudo dpkg -r {package-name}
There are lot of other options also which we can use with dpkg. For more details refer to man page of dpkg.

Apt-Get - The apt-get command is a powerful command-line tool used to work with Ubuntu's Advanced Packaging Tool (APT) performing such functions as installation of new software packages, upgrade of existing software packages, updating of the package list index, and even upgrading the entire Ubuntu system.

Apt-get maintains a list of packages available on repositories specified in /etc/apt/sources.list file. Unlike dpkg Apt-get automatically download the package from repository if available.

To install a new package ==> sudo apt-get install {package-name}
To remove a package ==> sudo apt-get remove {package-name}
To update index of packages ==> sudo apt-get update
To upgrade packages ==> sudo apt-get upgrade
You can find more detailed information on apt-get by typing man apt-get.

There are other tools also available like Aptitude to do all this. Ubuntu have very good graphical interfaces to do all above written stuff but if you are a Linux fan, you would love to do it from Command-line

Managing repositories for apt-get - In addition to the officially supported package repositories available for Ubuntu, there exist additional community-maintained repositories which add thousands more potential packages for installation. Two of the most popular are the Universe and Multiverse repositories. These repositories are not officially supported by Ubuntu, but because they are maintained by the community they generally provide packages which are safe for use with your Ubuntu computer.

  • Packages in the Multiverse repository often have licensing issues that prevent them from being distributed with a free operating system, and they may be illegal in your locality.
  • Be advised that neither the Universe or Multiverse repositories contain officially supported packages. In particular, there may not be security updates for these packages.

You can add/remove repositories either from UI by going to System->Administration->Software Sources or by editing /etc/apt/sources.list file.

Saturday, January 8, 2011

Link Files in Unix/Linux

Links in Unix - Links are used in Unix/Linux for better managebility of file system.

Command we use for linking two files is ln.

ln -[options] existingfilename newfilename

Common options -

-f ---> Link files without questioning the user, even if the mode of target forbids writing.
-s ---> Creates a symbolic link to existingfilename with the name of the newfilename.

Hard Link - A hard link is a reference to a file or directory that appears just like a file or directory, not a link. Hard links only work within a filesystem. In other words, don’t use hard links between mounted filesystems. A hard link is only a reference to the original file, not a copy of the file. Basically points to a file's inode. So if you delete one file , it can still be accessed from other hard link available.

How do we check hard links -
If we want to check hard links in one specific directory we can simple use ls -i command which list the files with their respective inode number.

If we want to find all files hard linked with one file we can use find command in following way -
find {location} -xdev -samefile {filename}

ls -lrt shows the number of links to a file. The column next to permissions shows number of links to that file.

Soft Link - A soft link/symbolic link is a pointer to another file or directory. It can be used just like the original file or directory. A symbolic link appears in a long listing (ls -l) with a reference to the original file/directory. A symbolic link, as opposed to a hard link, is required when linking from one filesystem to another and can be used within a filesystem as well.

How to find soft links -
If we do ls -lrt in one directory it shows the soft links with target files.
Find all links in system - find {location} -type l

How to unlink files -

unlink filename

PS: unlink and rm both remove the files, the difference is that unlink is a system call, rm is a shell utility that calls unlink.

Keep checking for more posts on Unix/Linux