Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 41

Network Programming

BTCS703
TCP & IP headers

TCP inserts header fields into the message stream in the order listed below:
.

 Source and destination TCP port numbers are the communication endpoints for
sending and receiving devices.
 Message senders use sequence numbers to mark the ordering of a group of messages.
Both senders and receivers use the acknowledgement numbers field to communicate the
sequence numbers of messages that are either recently received or expected to be sent.
 The data offset field stores the total size of a TCP header in multiples of four bytes. A
header not using the optional TCP field has a data offset of 5 (representing 20 bytes), while a
header using the maximum-sized optional field has a data offset of 15 (representing 60
bytes).

 Reserved data in TCP headers always has a value of zero. This field serves the
purpose of aligning the total header size as a multiple of four bytes (important for efficiency
of computer data processing).
 TCP uses a set of six standard and three extended control flags (each an individual bit
representing on or off) to manage data flow in specific situations. One bit flag, for example,
initiates TCP connection reset logic. The detailed operation of these fields goes beyond the
scope of this article.

 TCP senders use a number called window size to regulate how much data they send to
a receiver before requiring an acknowledgement in return. If the window size becomes too
small, network data transfer will be unnecessarily slow, while if the window size becomes too
large, the network link can become saturated (unusable for any other applications) or the
receiver may not be able to process incoming data quickly enough (also resulting in slow
performance). Windowing algorithms built into the protocol dynamically calculate size
values and use this field of TCP headers to coordinate changes between senders and
receivers.
 The checksum value inside a TCP header is generated by the protocol sender as a
mathematical technique to help the receiver detect messages that are corrupted or tampered
with.
 The urgent pointer field is often set to zero and ignored, but in conjunction with one
of the control flags, it can be used as a data offset to mark a subset of a message as requiring
priority processing.
 Usages of optional TCP data go beyond the scope of this article but include support
for special acknowledgement and window scaling algorithms.

 Version IPv4, IPv6 etc.


 IP Header Length (number of 32 -bit words forming the header, usually five)
 Type of Service (ToS), now known as Differentiated Services Code Point (DSCP)
(usually set to 0, but may indicate particular Quality of Service needs from the network, the
DSCP defines the way routers should queue packets while they are waiting to be
forwarded).
 Size of Datagram (in bytes, this is the combined length of the header and the data)
 Identification ( 16-bit number which together with the source address uniquely
identifies this packet – used during reassembly of fragmented datagrams)
 Flags (a sequence of three flags (one of the 4 bits is unused) used to control whether
routers are allowed to fragment a packet (i.e. the Don’t Fragment, DF, flag), and to indicate
the parts of a packet to the receiver)
 Fragmentation Offset (a byte count from the start of the original sent packet, set by
any router which performs IP router fragmentation)
 Time To Live (Number of hops /links which the packet may be routed over,
decremented by most routers – used to prevent accidental routing loops)
 Protocol (Service Access Point (SAP) which indicates the type of transport packet
being carried (e.g. 1 = ICMP; 2= IGMP; 6 = TCP; 17= UDP).
 Header Checksum (A 1’s complement checksum inserted by the sender and updated
whenever the packet header is modified by a router – Used to detect processing errors
introduced into the packet inside a router or bridge where the packet is not protected by a
link layer cyclic redundancy check. Packets with an invalid checksum are discarded by all
nodes in an IP network)
 Source Address (the IP address of the original sender of the packet)
 Destination Address (the IP address of the final destination of the packet)
 Options (not normally used, but, when used, the IP header length will be greater
than five 32-bit words to indicate the size of the options field)
Network Programming
BTCS703

Internet protocols

IP may refer to any of the following:

The Internet Protocol (IP) is the method or protocol by which data is sent from one computer
to another on the Internet. Each computer (known as a host) on the Internet has at least one IP
address that uniquely identifies it from all other computers on the Internet. 

When you send or receive data (for example, an e-mail note or a Web page), the message gets
divided into little chunks called packets. Each of these packets contains both the sender's
Internet address and the receiver's address. Any packet is sent first to a gateway computer
that understands a small part of the Internet. The gateway computer reads the destination
address and forwards the packet to an adjacent gateway that in turn reads the destination
address and so forth across the Internet until one gateway recognizes the packet as belonging
to a computer within its immediate neighborhood or domain. That gateway then forwards the
packet directly to the computer whose address is specified.

Short for Internet Protocol address, an IP or IP address is a number (example shown right)
used to indicate the location of a computer or other device on a network using TCP/IP. These
addresses are similar to those of your house, allowing data to reach the appropriate
destination on a network and the Internet.

IPv4 vs. IPv6

As the Internet and technology evolve, there has been an increasing demand for IP addresses.
To help meet the demand for IP addresses, there are two types of addresses used
today: IPv4 and IPv6. Although you may only deal with an IPv4 address in your local home,
school, or small office, you should also be aware of IPv6 addresses for when you encounter
them.

Example of an IPv4 address:


45.79.151.23
Example of an IPv6 address:
2601:681:4200:c5c0:516:f0bb:ac3b:46bd
IP address classes

With an IPv4 IP address, there are five classes of available IP ranges: Class A, Class B, Class
C, Class D and Class E, while only A, B, and C are commonly used. Each class allows for a
range of valid IP addresses, shown in the following table.

Class Address Range Supports

Class A 1.0.0.1 to 126.255.255.254 Supports 16 million hosts on each of 127 networks.


Class B 128.1.0.1 to 191.255.255.254 Supports 65,000 hosts on each of 16,000 networks.
Class C 192.0.1.1 to 223.255.254.254 Supports 254 hosts on each of 2 million networks.
Class D 224.0.0.0 to 239.255.255.255 Reserved for multicast groups.
Class E 240.0.0.0 to 254.255.255.254 Reserved for future use, or Research and Development Pur
Ranges 127.x.x.x are reserved for the loopback or localhost, for example, 127.0.0.1 is the
loopback address. Range 255.255.255.255 broadcasts to all hosts on the local network.
IP address breakdown

Every IP address is broken down into four sets of octets and translated into binary to
represent the actual IP address. The below table is an example of the IP 255.255.255.255. If
you are new to binary, we highly recommend reading our binary and hexadecimal
conversions section to get a better understanding of what we're doing in the below charts.

IP: 255 255 255 255


Binary value: 11111111 11111111 11111111 11111111
Octet value: 8 8 8 8
For an example, let's break down the IP "166.70.10.23" in the following table. The first row
contains the separate sections of the IP address, the second has binary values, and the third
row shows how the binary value equals the section of the IP address.
IP: 166 70 10 23

Binary value: 10100110 01000110 00001010 00010111


Numerical value: 128+32+4+2=166 64+4+2=70 8+2=10 16+4+2+1=23

Automatically assigned addresses

There are IP addresses that are automatically assigned (dynamic allocation) when you set up
a home network. These default addresses are what allow your computer and other network
devices to communicate and broadcast information over your network. Below are the most
commonly assigned default addresses for home networks.

192.168.1.0 0 is the automatically assigned network address.


192.168.1.1 1 is the commonly used address used as the gateway.
192.168.1.2 2 is also a commonly used address used for a gateway.
192.168.1.3 - 254 Addresses beyond 3 are assigned to computers and devices on the network.
192.168.1.255 255 is automatically assigned on most networks as the broadcast address.
If you have ever connected to your home network, you should be familiar with the gateway
address or 192.168.1.1, which is the address you use to connect to your home network router
to change its settings. Another common IP range that may be used is 10.0.0.3-254.
Getting an IP address

By default, the router you use will assign each of your computers their own IP address, often
using NAT to forward the data coming from those computers to outside networks such as the
Internet. If you need to register an IP address that can be seen on the Internet, you must
register through InterNIC or use a web host that can assign you addresses.

Anyone who connects to the Internet is assigned an IP address by their Internet Service
Provider (ISP), which has registered a range of IP addresses. For example, let's assume your
ISP is given 100 addresses, 109.145.93.150-249. In this range, the ISP owns addresses
109.145.93.150 to 109.145.93.249 and can assign any address in that range to its customers.
So, all these addresses belong to your ISP until they are assigned to a customers computer. In
the case of a dial-up connection, you are given a new IP address each time you dial into your
ISP. With most broadband Internet service providers, you are always connected to the
Internet your address rarely changes. It remains the same until the service provider requires
otherwise.

The above picture is taken from our "How do computers connect to each other over the
Internet" page and gives a good overview of how a computer can talk to another computer
over the Internet using an IP address.
Other internet protocols

An IP is just one type of protocols the Internet and networks use to communicate. There are
dozens of other protocols that are also used for communication between other programs and
devices. For example, SMTP (Simple Mail Transfer Protocol) is a protocol to send e-mail
from one computer to another computer. See our protocol page for a list of other popular
protocols.
Network Programming
BTCS703
IPv4 & v6 address structures

Octets or segments, or a combination of both, make up Internet Protocol version 4 (IPv4) and
Internet Protocol version 6 (IPv6) addresses.

An IPv4 address has the following format:  x . x . x . x where x is called an octet and must
be a decimal value between 0 and 255. Octets are separated by periods. An IPv4 address must
contain three periods and four octets. The following examples are valid IPv4 addresses:
 1.2.3.4
 01 . 102 . 103 . 104
The following example shows a screen that uses IPv4 addresses.

Ethernet IPv4 Panel 0175

Current Settings Frame 1:

IP Address (IPv4): 19.117.63.126

MAC Address: 18:36:F3:98:4F:9A

Gateway (IPv4): 19.117.63.253

Subnet Mask (IPv4): 255.255.253.0

[BACK] [ UP ] [DOWN] [ENTER]

Ethernet Mode: Manual IP Entry

Press ENTER to Change Settings

An IPv6 address can have either of the following two formats:


 Normal - Pure IPv6 format
 Dual - IPv6 plus IPv4 formats

An IPv6 (Normal) address has the following format:  y : y : y : y : y : y : y : y where y is


called a segment and can be any hexadecimal value between 0 and FFFF. The segments are
separated by colons - not periods. An IPv6 normal address must have eight segments,
however a short form notation can be used in the Tape Library Specialist Web interface for
segments that are zero, or those that have leading zeros. The short form notation can not be
used from the operator panel.
The following list shows examples of valid IPv6 (Normal) addresses:
 2001 : db8: 3333 : 4444 : 5555 : 6666 : 7777 : 8888
 2001 : db8 : 3333 : 4444 : CCCC : DDDD : EEEE : FFFF
 : : (implies all 8 segments are zero)
 2001: db8: : (implies that the last six segments are zero)
 : : 1234 : 5678 (implies that the first six segments are zero)
 2001 : db8: : 1234 : 5678 (implies that the middle four segments are zero)
 2001:0db8:0001:0000:0000:0ab9:C0A8:0102 (This can be compressed to eliminate
leading zeros, as follows: 2001:db8:1::ab9:C0A8:102 )
The following example shows a screen that uses IPv6 addresses:

Ethernet IPv6 Panel 0178

Current Settings
Frame 1, Port B

Manual IP (IPv6): 684D:1111:222:3333:4444:5555:6:77

MAC Address: 18:36:F3:98:4F:9A


DHCP IP (IPv6): Disabled

Press ENTER to Change Settings

Stateless Auto IP (IPv6): 0:0:0:0:0:0:0:0

[BACK] [ UP ] [DOWN] [ENTER]

An IPv6 (Dual) address combines an IPv6 and an IPv4 address and has the following
format: y : y : y : y : y : y : x . x . x . x. The IPv6 portion of the address (indicated with y's) is
always at the beginning, followed by the IPv4 portion (indicated with x's).

 In the IPv6 portion of the address, y is called a segment and can be any hexadecimal
value between 0 and FFFF. The segments are separated by colons - not periods. The
IPv6 portion of the address must have six segments but there is a short form notation
for segments that are zero.

 In the IPv4 portion of the address x is called an octet and must be a decimal value
between 0 and 255. The octets are separated by periods. The IPv4 portion of the
address must contain three periods and four octets.
The following list shows examples of valid IPv6 (Dual) addresses:
 2001 : db8: 3333 : 4444 : 5555 : 6666 : 1 . 2 . 3 . 4
 : : 11 . 22 . 33 . 44 (implies all six IPv6 segments are zero)
 2001 : db8: : 123 . 123 . 123 . 123 (implies that the last four IPv6 segments are zero)
 : : 1234 : 5678 : 91 . 123 . 4 . 56 (implies that the first four IPv6 segments are zero)
 : : 1234 : 5678 : 1 . 2 . 3 . 4 (implies that the first four IPv6 segments are zero)
 2001 : db8: : 1234 : 5678 : 5 . 6 . 7 . 8 (implies that the middle two IPv6 segments are
zero)

IPv4 Address Example


An example ip-address:

69.89.31.226

The above ip-address is in the dotted decimal number format. An ip address is in the format
of 4 sets of decimal numbers separated by dots. The decimal number in each and every set is
in the range 0 to 255. Each and every set is called octet. So, there are 4 octets in an ip
address.
However systems understands ip-address only in the binary format. So, when you configure
your system with an ip-address in a dotted decimal number format, it is converted to a binary
number format internally by the system as shown below.

01000101010110010001111111100010

(or)

01000101.01011001.00011111.11100010

IPv4 IP address are 32 bit numbers. In the above binary format, there are total of 32 binary
numbers. Each and every binary number that are separated by the dot is converted to its
corresponding binary number. There are total of 4 bytes here.
Each and every octet can have a value from 0 to 255. Since there are 4 octets in an ip-address,
the total possible combination of unique ipv4 ip addresses are 4,294,967,296.
IPv6 Address Example
IPv4 stands for Internet Protocol Version 4. Most of the networks and systems in the internet
is currently configured for IPv4. Since IPv4 ip address has only 32 bits (a total of
4,294,967,296 unique ip-addresses), the ip addresses in the internet are running out quickly.
Please note that there is a big block of these ip addresses are reserved for special purposes
(for example, private network and multicast addresses).
IPv6 stands for Internet Protocol Version 6. Since there is a possibility that we might run out
of ip address in the internet, IPv6 was developed. IPv6 ip address has 128 bits. This is a huge
improvement from the 32 bit ipv4 ip address. While lot of networks are getting configured for
both IPv4 and IPv6, there is still a huge number of networks and systems in the internet that
works only for IPv4. But eventually all these systems might go towards the IPv6 route.
IPv6 ip address is typically written in hexadecimal separated by colon. A colon separates 16
bit. The following is an example of IPv6 address:

2002:4559:1FE2::4559:1FE2

Leading zeros can be truncated. For example “0000” can be be just written as empty. In the
above example :: indicates that it has multiple 0’s in that location. Typically the IPv6 format
can be written down in three ways 1) compressed, 2) uncompressed and 3) fully
uncompressed as shown below. All of the following are the same:
 IPv6 Compressed (0000 is not displayed) – 2002:4559:1FE2::4559:1FE2
 IPv6 Uncompressed (0000 is displayed as 0) – 2002:4559:1FE2:0:0:0:4559:1FE2
 IPv6 Fully Uncompressed (0000 is fully displayed) –
2002:4559:1FE2:0000:0000:0000:4559:1FE2
Execute “ifconfig -a” which will display both ipv4 and ipv6 ip-addresss (if it is configured
appropriately):

# ifconfig -a | egrep 'inet|inet6'

inet addr:69.89.31.226

inet6 addr: 2002:4559:1fe2::4559:1fe2

Comparison :-

Description IPv4 IPv6

Address 32 bits long (4 bytes). Address 128 bits long (16 bytes). Basic architecture is
is composed of a network and 64 bits for the network number and 64 bits for
a host portion, which depend the host number. Often, the host portion of an
Description IPv4 IPv6

on address class. Various IPv6 address (or part of it) will be derived
address classes are defined: A, from a MAC address or other interface
B, C, D, or E depending on identifier.
initial few bits. The total Depending on the subnet prefix, IPv6 has a
number of IPv4 addresses is 4 more complicated architecture than IPv4.
294 967 296. The number of IPv6 addresses is 1028 (79 228
The text form of the IPv4 162 514 264 337 593 543 950 336) times
address isnnn.nnn.nnn.nnn, larger than the number of IPv4 addresses. The
where 0<=nnn<=255, and text form of the IPv6 address
eachn is a decimal digit. isxxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx,
Leading zeros can be omitted. where eachx is a hexadecimal digit,
Maximum number of print representing 4 bits. Leading zeros can be
characters is 15, not counting omitted. The double colon (::) can be used
a mask. once in the text form of an address, to
designate any number of 0 bits. For
example, ::ffff:10.120.78.40 is an IPv4-
mapped IPv6 address. (See  RFC 3513  for
details.

To view this RFC, see RFC Editor   


(www.rfc-editor.org/rfcsearch.html).

Address Originally, addresses were Allocation is in the earliest stages. The


allocation allocated by network class. As Internet Engineering Task Force (IETF) and
address space is depleted, Internet Architecture Board (IAB) have
smaller allocations using recommended that essentially every
Classless Inter-Domain organization, home, or entity be allocated
Routing (CIDR) are made. a /48 subnet prefix length. This would leave 16
Allocation has not been bits for the organization to do subnetting. The
balanced among institutions address space is large enough to give every
and nations. person in the world their own /48 subnet prefix
length.

Address Generally, not an applicable IPv6 addresses have two lifetimes: preferred
lifetime concept, except for addresses and valid, with the preferred lifetime always
Description IPv4 IPv6

assigned using DHCP. <= valid.


 After the preferred lifetime expires, the
address is not to be used as a source IP address
for new connections if an equally good
preferred address is available. After the valid
lifetime expires, the address is not used
(recognized) as a valid destination IP address
for incoming packets or used as a source IP
address. 
Some IPv6 addresses have, by definition,
infinite preferred and valid lifetimes; for
example link-local (see address scope).

Address Used to designate network Not used (see address prefix).


mask from host portion.

Address Sometimes used to designate Used to designate the subnet prefix of an


prefix network from host portion. address. Written as/nnn (up to 3 decimal
Sometimes written digits, 0 <= nnn <= 128) suffix after the print
as /nn suffix on presentation form. An example is fe80::982:2a5c/10, where
form of address. the first 10 bits comprise the subnet prefix.

Address Address Resolution Protocol is IPv6 embeds these functions within IP itself as
Resolution used by IPv4 to find a physical part of the algorithms for stateless
Protocol address, such as the MAC or autoconfiguration and neighbor discovery
(ARP) link address, associated with using Internet Control Message Protocol
an IPv4 address. version 6 (ICMPv6). Hence, there is no such
thing as ARP6.

Address For unicast addresses, the  In IPv6, address scope is part of the
scope concept does not apply. There architecture. Unicast addresses have two
are designated private address defined scopes, including link-local and
ranges and loopback. Outside global; and multicast addresses have 14
of that, addresses are assumed scopes. Default address selection for both
to be global. source and destination takes scope into
account. 
Description IPv4 IPv6

A scope zone is an instance of a scope in a


particular network. As a consequence, IPv6
addresses sometimes must be entered or
associated with a zone ID. The syntax
is %zid wherezid is a number (usually small)
or a name. The zone ID is written after the
address and before the prefix. For
example,2ba::1:2:14e:9a9b:c%3/48.

Address Unicast, multicast, and Unicast, multicast, and anycast. See IPv6


types broadcast. address types for descriptions.

Communica A tool to collect a detailed  Same for IPv6, and IPv6 is supported. 
tions trace trace of TCP/IP (and other)
packets that enter and leave
the system.

Configurati You must configure a newly  Configuration is optional, depending on


on installed system before it can functions required. IPv6 can be used with any
communicate with other Ethernet adapter and can be run over the
systems; that is, IP addresses loopback interface. IPv6 interfaces are self-
and routes must be assigned. configuring using IPv6 stateless
autoconfiguration. You can also manually
configure the IPv6 interface. So, the system
will be able to communicate with other IPv6
systems that are local and remote, depending
on the type of network and whether an IPv6
router exists. 

Domain Applications accept host Same for IPv6. Support for IPv6 exists using
Name names and then use DNS to AAAA (quad A) record type and reverse
System get an IP address, using socket lookup (IP-to-name). An application may elect
(DNS) APIgethostbyname(). to accept IPv6 addresses from DNS (or not)
Applications also accept IP and then use IPv6 to communicate (or not).
addresses and then use DNS to  The socket API gethostbyname() only
get host names supports IPv4. For IPv6, a
Description IPv4 IPv6

using gethostbyaddr(). new getaddrinfo() API is used to obtain (at


For IPv4, the domain for application choice) IPv6 only, or IPv4 and
reverse lookups is in- IPv6 addresses. 
addr.arpa. For IPv6, the domain used for reverse lookups
is ip6.arpa, and if not found then ip6.int (see
API getnameinfo()).

Dynamic Used to dynamically obtain an The i5/OS implementation of DHCP does not
Host IP address and other support IPv6.
Configurati configuration
on Protocol information. i5/OS supports a
(DHCP) DHCP server for IPv4.

File File Transfer Protocol allows The i5/OS implementation of FTP does not
Transfer you to send and receive files support IPv6.
Protocol across networks.
(FTP)

Fragments When a packet is too big for  For IPv6, fragmentation can only occur at the
the next link over which it is source node, and reassembly is only done at
to travel, it can be fragmented the destination node. The fragmentation
by the sender (host or router). extension header is used. 

Host table On iSeries Navigator, a Currently, this table does not support IPv6.
configurable table that Customers need to configure an AAAA record
associates an Internet address in a DNS for IPv6 domain resolution. You can
with a host name; for run the DNS locally on the same system as the
example, 127.0.0.1, loopback. resolver, or you can run it on a different
This table is used by the system.
sockets name resolver, either
before a DNS lookup or after a
DNS lookup fails (determined
by host name search priority).

Interface The conceptual or logical Same concept as IPv4.


entity used by TCP/IP to send Can be started and stopped independently of
Description IPv4 IPv6

and receive packets and each other and independently of TCP/IP using
always closely associated with iSeries Navigator only.
an IPv4 address, if not named
with an IPv4 address.
Sometimes referred to as a
logical interface.
Can be started and stopped
independently of each other
and independently of TCP/IP
using STRTCPIFC and
ENDTCPIFC commands and
using iSeries Navigator.

Internet ICMP is used by IPv4 to Used similarly for IPv6; however, Internet
Control communicate network Control Message Protocol version 6 (ICMPv6)
Message information. provides some new attributes.
Protocol Basic error types remain, such as destination
(ICMP) unreachable, echo request and reply. New
types and codes are added to support neighbor
discovery and related functions.

Internet IGMP is used by IPv4 routers Replaced by MLD (multicast listener


Group to find hosts that want traffic discovery) protocol for IPv6. Does essentially
Managemen for a particular multicast what IGMP does for IPv4, but uses ICMPv6
t Protocol group, and used by IPv4 hosts by adding a few MLD-specific ICMPv6 type
(IGMP) to inform IPv4 routers of values.
existing multicast group
listeners (on the host).

IP header Variable length of 20-60 Fixed length of 40 bytes. There are no IP


bytes, depending on IP options header options. Generally, the IPv6 header is
present. simpler than the IPv4 header.

IP header Various options that might The IPv6 header has no options. Instead, IPv6
options accompany an IP header adds additional (optional) extension headers.
(before any transport header). The extension headers are AH and ESP
Description IPv4 IPv6

(unchanged from IPv4), hop-by-hop, routing,


fragment, and destination. Currently, IPv6
supports some extension headers.

IP header The protocol code of the The type of header immediately following the
protocol transport layer or packet IPv6 header. Uses the same values as the IPv4
byte payload; for example, ICMP. protocol field. But the architectural effect is to
allow a currently defined range of next
headers, and is easily extended. The next
header will be a transport header, an extension
header, or ICMPv6.

IP header Used by QoS and Designates the IPv6 traffic class, similarly to
Type of differentiated services to IPv4. Uses different codes. Currently, IPv6
Service designate a traffic class. does not support TOS.
(TOS) byte

iSeries iSeries Navigator provides a Same for IPv6. No CL commands are


Navigator complete configuration available for IPv6 configuration.
support solution for TCP/IP.

LAN Used by an IP interface to get  IPv6 can be used with any Ethernet adapters
connection to the physical network. Many and is also supported over virtual Ethernet
types exist; for example, token between logical partitions. 
ring, and Ethernet. Sometimes
referred to as the physical
interface, link, or line.

Layer 2 L2TP can be thought of as Currently, the i5/OS implementation of L2TP


Tunnel virtual PPP, and works over does not support IPv6.
Protocol any supported line type.
(L2TP)

Loopback An interface with an address The concept is the same as in IPv4. The single
address of 127.*.*.*(typically 127.0.0. loopback address
1) that can only be used by a is 0000:0000:0000:0000:0000:0000:0000:0001 
node to send packets to itself. or::1 (shortened version). The virtual physical
Description IPv4 IPv6

The physical interface (line interface is named *LOOPBACK .


description) is named
*LOOPBACK.

Maximum Maximum transmission unit of IPv6 has an architected lower bound on MTU
Transmissio a link is the maximum number of 1280 bytes. That is, IPv6 will not fragment
n Unit of bytes that a particular link packets below this limit. To send IPv6 over a
(MTU) type, such as Ethernet or link with less than 1280 MTU, the link-layer
modem, supports. For IPv4, must transparently fragment and defragment
576 is the typical minimum. the IPv6 packets.

Netstat A tool to look at the status of Same for IPv6, and IPv6 is supported for both
TCP/IP connections, 5250 and iSeries Navigator.
interfaces, or routes. Available
using iSeries Navigator and
5250.

Network Basic firewall functions Currently, NAT does not support IPv6. More
Address integrated into TCP/IP, generally, IPv6 does not require NAT. The
Translation configured using iSeries expanded address space of IPv6 eliminates the
(NAT) Navigator. address shortage problem and enables easier
renumbering.

Network On iSeries Navigator, a Currently, no changes are made to this table


table configurable table that for IPv6.
associates a network name
with an IP address without
mask. For example, host
Network14 and IP address
1.2.3.4.

Node info Does not exist. A simple and convenient network tool that
query should work like ping, except with content: an
IPv6 node may query another IPv6 node for
the target's DNS name, IPv6 unicast address,
or IPv4 address. Currently, not supported.
Description IPv4 IPv6

Packet Basic firewall functions You cannot use packet filtering with IPv6.
filtering integrated into TCP/IP,
configured using iSeries
Navigator.

Packet The i5/OS TCP/IP stack can IPv6 packets are not forwarded.


forwarding be configured to forward IP
packets it receives for
nonlocal IP addresses.
Typically, the inbound
interface and outbound
interface are connected to
different LANs.

PING Basic TCP/IP tool to test Same for IPv6, and IPv6 is supported, for both
reachability. Available using 5250 and iSeries Navigator.
iSeries Navigator and 5250.

Point-to- PPP supports dialup interfaces  Currently, the i5/OS implementation of PPP
Point over various modem and line does not support IPv6. 
Protocol types.
(PPP)

Port These i5/OS panels allow a  Same for IPv6. Port restrictions for IPv6 are
restrictions customer to configure a identical to those available in IPv4.  
selected port number or port
number ranges for TCP or
UDP so that they are only
available for a specific profile.

Ports TCP and UDP have separate For IPv6, ports work the same as IPv4.
port spaces, each identified by Because these are in a new address family,
port numbers in the range 1- there are now four separate port spaces. For
65535. example, there are two TCP port 80 spaces to
which an application can bind, one in
AF_INET and one in AF_INET6.
Description IPv4 IPv6

Private and All IPv4 addresses are public, IPv6 has an analogous concept, but with
public except for three address ranges important differences.
addresses that have been designated as Addresses are public or temporary, previously
private by IETF RFC termed anonymous. See RFC 3041. Unlike
1918: 10.*.*.* IPv4 private addresses, temporary addresses
(10/8),172.16.0.0 through 172. can be globally routed. The motivation is also
31.255.255 (172.16/12) , different; IPv6 temporary addresses are meant
and 192.168.*.* (192.168/16). to shield the identity of a client when it
Private address domains are initiates communication (a privacy concern).
commonly used within Temporary addresses have a limited lifetime,
organizations. Private and do not contain an interface identifier that
addresses cannot be routed is a link (MAC) address. They are generally
across the Internet. indistinguishable from public addresses.
IPv6 has the notion of limited address scope
using its architected scope designations
(see address scope).

Protocol On iSeries Navigator, a  The table can be used with IPv6 without
table configurable table that change. 
associates a protocol name
with its assigned protocol
number; for example, UDP,
17. The system is shipped with
a small number of entries: IP,
TCP, UDP, ICMP.

Quality of Quality of service allows you  Currently, the i5/OS implementation of QoS
service to request packet priority and does not support IPv6. 
(QoS) bandwidth for TCP/IP
applications.

Renumberin Done by manual Is an important architectural element of IPv6,


g reconfiguration, with the and is largely automatic, especially within
possible exception of DHCP. the /48 prefix.
Generally, for a site or
Description IPv4 IPv6

organization, a difficult and


troublesome process to avoid
if possible.

Route Logically, a mapping of a set  Conceptually, similar to IPv4. One important


of IP addresses (might contain difference: IPv6 routes are associated (bound)
only one) to a physical to a physical interface (a link, such as ETH03)
interface and a single next-hop rather than an interface. One reason that a
IP address. IP packets whose route is associated with a physical interface is
destination address is defined because source address selection functions
as part of the set are forwarded differently for IPv6 than for IPv4. See Source
to the next hop using the line. address selection.  
IPv4 routes are associated
with an IPv4 interface, hence,
an IPv4 address.
The default route is
*DFTROUTE.

Routing RIP is a routing protocol Currently, RIP does not support IPv6. IPv6
Information supported by the routed routing uses static routes.
Protocol daemon.
(RIP)

Services On i5/OS, a configurable table No changes are made to this table for IPv6.
table that associates a service name
with a port and protocol; for
example, service name FTP-
control, port 21, TCP, and
User Datagram Protocol
(UDP).
A large number of well-known
services are listed in the
services table. Many
applications use this table to
determine which port to use.
Description IPv4 IPv6

Simple SNMP is a protocol for system  Currently, the i5/OS implementation of


Network management. SNMP does not support IPv6.  
Managemen
t Protocol
(SNMP)

Sockets API These APIs are the way IPv6 enhances sockets so that applications can
applications use TCP/IP. now use IPv6, using a new address family:
Applications that do not need AF_INET6.
IPv6 are not affected by The enhancements have been designed so that
sockets changes to support existing IPv4 applications are completely
IPv6. unaffected by IPv6 and API changes.
Applications that want to support concurrent
IPv4 and IPv6 traffic, or IPv6-only traffic, are
easily accommodated using IPv4-mapped IPv6
addresses of the form::ffff:a.b.c.d,
where a.b.c.d is the IPv4 address of the client.
The new APIs also include support for
converting IPv6 addresses from text to binary
and from binary to text.
See Using AF_INET6 address family for more
information about sockets enhancements for
IPv6.

Source An application may designate As with IPv4, an application can designate a


address a source IP (typically, using source IPv6 address using bind(). Similarly to
selection sockets bind()). If it binds to IPv4, it can let the system choose an IPv6
INADDR_ANY, a source IP is source address by using in6addr_any. But
chosen based on the route. because IPv6 lines have many IPv6 addresses,
the internal method of choosing a source IP is
different.

Starting and Use STRTCP and ENDTCP to Same as IPv4. IPv4 and IPv6 are not started or
stopping start or end TCP/IP. stopped independently of one another or
independently of TCP/IP. That is, you start
Description IPv4 IPv6

and stop all of TCP/IP, not just IPv4 or IPv6.


 Any IPv6 interfaces are automatically started
if the AUTOSTART parameter = *YES (the
default). IPv6 cannot be used or configured
without IPv4. The IPv6 loopback interface,::1,
will automatically be defined and activated
when IPv6 is started. 

Telnet Telnet allows you to log on  Currently, the i5/OS implementation of Telnet
and use a remote computer as does not support IPv6. 
though you were connected to
it directly.

Trace route Basic TCP/IP tool to do path Same for IPv6, and IPv6 is supported for both
determination. Available using 5250 and iSeries Navigator.
iSeries Navigator and 5250.

Transport  TCP, UDP, RAW.   The same transports exist in IPv6.


layers

Unspecified Apparently, not defined, as Defined as ::/128 (128 0 bits). It is used as the


address such. Socket programming source IP in some neighbor discovery packets,
uses 0.0.0.0 as and various other contexts, like sockets.
INADDR_ANY. Socket programming
uses ::/128 asin6addr_any.

Virtual Virtual private network (using  Currently, the i5/OS implementation of VPN
private IPsec) allows you to extend a does not support IPv6.  
network secure, private network over
(VPN) an existing public network.
Programming Applications: Time & date routines

The basic time service provided by the UNIX kernel counts the number of seconds that have
passed since the Epoch: 00:00:00 January 1, 1970, Coordinated Universal Time (UTC).
In Section 1.10, we said that these seconds are represented in a time_t data type, and we call
them calendar times. These calendar times represent both the time and the date.

The UNIX System has always differed from other operating systems in
(a) keeping time in UTC instead of the local time,
(b) automatically handling conversions, such as daylight saving time, and
(c) keeping the time and date as a single quantity.
The time function returns the current time and date.

#include <time.h> time_t time(time_t *calptr);

Returns: value of time if OK, 1 on error

The time value is always returned as the value of the function. If the argument is non- null,
the time value is also stored at the location pointed to by calptr.
We haven't said how the kernel's notion of the current time is initialized. Historically, on
implementations derived from System V, the stime(2) function was called, whereas BSD-
derived systems used settimeofday(2).
The Single UNIX Specification doesn't specify how a system sets its current time.
The gettimeofday function provides greater resolution (up to a microsecond) than
the time function. This is important for some applications.

[View full width]


#include <sys/time.h> int gettimeofday(struct timeval *restrict tp, void *restrict tzp);

Returns: 0 always

This function is defined as an XSI extension in the Single UNIX Specification. The only legal
value fortzp is NULL; other values result in unspecified behavior. Some platforms support
the specification of a time zone through the use of tzp, but this is implementation-specific and
not defined by the Single UNIX Specification.
The gettimeofday function stores the current time as measured from the Epoch in the memory
pointed to by tp. This time is represented as a timeval structure, which stores seconds and
microseconds:
struct timeval { time_t tv_sec; /* seconds */ long tv_usec; /* microseconds */ };

Once we have the integer value that counts the number of seconds since the Epoch, we
normally call one of the other time functions to convert it to a human-readable time and date.
Figure 6.8 shows the relationships between the various time functions.

Figure 6.8. Relationship of the various time functions

(The four functions in this figure that are shown with dashed lineslocaltime, mktime, ctime,
andstrftimeare all affected by the TZ environment variable, which we describe later in this
section.)
The two functions localtime and gmtime convert a calendar time into what's called a broken-
down time, a tm structure.
struct tm { /* a broken-down time */ int tm_sec; /* seconds after the minute: [0 - 60] */ int
tm_min; /* minutes after the hour: [0 - 59] */ int tm_hour; /* hours after midnight: [0 - 23] */
int tm_mday; /* day of the month: [1 - 31] */ int tm_mon; /* months since January: [0 - 11] */
int tm_year; /* years since 1900 */ int tm_wday; /* days since Sunday: [0 - 6] */ int tm_yday;
/* days since January 1: [0 - 365] */ int tm_isdst; /* daylight saving time flag: <0, 0, >0 */ };

The reason that the seconds can be greater than 59 is to allow for a leap second. Note that all
the fields except the day of the month are 0-based. The daylight saving time flag is positive if
daylight saving time is in effect, 0 if it's not in effect, and negative if the information isn't
available.
In previous versions of the Single UNIX Specification, double leap seconds were allowed.
Thus, the valid range of values for the tm_sec member was 061. The formal definition of
UTC doesn't allow for double leap seconds, so the valid range for seconds is now defined to
be 060.

#include <time.h> struct tm *gmtime(const time_t *calptr); struct tm *localtime(const time_t


*calptr);

Both return: pointer to broken-down time

The difference between localtime and gmtime is that the first converts the calendar time to
the local time, taking into account the local time zone and daylight saving time flag, whereas
the latter converts the calendar time into a broken-down time expressed as UTC.
The function mktime takes a broken-down time, expressed as a local time, and converts it
into a time_tvalue.

#include <time.h> time_t mktime(struct tm *tmptr);

Returns: calendar time if OK, 1 on error

The asctime and ctime functions produce the familiar 26-byte string that is similar to the


default output of the date(1) command:
Tue Feb 10 18:27:38 2004\n\0

#include <time.h> char *asctime(const struct tm *tmptr); char *ctime(const time_t *calptr);

Both return: pointer to null-terminated string

The argument to asctime is a pointer to a broken-down string, whereas the argument


to ctime is a pointer to a calendar time.
The final time function, strftime, is the most complicated. It is a printf-like function for time
values.

#include <time.h> size_t strftime(char *restrict buf, size_t maxsize, const char *restrict format,
const struct tm *restrict tmptr);

Returns: number of characters stored in array if room, 0 otherwise

The final argument is the time value to format, specified by a pointer to a broken-down time
value. The formatted result is stored in the array buf whose size is maxsize characters. If the
size of the result, including the terminating null, fits in the buffer, the function returns the
number of characters stored in buf, excluding the terminating null. Otherwise, the function
returns 0.
The format argument controls the formatting of the time value. Like the printf functions,
conversion specifiers are given as a percent followed by a special character. All other
characters in the formatstring are copied to the output. Two percents in a row generate a
single percent in the output. Unlike the printf functions, each conversion specified generates a
different fixed-size output stringthere are no field widths in the format string. Figure 6.9
describes the 37 ISO C conversion specifiers. The third column of this figure is from the
output of strftime under Linux, corresponding to the time and dateTue Feb 10 18:27:38 EST
2004.

Forma
t Description Example

%a abbreviated weekday name Tue

%A full weekday name Tuesday

%b abbreviated month name Feb

%B full month name February

Tue Feb 10 18:27:38


%c date and time 2004

%C year/100: [0099] 20

%d day of the month: [0131] 10

%D date [MM/DD/YY] 02/10/04

day of month (single digit preceded by space)


%e [131] 10

%F ISO 8601 date format [YYYYMMDD] 2004-02-10

last two digits of ISO 8601 week-based year


%g [0099] 04

%G ISO 8601 week-based year 2004


Forma
t Description Example

%h same as %b Feb

%H hour of the day (24-hour format): [0023] 18

%I hour of the day (12-hour format): [0112] 06

%j day of the year: [001366] 041

%m month: [0112] 02

%M minute: [0059] 27

%n newline character

%p AM/PM PM

%r locale's time (12-hour format) 06:27:38 PM

%R same as "%H:%M" 18:27

%S second: [0060] 38

%t horizontal tab character

%T same as "%H:%M:%S" 18:27:38

%u ISO 8601 weekday [Monday=1, 17] 2

%U Sunday week number: [0053] 06

%V ISO 8601 week number: [0153] 07

%w weekday: [0=Sunday, 06] 2

%W Monday week number: [0053] 06

%x date 02/10/04
Forma
t Description Example

%X time 18:27:38

%y last two digits of year: [0099] 04

%Y year 2004

%z offset from UTC in ISO 8601 format -0500

%Z time zone name EST

%% translates to a percent sign %

Figure 2 Conversion specifiers for strftime

The only specifiers that are not self-evident are %U, %V, and %W. The %U specifier
represents the week number of the year, where the week containing the first Sunday is week
1. The %W specifier represents the week number of the year, where the week containing the
first Monday is week 1. The %V specifier is different. If the week containing the first day in
January has four or more days in the new year, then this is treated as week 1. Otherwise, it is
treated as the last week of the previous year. In both cases, Monday is treated as the first day
of the week.
As with printf, strftime supports modifiers for some of the conversion specifiers.
The E and Omodifiers can be used to generate an alternate format if supported by the locale.
Some systems support additional, nonstandard extensions to the format string for strftime.
We mentioned that the four functions in Figure 6.8 with dashed lines were affected by
the TZenvironment variable: localtime, mktime, ctime, and strftime. If defined, the value of
this environment variable is used by these functions instead of the default time zone. If the
variable is defined to be a null string, such as TZ=, then UTC is normally used. The value of
this environment variable is often something like TZ=EST5EDT, but POSIX.1 allows a much
more detailed specification. Refer to the Environment Variables chapter of the Single UNIX
Specification [Open Group 2004] for all the details on the TZ variable.
All the time and date functions described in this section, except gettimeofday, are defined by
the ISO C standard. POSIX.1, however, added the TZ environment variable. On FreeBSD
5.2.1, Linux 2.4.22, and Mac OS X 10.3, more information on the TZ variable can be found
in the tzset(3) manual page. On Solaris 9, this information is in the environ(5) manual page.
Network Programming
BTCS703
TCP & IP headers

TCP inserts header fields into the message stream in the order listed below:
.

 Source and destination TCP port numbers are the communication endpoints for
sending and receiving devices.
 Message senders use sequence numbers to mark the ordering of a group of messages.
Both senders and receivers use the acknowledgement numbers field to communicate the
sequence numbers of messages that are either recently received or expected to be sent.
 The data offset field stores the total size of a TCP header in multiples of four bytes. A
header not using the optional TCP field has a data offset of 5 (representing 20 bytes), while a
header using the maximum-sized optional field has a data offset of 15 (representing 60
bytes).
 Reserved data in TCP headers always has a value of zero. This field serves the
purpose of aligning the total header size as a multiple of four bytes (important for efficiency
of computer data processing).
 TCP uses a set of six standard and three extended control flags (each an individual bit
representing on or off) to manage data flow in specific situations. One bit flag, for example,
initiates TCP connection reset logic. The detailed operation of these fields goes beyond the
scope of this article.

 TCP senders use a number called window size to regulate how much data they send to
a receiver before requiring an acknowledgement in return. If the window size becomes too
small, network data transfer will be unnecessarily slow, while if the window size becomes too
large, the network link can become saturated (unusable for any other applications) or the
receiver may not be able to process incoming data quickly enough (also resulting in slow
performance). Windowing algorithms built into the protocol dynamically calculate size
values and use this field of TCP headers to coordinate changes between senders and
receivers.
 The checksum value inside a TCP header is generated by the protocol sender as a
mathematical technique to help the receiver detect messages that are corrupted or tampered
with.
 The urgent pointer field is often set to zero and ignored, but in conjunction with one
of the control flags, it can be used as a data offset to mark a subset of a message as requiring
priority processing.
 Usages of optional TCP data go beyond the scope of this article but include support
for special acknowledgement and window scaling algorithms.

 Version IPv4, IPv6 etc.


 IP Header Length (number of 32 -bit words forming the header, usually five)
 Type of Service (ToS), now known as Differentiated Services Code Point (DSCP)
(usually set to 0, but may indicate particular Quality of Service needs from the network, the
DSCP defines the way routers should queue packets while they are waiting to be
forwarded).
 Size of Datagram (in bytes, this is the combined length of the header and the data)
 Identification ( 16-bit number which together with the source address uniquely
identifies this packet – used during reassembly of fragmented datagrams)
 Flags (a sequence of three flags (one of the 4 bits is unused) used to control whether
routers are allowed to fragment a packet (i.e. the Don’t Fragment, DF, flag), and to indicate
the parts of a packet to the receiver)
 Fragmentation Offset (a byte count from the start of the original sent packet, set by
any router which performs IP router fragmentation)
 Time To Live (Number of hops /links which the packet may be routed over,
decremented by most routers – used to prevent accidental routing loops)
 Protocol (Service Access Point (SAP) which indicates the type of transport packet
being carried (e.g. 1 = ICMP; 2= IGMP; 6 = TCP; 17= UDP).
 Header Checksum (A 1’s complement checksum inserted by the sender and updated
whenever the packet header is modified by a router – Used to detect processing errors
introduced into the packet inside a router or bridge where the packet is not protected by a
link layer cyclic redundancy check. Packets with an invalid checksum are discarded by all
nodes in an IP network)
 Source Address (the IP address of the original sender of the packet)
 Destination Address (the IP address of the final destination of the packet)
 Options (not normally used, but, when used, the IP header length will be greater
than five 32-bit words to indicate the size of the options field)
Network Programming
BTCS703
UUCP, XNS, IPX/SPX for LANs
UUCP (UNIX-to-UNIX Copy Protocol) is a set of UNIX programs for copying (sending)
files between different UNIX systems and for sending commands to be executed on another
system. The main UUCP commands (each supported by a UUCP program) are:

 uucp, which requests the copying of a specific file to another specified system

 uux, which sends a UNIX command to another system where it is queued for
execution

 uucico, which runs on a UNIX system as the program that carries out the copying and
initiates execution of the commands that have been sent. Typically, this program is run at
various times of day; meanwhile, the copy (uucp) and command (uux) requests are
queued until the uucico program is run.

 uuxqt, which executes the commands sent by uux, usually after being started by the
uucico program

The uucico programs are the programs that actually communicate across a network. There are
several network protocols (variations on packet size and error-checking) that can be used by
uucico programs, depending on the kinds of carrier networks being used.

Xerox Network Systems (XNS) and the OSI Model


We need to take a brief look at the Xerox Network Systems XNS model developed at Palo
Alto Research Center (Parc), because several of the major LAN vendors (notably Novell and
Banyan) have based portions of their NOS on the XNS model. See the Xerox Network
Systems (XNS) .

Xerox Network Systems (XNS) is a set of protocols that were used by Xerox Systems for
data communication. Xerox used XNS for file transfers, sharing network resources, packet
transfers, sharing routing information and remote procedure calls. Its basic working
mechanism is almost the same as in the TCP/IP protocol suit, but XNS contains only two
network layers. This differs from the seven-layer Open Systems Interconnection (OSI)
model, although the functionality is basically the same.

XNS was a public domain technology and therefore became one of the most commonly used
networking technologies through 1980s. It was replaced by the Internet Protocol suite. The
XNS protocol suite became very popular right after its launch in the early 1980s and has been
used by many local area networks, particularly for large companies. Over time, changes were
made the the protocol structure to create a more efficient output.
XNS contains two major layers, a network layer and a transport layer. The network layer
provides the packet-carrying service and logical addressing. XNS was developed for many
purposes, such as office applications, transmissions, communication media and processors.
There is an echo protocol inside the XNS suite, which works as a door knocker, checking the
connectivity between the two systems. This is similar to ping in IP systems.

XNS is based on a five-layer model, in contrast to the seven-layer Open Systems


Interconnection (OSI) reference model for networking. The layers of the XNS protocol stack
are as follows:
 Level 0 (media access layer): Maps to the OSI physical layer and data-link layer and
performs similar functions. XNS does not tie into any one media access protocol and
supports the Ethernet, Token Ring, High-level Data Link Control (HDLC),
and X.25 protocols, among others. 
 Level 1 (network layer): Maps to the OSI network layer and defines the Internet
Datagram Protocol (IDP). IDP functions similarly to the Internet Protocol (IP) of TCP/IP
and uses a logical addressing scheme that requires four-byte network numbers, four-byte
host numbers, and two-byte socket numbers for both source and destination addresses.
IDP is responsible for delivering datagrams by using unicast, multicast,
and broadcast methods. Level 1 also defines the Routing Information Protocol (RIP),
which handles dynamic routing and has evolved into later versions for use in IPX/SPX
and TCP/IP networks. 
 Level 2 (transport layer): Maps to the OSI transport layer and defines the Sequenced
Packet Protocol (SPP). SPP functions similarly to the Transmission Control Protocol
(TCP) of TCP/IP and is responsible for providing reliable transmission of IDP packets,
including sequence numbers and acknowledgments. Level 2 also defines the Packet
Exchange Protocol (PEP), which functions similarly to the User Datagram Protocol
(UDP) of TCP/IP. For troubleshooting purposes, the Echo Protocol (EP) functions
similarly to the ping utility of TCP/IP. 
 Level 3: Maps to the OSI presentation layer and includes the Filing Protocol (FP),
Clearinghouse Protocol (CP), Printing Protocol (PP), and others. 
 Level 4: Maps to the OSI application layer. 

XNS Applications
XNS also defines standards for application level functions. These include the following
services:
clearinghouse for data network resources (such as addresses)
authentication and security services
time stamping information
character code standards
document management and interchange
print, file and mail standards

IPX and SPX


IPX and SPX are derived from Xerox Network Systems' IDP and SPP protocols, respectively.
IPX is a network layer protocol (layer 3 of the OSI Model), while SPX is a transport
layerprotocol (layer 4 of the OSI Model). The SPX layer sits on top of the IPX layer and
provides connection-oriented services between two nodes on the network. SPX is used
primarily byclient–server applications.
IPX and SPX both provide connection services similar to TCP/IP, with the IPX protocol
having similarities to IP, and SPX having similarities to TCP. IPX/SPX was primarily
designed forlocal area networks (LANs), and is a very efficient protocol for this purpose
(typically SPX's performance exceeds that of TCP on a small LAN, as in place of congestion
windows and confirmatory acknowledgements, SPX uses simple NAKs). TCP/IP has,
however, become the de facto standard protocol. This is in part due to its superior
performance overwide area networks and the Internet (which uses TCP/IP exclusively), and
also because TCP/IP is a more mature protocol [citation needed], designed specifically with this
purpose in mind.
Despite the protocols' association with NetWare, they are neither required for NetWare
communication (as of NetWare 5.x), nor exclusively used on NetWare networks. NetWare
communication requires an NCP implementation, which can use IPX/SPX, TCP/IP, or both,
as a transport.
Network Programming
BTCS703
Web server working method & programming.

Web server is a computer where the web content is stored. Basically web server is used to
host the web sites but there exists other web servers also such as gaming, storage, FTP, email
etc.

Web site is collection of web pages whileweb server is a software that respond to the request
for web resources.
Web Server Working
Web server respond to the client request in either of the following two ways:

 Sending the file to the client associated with the requested URL.

 Generating response by invoking a script and communicating with database

Key Points
 When client sends request for a web page, the web server search for the requested
page if requested page is found then it will send it to client with an HTTP response.

 If the requested web page is not found, web server will the send an HTTP
response:Error 404 Not found.

 If client has requested for some other resources then the web server will contact to the
application server and data store to construct the HTTP response.

Architecture
Web Server Architecture follows the following two approaches:

1. Concurrent Approach

2. Single-Process-Event-Driven Approach.

Concurrent Approach
Concurrent approach allows the web server to handle multiple client requests at the same
time. It can be achieved by following methods:

 Multi-process

 Multi-threaded

 Hybrid method.

Multi-processing
In this a single process (parent process) initiates several single-threaded child processes and
distribute incoming requests to these child processes. Each of the child processes are
responsible for handling single request.

It is the responsibility of parent process to monitor the load and decide if processes should be
killed or forked.

Multi-threaded
Unlike Multi-process, it creates multiple single-threaded process.

Hybrid
It is combination of above two approaches. In this approach multiple process are created and
each process initiates multiple threads. Each of the threads handles one connection. Using
multiple threads in single process results in less load on system resources.

Examples
Following table describes the most leading web servers available today:
S.N. Web Server Descriptino

Apache HTTP Server


This is the most popular web server in the world developed by the Apache Software
1 Foundation. Apache web server is an open source software and can be installed on
almost all operating systems including Linux, UNIX, Windows, FreeBSD, Mac OS X
and more. About 60% of the web server machines run the Apache Web Server.

Internet Information Services (IIS)


The Internet Information Server (IIS) is a high performance Web Server from
Microsoft. This web server runs on Windows NT/2000 and 2003 platforms (and may
2.
be on upcoming new Windows version also). IIS comes bundled with Windows
NT/2000 and 2003; Because IIS is tightly integrated with the operating system so it is
relatively easy to administer it.

Lighttpd
The lighttpd, pronounced lighty is also a free web server that is distributed with the
3. FreeBSD operating system. This open source web server is fast, secure and consumes
much less CPU power. Lighttpd can also run on Windows, Mac OS X, Linux and
Solaris operating systems.

Sun Java System Web Server


This web server from Sun Microsystems is suited for medium and large web sites.
Though the server is free it is not open source. It however, runs on Windows, Linux
4.
and UNIX platforms. The Sun Java System web server supports various languages,
scripts and technologies required for Web 2.0 such as JSP, Java Servlets, PHP, Perl,
Python, and Ruby on Rails, ASP and Coldfusion etc.

Jigsaw Server
Jigsaw (W3C's Server) comes from the World Wide Web Consortium. It is open
5. source and free and can run on various platforms like Linux, UNIX, Windows, and
Mac OS X Free BSD etc. Jigsaw has been written in Java and can run CGI scripts and
PHP programs.

Web programming

 Web programming is a very broad topic


 We're going to break it up into five parts:
1. HTTP basics
2. Client programming:
 HTML Forms
 Javascript
3. Server as a client:
 Downloading and analyzing content from the web
4. Server programming:
 CGI
5. Putting it all together:
 AJAX

You might also like