Internet Protocol Architectures and Network Programming
Internet Protocol Architectures and Network Programming
Internet Protocol Architectures and Network Programming
Abhaya S. INDURUWA
Department of Computing
Canterbury Christ Church University
North Holmes Road
Canterbury CT1 QU
U.K.
________________________________________________________________
These lecture notes are intended only for distribution to participants
Internet Protocol Architectures
and
Network Programming
Abhaya Induruwa∗
Department of Computing
Canterbury Christ Church University
Canterbury
United Kingdom
LNS
∗
[email protected]
Abstract
This Chapter is intended to give a broad overview of the Internet and its
architecture comprising network protocols, standards, hardware and sup-
porting technologies. Various protocol architectures are presented in order
to be able to understand the most desirable features that are required in a
protocol to support the characteristics of modern day communication sys-
tems. The Internet Protocol (IP) architecture and its components used in time
critical data communication are discussed.
Also discussed are High Speed LANs based on ATM technology and the
new variants of Ethernets running at Gigabit speeds. More recent attempts
based on WAP to deliver Internet content and services to hand-held mobile
devices and the deployment of ADSL to deliver Internet to the home user are
introduced.
Bluetooth, a wireless communication technology capable of location/ de-
vice aware connection and switching, and is aiming to take the place of wires
for connecting peripherals, telephones, computers, is also briefly discussed.
The lectures also briefly cover the features in JavaTM that enable todays
network programmers to implement sophisticated networking applications
using Java APIs.
Contents
1 Introduction 1
2 The Internet 2
3 Network Classification 2
3.1 Geographical Coverage . . . . . . . . . . . . . . . . . . . . . . 2
3.2 Network Topology . . . . . . . . . . . . . . . . . . . . . . . . . 3
4 Network Architecture 5
4.1 What is a Network Protocol? . . . . . . . . . . . . . . . . . . . 5
4.2 Transmission Mechanism . . . . . . . . . . . . . . . . . . . . 7
4.2.1 Packet Switching . . . . . . . . . . . . . . . . . . . . 8
4.2.2 Frame Relay . . . . . . . . . . . . . . . . . . . . . . 8
4.2.3 Cell Switching . . . . . . . . . . . . . . . . . . . . . 8
4.3 Physical Media . . . . . . . . . . . . . . . . . . . . . . . . . . 9
5 Internetworking 9
5.1 Building Internets and Intranets . . . . . . . . . . . . . . . . 10
5.2 Repeaters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
5.3 Bridges and Switches . . . . . . . . . . . . . . . . . . . . . . . 11
5.4 Routers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
5.5 Gateways . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
5.6 Multiport-Multiprotocol Devices . . . . . . . . . . . . . . . . 12
13 Summary 74
References 76
1
1 Introduction
Computer networks have become an integral and indispensable part of scientific
as well as public life today. Over the last couple of decades data networks have
changed their character from a few slow speed point to point links to a high speed
data communication backbone supporting full multimedia information transfer.
The last few years have seen a phenomenal rise in the interest in the collection
of computers and networks known as the Internet. The Web (World Wide Web)
has truly transformed the access to information content, and their delivery over
the Internet.
More recently the emergence of hand-held PDAs (Personal Data Assistants) in-
cluding wireless phones based on WAP (Wireless Application Protocol), and ADSL
(Asynchronous Digital Subscriber Line) technology that supports high speed data
transfer rates over twisted pair subscriber lines, have revolutionised the provi-
sion of public access to the Internet and its information services.
In parallel with these advances in technologies associated with the content
delivery over the Internet, Java and other object oriented programming language
variants have given the programmer the opportunity to bring to life the hitherto
static multimedia Web presentations by adding ’dynamic content’ to the Web
pages. As a results the Web pages of today have become live; they have become
interactive and animated. The static 2D images on Web pages have now become
3D animated images.
The underlying network architecture supporting the above capability is based
on the TCP/IP protocol suite which lets hundreds of millions of computers and
hundreds of thousands of computer networks spread across hundreds of coun-
tries to be internetworked to form the global Wide Area Network (WAN), the Inter-
net, which is now used by hundreds of millions of users. The familiar application
protocols like FTP, HTTP, SMTP, etc., make use of TCP/IP to achieve a reliable
stream transport across inherently unreliable network links. TCP/IP is also the
basis for client/server computing. Other more specific protocols such as the
RTP (Real-time Transport Protocol), together with RTCP (Real-time Transport
Control Protocol), have been devised to facilitate the communication of Real Time
data over computer networks which have been designed and built to guarantee
the delivery of time insensitive bursty data. IPv6 is emerging as the next gener-
ation Internet Protocol with all the features necessary to support the delivery of
multimedia and other real time data services at high speed.
At the Local Area Network (LAN) level, the popular Ethernet running at 10
Mbps has already been enhanced to operate at 100 Mbps (Fast Ethernet) and
1000 Mbps (Gigabit Ethernet) thus making it suitable as a delivery mechanism
of Real Time traffic to the desktop. Work has already begun to formulate 10
Gbps Ethernet specifications which will initially be deployed to enhance the high
speed local backbones.
Wireless bearer technologies have matured in the last couple of years to an
extent that now they take the place of wired connections. Technologies such as
Bluetooth and WiFi, which are capable of location/devices aware switching have
started to revolutionise the way public access to the Internet is provided.
2 Internet Protocols and Network Programming
2 The Internet
The one and only global network of interest to the whole scientific community of
the world today is the Internet, which is based on the Internet Protocol (IP) at
its network layer and Transmission Control Protocol (TCP) at its transport
layer.
The Internet is a network of computer networks and computers. It intercon-
nects computers of all types and specifications without regard to their operating
system or hardware specifics. It interconnects all types of computer networks
irrespective of their topology and other physical characteristics. The Internet
spans across almost all countries in the world disregarding their socio-economic
status and political boundaries. The one thing that binds them onto one single
network is the Internet Protocol suite, TCP/IP.
TCP/IP is designed to provide a reliable stream transport service across unre-
liable network links to the application level protocols that use it. TCP/IP is also
the basis for client server networking and distributed computing.
3 Network Classification
A computer network is a collection of co-operating computers interconnected
by one or more transmission paths for the purpose of transfer and exchange of
data between them. Today these networks span the entire globe and belong to
many different nations and network operators. Such networks can be classified
in many ways depending on the switching mechanism, transmission speed, etc,
[3, 40, 42]. They can also be classified on the basis of their geographical coverage
or network topology.
The bus topology has been used initially in the Ethernet (broadcast) and later
in Token Bus and the DQDB (Distributed Queue Dual Bus).
The token passing mechanism shown in Figure 1 has originally been used in
the Token Ring and later in FDDI.
Data
Token
D Header
1. Broadcast Networks
Figure 2 shows a broadcast network which is used to broadcast from 1 to
many. CSMA/CD (Carrier Sense Multiple Access/Collision Detect), com-
monly known as Ethernet, is a Medium Access Control (MAC) protocol
which is used to broadcast on a bus topology.
4 Internet Protocols and Network Programming
2. Switched Networks
In Figure 3 is shown a switched network which is used to switch data from
1 to 1, 1 to many, or many to many. The telephone network is an example
of a circuit switched network. It can be used to support applications such
as tele conferencing and video conferencing (using ISDN) which involves the
switching of many to many.
3. Hybrid Networks
Figure 4 shows a hybrid network which consists of a switched part and a
broadcast part.
4 Network Architecture
The topology, transmission mechanism, and a protocol which manages the trans-
mission mechanism together define a network architecture.
In addition to the above there are hundreds of vendor specific protocols such as:
Network IP X.25−3
Data Link Physical X.25−2 LLC/MAC
802.3 802.3a 802.3z 802.4 802.5 802.6 802.7 802.8 802.9 802.10 802.11 802.12 802.15 802.16 802.20
VG−Any Wireless
SMDS/ Broadband Mobile
CSMA/CD Fast Gigabit Token Token Broadband Optical Integrated Secure Wireless
LAN Personal Wireless Broadband MAC
Ethernet Ethernet Bus Ring DQDB Fibre Voice/ Data Tech
Tech (Demand Area Access Wireless
(FDDI) MAN Tech Data Exchange CSMA/CA Access
Priority) Networks
COAX UTP UTP COAX STP COAX 2.4 − 5 UTP 2.4 GHz 2−11 GHz 3.5 GHz
1−10Mbps 4−16Mbps OF OF Shortrange
UTP STP GHz WMANs 1+ Mbps
OF (Bluetooth @ speeds Physical
OF OF OF OF Tech) 10−66 GHz upto
45−155
10Mbps 100Mbps 1Gbps 5−20Mbps 100Mbps Mbps 1−54 Mbps 100Mbps 22Mbps 100+ Mbps 250 kmph
Head
Head
Although the DQDB access layer is independent of the physical medium, the
speeds at which DQDB MANs operate demand the use of fibre or coaxial cables.
For example, ANSI-DS3 operates at 44.736 Mbps over 75 Ω coax or fibre and
ANSI SONET STS3 (Synchronous Optical NETwork) operates at 155.52 Mbps
over single mode fibre. The ITU-T G.703 operates at 34.368 Mbps and 139.264
Mbps over a metallic medium.
Node 1
Head
Node
Node 2
Frame Relay offers a high speed version of packet switching and has the potential
of operating effectively at much higher speeds compared to X.25, reaching speeds
of 45 Mbps. Frame relay is well suited to high speed data applications, but not
suited for delay sensitive applications such as voice and video because of the
variable length of frames [37, 38].
Cell Relay is a transmission mechanism that combines the benefits of time di-
vision multiplexing with packet switching. It operates on the packet switching
principle of statistically interleaving cells on a link, on an ‘as required basis’,
rather than on the basis of a permanently allocated time slot. The fixed cell size
used enables a reasonably deterministic delay to be achieved across a network.
This deterministic nature of cell relay guarantees Quality Of Service (QOS) and
hence makes it suitable for all traffic types including real time traffic, within a
single network.
ATM (Asynchronous Transfer Mode) has become the dominant form of cell re-
lay. It uses a cell of 53 bytes long (5 bytes header and 48 bytes data) and typically
operates at speeds of 155 and 622 Mbps. ATM is delivered to the desktop at 25
Mbps and Gbps platforms are being tested [25]. ITU-T has selected ATM as the
transport technique for B-ISDN (Broadband Integrated Services Digital Network)
[10, 17, 38].
1
formerly CCITT – Consultative Committee for International Telephony and Telegraphy
9
Today all of the above media are used to carry data in excess of 100 Mbps
speeds. Only the distances they cover are different (for example, optical fibre can
operate at gigabit speeds for a few km whereas UTP can operate at 100 Mbps
over a distance of 100 m without repeaters).
With the spread of handheld mobile communication devices such as PDAs
and 3G mobile phones there is a rapidly growing demand for the delivery of
high bandwidth services to these devices. This is reflected in the recent work on
wireless standards carried out by various standard bodies and industry consortia
[13].
5 Internetworking
By internetworking is meant the process of interconnection of computers and
their networks to form a single internet. In other words to make two or more
physical networks to logically look and work like one. The Internet (note the
uppercase ‘I’) is such an internet and uses TCP/IP (Transmission Control Proto-
col /Internet Protocol) protocol suite [45].
TCP is connection oriented and provides a reliable stream transport service.
Although TCP is commonly associated with IP (as its underlying network proto-
col), it is an independent, general purpose protocol that can be adapted to use
with other delivery systems. The popularity of TCP has resulted in the develop-
ment of ISO – TP4, which is a TCP derivative. TCP, together with IP, provides a
reliable stream delivery for data traffic.
TCP/IP protocol suite has become the de facto standard for open system in-
terconnection in the computer industry. It is used world wide in academic,
government, private and public institutions. Some of the reasons for its wide
acceptance can be attributed to the following:
Over the years Unix (and hence Linux) and TCP/IP have become almost syn-
onymous. It has now become part of the operating system kernel. The OS runs
a separate process for IP, TCP input/output and UDP input/output.
The proliferation of TCP/IP is such that today there is hardly a single hard-
ware/software platform that does not support TCP/IP.
10 Internet Protocols and Network Programming
1. Repeaters
2. Bridges and Switches
3. Routers and Brouters
4. Gateways.
Figure 9 shows the use of these components in relation to the ISO-OSI Refer-
ence Model.
Presentation Presentation
Session Session
Transport Transport
5.2 Repeaters
When two networks are to be connected at the lowest level ie. the physical
level, an interconnecting device known as a repeater is used. A repeater simply
takes bits arriving from one network and just forwards (repeats) them on to the
other. In some cases a repeater might have to translate between two different
physical layer formats, for example from optical fibre to UTP (Unshielded Twisted
Pair) cable. This may involve some processing such as signal regeneration of
the received signal for noise elimination. However, repeaters pass on the data
received without paying attention to the address information.
11
5.4 Routers
Routers interconnect networks at the network layer (level 3 in the OSI-RM and
the IP layer of the TCP/IP suite) and perform routing functions. This is the main
building block in internetworking, that is building internets or intranets, using
IP. Most routers now support at least one of the multicast routing protocols,
which is an essential functionality to support the delivery of Real Time data over
IP.
For performance reasons the functionality of a bridge and a router is com-
bined to form a brouter. Whenever possible a brouter bridges data for better
efficiency rather than routing.
5.5 Gateways
Gateways are used when networks based on completely different network archi-
tectures have to be interconnected at layers higher than the network layer and
12 Internet Protocols and Network Programming
INTERNATIONAL CONNECTIVITY
Version 16 - 6/15/97
Internet
Bitnet but not Internet Copyright © 1997
Larry Landweber
EMail Only (UUCP, FidoNet) and the Internet Society.
Unlimited permission to
No Connectivity copy or use is hereby granted
subject to inclusion of
This map may be obtained via anonymous ftp this copyright notice.
from ftp.cs.wisc.edu, connectivity_table directory
7.1 IP Addressing
IPv4 uses 5 classes of addresses as shown in Figure 14. These map on to IP
address ranges shown in Figure 15.
0 12 3 4 7 15 23 31
Class A 0 netid hostid
Address Network No of No of
Address Range
Class ID Networks Hosts
Class A 1.0.0.0 − 126.255.255.255 1 − 126 126 16,777,214
Class B 128.0.0.0 − 191.255.255.255 128 − 191 16,384 65,534
Class C 192.0.0.0 − 223.255.255.255 192 − 223 2,097,151 254
Ethernet 128.10.0.0
192.5.48.3 192.5.48.7
IP Header Data
USER A USER B
TCP TCP
IP IP IP
• Total Length: 16 bits; is the length of the datagram including header and
data.
• Identification: 16 bits; a value assigned by the sender to aid in assembling
the fragments of a datagram.
• Flags: 3 bits; Bit 0 is reserved and must be 0. Bit 1 is used to set fragment-
ing policy (May/Don’t) and Bit 2 to indicate either last fragment or more
fragments to follow.
• Fragment Offset: 13 bits; indicates where in the datagram this fragment
belongs. The first fragment has zero offset.
• Time To Live: 8 bits; sets the maximum time the datagram is allowed to
remain in the internet. Prevents continuous looping of datagrams.
• Protocol: 8 bits; indicates the Transport Layer Protocol that the data portion
of this datagram is passed to. The values for various protocols were origi-
nally specified in the Assigned Numbers RFCs until October 1994 [29], but
now they are available in an on-line database1 (RFC 3232 [36]).
• Header Checksum: 16 bits; for header only. Since some header fields
change (eg. TTL), this is recomputed and verified at each point that the
header is processed.
• Source Address: 32 bits
• Destination Address: 32 bits
• Options: variable; may or may not appear in a datagram.
1
http://www.iana.org
19
# of 16 bit
16 bits words
Internet
Version (4b) Header Length Type of Service (8b) 1
IHL (4b)
Identification (16b) 1
Padding(variable)
32 bits
Data (variable)
32 bits
Data
TCP/UDP
Port # Data
The IP datagram carries the machine identification (its IP address) and the
TCP segment or UDP packet as data. The TCP segment or the UDP packet car-
ries the Port Numbers (16 bits long) and the data for the application (Figure
22). On receipt of the TCP segment, the machine (already identified by its IP
address) directs the data to the correct application/service associated with the
port number attached to that application/service.
also known as network services, are identified by 16 bit long port addresses.
HTTP
port 80
TCP
protocol 6
address 140.125.12.167
IP
Header 6
140.125.12.167
TCP 80
Header
32 bits
Once data are routed through the network and delivered to a specific host,
a mechanism must exist to deliver the data to the correct user application or
process. This mechanism needs to be able to deliver data to the correct protocols
in each layer as the data moves up or down the layers of the TCP/IP stack. This
mechanism must also be able to combine data from many applications into a few
transport protocols and from the transport protocol to the Internet Protocol. In
other words the many data streams must be multiplexed into a single data stream
before transporting on the network and the data arriving from the network must
be demultiplexed.
IP uses protocol numbers (field 9 of the IP datagram header – see figure 19
on page 19) to identify transport protocols and the transport protocols use port
numbers (fields 1 and 2 of the TCP segment header – see figure 20 on page 20)
to identify applications.
Figure 23 shows how the IP address, protocol number and the port number
are extracted from the IP datagram header and the TCP segment header.
Some protocol and port numbers are reserved to identify well known services
such as HTTP and FTP. These are documented in the Assigned Numbers RFC.
On a Unix (Linux) system the protocol numbers are defined in /etc/protocols file.
The first few lines of this file from a Linux machine is shown below:
# /etc/protocols:
# $Id: net.tex,v 1.1.1.1 2003/11/14 15:06:22 rtime Exp $
#
# Internet (IP) protocols
#
# from: @(#)protocols 5.1 (Berkeley) 4/17/89
#
23
On Unix systems the port numbers are defined in /etc/services file. The 16
bits gives rise to 64 K port addresses. Port numbers below 256 are reserved
for well known services such as FTP and HTTP. Port numbers between 256 and
1024 are used for Unix-specific services (such as rlogin, which is no longer Unix
specific).
The following is a few lines from /etc/services file:
# /etc/services:
# $Id: net.tex,v 1.1.1.1 2003/11/14 15:06:22 rtime Exp $
#
# Network services, Internet style
#
# Note that it is presently the policy of IANA to assign a single
# well-known port number for both TCP and UDP; hence, most entries
# here have two entries even if the protocol doesn’t support UDP
# operations. Updated from RFC 1700, ‘‘Assigned Numbers’’
# (October 1994). Not all ports are included, only the
# more common ones.
tcpmux 1/tcp # TCP port service multiplexer
echo 7/tcp
echo 7/udp
daytime 13/tcp
daytime 13/udp
ftp 21/tcp
fsp 21/udp fspd
ssh 22/tcp # SSH Remote Login Protocol
ssh 22/udp # SSH Remote Login Protocol
telnet 23/tcp
# 24 - private
smtp 25/tcp mail
24 Internet Protocols and Network Programming
# 26 - unassigned
time 37/tcp timserver
time 37/udp timserver
whois 43/tcp nicname
mtp 57/tcp # deprecated
finger 79/tcp
www 80/tcp http # WorldWideWeb HTTP
www 80/udp # HyperText Transfer Protocol
link 87/tcp ttylink
kerberos 88/tcp kerberos5 krb5 # Kerberos v5
kerberos 88/udp kerberos5 krb5 # Kerberos v5
Port numbers are unique only within a specific transport protocol. In other
words both TCP and UDP can, and do, assign the same port numbers. It is
combination of protocol and port number that uniquely identifies the specific
application and provides all of the information necessary to deliver the data to
the correct application.
7.7.2 Sockets
In addition to the use of well known port numbers, the operating system can use
dynamically allocated ports. As the name implies, these are not pre-assigned
and are assigned to processes when needed. The operating system ensures that
the same port number is not simultaneously assigned to another application
and that the numbers assigned are above the range of standard port numbers
reserved for well known services.
The dynamically assigned ports provide the flexibility needed to support con-
current multiple users. Once a service on a well known port is assigned to a user
the second user requesting the same service cannot be assigned the same port
number. In order to overcome this problem, the operating system dynamically
allocates a port number for the source port but uses the well known port number
for the destination port.
The dynamically allocated port number in conjunction with the IP address
is used to uniquely identify a single network process within the entire Internet.
This combination of an IP address and a port number is called a socket.
A socket is one endpoint of a two way logical communication link between
two programs associated with a client and a server. A socket is bound to a port
number so that the TCP layer can identify the application that data are destined
to be sent. The client and the server can reside on two different machines or on
the same physical machine.
The server which listens on a socket bound to a well known port (pre assigned)
responds to a client requesting a connection through that port by creating an-
other socket bound to a different port number. The server then informs the client
of this port number and the client communicates with the application running
on the server through this port (Figure 24). The server continues to listen on
25
the first socket/port. At the end of communication session the sockets/ports are
closed down.
P connection
Server o Client
r request
t
P
o
Server r
t
Port
Two way Client−Server P
o Client
Communication Channel r
t
7.8 IP Multicasting
Recipients
Router
Router Router
Router
Recipient
Multicast Server
The RSVP protocol basically acts according to its name. An RSVP request
specifies the level of resources to be reserved for some or all of the packets in a
particular session. An application requests resources by specifying a flow speci-
fication, which describes the type of traffic anticipated (for example, average and
peak bandwidths and level of burstiness), and a resource class specifying the
type of service required (such as guaranteed delay). A filter specification is also
specified, which determines the sources to which a given reservation applies.
RSVP mandates that a resource reservation be initiated by the receiver rather
than the sender. While the sender knows the properties of the traffic stream it
is transmitting, it has been found that the sender initiated reservation scales
poorly for large, dynamic multicast delivery trees. Receiver initiated reservation
27
deals with this by having each receiver request a reservation appropriate to it-
self; differences among heterogeneous receivers are resolved within the network
by RSVP. After learning sender’s flow specification via a higher level “out of band
mechanism”, the receiver generates its own desired flow specification and prop-
agates it to senders, making reservations in each router along the way.
RSVP itself uses a connectionless approach to multicast distribution. The
reservation state is cached in the router and periodically refreshed by the end
station. If the route changes, these refresh messages automatically install the
necessary state along the new route.
RTP and RTCP information is simply data from the point of view of routers
that move the packets to their destination. RSVP prioritises multimedia traffic
and provides a guaranteed quality of service. Routers that have been upgraded
to support RSVP can reserve carrying capacity for video and audio streams and
prevent unpredictable delays that would interfere with their transmission.
Around 1984, Rick Adams implemented SLIP for 4.2 Berkeley Unix and Sun Mi-
crosystems workstations and released it to the world. It quickly caught on as an
easy and reliable way to connect TCP/IP hosts and routers with serial lines.
The Serial Line Internet Protocol (SLIP), documented in RFC 10551 , is a
packet-framing protocol for relaying IP packets over dial-up lines. It defines
an encapsulation mechanism that frames IP packets on a serial line. There is
no support for dynamic address assignment, link testing, multiplexing different
protocols over a single link, packet type identification, error detection/correction
or compression mechanisms.
SLIP is commonly used on dedicated serial links and sometimes for dialup
purposes, and is usually used with line speeds between 1200 bps and 19.2 Kbps.
It is useful for allowing mixes of hosts and routers to communicate with one
another (host-host, host-router and router- router are all common SLIP network
configurations).
The SLIP protocol does not define any link control information that could be
used to dynamically control the characteristics of a connection. Therefore, SLIP
systems must assume certain link characteristics. Because of this limitation,
1
Nonstandard for transmission of IP datagrams over serial lines: SLIP
28 Internet Protocols and Network Programming
SLIP can only be used when both hosts know each other’s address, and only
when IP datagrams are being transmitted.
SLIP sends the datagram across the serial line as a series of bytes, and it uses
special characters to mark when a series of bytes should be grouped together as
a datagram. SLIP defines two special characters for this purpose:
1. The SLIP ”END” character, a single byte with the decimal value 192, is
the character that marks the end of a datagram. When the receiving SLIP
encounters the ”END” character, it knows that it has a complete datagram
that can be sent up to IP.
2. The SLIP ”ESC” character, a single byte with the decimal value of 219, is
used to ”escape” the SLIP control characters.
If the sending SLIP encounters a byte value equivalent to either a SLIP ”END”
character or a SLIP ”ESC” character in the datagram it is sending, it converts
that character to a sequence of two characters. The two-character sequences
are ”ESC 220” for the ”END” character, and ”ESC 221” for the ”ESC” character
itself. When the receiving SLIP encounters these two-byte sequences, it converts
them back to single-byte values. This procedure prevents the receiving SLIP from
incorrectly interpreting a data byte as the end of the datagram. Here ”ESC” refers
to the SLIP escape character, and not the ASCII escape character.
1. A framing method that unambiguously detects the end of one frame and the
start of the next one. The frame format also handles error detection.
2. A Link Control Protocol (LCP) for bringing lines up, testing them, negotiating
options and bringing them down gracefully when they are no longer needed.
LCP supports both synchronous and asynchronous circuit technologies and
byte oriented and bit oriented encodings.
3. A different Network Control Protocol (NCP) for each network layer sup-
ported. This allows to negotiate network layer options in a way that is
independent of the network layer protocol to be used.
The PPP frame format (see figure 26) closely resembles the HDLC (High level
Data Link Control) frame format, the major difference being that PPP is character
oriented whereas HDLC is bit oriented. In particular PPP uses byte stuffing on
dial up lines so all frames are an integral number of bytes. PPP uses the same
29
1 1 1 1−2 variable 2 or 4 1
Flag Address Control Protocol Payload Checksum Flag
01111110 11111111 00000011 01111110
HDLC flags which are byte stuffed if they occur within the payload field. The
address field is always set to 11111111 to indicate that all stations are to accept
the frame thus avoiding the need to assign data link addresses.
PPP does not support reliable transmission using sequence numbers and ac-
knowledgements as the default. Hence the control field is set to 00000011 in-
dicating unnumbered mode. In noisy environments such as wireless networks,
RFC 1663 defines a reliable transmission using numbered mode that is rarely
used.
The default LCP settings allow two parties to negotiate an option to just omit
the transmission of Address and Control fields altogether thus saving 2 bytes per
frame.
PPP defines codes for the protocol field. Protocol codes starting with a 0 bit
are network layer protocols such as IP, IPX and OSI CLNP. Those starting with a
1 bit are used to negotiate other protocols including LCP and a different NCP for
each network layer supported. The default size of the protocol field is 2 bytes.
However, using LCP it can be negotiated down to 1 byte.
Each Network Control Protocol (NCP) on the other hand is specific to some
network layer protocol and allows configuration requests to be made that are
specific to that protocol.
In PPP the default payload length is 1500 bytes but can be negotiated up to a
maximum length using LCP during line set up. The checksum field is normally 2
bytes (16 bits) but a 4 byte (32 bit) checksum can be negotiated.
Most Linux systems include both SLIP and PPP. However, on some Unix sys-
tems such as Solaris, PPP is included and SLIP is not. As a simple rule use PPP
where you can and SLIP where you must.
Source Address
(128 bits)
Destination Address
(128 bits)
8.3 Simplifications
The design of IPv6 has included three major simplifications (based on the expe-
rience gained in operating IPv4 for over 20 years!):
1. assign a fixed format to all headers
2. remove the header checksum
3. remove the hop by hop segmentation procedure.
IPv6 handles options in a different way (see Figure 28) compared to IPv4, ie.
in the form of extension headers and hence there is no need for header length
field in the IPv6 header.
31
IPv6 Header
Next Header = TCP Header + Data
TCP
communications in the new Internet. Flow labels will allow the stipulation of
severe real time constraints, for example.
Assigning higher priority to the queue of real time packets over that of data
packets is not enough. It is necessary to ensure that the service rate is equal to
or higher than the arrival rate of packets. This can be achieved as follows:
R1
R2
R3 S
R4
data
If each real time queue is serviced at a rate compatible with its requirements
then it will never suffer from unpredictable queueing delays (see Figure 30). The
data queue, however, will only be serviced on a best effort basis.
The proposers of IPv6 suggest that the New Internet is capable of providing
all the services required by its users, including Real Time Audio and Video. It is
their opinion that ATM is ”Another Terrible Mistake”.
TCP
IPv4 IPv6
Ethernet
the IPv4 based Internet [24]. This is known as IPv6 tunnelling (see Figure 32).
Tunnel
Real Time applications typically run RTP on top of UDP to make use of its mul-
tiplexing and checksum services (see Figure 33). Tailoring RTP to the application
is accomplished through auxiliary profile and payload format specifications. A
payload format defines the manner in which a particular payload, such as an
audio or video encoding, is to be carried in RTP. A profile assigns payload type
numbers for the set of payload formats that may be used in the application.
Real time Server
UDP
Router Router
RTP RTP RTP
RTCP
RSVP RSVP
RTCP control RSVP control
information information
RSVP
However RTP is not limited to be used with UDP/IP. It can equally be used
with other underlying network or transport protocols such as ATM or IPX. More-
over, RTP supports data transfer to multiple destinations using multicast distri-
bution if provided by the underlying network, a feature which makes RTP ideal
for multi party multimedia conferencing.
36 Internet Protocols and Network Programming
RTP is designed to work in conjunction with RTCP (Real time Transport Con-
trol Protocol) to monitor the quality of service. RTP delivers real time traffic with
timing information for reconstruction as well as feedback on reception quality.
The Resource Reservation Protocol (RSVP) is used to reserve network bandwidth
and assign priority for various traffic types.
• RTP Payload
The data transported by RTP in a packet, for example audio samples or
compressed video data.
• RTP Packet
A data packet consisting of the fixed RTP header, a possibly empty list of
contributing sources, and the payload data. Typically one packet of the
underlying protocol contains a single RTP packet, but several RTP packets
may be contained if permitted by the encapsulation method.
• RTCP Packet
A control packet consisting of a fixed header part similar to that of RTP
data packets, followed by structured elements that vary depending upon
the RTCP packet type. Typically multiple RTCP packets are sent together
as a compound RTCP packet in a single packet of the underlying protocol.
This is enabled by the length field of the fixed header of each RTPC packet.
• Port
The “Abstraction” that transport protocols use to distinguish among mul-
tiple destinations within a given host computer (TCP/IP protocols identify
ports using small positive integers. The transport selectors (TSEL) used by
the OSI Transport layer are equivalent to ports). RTP depends on the lower
layer protocol to provide some mechanism such as ports to multiplex the
RTP and RTCP packets of a session.
• Transport Address
The combination of a network address and the port that identifies a trans-
port level end point, for example an IP address and a UDP port. Packets
are transported from a source transport address to a destination transport
address.
• RTP Session
The association among a set of participants communicating using RTP. For
each participant, the session is defined by a particular pair of destination
transport addresses consisting of one network address and a port pair for
RTP and RTCP. The destination transport address pair may be common
for all participants, as in the case of IP multicast, or may be different for
each, as in the case of individual unicast network addresses plus a common
37
0 1 2 3 4 8 15 31
time stamp
Payload Payload
Physical Medium
network, whereas virtual channels are concerned with switching and connec-
tion establishment functions. Virtual paths are statistically multiplexed on the
physical link on a cell multiplexing basis.
GFC (Generic Flow Control) is used to control the amount of traffic entering
the network.
VPI and VCI are used for routing. VPI will change from one node to the next
when it travels through the ATM layer. VCI is predefined and usually remains
the same throughout the duration of the transmission. PTI (Payload Type Iden-
tifier) is used to distinguish between cells that are carrying user data and those
carrying control information. CLP is a single control bit which provides selective
discard during network congestion and HEC is used to check header errors.
The ATM cell formats used at the UNI (User-Network Interface) and NNI
(Network-Node Interface) are shown in Figure 35.
The actual physical link could be either optical or coaxial with the possibility
of Unshielded Twisted Pair (UTP Category 3/5) and Shielded Twisted Pair
(STP Category 5) in the mid range (12.5 to 51 Mbps).
• ATM Layer
ATM layer mainly performs switching, routing and multiplexing. The char-
acteristic features of the ATM layer are independent of the physical medium.
Four functions of this layer have been identified.
This layer accepts or delivers cell payloads. It adds appropriate ATM cell
headers when transmitting and removes cell headers in the receiving direc-
tion so that only the cell information field is delivered to the ATM Adaptation
Layer.
At the ATM switching/cross connect nodes VPI and VCI translation occurs.
At a VC switch new values of VPI and VCI are obtained whereas at a VP
switch only new values for the VPI field are obtained (see Figure 37). De-
pending on the direction, either the individual VPs and VCs are multiplexed
into a single cell or the single cell is demultiplexed to get the individual VPs
and VCs.
42 Internet Protocols and Network Programming
Virtual
channel
switches
VCIn VCIm VCIp
VCIm
Virtual
path
switches
In the case of transfer of information in real time, AAL1 and AAL2 which
support connection oriented services are important. AAL4 which supports
a connection less service was originally meant for data which is sensitive
to loss but not to delay. However, the introduction of AAL5 which uses a
48 byte payload with no overheads, has made AAL3/4 redundant. Frame
Relay and MPEG–2 (Moving Pictures Expert Group) video streaming are two
services which will specifically use AAL5.
43
Application
TCP Layer
IP Layer
AAL
ATM Layer
Physical Layer
IP based LAN/WAN
IP/TV1 consists of a Viewer, a Program Guide and a Server (Figure 39). The
program guide shows a schedule of multicasts and can be accessed via a Web
browser with HTTP (Hyper Text Transport Protocol). MBONE session information
can be accessed with the Program Guide which controls the number of streams
allowed on the network and the format of those streams, ie. audio only, audio
and video or some other combination. The server delivers pre-recorded or live
multimedia streams based on the Program Guide schedule and parameters such
as start time and file name.
The IP/TV viewer, a tool for signing up for scheduled multicasts, is designed to
provide VCR like controls as well as “channel changing” controls. With a software
based codec (compliant with ITU–T video conferencing standard H.320/H.261)
colour video running at a rate of 30 frames per second uses about 500 Kbps
bandwidth. The use of IP multicasting helps to conserve network bandwidth by
transmitting over the network a single data stream that can be picked up by any
interested user. The use of RSVP provides the ability to reserve bandwidth on
RSVP compliant routers, thereby giving priority to time dependent audio/video
streams over less critical network traffic thus ensuring the desired Quality of
Service (QOS).
1
available with Flashware from Precept Software Inc.
45
Ethernet was invented by Dr Robert M Metcalfe in the 1970s at the Xerox PARC
(Palo Alto Research Centre). This was at a time when a network bandwidth of 3
Mbps was found to be adequate to serve the needs of the users whose computers
were connected to such networks. Formal specifications for Ethernet were pub-
lished in 1980 by a multi vendor consortium that created the DEC-Intel-Xerox
(DIX) standard and turned the 3 Mbps Ethernet into an open production quality
Ethernet operating at 10 Mbps. The popularity of Ethernet made the LAN Stan-
dards Committee of the Institute of Electrical and Electronic Engineers (IEEE
802) to adopt and publish this as an IEEE standard in 1985. The IEEE specifi-
cation which is based on the original DIX technology and provides an “Ethernet
like” system, is called the IEEE 802.3 Carrier Sense Multiple Access/ Collision
Detect (CSMA/CD) standard.
The original specification of 1985 specifies copper based transmission media,
specially, thick (10base5) and thin (10base2) coaxial cables. Since then it has
grown to include twisted pair (10/100baseT) and optical fibre (10/100baseFL). It
is estimated that there are about 500 million Ethernet connections in the world
today, making it the most widely deployed LAN technology.
However, the majority of today’s computing is based on client/server and peer-
to-peer (p2p) technologies. As more applications are moved from desktops to
severs, and the number of desktop clients increases, the demand placed on a
typical Ethernet operating at 10 Mbps tends to affect the application response
time and impair the users’ ability to effectively access, manipulate and transmit
information. Moreover the high performance servers of today need maximum
bandwidth and highly reliable network connections to make the most of their
powerful processing capabilities.
Clients, on the other hand, require high speed, low cost connections to the
high bandwidth networks. This asymmetric approach to client/server network
design has led to the development of Fast Ethernet (IEEE 802.3u – 100base..
family) and Gigabit Ethernet (IEEE 802.3z – 1000base.. family) specifications
giving a speed advantage of 10 and 100 times respectively, compared to the
original Ethernet. Associated with the high bandwidth is also the switching
technique, which makes the Ethernet and its variants to be appropriate for the
delivery of real time data.
The signal topology of the Ethernet is also known as the logical topology to distin-
guish it from the actual physical layout of the media cabling. The logical topology
of an Ethernet provides a single channel (bus) that carries signals to all stations
attached to it. Repeaters which amplify and re-time the signals can be used to
link multiple Ethernet segments together to form large Ethernets.
The signal timing is based on the amount of time it takes to traverse the
46 Internet Protocols and Network Programming
complete media system from one end to the other and back. This is also called
the round trip time, the maximum of which is strictly limited to ensure that
every interface can hear all network signals within the specified amount of time
provided in the Ethernet Medium Access Control (MAC) mechanism.
The longer a given network segment is the more time it takes for a signal to
traverse it. Therefore configuration guidelines (rules) are provided to make sure
that the round trip timing limits are met, no matter what combination of media
segments are used in the network configuration.
However the expansion of Ethernet using repeaters is limited because of the
signal timing restrictions. In order to meet the expansion needs of today, two
kinds of hubs known as repeater hubs and packet switching hubs are available.
The advantage of using a switching hub is that each port of the hub operates on
full duplex mode and provides a connection to an Ethernet media system that
operates as a separate Ethernet LAN, and the round trip timing rules for each
LAN stop at the switching hub port. This in effect allows several individual LANs
each supporting hundreds of computers to be linked together forming a much
larger LAN, but still meeting the requirements of signal timing.
The use of switching hubs allows, in addition, to mix Ethernet links operating
at 10 Mbps with links operating at higher link speeds and to operate either some
or all of the links at higher bandwidths, namely 100 Mbps or 1000 Mbps.
An Ethernet switch at its basic level can be thought of as a bridge with many
ports and low latency. A network segment connected to each of the ports phys-
ically represent a separate Ethernet with its own repeater count and timing re-
strictions. Switches are useful in segmenting large networks for improved perfor-
47
mance and/or easy manageability. However, the many segments of the network
operate as one single logical network.
The design of Ethernet switches gives rise to the following classification based
on the type of packet forwarding technique used in the switch architecture. The
packet switching type employed has an effect on latency which describes the
delay in the switch. The latency has the greatest impact in environments where
real time video and audio applications are supported.
A store and forward switch stores each incoming frame in a buffer, checks
for errors, and if the frame is good then forwards the frame to its destination
port. The store and forward technique has the advantage that it prevents wast-
ing network bandwidth by effectively blocking the damaged frames. However
the disadvantage is that it increases the latency and therefore results in lower
throughput in networks with few errors. Store and forward switches are useful
in networks which may experience high error rates.
In general Store and Forward switching is likely to be the best choice when a
network needs efficiency and stability.
• Hybrid Switches
Hybrid switch is the result of an attempt to achieve the best of both, the Store
& Forward and Cut Through techniques. In its normal operating mode a hybrid
switch operates as a Cut Through switch constantly monitoring the rate at which
damaged or invalid frames are forwarded. When the error rate is above a certain
threshold then the switch reverts to Store and Forward mode and continues to
operate in that mode until the error rate has fallen to an acceptable level before
reverting to Cut Through mode.
The Hybrid switch has the performance advantage of a Cut Through switch
when the error rate is low, and the error trapping ability of a Store and Forward
switch when the error rates are high.
The above types are only applicable when the source and destination ports are
all running at the same speed. If the switch has to perform a speed conversion,
which is the case in many new network installations especially if a standard
Ethernet is migrated to high performance Ethernet, then the switch must operate
in the Store and Forward mode to cater to the differing link speeds.
48 Internet Protocols and Network Programming
Media support Coax, UTP, Optical Fiber UTP, STP, Optical Fiber
Fast Ethernet also supports multiple media types. For 100baseT the same
cabling installed for a 10baseT network can be used. Figure 41 shows the three
media specifications supported by Fast Ethernet, namely 100baseTX (2 pairs of
high quality cables), 100baseT4 (4 pairs of normal quality cables) and 100baseFX
(optical).
• 100baseTX
The 100baseTX specification supports 100 Mbps transmission speed over
two pairs of UTP Category 5 or STP Category 5. The RJ45 connector used for
49
(AUI Equivalent)
100baseTX UTP is exactly the same as that used by 10baseT UTP. For STP wiring,
100baseTX also specifies the traditional DB-9 connector.
• 100baseT4
• 100baseFX
100baseFX media specification defines 100 Mbps operation over two strands
of 62.5/125 micron fibre and allows transmission over greater distances than
UTP. The fibre optic connectors are the same as those defined for 10baseFX
networks.
Fast Ethernet specification includes a Media Independent Interface (MII) which
defines a standard interface between the CSMA/CD MAC layer and any of the
three media specifications supported. This is much like the AUI connector for
standard Ethernet. The MII defines a 40 pin connector to connect to the external
transceivers.
The Fast Ethernet however does not support coaxial cabling largely due to its
inability to support high data rates over the distances of interest. The ISO 11801
cabling standard is applicable to Fast Ethernet implementation.
The indoor operating ranges for Wireless LANs are typically 30 m at 11 Mbps
and 90 m at 1 Mbps [13]. The typical outdoor operating ranges are much larger
(120 m at 11 Mbps and 460 m at 1 Mbps).
A hotspot provides wireless LAN service, for free or for a fee, from a wide va-
riety of public meeting areas, including coffee shops and airport lounges. There
are currently thousands of hotspots worldwide and new access points are being
added daily. To use hotspots, your notebook must be configured with Wi-Fi Cer-
tified (Wi-Fi Alliance is a non profit international organisation set up to certify
interoperability of wireless local area network products based on IEEE 802.11
specification) technology so you can connect with other products. Wi-Fi Certified
notebooks can send and receive data anywhere within the range of a wireless
LAN base station.
The IEEE has two more committees developing standards for Broadband
Wireless communication systems. IEEE 802.16 committee is working on Broad-
band Wireless Access Standards where as the IEEE 802.20 committee works on
Mobile Broadband Wireless Access (MBWA) standards.
52 Internet Protocols and Network Programming
The companies belonging to the Bluetooth SIG, and there are more than 1,000
of them, want to let Bluetooth’s radio communications take the place of wires for
connecting peripherals, telephones and computers.
Bluetooth communicates at a frequency of 2.4 gigahertz, which has been set
aside by international agreement for the use in Industrial, Scientific and Medical
(ISM) devices. A number of devices that are already in use take advantage of
this same radio-frequency band. Baby monitors, garage-door openers and the
newest generation of cordless phones all make use of frequencies in the ISM
band. Making sure that Bluetooth and these other devices do not interfere with
one another has been a crucial part of the design process. In order to limit
spectral emissions and interference, it provides three different power classes
corresponding to 10, 20 and 100 m distance operation.
Originally Bluetooth aimed to provide low cost, low power connections be-
tween a variety of consumer products. As an example, a Bluetooth link between
a laptop and a 3G cellular phone could enable the laptop computer to gain access
1
Named after Harald Bluetooth who was king of Denmark in the late 900s. He managed to
unite Denmark and part of Norway into a single kingdom and then introduced Christianity into
Denmark. He left a large monument, the rune stone in Jelling, in memory of his parents. He was
killed in 986 during a battle with his son, Svend Forkbeard.
53
to the Internet by means of the 3G packet data transmission. The work of IEEE
802.15 committee aims to standardise the physical and datalink layers of Wire-
less Personal Area Networks (WPANs) based on Bluetooth specification which
specifies a complete system from the physical layer to the application layer. Al-
though the Bluetooth SIG and IEEE 802.15.1 versions are not identical, it is
hoped that they will soon converge to a single standard.
Wireless Internet will drive four wireless applications namely, messaging, brows-
ing, interacting and conversing. The emerging trend is for mobile networks to
migrate to fully IP based 4G systems. These will use a new spectrum and packet
switching technology to support data rates of 10+ Mbps. The 3G and 4G systems
will provide multimedia services to users everywhere, while WLANs will provide
broadband services in hotspots, and WPANs will connect personal devices to-
gether at very short distances.
Information
Server
Telephone
Network Subscriber line
ADSL ADSL
Modem Subscriber
Equipment Modem 1.5 Mbps - 6 Mbps
(5.5 km) (2.7 km)
16 to 800 kbps
Internet
In transmitting digital compressed video as a real time signal, ADSL cannot use
link level or network level error control procedures commonly found in other
data communication systems due to the fact that they are generally based on
error recovery by re–transmission best suited for non-real time services. ADLS
modems therefore incorporate forward error correction.
Multiple channels are created by the ADSL modem by dividing available band-
width of a telephone line in one of two ways (see Figure 43):
In FDM one frequency band is assigned for upstream data and another for
downstream data. The downstream path is then divided by FDM into one or
more channels at the desired data rates.
Echo cancellation, a technology used in V.32 and V.34 modems, assigns the
upstream band such that it overlaps the downstream band and separates the
two by local echo cancellation.
With either technique ADSL splits a 4 KHz region for POTS at the DC end
of the frequency spectrum and guarantees the availability of telephone channel
even if ADSL fails.
55
Upstream
POTS
POTS
0 4 kHz 1 MHz 0 4 kHz 1 MHz
Frequency Frequency
Figure 43: Creating ADSL Channels by (i) FDM and (ii) Echo Cancellation
The final step has helped moving towards vendor interoperability and service
provider acceptance, further increasing ADSL deployment.
ATM Forum has recognised ADSL as a physical layer transmission protocol
for UTP medium.
• mobile phones
• pagers
• two way communication radios
• smart phones
• communicators, etc.
WAP supports most wireless network transmission technologies in use today,
most notable being CDMA (Code Division Multiple Access), GSM (Global Sys-
tem for Mobile communications), TDMA (Time Division Multiple Access), HSCSD
(High Speed Circuit Switched cellular Data), CDPD (Cellular Digital Packet Data),
SMS (Short Messaging Service), GPRS (General Packet Radio Service), UMTS
(Universal Mobile Telecommunication System), etc.
The operating systems that support WAP are many. Those specifically engi-
neered for hand-held devices include:
• PalmOS
• Windows CE – Compact Edition
• J2ME – Java 2 Mobile Edition, etc.
Although WAP supports HTML and XML, the WML (Wireless Mark-up Lan-
guage) is specifically designed for small screens of typically 150 x 150 pixel
resolution and one hand navigation without a keyboard as opposed to using
point-and-click action of a mouse. Like XML, WML is scalable and extensible as
it allows users to define new markup tags.
WAP supports WMLScript (similar to JavaScript) but makes minimal demands
on limited memory and CPU power of hand-held devices. Browsers that are
specially designed to run on WAP devices and called micro-browsers are of small
file size.
SNMP
JAVA Logging Subscriber DB Applications
Bearers Internet
Firewall etc.
content to match client expectations and differentiate themselves from their com-
petitors with new, enhanced information services.
While WAP users benefit from easy, secure access to Internet based infor-
mation such as unified messaging, banking, and entertainment, they will also
enjoy considerable freedom of choice when selecting mobile devices and network
operators.
• HTTP Interface – This serves to retrieve from the Internet, the WAP content
requested by the mobile device. WAP content (WML, WMLScript) is then
converted into a compact binary byte code for efficient transmission over
the air channel.
The WAP microbrowser software resident within the mobile device interprets
this byte code and displays the interactive WAP content.
• WSP – The WAP Session Protocol layer provides a light weight session to al-
low efficient exchange of data between applications. It supports connection-
oriented for two way communication between the device and the network
and connection-less for broadcasting or streaming the data to the device.
• WTP – The WAP Transport Protocol layer provides transaction support adding
reliability to the datagram services provided by the WDP layer.
58 Internet Protocols and Network Programming
The WAP gateway server can operate under two possible scenarios:
1. If the web server provides content in WML, the WAP gateway transmits this
data directly to the WAP client.
2. If the web server delivers content in HTML, the WAP gateway server encodes
HTML into WML before transmitting to the WAP client.
The present day wireless bearer technologies include GSM, HSCSD, SMS,
GPRS and UMTS among others. Table 2 compares some of their important char-
acteristics.
WAP was primarily developed for 2G mobile systems that provide slow data
rates between 9.6 – 14.4 Kbps. The development of 3G wireless systems such
as UMTS with data rates of 2 – 4 Mbps is expected to resolve the problem of
limited bandwidth. With such systems it is natural that WAP will not be needed.
However the WAP Forum argues that, even in 3G systems, bandwidth will play
a crucial role as new applications will continue to demand higher bandwidths
and data rates. In addition they can benefit from the ability to deal with small
screen size, low power consumption, carrier independence, multi-device support
and intermittent coverage.
Figure 45 shows the ’wapalised’ ICTP homepage as it would appear on the
screen of a WAP enabled mobile phone.
such as XML, SOAP (Simple Object Access Protocol), WSDL (Web Services De-
scription Language) of the W3C (World Wide Web Consortium), UDDI (Universal
Description, Discovery, and Integration) and HTTP.
Mobile web services provide content delivery, location discovery, user authen-
tication, presence awareness, user profile management, terminal profile man-
agement and event notification. Initially wireless terminals are likely to access
Mobile Web Services indirectly, through application servers which will manage
the interaction with the required Web service.
60 Internet Protocols and Network Programming
There are other methods in the java.net package which return InetAddress
objects. In Java 2 version 1.5 (Sun now calls this Java 5.0) these methods
include:
1
http://java.sun.com/j2se/1.5/docs/api
61
DatagramPacket.getAddress(),
DatagramSocket.getInetAddress(),
DatagramSocket.getLocalAddress(),
MulticastSocket.getInterface(),
ServerSocket.getInetAddress(),
Socket.getInetAddress(), and
Socket.getLocalAddress().
The following code segments illustrate the use of some of the classes and
methods available.
import java.net.*;
A string containing the dotted quad form of the IP address can be passed to
InetAddress.getByName().
The other two methods are:
InetAddress Class
public String getHostName() — returns the hostname of an InetAddress
object as a string;
public byte[] getAddress() — returns the address as a byte array.
Beware!!! Type byte in Java is signed! Addresses between 128 and 255 are
returned as negative numbers!! Add 256 to the negative bytes!!!
public String getHostName() — returns the address as a string.
Notice that there are no setHostName() and setAddress() methods. Java
guarantees that packages out side java.net cannot change an InetAddress ob-
ject’s fields behind its back.
The InetAddress class has seen many changes in J2SE 1.4 in order to ac-
commodate IPv6 support. Inet4Address and Inet6Address classes have been
added as two subclasses of InetAddress to represent the 32 bit IPv4 addresses
and the 128 bit IPv6 addresses respectively. However, in most common cases
the IPv6 support is transparent to the developer who will continue to manipu-
late instances of InetAddress. All static methods in InetAddress return either
an Inet4Address or Inet6Address depending on the resolution. Similarly all
socket methods returning an InetAddress, such as Socket.getInetAddress
will return an instance of Inet4Address or Inet6Address.
java.net.URL Class
It is a final class hence cannot be subclassed.
It is Java’s abstraction of the Uniform Resource Locator (URL).
URL object is not stored as a string. Rather it is treated in Java as an object with
fields such as:
63
protocol
hostname
port
path
query string, etc. . .
try {
URL u = new URL("http://mlab-14.ictp.trieste.it");
}
catch (MalformedURLException e) {
System.out.println("Invalid String");
}
try {
catch (MalformedURLException e) {
// All known virtual machines should recognise http!
}
The above assumes the default port which for HTTP is port 80.
For cases where the default port is not applicable the following allows the
redefinition of a port number in the constructor:
64 Internet Protocols and Network Programming
try {
catch (MalformedURLException e) {
System.err.println (e);
}
try {
URL u = new URL("http://www.hamsterjam.com");
InputStream is = URL.openStream(); // returns raw data
// ASCII if text file
// binary if an image file
int c;
while ((c = is.read()) != -1)
System.out.write(c);
}
catch (IOException e) {
System.err.println (e);
}
catch (MalformedURLException e) {
System.err.println (e);
}
using FTP. In this model a server waits (or listens) for a client to request a ser-
vice. For standard applications such as HTTP and FTP these services are offered
through well known ports; 80 for HTTP and 21 for FTP. Other services may be
offered at any port number assigned by the server’s operating system. On Linux,
the port numbers associated with particular services are in /etc/services.
A Socket object represents the Java version of a TCP connection. The sending
and receiving paths are represented by an InputStream and an OutputStream
in the socket.
When a Socket object is created a connection is made to a specified computer.
When a ServerSocket connection is made the server on which it is made listens
to clients and establishes a connection when it hears the connection request.
There are a number of constructors for the Socket and the most popular ones
take the name of a host computer and a port number as arguments.
Socket Constructors
The following constructor creates a TCP socket to the specified port on the spec-
ified host and attempts to connect to the remote host.
try {
Socket Google = new Socket ("www.google.com", 80);
// String hostname, int portnumber
// ...........
// send and receive data
// ...........
}
catch (UnknownHostExeption e) {
System.err.println (e);
}
catch (IOExeption e) {
System.err.println (‘‘An I/O error has occurred’’);
}
catch (SecurityException e) {
System.out.println
("A Security Manager exists - does not allow operation");
}
The following is similar to the previous constructor, but uses the InetAddress
object, rather than the hostname.
try {
InetAddress GoogleAddress = InetAddress.getByName("www.google.com");
Socket GoogleSocket = new Socket (GoogleAddress, 80);
//
}
catch (UnknownHostExeption e) {
System.err.println (e);
}
catch (IOExeption e) {
System.err.println (e);
}
66 Internet Protocols and Network Programming
If the socket has to be created using a particular NIC (such as a 100 Mbps
Ethernet card as opposed to a 10 Mbps card on a multihomed host), then:
try {
InetAddress FEcard = InetAddress.getByName("FE.mymachine.com");
Socket FEGoogleSocket = new Socket("www.google.com", 80, FEcard, 0);
// String host, int port, InetAddress interface, int local port
// ’0’ for local port means ’don’t care’
//
}
catch (UnknownHostExeption e) {
System.err.println (e);
}
catch (IOExeption e) {
System.err.println (e);
}
try {
InetAddress ATMcard = InetAddress.getByName("ATM.mymachine.com");
InetAddress Google = InetAddress.getByNAme("www.google.com");
Socket ATMGoogleSocket=new Socket(Google, 80, ATMcard, 0);
}
catch (UnknownHostExeption e) {
System.err.println (e);
}
catch (IOExeption e) {
System.err.println (e);
}
import java.net.*;
class Hosts {
import java.net.*;
import java.io.*;
class GetContents {
if (args[0].startsWith("http://")) {
urlstring = args[0].substring(7);
}
else {
urlstring = args[0];
}
InputStream is = webURL.openStream();
BufferedReader ds = new BufferedReader(new InputStreamReader(is));
while (true) {
str = ds.readLine();
if (str == null) {
break;
}
System.out.println(str.trim());
}
}
}
69
import java.net.*;
import java.io.*;
class UDPDaytimeClient {
public static void main (String args[]) throws
UnknownHostException, SocketException, SocketTimeOutException {
try {
InetAddress host = InetAddress.getByName(args[0]);
// get IP address of host
DatagramSocket mySocket = new DatagramSocket();
// create a datagram socket
import java.io.*;
import java.net.*;
out.close();
in.close();
echoSocket.close();
}
}
71
1. thread per client – a new thread is spawned to handle each client connection.
2. thread pool – a fixed number of pre-spawned threads work together to serve
client connections.
They are independent of the type of client-server protocol (TCP or UDP) that
is used.
each connection request, the server creates a thread pool with a fixed number
of threads and client requests are assigned to a thread from this pool. When
the thread finishes servicing the client it returns to the pool so that it can be
reassigned to a new request. Connection requests from clients that arrive when
all threads in the pool are busy are queued until a thread becomes available.
74 Internet Protocols and Network Programming
13 Summary
TCP/IP is a time tested and a proven technology which is now universally avail-
able under almost all operating system platforms. In the recent times TCP/IP
has been used in transporting time critical streaming data such as video and
audio over the global Internet. A new version of Internet Protocol, IPv6, is being
formulated taking care of the shortcomings of IPv4 making it more suitable for
real time data communication applications.
Real time Transport Protocol (RTP), together with a host of other protocols
facilitate the transfer of real time data streams over existing LANs and WANs
based on the Internet Protocol (IPv4) technology.
The overall success and acceptability of Ethernet as a LAN technology has led
to its enhancement to high performance platforms operating at 100 Mbps (Fast
Ethernet) and 1 – 10+ Gbps (Gigabit Ethernet). These two offer the users the
familiar Ethernet operating environment with the ability to deliver high band-
width real time data such as video and imaging to the desktop. In the last few
years however, there has been a noticeable drive to develop wireless technology
to support computing in the personal and home environment as well as mobile
and as a replacement to the local area and wide area connectivity based on wired
technologies. As a result there are medium to high bandwidth wireless solutions
in the market today slowly revolutionising the way not only homes and offices
but entire cities, regions or even countries are interconnected.
Java programming environment provides a rich collection of features to en-
able network programmers to easily develop sophisticated data communication
applications for time critical data over distributed data communication networks.
Over the years the Internet and its TCP/IP protocol suite have been used for
such diverse applications for which types neither the Internet nor its protocols
were designed in the first place. In the last decade the Internet and its TCP/IP
protocol architecture have become the basis for the implementation of GRID
Infrastructure [12, 2], aimed at delivering computational power to applications
on demand. These applications, although belong to diverse areas of scientific
research on the one hand as well as business and commercial on the other,
have one thing in common. They both demand enormous CPU performance and
storage capacities, that cannot be satisfied by the use of a single or multiple
supercomputers of our time for their successful execution.
The concept of GRID infrastructure is to bring together CPUs, sensors, in-
struments, storage devices, and such like scattered all over the world into one
pool that can then be shared over the Internet. Already there are hundreds
of national and international GRID infrastructure development projects in mo-
tion. In the short term the Internet has been, and will further be, enhanced by
developing the middleware components required to perform GRID specific com-
putational tasks. These collaborations have already provided an opportunity
to scientists hitherto unavailable, in order to tackle some of the hardest com-
putational problems known to them including earth quake prediction, disaster
75
References
[1] Barnes D J, Object-Oriented Programming with Java; An Introduction,
Prentice Hall, 2000.
[2] Berman F, Fox G C and Hey A J G, (Eds), Grid Computing – Making the
Global Infrastructure a Reality, Wiley, 2003.
[4] Black U, TCP/IP and Related Protocols (2nd Edition), McGraw Hill, 1995.
[8] Comer D and Stevens D L, Internetworking with TCP/IP - Vol II: Design,
Implementation, and Internals, Prentice Hall, 1991.
[10] De Prycker M, ATM Solutions for Broadband ISDN (3rd Edition), Prentice
Hall, 1995.
[11] Deitel H M and Deitel P J, Java: How to Program (5th Edition), Prentice
Hall, 2003.
[12] Foster I and Kesselman C, (Eds),The GRID 2: Blueprint for a New Com-
puting Infrastructure (2nd Edition), Morgan Kaufmann, 2004.
[19] Huitema C, IPv6: The New Internet Protocol, Prentice Hall, 1996.
[20] Ince D & Freeman A, Programming the Internet with Java, Addison-
Wesley, 1997.
[22] Jain R, FDDI Handbook - High Speed Networking using Fibre and Other
Media, Addison-Wesley, 1994.
[24] Miller P E & Miller M A, Implementing IPv6 (2nd Edition), Hungry Minds,
2000.
[30] RFC 1883, Internet Protocol, Version 6 (IPv6) Specification, April 1996.
[31] RFC 1889, RTP: A Transport Protocol for Real Time Applications, Jan-
uary 1996.
[32] RFC 1890, RTP Profile for Audio and Video Conferences with Minimal
Control, January 1996.
[34] RFC 2236, IGMP – Internet Group Management Protocol (Version 2),
November 1997.
[38] Stallings W, ISDN and Broadband ISDN with Frame Relay and ATM (4th
Edition), Prentice Hall, 1998.
[39] Stallings W, Local and Metropolitan Area Networks (6th Edition), Pren-
tice Hall, 2000.
[45] Wilder F, A Guide to the TCP/IP Protocol Suite, Artech House, 1993.