You are on page 1of 27

4

MODULE 1. PROGRAMMING CS EXAMPLES

Figure 1.1: CS is similar to talking through tin-cans connected by a string.

Li Simulating Query-Response CS
We will start simply by simulating a CS pair in a single program. By doing
this, I hope that you will undertand how things work in a real CS application.
Later on, we will divide the code between the client and the server and convert
the program into a real, yet simple, CS applicatio:n. The C code listed in
Program 1.1 simulates a query-response CS. The client is simulated by the
function client while the main routine simulates the server.
Now that you have seen the code, how are we going to do it? Well, just
Copy Program 1.1 into any text editor and save it as localtest c. Make
sure that you copy the code correctly, including the right casing of characters
because C, as you already know it, is case-sensitive. Compile the code using
any American National Standards Institute (ANSI)-compliant C compiler
(121). I personally used the freely available Gnu C Compiler (gee) that can
be downloaded from the Internet in either binary or source code forms (181).
The compiler can be run in any platform. After compiling the program, run
the executable to get the output lines similar to what is shown below.
Please enter your name: Apolinario
Hi, Apolinario
Please enter your year of birth: 1968
Your approxi mate age is 34.
Enter q to quit: q

How did the code in locartest c do it? Well, you do not have to be
an expert in C programming to be able to fully understand the code well.
Figure 1.2 illustrates the data and logic flows of Program 1.1. The simu lated server main sends the string Please enter your name to the simulated

1.1. SIMULATING QUERY-RESPONSE CS

Program 1.1 localtest . c: A simulation of a simple CS


1* local test of client-server code *1
#include <stdio.h>
#include <stdlib.h>
#include
<string.h>
char name [256] = ""
char buffer[256] = "";
void client(char *buffer) {
printf("%s", buffer);
fgets(buffer, 256, stdin);
}

int main(int argc, char *argv[])


int year, age;
sprintf (buffer, "Please enter your name: .);
client(buffer);
strcpy(name,buffer);
sprintf (buffer,
"Hi, %sPlease enter your year of birth: "
name);
client(buffer);
year = atoi(buffer);
age = 2002 - year;
sprintf (buffer,
"Your approximate age is %d.\nEnter q to quit:
age);
client (buffer);
return (0) ;

client client through the array buffer buffer. client prints the string,
reads the name as a string from keyboard, and returns that string through
buffer. Then main asks for the year of birth. When client collects it as
a string, main converts it to a number and subtracts it from 2002. It sends
the resulting approximate age back to client. Because client needs a keyboard entry before returning, main requests that the character q be entered.
You can eliminate this unnecessary awkwardness through a more sophisticated coding and I leave that part to you as a homework. This simulated CS (8 homework)
illustrates passing strings between server and client, asking and responding
to questions, and doing arithmetic.

MODULE 1. PROGRAMMING CS EXAMPLES

6
SERVER

BUFFER

CLIENT

Figure L2: The data flow of localtest . c.

1.2 The Hello World CS


Now let us write 3 a real, yet very simple, CS program. We will call this
the Hello World CS program because what it does is simply prints out the
string Hello World Appendix A lists the C code for the Hello World server
program while Appendix B lists the Hello World client program.
Using your favorite text editor, type the client and server codes and save
them as server. c and client . c, respectively. The server runs on your
local computer, so it only needs to know the port number to define a socket.
The client runs on any computer, so it needs to know both its target server
computer and the server's port number. You have thousands of port numbers
to play with. just don't use a port that is already taken. If you are using
Linux or any Unix-type OS, the file /etc/services lists most of the ports
in use.
Now, as mentioned earlier, you need not be connected to a network to
work these examples out. However, you need to have your computer con figured for networking for the client and server programs to behave perfectly. Be warned though that this code will not run if you use the generic
name locaihost. You have to give the explicit name of your computer.
So assuming you are set up for networking, start the server by typing the
following at your OS shell prompt:
server 1024
The number after the command server is the port number where the
server is going to link to for connnections. If you are using Linux or Unix0r should I say type.

1.3. MODULE SUMMARY

type OS, it will be nice to run the server in the background by adding the
ampersand symbol after the command such as:
$ server 1024 &
Start the client by typing the following (assuming that your server's name
is oblation):
client oblation 1024

The hostname oblation can also be replaced by the computer's Internet Protocol (IP) address. If things work right, you will see output lines similar to
what is shown below.

Connection request from 192.168.21.19


14: Hello, World!
The first line gives the IP address of the client, and the second line is the
message from the server to the client. Considering all the codes involved, this
would be a good entry for the World's Most Complex Hello World Program
contest! if there is any. Note that the server keeps running in the background
until you kill it with ctrl-C for DOS and Windows and with the command
fg followed by ctrl-C for Linux and Unix users. You will only use the
command fg if you run the server in the background with the ampersand
appended in the command.

1.3 Module Summary


In this module, you have experienced writing, compiling, and running simulated and simple CS applications. The simulated CS is written in C and
explains the basic notion of CS computing via the functions main and client
with the data structure buffer mimicking the communication medium. The
simple CS program is similarly written in C and has two parts, namely the
server code and the client code. This program uses the C libraries for con necting to, listening to, and reading stream of data from sockets. It also
illustrates the use of threads to fork processes to simulate concurrent processing in a serial computer.

SAQ
Now that you have seen example codes for a real, yet simple, CS program, do
you think you can rewrite the simulated query-response CS program (listed
in Program 1.1) into a real CS pair? Assuming that you were able to run
the Hello World CS programs, why is it the things will not work if we use
the generic name iocalhost?

MODULE I. PROGRAMMING CS EXAMPLES

ASAQ
Well, do not worry if your answer to the SAQ is negative. However, it will
not hurt if you will just try translating Program 1.1 using the CS pair codes
listed in Appendices A and B as patterns. I will actually be glad if any or
both of your client and server translations will not work. That way, you
will be asking more questions and that is a good sign of learning things by
yourself'. Have you heard of the saying, If it works at the first time, you
have not learned anything? So, be glad if your translations will not work at
the start. That means you are learning!

(6 homework)

Now, on to the next module. But wait! What is the answer to the second
question: why using the generic name locaihost will not work? Well, you
are an Iskolar ng Bayan, I leave that up to you as an assignment.

'This is how UP students, the so called Iskolar ng Bayan, are trained: By asking more
questions, doing things by themselves, reading ahead, etc.

Module 2
Introduction to Networking
Contents
2.1

Computer Network ......................................................


TCP/IP Networks .........................................................

10
11
2.2 2.2.1 Introduction to TCP/IP Networks .......................... 12
2.2.2 Ethernets ................................................................. 13
2.2.3 Other Hardware Types............................................... 14
2.2.4 IP ............................................................................... 16
2.2.5 IP Over Serial Lines ................................................ 17
2.2.6 TCP ............................................................................ 17
2.2.7 The User Datagram Protocol (UDP) ....................... 18
2.2.8 Ports .

. .....

. . . . .................................. 19

2.3 UUCP Networks ............................................................

20

2.4 Module Summary .........................................................

20

You probably won't believe it if you hear that the idea of networking
is actually as old as telecommunications itself. Well, consider the people
living in the Stone Age, when smoke may have been used to transmit mes sages between individuals (Figure 2.1). Suppose caveman A wants to invite
caveman B over for a game of hurling rocks, but they live too far apart for
B to see A's smoke. What are A's options? Well, he could:
1.walk over to B's place (but this solution defeats the purpose of smoke
signaling and might take him hours to travel just to communicate two
sentences);
2.start a bigger fire to create a bigger puff (but this solution is not
environment-friendly and besides, fire fighting as a career has not been
invented yet so there is no one who will control the fire in case it had
gone out of control); or

10

MODULE 2. INTRODUCTION TO NETWORKING ,


3. ask cavemen GI, G2,
forward the message.

CO, where n > 0, who live between them, to

The last option is called networking.

rnag="Go for a hurling rocks garner.;


Azicauanutri("A"); B=cavetnan("B");
routers=C4i1 toreach i=1 to n;
packet=send(rnsg, A. B): route(packet,
array1C));
wait(rePlY);

Figure 2.1: Stone Age communication and networking means.


Of course, we have come a long way from the primitive pursuits and
devices of our forefathers. Nowadays, we have computers that talk to each
other over vast assemblages of wires, fiber optics, microwaves, and the like,
and we use them, for example, to make an appointment for Saturday's basketball match. In this module, we will deal with the means and ways by
which this is accomplished. But of course we will leave out the wires, as well
as the basketball part.

Module Objectives
At the end of this module, you are expected to describe and differentiate
between Transmission Control Protocol/IP (TCP/IP) and Unix-to-Unix
Copy Protocol (UUCP) networks.

2.1 Co mputer Network


We will describe two types of networks in this module. However, we will
focus on TCP/IP most heavily because it is the most popular protocol suite
in use on all types of computer networks including even the Internet. We
will also take a look at UUCP. UUCP was once commonly used to transport
news and mail messages over dialup telephone connections. It is now less

2.2. TCP/IP NETWORKS

11

common today, but is still useful in a variety of situations. Each of these


protocols are networking protocols and are used to carry data between host
computers. We will discuss here how they are used and introduce you to
their underlying principles.
What is a network? We define a network as a collection of hosts that (6 network)
are able to communicate with each other, often by relying on the services of
a number of dedicated hosts that relay data between the participants. What
are hosts? Well, hosts are often computers, but need not be because one can
also think of terminals or intelligent printers as hosts. Small agglomerations
of hosts are also called sites. In a more strict technical parlance, hosts are
also called nodes.
Communication is impossible without some sort of language or code. In
computer networks, these languages are collectively referred to as protocols.
However, you should not think of written protocols here, but rather of the
highly formalized code of behavior such as the protocols observed when heads
of state meet. In a very similar fashion, the protocols used in computer net- (6 protocol)
works are nothing but very strict rules for the exchange of messages between
two or more hosts.

2.2 TCP/IP Networks


Modern networking applications require a sophisticated approach in carrying
data from one machine to another. If you are managing a computer that has
many users, each of whom may wish to simultaneously connect to remote
hosts on a network, you need a way of allowing them to share your network
connection without interfering with each other, The approach that a large
number of modern networking protocols uses is called packet-switching. A
packet is a small chunk of data that is transferred from one machine to (6 packet)
another across the network. The switching occurs as the datagram is carried
across each link in the network. A packet-switched network shares a single
network link among many users by alternately sending packets from one user
to another across that link.
The communication solution that many computer networks have adopted
is known as TCP/IP. When talking about TCP/IP networks, you will hear
the term datagram, which technically has a special meaning but is often
used interchangeably with packet. In this section, we will have a look at
underlying concepts of the TCP/IP protocols.

12

MODULE 2. INTRODUCTION TO NETWORKING

2.2.1 Introduction to TCP/IP Networks


For something concrete to look at as we discuss TCP/IP throughout this
module, we will consider the computer network setting at the UPLB 1 as an
example. Most departments run their own LANs, while some share one and
others run several of them. They are all interconnected and hooked to the
Internet through a single high-speed link.
Suppose your PC is connected to a LAN of Unix hosts at the Institute
of Mathematical Sciences and Physics (IMSP), and its name is euclid. To
access a host at the Institute of Biological Sciences (IBS), say mendel, you
enter the following command:
$ rlogin mendel.ibs
Welcome to Institute of Biological Sciences at UPLB
(ttyl) login:

(6

shell)

At the prompt, you enter your login name, say guest, and your password.
You are then given a shell 2 on mendel, to which you can type as if you were
sitting at the system's console. After you exit the shell, you are returned to
your own machine's prompt. You have just used one of the instantaneous,
interactive applications that TCP/IP provides: remote login.
While being logged into mendei, you might also want to run a graphical
user interface (GUI) application, like a word processing program, a graphics
drawing program, or even a WWW browser. The X windows system is a
fully network-aware graphical user environment, and it is available for many
different computing systems. To tell this application that you want to have
its windows displayed on your host's screen, you have to set the DISPLAY
environment variable as follows:
$ DISPLAY=erdos.maths:0,0
$ export DISPLAY
If you now start your application, it will contact your X server instead of
mendel's, and display all its windows on your screen. Of course, this requires
that you have X11 runnning on euclid. The point here is that TCP/IP
allows mendel and euclid to send X11 packets back and forth to give you
the illusion that you're on a single system. The network is almost transparent
here.

NFS)

Another very important application in TCP/IP networks is NFS, which


stands for Network File System. It is another form of making the network
transparent, because it basically allows you to treat directory hierarchies
from other hosts as if they were local file systems and look like any other
1
This network setting is futuristic and ideal and does not actually reflect the current
UPLB network cornfiguration.
2
The shell is a command-line interface to the Unix and Linux OS. It is similar to the
DOS prompt in a MS Windows environment, albeit much more powerful.

2.2. TCP/IP NETWORKS

13

directories on your host. For example, all users' home directories can be kept
on a central server machine from which all other hosts on the LAN mount
them. The effect is that users can log in to any machine and find themselves
in the same home directory. Similarly, it is possible to share large amounts of
data (such as a database, documentation or application programs) among
many hosts by maintaining one copy of the data on a server and allowing
other hosts to access it.
Of course, these are only examples of what you can do with TCP/IP
networks. The possibilities are almost limitless, and we will introduce you
to more as you read on through this module. We will now have a closer look
at the way TCP/IP works. This information will help you understand how
and why you have to configure your machine. We will start by examining
the hardware, and slowly work our way up.

2 .2 .2 Et he r n et s
The most common type of LAN hardware is known as Ethernet. In its (6 Ethernet)
simplest form, it consists of a single cable with hosts attached to it through
connectors, taps, or transceivers. Simple Ethernets are relatively inexpensive
to install, which together with a net transfer rate of 10, 100, or even 1,000
Megabits per second (mbps), accounts for much of its popularity.
Ethernets come in three flavors: thick, thin, and twisted pair. Thin and
thick Ethernet each use a coaxial cable, differing in diameter and the way
you may attach a host to this cable. Thin Ethernet uses a T-shaped BNC
connector, which you insert into the cable and twist onto a plug on the back
of your computer. Thick Ethernet requires that you drill a small hole into the
cable, and attach a transceiver using a vampire tap [27]. One or more hosts
can then be connected to the transceiver. Thin and thick Ethernet cable can
run for a maximum of 200 and 500 meters respectively, and are also called
10base-2 and 10base-5. The base refers to baseband modulation [9] and simply
means that the data is directly fed onto the cable without any modem. The
number at the start refers to the speed in mbps, and the number at the end
is the maximum length of the cable in hundreds of meter. Twisted pair uses
a cable made of two pairs of copper wires and usually requires additional
hardware known as active hubs. Twisted pair is also known as lObase-T, the
T means twisted pair. The 100 mbps version is known as 100base-T.
To add a host to a thin Ethernet installation, you have to disrupt network
service for at least a few minutes because you have to cut the cable to insert
the connector. Although adding a host to a thick Ethernet system is a little
complicated, it does not typically bring down the network. Twisted pair
Ethernet is even simpler. It uses a device called a hub, which serves as an
interconnection point. You can insert and remove hosts from a hub without
interrupting any other users at all.
One of the drawbacks of Ethernet technology is its limited cable length,
which precludes any use of it other than for LANs. However, several Ethernet

14
(6 repeater)

(6 frame)

MODULE 2. INTRODUCTION TO NETWORKING

segments can be linked to one another using repeaters, bridges, or routers.


Repeaters simply copy the signals between two or more segments so that
all segments together will act as if they are one Ethernet. Due to timing
requirements, there may not be more than four repeaters between any two
hosts on the network. Bridges and routers are more sophisticated. They
analyze incoming data and forward it only when the recipient host is not on
the local Ethernet.
Ethernet works like a bus system, where a host may send packets (or
frames) of up to 1,500 bytes to another host on the same Ethernet. A host
is addressed by a six-byte address hardcoded into the firmware of its Eth ernet network interface card (NIC). These addresses are usually written as a
sequence of two-digit hex numbers separated by colons, as in aa:bb:cc:dd:ee:ff.

A frame sent by one station is seen by all attached stations, but only
the destination host actually picks it up and processes it. If two stations try
(6 co - s o to send at the same time, a collision occurs. Collisions on an Ethernet are
detected very quickly by the electronics of the interface cards and are resolved
by the two stations aborting the send, each waiting a random interval and
re-attempting the transmission.

2.2.3 Other Hardware Types


In larger network installations, such as UPLB's, Ethernet is usually not the
only type of equipment used. There are many other data communications
protocols available and in use, but due to space constraints we will describe
them briefly. Many of the protocols have HOWTO documents that describe
them in detail, so you should refer to those if you are interested in exploring
those that we do not describe in this book.
FDDI

(6 FDDI)

At UPLB, each department's LAN is linked to the campus high-speed backbone network, which is a fiber optic cable running a network technology called
Fiber Distributed Data Interface 3 (FDDI). FDDI uses an entirely different
approach to transmitting data, which basically involves sending around a
number of tokens, with a station being allowed to send a frame only if it captures a token. The main advantage of a token-passing protocol is a reduction
in collisions. Therefore, the protocol can more easily attain the full speed of
the transmission medium, up to 100 mbps in the case of FDDI. FDDI, being
based on optical fiber, offers a significant advantage because its maximum
cable length is much greater than wire-based technologies. It has limits of
up to around 200 km, which makes it ideal for linking many buildings in a
city, or as in UPLB's case, many buildings on a campus.
'Well, actually, due to budgetary constraints UPLB is not using FDDI but rather an
equally fast yet cost-effective star Ethernet over fiber.

2.2. TCP/IP NETWORKS

15

IBM Token Ring


IBM Token Ring is used as an alternative to Ethernet in some LAN envi- (6 token ring)
ronments, and offers the same advantages as FDDI in terms of achieving full
wire speed, but at lower speeds (4 mbps or 16 mbps), and lower cost because
it is based on wire rather than fiber. Token Ring networking is configured
in almost precisely the same way as Ethernet, so we do not cover it here
specifically.

Packet Switching
The networks operated by most telecommunications companies support
packet switching protocols. The most popular of these is a standard named
X.25. X.25 defines a set of networking protocols that describes how data ter- (5 X.25)
minal equipment, such as a host, communicates with data communications
equipment (for example, an X.25 switch). X.25 requires a synchronous data
link, and therefore special synchronous serial port hardware. It is possible
to use X.25 with normal serial ports if you use a special device called a PAD
(Packet Assembler Disassemble* The PAD is a standalone device that pro- (6 PAD)
vides asynchronous serial ports and a synchronous serial port. It manages
the X.25 protocol so that simple terminal devices can make and accept X.25
connections. X.25 is often used to carry other network protocols, such as
TCP/IP. Since IP datagrams cannot simply be mapped onto X.25 (or vice
versa), they are encapsulated in X.25 packets and sent over the network.

Fame Relay
The frame relay protocol shares a number of technical features with the (5 frame relay)
X.25 protocol, but is much more like the IP protocol in behavior. Like X.25,
frame relay requires special synchronous serial hardware.

ATM
If you need higher speed networking that can carry many different types of
data, such as digitized voice and video, alongside your usual data, ATM (5 ATM)
(Asynchronous Transfer Mode) is probably what you'll be interested in,
ATM has been specifically designed to provide a manageable, high-speed,
low-latency means of carrying data, and provide control over the Quality
of Service (QoS). Many telecommunications companies are deploying ATM
network infrastructure because it allows the convergence of a number of different network services into one platform, in the hope of achieving savings in
management and support costs. ATM is often used to carry TCP/IP.

16

(8 AX.25)

MODULE 2. INTRODUCTION TO NETWORKING

Packet Radio
Frequently, radio amateurs use their radio equipment to network their computers; this is commonly called packet radio. One of the protocols used by
amateur radio operators is called AX_25 and is loosely derived from X.25.
Amateur radio operators use the AX.25 protocol to carry TCP/IP and other
protocols, too. AX.25, like X.25, requires serial hardware capable of synchronous operation, or an external device called a Terminal Node Controller
to convert packets transmitted via an asynchronous serial link into packets
transmitted synchronously.

2.2.4 IP
Of course, you would not want your networking to be limited to one Ethernet or one point-topoint data link. Ideally, you would want to be able to communicate with a host computer
regardless of what type of physical network it is connected to. For example, in larger
installations such as that of UPLB, you usually have a number of separate networks that have to
be connected in some way. At UPLB, IMSP runs two Ethernets: one with fast machines for
professors and graduates, and another with slow machines for undergraduates. Both are linked to
the FDDI campus backbone network.
This connection is handled by a dedicated host called a gateway that handles incoming and
outgoing packets by copying them between the two Ethernets and the FDDI fiber optic cable. For
example, if you are at IMSP and want to access mendel on IBS's LAN from your PC, the
networking software will not send packets to mendel directly because it is not on the same Ethernet.
Therefore, it has to rely on the gateway to act as a forwarder. The gateway (named calculus) then
forwards these packets to its peer gateway linneus at II3S, using the FDDI backbone network,
with linneus delivering it to the destination machine (Figure 2.2).
(5 routing)

This scheme of directing data to a remote host is called routing, and packets are often referred
to as datagrams in this context. To facilitate things, datagram exchange is governed by a single
protocol that is independent of the hardware used: IP.
The main benefit of IP is that it turns physically dissimilar networks into one apparently
homogeneous network. This is called internetworking, and the resulting meta-network is called
an internet. Note the subtle difference here between an internet and the Internet. The latter is
the official name of one particular global internet.
Of course, IP also requires a hardware-independent addressing scheme. This is achieved by
assigning each host a unique 32-bit number called the IP address. An IP address is usually
written as four decimal numbers, one for each 8-bit portion, separated by dots. For example,
mendel might have an IP address of Ox954C0C04, which would be written as 149.76.12.4. This
format is also called dotted decimal notation or dotted quad notation.

2.2. TCP/IP NETWORKS

17

Figure 2.2: The data flow between euclid and mendel.


You will notice that we now have three different types of addresses: first
there is the host's name, like mendel, then there are IP addresses, and finally,
there are hardware addresses, like the 6-byte Ethernet address. All these
addresses somehow have to match so that when you type rlogin mendel,
the networking software can be given menders IP address; and when IP
delivers any data to the IBS's Ethernet, it somehow has to find out what
Ethernet address corresponds to the IP address.
The steps of finding addresses are called hostnarne resolution, for mapping
hostnames onto IP addresses, and address resolution, for mapping the latter
to hardware addresses.

2.2.5 IP Over Serial Lines


On serial lines, a de facto standard exists known as SLIP, or Serial Line
IP. A modification of SLIP known as CSLIP, or Compressed SLIP, performs (6 SLIP)
compression of IP headers to make better use of the relatively low bandwidth
provided by most serial links. Another serial protocol is PPP, or the Point- (5 PPP)
to-Point Protocol. PPP is more modern than SLIP and includes a number
of features that make it more attractive. Its main advantage over SLIP is
that it isn't limited to transporting IP datagrams, but is designed to allow
just about any protocol to be carried across it.

2 .2 .6 TC P
Sending datagrams from one host to another is not the whole story. If you log
in to euclid, you want to have a reliable connection between your riogin

18

MODULE 2. INTRODUCTION TO NETWORKING

process on mendel and the shell process on euclid. Thus, the information
sent to and fro must be split up into packets by the sender and reassembled
into a character stream by the receiver. Trivial as it seems, this involves a
number of complicated tasks.
A very important thing to know about IP is that, by intent, it is not
reliable. Assume that ten people on your Ethernet started downloading
the latest release of Netscape's web browser source code from UPLB's FTP
server. The amount of traffic generated might be too much for the gateway to
handle, because it is too slow and it is tight on memory. Now if you happen
to send a packet to mendel, linneus might be out of buffer space for a
moment and therefore unable to forward it. IP solves this problem by simply
discarding it. The packet is irrevocably lost. It is therefore the responsibility
of the communicating hosts to check the integrity and completeness of the
data and retransmit it in case of error.
(6 TCP)

This process is performed by yet another protocol, TCP, which builds a


reliable service on top of IP. The essential property of TCP is that it uses
IP to give you the illusion of a simple connection between the two processes
on your host and the remote machine, so you do not have to care about how
and along which route your data actually travels. A TCP connection works
essentially like a two-way pipe that both processes may write to and read
from. Think of it as a telephone conversation.
TCP identifies the end points of such a connection by the IP addresses
of the two hosts involved and the number of a port on each host. Ports may
be viewed as attachment points for network connections. Take for example
the telephone and imagine that cities are like hosts. One might compare IP
addresses to area codes (where numbers map to cities), and port numbers
to local codes (where numbers map to individual people's telephones). An
individual host may support many different services, each distinguished by
its own port number.
In the rlogin example, the client application (rlogin) opens a port on
euclid and connects to port 513 on mendel, to which the rlogind server
is known to listen. This action establishes a TCP connection. Using this
connection, rlogind performs the authorization procedure and then spawns
the shell. The shell's standard input and output are redirected to the TCP
connection, so that anything you type to rlogin on your machine will be
passed through the TCP stream and be given to the shell as standard input.

2.2.7 The User Datagram Protocol (UDP)


Of course, TCP is not the only user protocol in TCP/IP networking.
Although suitable for applications like rlogin, the overhead involved is

(6 UDP)

prohibitive for applications like NFS, which instead uses a sibling protocol
ofTCPcalledUDP.JustlikeTCP,UDPallowsanapplicationtocontact

2.2. TCP/IP NETWORKS

19

a connection for this. Instead, you use it to send single packets to the
destination service, thus its name.
Assume you want to request a small amount of data from a database
server. It takes at least three datagrams to establish a TCP connection,
another three to send and confirm a small amount of data each way, and
another three to close the connection. UDP provides us with a means of
using only two datagrams to achieve almost the same result. UDP is said to
be connectionless, and it does not require us to establish and close a session.
We simply put our data into a datagram and send it to the server; the server
formulates its reply, puts the data into a datagram addressed back to us, and
transmits it back. While this is both faster and more efficient than TOP for
simple transactions, UDP was not designed to deal with datagram loss. It is
up to the application, a name server for example, to take care of this.

2.2.8 Ports
Ports may be viewed as attachment points for network connections. If an (6 port)
application wants to offer a certain service, it attaches itself to a port and
waits for clients (this is also called listening on the port). A client who
wants to use this service allocates a port on its local host and connects to
the server's port on the remote host. The same port may be open on many
different machines, but on each machine only one process can open a port at
any one time.
An important property of ports is that once a connection has been established between the client and the server, another copy of the server may
attach to the server port and listen for more clients. This property permits,
for instance, several concurrent remote logins to the same host, all using
the same port 513. TOP is able to tell these connections from one another
because they all come from different ports or hosts. For example, if you log
in twice to mendel from euclid, the first rlogin client will use the local port
1023, and the second one will use port 1022. Both, however, will connect to
the same port 513 on mendel. The two connections will be distinguished by
use of the port numbers used at euclid.
This example shows the use of ports as rendezvous points, where a client
contacts a specific port to obtain a specific service. In order for a client to
know the proper port number, an agreement has to be reached between the
administrators of both systems on the assignment of these numbers. For
services that are widely used, such as rlogin, these numbers have to be
administered centrally.
It is worth noting that although both TOP and UDP connections rely on
ports, these numbers do not conflict. This means that TOP port 513, for
example, is different from UDP port 513. In fact, these ports serve as access
points for two different services, namely rlogin (TCP) and rwho (UDP).

Ports are also discussed in Section 4.2.2.

20

MODULE 2. INTRODUCTION TO NETWORKING

2.3 UUCP Networks


(6 UUCP)

UUCP started out as a package of


programs that transferred files over
serial
lines,
scheduled
those
transfers, and initiated execution of
programs on remote sites. It has
undergone major changes, but is still
rather wanting in the services it offers.
Its main application is in Wide Area
Networks (WAN), based on periodic
dialup telephone links.
One of the main disadvantages of
UUCP networks is that they operate
in batches. Rather than having a
permanent connection established
between hosts, it uses temporary
connections. A UUCP host machine
might dial in to another UUCP host
only once a day, and then only for a
short period of time. While it is
connected, it will transfer all of the
news, email, and files that have been
queued, and then disconnect. It is
this queuing that limits the sorts of
applications that UUCP can be
applied to. In the case of email, a
user may prepare an email message
and post it. The message will stay
queued on the UUCP host machine
until it dials in to another UUCP
host to transfer the message. This is
fine for network services such as
email, but is no use at all for services
such as riogin.

2.4 Module Summary


In this module, we differentiated.
TCP/IP and UUCP although we
discussed heavily the former. In the
hardware
level,
the
available
hardware protocols are Ethernet and
FDDI. Ethernet usually runs over
FDDI as the former works
efficiently on LANs while the latter
is designed for WANs. Thus, it is

common to hear a network hardware


configuration such as Ethernet over
FDDI which means, at the hardware
level, the network uses Ethernet over
FDDI. Aside from Ethernet, LANs
might also be running on serial
connections. You can use the three
available technologies for serial
connections namely, SLIP, CSLIP,
and PPP.
At the next level, the available
technology is usually IP. Thus it is
possible
to
have
a
network
configuration where IP runs over
Ethernet over FDDI, IP over SLIP, IP
over CSLIP, or IP over PPP. At the
next level, there are two commonly
available protocols: TCP and UDP.
These two might be running on top of
IP. Thus the name TCP/IP or UDP/IP.
Applications need a port to connect to
and each of the TCP and UDP use
ports. The available protocols are
summarized in Table 2.1.
UUCP, as compared to TCP/IP or
UDP/IP uses a non-persistent connection and only applicable for network
services that do not require continuous
communication.

SAQ
L Define Computer Networks in
your own words.

14. MODULE SUMMARY

21

Table 2.1: The commonly available networking rotocols.


Level 5 UDP Port
TCP Port
Level 4 UDP
TCP
Level 3
IP
Level 2 Ethernet
Serial (SLIP, CSLIP,
PPP)
Level 1 _
FDDI
2.What is a Protocol?
3.Differentiate between TCP/IP and UUCP.
4.Discuss by giving examples or analogy the difference between TCP and
UDP.
5.Do you think it is advisable to use UUCP for real-time multi-player
gaming and simulation? Why or why not?

A SAQ
1.A network is a collection of hosts that are able to communicate with
each other, often by relying on the services of a number of dedicated
hosts that relay data between the participants.
2.A protocol is a set of very strict rules for the exchange of messages
between two or more hosts.
3.UUCP, as compared to TCP/IP or UDP/IP uses a non-persistent connection and only applicable for network services that do not require
continuous communication.
4.TCP and UDP are differentiated below:
(a) TCP
When two applications want to communicate to each other reliably, they establish a connection and send data back and forth
over that connection. This is analogous to making a telephone
call. If you want to speak to a relative in Laguna, a connection
is established when you dial your relative's phone number and
he answers. You send data back and forth over the connection
by speaking to one another over the phone lines. Like the phone
company, TCP guarantees that data sent from one end of the connection actually gets to the other end and in the same order it was
sent. Otherwise, an error is reported.
TCP provides a point-to-point channel for applications that
require reliable communications. The Hypertext Transfer Pro-

tocol (HTTP), FTP, and telnet are all examples of applications

MODULE 2. INTRODUCTION TO NETWORKING

22

that require a reliable communication channel. The order in


which the data is sent and received over the network is critical
to the success of these applications. When HTTP is used to read
from a uniform resource locator (URL), the data must be received
in the order in which it was sent. Otherwise, you end up with
a jumbled HTML file, a corrupt zip file, or some other invalid
information.
(b) UDP
The UDP protocol provides for communication that is not guaranteed between two applications on the network. UDP is not
connection-based like TCP. Rather, it sends independent packets
of data, called datagrams, from one application to another.
Sending datagrams is much like sending a letter through the
postal service: The order of delivery is not important and is not
guaranteed, and each message is independent of any other.
For many applications, the guarantee of reliability is critical to the
success of the transfer of information from one end of the connection to the other. However, other forms of communication do not
require such strict standards. In fact, they may be slowed down
by the extra overhead or the reliable connection may invalidate
the service altogether.
Consider, for example, a clock server that sends the current time
to its client when requested to do so, If the client misses a packet,
it doesn't really make sense to resend it because the time will
be incorrect when the client receives it on the second try. If the
client makes two requests and receives packets from the server out
of order, it does not really matter because the client can figure
out that the packets are out of order and make another request.
The reliability of TCP is unnecessary in this instance because it
causes performance degradation and may hinder the usefulness of
the service.
Another example of a service that does not need the guarantee of
a reliable channel is the ping command. The purpose of the ping
command is to test the communication between two programs over
the network. In fact, ping needs to know about dropped or out oforder packets to determine how good or bad the connection is. A
reliable channel would invalidate this service altogether.
The UDP protocol provides for communication that is not guaranteed between two applications on the network. UDP is not
connection-based like TCP. Rather, it sends independent packets
of data from one application to another. Sending datagrams is
much like sending a letter through the mail service: The order of
delivery is not important and is not guaranteed, and each message
is independent of any others.

2.4. MODULE SUMMARY

23

5. So what do you think? Is UUCP advisable for real-time multi-player


gaming ans simulation? I, again, leave this to you as something to
ponder or debate yourself about.
(6 homework)

24

MODULE 2. INTRODUCTION TO NETWORKING

Module 3
Advantages of CS Computing
Contents

3.1

I mp r ov ed Da t a S h a r in g ..............................................

26

3.2

Integrated Services ......................................................

26

3.3

Resource Sharing ............................................................

26

3.4

Data Interchangeabilit y and Interoperabili t y .

27

3.5

M a s ke d P h ys i ca l Da t a Acc e s s .................................

28

3.6

Location Independence of Data and Processing

29

3.7

C en t r a l i z ed M a na ge men t ...........................................

30

3.8

Module Summary ..........................................................

30

Aside from being able to programmatically manipulate computers to communicate to one another, you will see in the following discussions that. CS
computing can satisfy the IT requirements of even big businesses and insti tutions. You will see here that CS can provide the integration of a user's
productivity applications with the total information processing requirements
of the company or institution to which the user belongs. This module dis cusses the advantages of the CS computing model as used in day-to-day
business transactions.

Module Objectives
At the end of this module, you are expected to enumerate and explain the
advantages and disadvantages of CS computing.

25

26

MODULE 3. ADVANTAGES OF CS COMPUTING

3.1 Improved Data Sharing

(5 SQL)

The data that you might be collecting during business transactions can be
maintained on a server and made available to all other users in your company or institution. Defining and manipulating these data using Structured
Query Language (SQL) can give you support for open access from all client
processors and software. This is because SQL lets you grant all your intended
users' access to the information via a view that is consistent with your business need. Network services that is transparent 2 can ensure that the same
data is available to all users that you authorized. Thus, data sharing among
all intended users in your business using CS computing is enhanced.

3.2 Integrated Services


Since data sharing is enhanced, all information that your user is entitled to
is available at the desktop level. Unlike in the mainframe-centric model (see
4.1.1), there is no need for your users to change into terminal mode or log
into another computer to access information. You can make all authorized
information and processes directly available from the desktop interface. The
information provided by your CS applications and by the database servers
resident on the network can be linked or embedded to your company's existing
desktop tools such as e-mail, spreadsheet, presentation graphics, and word
processing. Desktop users can use their desktop tools in conjunction with
information made available from the CS systems to produce new and useful
information.
Figure 3.1 shows a typical example of service integration. An annual
report for a business operation may be word-processed and include figures
created from a drawing package, financial tables pasted from a spreadsheet,
and a list of customers embedded from your CS application. If you are using
MS products, the facilities of the Dynamic Data Exchange (DDE) enable
graphics and spreadsheet data to be cut and pasted into the word-processed
document along with the window of information extracted from your office
database.

3.3 Resource Sharing


True open system computing is one thing that CS computing can provide.
You may create and implement applications that are hardware independent_
Thus, your users may obtain services and transparent access to the services
provided by your database, communications, and applications servers. This
'Note that intended users here may mean your co-employees in the company or your
clients and customers.
2
Available to your intended users.

3.4. DATA INTERCHANGEABILITY AND INTEROPERABILITY 27


Spreadsheet

Graphics

CS Application

Figure 3.1: Annual report created from integrated applications.


is because operating systems software and platform hardware are also independent of the application and masked by the development tools used to
build the application.
In the CS approach, your business applications can be developed to deal
with business processes that may exist because of a user-created event. An (6 event)
event such as the push of a button, selection of a list element, entry in a
dialog box, or scan of a bar code occurs without the application logic being
dependent to the physical platforms where it is resident.
You can design your CS applications to operate in two ways:
1.They can function as front-ends to existing applications (such as maybe a
limited mainframe-centric application); or
2.They can provide data entry, storage, and reporting by the use of a
distributed set of clients and servers.
In either case, the use (or even the existence) of a mainframe host, as you
can see, is totally masked from the workstation level by the use of standard
interfaces such as SQL.

In CS, resources are shared amidst heterogenous platforms.

3.4 Data Interchangeability and Interoper ability


SQL is an industry-standard data definition and access language. This
standard definition has enabled many vendors to develop production-class

28

MODULE 3. ADVANTAGES OF CS COMPUTING

database engines to manage data using SQL tables. Nowadays, almost all
the development tools used for CS development are referenced by back-end
database servers accessed through SQL and presented on the client-side by
hypertext markup language (HTML) browsers. Network services provide
transparent connectivity between the client and local or remote servers. With
some database products, a user or application can define a consolidated view
of data that is actually distributed between heterogeneous, multiple plat forms.
Spider-based search engines, such as Google's MOD, are examples of
CS applications where heterogeneity using production-class database engine
product is a feature. Before, most systems were implemented to use a single
target platform for data maintenance. However, the ability to do high-volume
updates at multiple locations and maintain database integrity across all types
of errors is becoming available with production-level quality performance and
recovery. Systems developed today that use SQL are inherently transparent
to data storage location and the technology of the data storage platform.
The SQL syntax does not specify a location or platform. This transparency
enables tables to be moved to other platforms and locations without affecting
the application code (Figure 3.2). This feature is especially valuable when
adopting proven, new technology or if it makes business sense to move data
closer to its owner.

Figure 3.2: An interoperable application using SQL.

3.5 Masked Physical Data Access


When you use SQL for data access, information can be accessed from
databases anywhere in your network. From your local PC, local server, or
network server, data access is supported. Even both you (the developer)

You might also like