Communication Basics

Table of contents:

To understand how sockets work, a basic understanding of some of the details of process communications in a networked environment and its associated terminology is needed.

10.2.1 Network Addresses

Every host on a network has, at a minimum, two unique addresses. The first unique address is a 48-bit [1] media access control (MAC) address that is assigned to its network interface card (NIC). The manufacturer of the card assigns this address. The MAC address (sometimes called its Ethernet or hardware address) is written in hexadecimal notation. The address is broken into six 8-bit numbers with intervening colons ( : ). When using hexadecimal, each 8-bit number will be, at most, two digits, each consisting of 09, AF. The case of the alphabetic digits is not important, and leading 0s are often not included. The first three groupings (bytes) of this number identify the hardware manufacturer. A variety of sites exist on the Internet that map manufacturer identifier values to their corresponding vendor. One such table can be found at

[1] In IPv4 (Internet Protocol version 4, which has been around for about 20 years ) these addresses are 48-bit. In IPv6 (originally called IPng: Internet Protocolthe next generation) these addresses are 64-bit.

On some UNIX-based systems the file /etc/ethers contains the MAC addresses for local hosts . Additionally, the file /proc/net/arp contains recently resolved addresses (Internet addresses and their corresponding hardware address). On a Linux host the ifconfig utility can be used to display the hardware address of its NICs. Figure 10.1 shows the output of the ifconfig command when passed the -a (all) option.

Figure 10.1 Displaying the MAC addresses on a Linux host.

linux$ /sbin/ifconfig -a
eth0 Link encap:Ethernet HWaddr


<-- 1

 RX packets:0 errors:0 dropped:0 overruns:0 frame:0
 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
 collisions:0 txqueuelen:100
 Interrupt:16 Base address:0xecc0 Memory:e08fc000-e08fcc40

eth1 Link encap:Ethernet HWaddr


<-- 1

inet addr: Bcast: Mask:


MULTICAST MTU:1500 Metric:1
 RX packets:471693034 errors:2 dropped:0 overruns:27398 frame:2
 TX packets:2147483647 errors:0 dropped:0 overruns:0 carrier:0
 collisions:0 txqueuelen:100
 Interrupt:26 Base address:0xd4c0 Memory:e08fe000-e08fec40

lo ink encap:Local Loopback
 inet addr: Mask:
 RX packets:95939986 errors:0 dropped:0 overruns:0 frame:0
 TX packets:95939986 errors:0 dropped:0 overruns:0 carrier:0
 collisions:0 txqueuelen:0

(1) This host has two network cards. As shown, only eth1 is active

The second unique address for a host is a 32-bit [2] Internet (IP) address. Internet addresses used to be assigned by the Internet Network Information Center (InterNIC). At present, the process is a bit more complicated. At the uppermost level ICANN (the Internet Corporation for Assigned Names and Numbers) assigns blocks of addresses on a regional basis. At the regional level the American Registry for Internet Numbers (ARIN) allocates IP address space in North and South America, the Caribbean, and sub-Saharan Africa; APNIC (Asia Pacific Network Information Center) allocates addresses for Asia and the Pacific; RIPE (R seaux IP Europ ens) handles European addresses. At a local level Internet service providers (ISPs) obtain their addresses from their regional authority. At the next level users request their addresses from the ISP. A 32-bit IP address is broken into four 8-bit numbers, each separated by a dot ( . ). Written in dotted decimal notation (DDN), each of the four subnumbers can range from 0 to 255 (although the numbers 0 and 255 in the last grouping often have a special meaning, such as a local loopback or broadcast address).

[2] With IPv6, the 32-bit IP addresses will become 128-bit.

An IPv4 Internet address may be subdivided into a network and local portion. The network portion, or netid , occupies the leftmost portion of the IP address, and the local portion, or hostid , the rightmost portion. Using the leading bits of the netid value, networks can be divided into five classes, A through E. We will look at the first three classes. [3] In a Class A network bit 0 is 0; in a Class B the first two bits are 10, and in a Class C the first 3 bits are 110. The netid portion of the address is assigned by the ISP and indicates your network association. The content of the hostid portion is determined by the local network administrator and specifies the individual host (workstation) within your network. As can be seen in Figure 10.2, the range of hostids that a local network administrator can assign is directly related to the class of the network. In general, small sites have Class C network addresses, larger sites Class B, and so on. When this numbering scheme was initiated, it was not anticipated that the range of available network addresses would be restrictive , as it allowed for 2 7 Class A networks, 2 14 Class B networks, and 2 21 Class C networks (see Exercise 10.1 for more on this topic).

[3] Classes D and E are special network classes. Class D is used for multicasting, and Class E is reserved for experimental use. Neither of these classes has an inherent host-addressing scheme.

Figure 10.2. Network class numbering scheme.


It is the responsibility of the host to map a specific Internet address to its corresponding Ethernet (hardware) address. This process, called address resolution, uses its own protocol called address resolution protocol (ARP). The command /sbin/arp -a displays a listing of recently resolved Internet/Ethernet address pairs on the current host. In discussing sockets, when we refer to an address, unless otherwise noted, we are referring to its Internet (IP) address.


The long- term solution to providing sufficient IP addressing space will be to move to 128-bit IPv6 addresses. In the interim Classless Interdomain Routing (CIDR) is being offered as a solution. What is CIDR, and why is it a more efficient method for assigning 32-bit IP addresses?

10.2.2 DomainsNetwork and Communication

While IP addresses are a handy way to reference a specific host, we often map a dotted IP address into a more easily understood symbolic notation using the Domain Name System (DNS). In this schema, all Internet addresses are divided into a set of high-level organizational and geographical domains. Each organizational domain (sometimes called a top-level domain) has an identifying code (usually three lowercase letters ), such as com (commercial), edu (education), and gov (government). Each geographical domain consists of a two-letter country code, such as fi (Finland), ca (Canada), and us (United States). [4] Within each high-level domain are subdomains. For example, within the edu domain is the subdomain hartford (for the University of Hartford). Within the hartford domain there may be further subdomains (such as cs for Computer Science), or just an individual host's name. While there appears to be no established limit, usually the maximum number of levels for domain names is four to five. By using the domain naming system we can now reference a host as, for example, instead of . When reading names in this format, the domain with the broadest scope is listed on the far right. As you move to the left, each domain found is within the domain to its right. The last name in the sequence (the leftmost) is usually the name of the host. Most networks run software (such as BIND [Berkeley Internet Name Domain system]) that, using distributed DNS database information will dynamically map a domain-name reference to its corresponding Internet (IP) address.

[4] The Web site site has a complete list of the two-letter country codes.


Explore the dig (Domain Information Groper), nslookup , and host commands by reading their manual pages. Pass dig your domain name (e.g., dig ). Check the returned AUTHORITY SECTION information. What is the symbolic name of the DNS server for your domain? Given this symbolic name what is the IP address of this server (try using the command host -a with the symbolic name)? If nslookup is supported on your system (it is deprecated but still in wide use) invoke the command and set the server to be the appropriate DNS server. Then issue the command ls for the domain. What does the command display?

The term domain is utilized again in reference to the communication type for a socket interface. When we create the socket, we specify its communication domain . The two types of socket communication domains that we will discuss are

  1. UNIX domain . In this domain, when sockets are created, they have actual file ( path ) names. These sockets can be used only with processes that reside on the same host. UNIX domain sockets are sometimes used as the first step in the development of socket-based communications because, due to their locality, they are somewhat easier to debug.
  2. Internet domain . These sockets allow unrelated processes on different hosts to communicate.

While it should be clear by the context of the discussion, most often when we speak of domain, we will be talking about the communication domain of the socket, not the domain name of a host.

10.2.3 Protocol Families

Processes must also agree upon a set of rules and conventions for their communications. A set of such rules and conventions is called a protocol . Protocols, which can be quite complex in their entirety, are designed in layers . The layering of protocols facilitates a certain degree of isolation that permits changes to one layer to not affect the functionality of adjacent layers. The International Standards Organization (ISO) Open Systems Interconnect (OSI) reference model is often used as a generalized guide for how this layering should occur. [5] Figure 10.3 shows the standard seven-layer OSI model.

[5] Some protocols, such as TCP, preceded the OSI model and thus do not cleanly map to its layering. TCP/IP accomplishes the same functionality with four conceptual layers: application, transport, Internet, and network interface (data link). The transport and network layers of TCP/IP are roughly equivalent to the transport and network access layers of the OSI model except TCP/IP supports UDP, an unreliable protocol.

Figure 10.3. The ISO/OSI layer cake.




Higher Level


Provides processes access to interprocess facilities.



Responsible for data conversiontext compression and reformatting, encryption.



Addresses the synchronization of process dialogestablishes, manages , and terminates connections.



Responsible for maintaining an agreed-upon level of data exchange. Determines type of service, flow control, error recovery, and so on.

Protocol Family


Concerned with the routing of data from one network to anotherestablishing, maintaining, and terminating connections.


Data Link

Insures error-free transmission of data.

Lower Level


Addresses physical connections and transmission of raw data stream.

A grouping of layers, most commonly the transport and network layers of the OSI model, forms a protocol family or suite. As can be seen, a protocol family encompasses such things as data formats, addressing conventions, type of service information, flow control, and error handling. There are a number of protocol families, including the following:

  • SNA IBM's Systems Network Architecture
  • UUCP UNIX-to-UNIX copy
  • XNS Xerox Network System
  • NETBIOS IBM's Network Basic Input/Output System
  • TCP/IP DARPA (Defense Advanced Research Projects Agency) Internet

Our discussion centers on the TCP/IP protocol family (PF_INET), Internet domain, which is composed of

  • TCP Transmission Control Protocol. TCP is reliable, full duplex and connection-oriented. Data is transmitted as a byte stream.
  • IP Internet Protocol. Provides delivery of packets. TCP, UDP and ICMP usually call IP.
  • ARP/RARP Address/Reverse Address Resolution Protocol. These protocols are used to resolve Internet/hardware addressing.
  • UDP User Datagram Protocol. UDP is nonreliable, full duplex, and connectionless. Data is transmitted as a series of packets.
  • ICMP Internet Control Message Protocol. Used for error handling and flow control.

Within the TCP/IP family, we focus on TCP and UDP. When we create a socket, we will specify its protocol family to be either PF_UNIX (UNIX) [6] or PF_INET (TCP/IP). For the curious , the protocol definition file /etc/ protocols contains the list of DARPA Internet protocols available with the TCP/IP subsystem.

[6] Technically, UNIX is not a true communications protocol, but will be treated as such for our socket discussions.

10.2.4 Socket Types

For processes to communicate in a networked setting, data must be transmitted and received. We can consider the communicated data to be in a stream (i.e., a sequence of bytes) or in datagram format. Datagrams are small, discrete packets that, at a gross level, contain header information (such as addresses), data, and trailer information (error correction, etc.). As datagrams are small in size , communications between processes may consist of a series of datagrams.

When we create a socket, its type will determine how communications will be carried on between the processes using the socket. Sockets must be of the same type to communicate. There are two [7] basic socket types the user can specify:

[7] Again, a slight fudgethere are other socket types, such as raw and sequenced packet sockets. Raw sockets are for those with superuser access that wish to design and implement their own network protocol. We will not address using raw or sequenced packet sockets.

  1. Stream sockets . These sockets are reliable . When these sockets are used, data is delivered in order, in the same sequence in which it was sent. There is no duplication of data, and some form of error checking and flow control is usually present. Stream sockets allow bidirectional (full duplex) communication. Stream sockets are connection-oriented. That is, the two processes using the socket create a logical connection (a virtual circuit). Information concerning the connection is established prior to the transmission of data and is maintained by each end of the connection during the communication. Data is transmitted as a stream of bytes. In a very limited fashion, these sockets also permit the user to place a higher priority urgent message ahead of the data in the current stream.
  2. Datagram sockets . Datagram sockets are potentially unreliable . Thus, with these sockets, received data may be out of order. Datagram sockets support bidirectional communications but are considered connectionless . There is no logical connection between the sending and receiving processes. Each datagram is sent and processed independently. Individual datagrams may take different routes to the same destination. With connectionless service, there is no flow control. Error control, when specified, is minimal. Datagram packets are normally small and fixed in size.

There is an often-given analogy that compares stream socket communication to that of a phone conversation (address of sender and receiver determined when the connection is established) and datagram communication with communication (correspondence) via postcards (each card packet has its own address information). While the analogy is not entirely accurate, it does capture the spirit of the two types of communication.

Programs and Processes

Processing Environment

Using Processes

Primitive Communications


Message Queues


Shared Memory

Remote Procedure Calls



Appendix A. Using Linux Manual Pages

Appendix B. UNIX Error Messages

Appendix C. RPC Syntax Diagrams

Appendix D. Profiling Programs

Interprocess Communication in Linux
Interprocess Communications in Linux: The Nooks and Crannies
ISBN: 0130460427
EAN: 2147483647
Year: 2001
Pages: 136 © 2008-2020.
If you may any questions please contact us: