Date post: | 09-Apr-2018 |
Category: |
Documents |
Upload: | niranjanass |
View: | 216 times |
Download: | 0 times |
of 38
8/7/2019 CSC383 Lecture Notes Ch 1 2 3
1/38
CSC383 Computer NetworksCSC383 Computer Networks
Dr. Allen M. Johnson, Jr.Dr. Allen M. Johnson, Jr.
8/7/2019 CSC383 Lecture Notes Ch 1 2 3
2/38
HistoryHistory
11stst networks designed to share largenetworks designed to share large--scalescalecomputational powercomputational power
11
stst
commercially available network systemcommercially available network systemwas IBMs PROFS system. (mainframes)was IBMs PROFS system. (mainframes)
Late 1960s, ARPA started investigatingLate 1960s, ARPA started investigatingdata networking.data networking.
Idea of networking computers of differentIdea of networking computers of differentarchitecturesarchitectures
Thought to be a crazy idea by manyThought to be a crazy idea by many
8/7/2019 CSC383 Lecture Notes Ch 1 2 3
3/38
History History
In the late 1970s inexpensiveIn the late 1970s inexpensive
minicomputers provided timeminicomputers provided time--sharingsharing
facilities to people within a department.facilities to people within a department. Organizations installed Local AreaOrganizations installed Local Area
Networks (LANs) to interconnect theseNetworks (LANs) to interconnect these
machines together.machines together.
8/7/2019 CSC383 Lecture Notes Ch 1 2 3
4/38
HistoryHistory
ARPA chose to investigate a revolutionaryARPA chose to investigate a revolutionaryapproach, known asapproach, known aspacket switchingpacket switching..
They hired people to work on networkThey hired people to work on networkresearch and contractors to turn the designsresearch and contractors to turn the designsinto a working system called theinto a working system called the ARPANETARPANET..
This was so successful that ARPAThis was so successful that ARPA
continued funding research into acontinued funding research into anetworking technology callednetworking technology calledinternetworkinginternetworking..
8/7/2019 CSC383 Lecture Notes Ch 1 2 3
5/38
HistoryHistory
By the 1970s, internetworking was theBy the 1970s, internetworking was the
focus of ARPA research and thefocus of ARPA research and the InternetInternet
had emerged.had emerged. ARPA continued funding research into theARPA continued funding research into the
1980s,1980s,
Internet became a commercial success inInternet became a commercial success inthe 1990s.the 1990s.
8/7/2019 CSC383 Lecture Notes Ch 1 2 3
6/38
Growth of InternetGrowth of Internet
The Internet has grown from an early researchThe Internet has grown from an early research
prototype into a global communications systemprototype into a global communications system
that connects every country.that connects every country. By 1999, the Internet was growing so fast that aBy 1999, the Internet was growing so fast that a
new computer was added to the Internet everynew computer was added to the Internet every
second.second.
8/7/2019 CSC383 Lecture Notes Ch 1 2 3
7/38
Growth of InternetGrowth of Internet
8/7/2019 CSC383 Lecture Notes Ch 1 2 3
8/38
Growth of InternetGrowth of Internet
8/7/2019 CSC383 Lecture Notes Ch 1 2 3
9/38
Protocols and LayeringProtocols and Layering
Computer networks are complex systemsComputer networks are complex systems
including both hardware and software.including both hardware and software.
Designers divided the communicationDesigners divided the communicationproblem into subparts, calledproblem into subparts, called layerslayers, with the, with the
interfaces between the layers defined byinterfaces between the layers defined by
protocolsprotocols..
8/7/2019 CSC383 Lecture Notes Ch 1 2 3
10/38
TCP/IP 5TCP/IP 5--layer Reference Modellayer Reference Model
8/7/2019 CSC383 Lecture Notes Ch 1 2 3
11/38
TCP/IP Layered ModelTCP/IP Layered Model
physical layer corresponds to basic network hardware.physical layer corresponds to basic network hardware. Networkinterface layer specifies how data is divided intoNetworkinterface layer specifies how data is divided into
frames for transmission over a network.frames for transmission over a network.
Internet layer protocols specify the format of packets sentInternet layer protocols specify the format of packets sent
across an internet as well as the mechanisms used toacross an internet as well as the mechanisms used toforward packets from a computer through one or moreforward packets from a computer through one or morerouters to a final destination.routers to a final destination.
Transport layer specifies how to provide reliable transferTransport layer specifies how to provide reliable transfer
and theand the Transmission ControlProtocolTransmission ControlProtocol(TCP) software(TCP) softwarealso provides additional facilities required by higheralso provides additional facilities required by higher--levellevelapplications.applications.
Application layer specifies how applications use theApplication layer specifies how applications use the
Internet.Internet.
8/7/2019 CSC383 Lecture Notes Ch 1 2 3
12/38
Probing the InternetProbing the Internet
Simplest probing tool is theSimplest probing tool is the PacketInterNetPacketInterNet
GroperGroper, or, orpingping..
According to the Internet requirementsAccording to the Internet requirementsdocumentdocument [RFC 1122][RFC 1122] , every TCP/IP stack, every TCP/IP stack
should implement such a program.should implement such a program.
8/7/2019 CSC383 Lecture Notes Ch 1 2 3
13/38
PING Command ExamplePING Command Examplepenguin(101)% ping -c5 www.netbook.cs.purdue.edu PING
lucan.cs.purdue.edu (128.10.19.20) from 193.61.29.127: 56(84) bytes of data64 bytes from lucan.cs.purdue.edu (128.10.19.20): icmp_seq=1 ttl=235
time=131 ms 64 bytes from lucan.cs.purdue.edu (128.10.19.20): icmp_seq=2
ttl=235 time=131 ms 64 bytes from lucan.cs.purdue.edu (128.10.19.20):
icmp_seq=3 ttl=235 time=131 ms 64 bytes from lucan.cs.purdue.edu
(128.10.19.20): icmp_seq=4 ttl=235 time=131 ms 64 bytes fromlucan.cs.purdue.edu (128.10.19.20): icmp_seq=5 ttl=235 time=131 ms ---
lucan.cs.purdue.edu ping statistics --- 5 packets transmitted, 5 received, 0%
loss, time 4008ms rtt min/avg/max/mdev = 131.394/131.742/131.978/0.317
ms penguin(102)%
-c5 instructs ping to stop after sending five probes
summary on the first line indicates an alternative name for the target is
lucan.cs.purdue.edu, that its IP address is 128.10.19.20, and its sending 56 bytes
of data in an 84-byte IP datagram.
The next five lines are the responses received. These indicate that there are
8/7/2019 CSC383 Lecture Notes Ch 1 2 3
14/38
What Good Is PINGWhat Good Is PING
ConsCons
Little info for average userLittle info for average user
Not good as debug toolNot good as debug tool
Output occurs only when computer respondsOutput occurs only when computer responds
Fails if networkis congestedFails if networkis congested
PING cannot determine cause of problemPING cannot determine cause of problem
Some companies configure systems to reject pingsSome companies configure systems to reject pings
ProsPros
Determine which part of networkis still operatingDetermine which part of networkis still operating
Results help pinpoint failure quickleyResults help pinpoint failure quickley
8/7/2019 CSC383 Lecture Notes Ch 1 2 3
15/38
TracerouteTraceroute
Determine intermediate computers alongDetermine intermediate computers along
the waythe way
Uses same arguments as PING (remoteUses same arguments as PING (remotecomputers name or address)computers name or address)
Shows how the hops between source andShows how the hops between source and
destination.destination.
http://www.net.cmu.edu/cgihttp://www.net.cmu.edu/cgi--bin/netops.cgibin/netops.cgi
8/7/2019 CSC383 Lecture Notes Ch 1 2 3
16/38
Figure 2.6
8/7/2019 CSC383 Lecture Notes Ch 1 2 3
17/38
Chapter 3 IntroductionChapter 3 Introduction
Use of a network requires programs (andUse of a network requires programs (andsystems) that are networksystems) that are network--aware.aware.
Some applications are usually provided withSome applications are usually provided withmachines (e.g. web clients, emachines (e.g. web clients, e--mail clients,mail clients,file sharing).file sharing).
New custom applications must use theNew custom applications must use the
interface (API) to the network facilitiesinterface (API) to the network facilitiesprovided by the system.provided by the system.
We will look at a simple API and threeWe will look at a simple API and threesample applications (both the client and thesample applications (both the client and the
server).server).
8/7/2019 CSC383 Lecture Notes Ch 1 2 3
18/38
Network CommunicationNetwork Communication
Networks are the mechanisms that transmitNetworks are the mechanisms that transmit
data from one point to another.data from one point to another.
Logically, networks are (or should be)Logically, networks are (or should be)passive, and do not understand, act on, orpassive, and do not understand, act on, or
modify the data being moved.modify the data being moved.
There are two ends of a networkThere are two ends of a network
communication, each associated with ancommunication, each associated with an
application program that understands theapplication program that understands the
generation and interpretation of the datageneration and interpretation of the data
being moved across the network.being moved across the network.
8/7/2019 CSC383 Lecture Notes Ch 1 2 3
19/38
ClientClient--Server ComputingServer Computing
The two applications that communicateThe two applications that communicate
using a network must locate each other.using a network must locate each other.
Typically, one application (the server) startsTypically, one application (the server) startsand then waits for the other application (theand then waits for the other application (the
client) to contact it.client) to contact it.
This arrangement is usually called theThis arrangement is usually called the
clientclient--server paradigmserver paradigm, or just, or just clientclient--serverserver
computingcomputing..
The client must, of course, be able to locateThe client must, of course, be able to locate
the server for this arrangement to work.the server for this arrangement to work.
8/7/2019 CSC383 Lecture Notes Ch 1 2 3
20/38
Addressing Internet ApplicationsAddressing Internet Applications
Each network server application has a twoEach network server application has a two--part address ofpart address of
the form (the form (computercomputer,,applicationapplication).).
TheThe computercomputerpart of the address identifies the particularpart of the address identifies the particular
computer on which the application is running. This can becomputer on which the application is running. This can beprovided in symbolic (e.g. apollo.unomaha.edu) orprovided in symbolic (e.g. apollo.unomaha.edu) or
numeric (e.g. 137.48.1.12) form.numeric (e.g. 137.48.1.12) form.
The application part of the address identifies the particularThe application part of the address identifies the particular
application. It, too, can be provided symbolically orapplication. It, too, can be provided symbolically ornumerically.numerically.
When transmitted on a network, theWhen transmitted on a network, the
((computercomputer,,applicationapplication) address is always sent in binary.) address is always sent in binary.
8/7/2019 CSC383 Lecture Notes Ch 1 2 3
21/38
Communication ParadigmCommunication Paradigm
Most Internet applications follow this basicMost Internet applications follow this basicsequence of operations for communication:sequence of operations for communication:
The server starts first, and waits for contactThe server starts first, and waits for contact
from a client.from a client.
The client contacts the server by specifyingitsThe client contacts the server by specifyingitslocation and requesting communication.location and requesting communication.
The client and the server exchange messages.The client and the server exchange messages.
After they finish, the client and server eachAfter they finish, the client and server eachsend ansend an endend--ofof--filefile to terminate communication.to terminate communication.
Functions are provided in the class libraryFunctions are provided in the class library
on apollo to perform each of these tasks.on apollo to perform each of these tasks.
8/7/2019 CSC383 Lecture Notes Ch 1 2 3
22/38
An Example Application Program InterfaceAn Example Application Program Interface
The term application program interface,The term application program interface,
or API, is used to describe the set ofor API, is used to describe the set of
operations available (in a particularoperations available (in a particularprogramming domain) to a programmer.programming domain) to a programmer.
The simplified API presented in theThe simplified API presented in the
textbook hides much of the complexity intextbook hides much of the complexity in
network programming, but also doesntnetwork programming, but also doesnt
provide the richness of the usual networkingprovide the richness of the usual networking
API. We will see more details in laterAPI. We will see more details in later
chapters.chapters.
8/7/2019 CSC383 Lecture Notes Ch 1 2 3
23/38
Example API OverviewExample API Overview
Operation Meaning
await_contact used by server to wait for a contact
make_contact used by client to contact a server
cname_to_comp translate a computer name to anequivalent internal binary value
appname_to_appnum translate a program name to an
equivalent internal binary value
send used by client or server to send data
recv used by client or server to receive data
send_eof used by client or server after all data
has been sent.
8/7/2019 CSC383 Lecture Notes Ch 1 2 3
24/38
An Intuitive Look at the APIAn Intuitive Look at the API
The application actions usually follow thisThe application actions usually follow thispattern:pattern:
The server callsThe server calls await_contactawait_contactto wait forto wait for
contact from a client. The client callscontact from a client. The client callsmake_contactmake_contactto establish the connection. [Theto establish the connection. [Theserveris said to beserveris said to be blockedblockeduntil the contact isuntil the contact ismade.]made.]
Once contact is made, the applications useOnce contact is made, the applications usesendsendandand recvrecv to exchange data. [Theto exchange data. [Theprotocolprotocoldictates when each application sends ordictates when each application sends orreceives.]receives.]
Once the data exchange is complete, the clientOnce the data exchange is complete, the client
8/7/2019 CSC383 Lecture Notes Ch 1 2 3
25/38
A Trivial ExampleA Trivial Example
8/7/2019 CSC383 Lecture Notes Ch 1 2 3
26/38
API DefinitionAPI Definition Data TypesData Types
There are three data types (in addition to theThere are three data types (in addition to theusual integer, character, and real data types)usual integer, character, and real data types)used in the API:used in the API:
appnumappnum: a binary value used to identify an: a binary value used to identify anapplication [this is really aapplication [this is really aport numberport number].].
computercomputer: a binary value used to identify a: a binary value used to identify a
computer [this is really ancomputer [this is really anInternet
P
rotocol
Internet
P
rotocoladdressaddress, or, orIPaddressIPaddress.].]
connectionconnection: a value used to identify one: a value used to identify oneendpoint of a connection between a client and aendpoint of a connection between a client and a
server [normally this identifies aserver [normally this identifies asocketsocketdatadatastructure .structure .
8/7/2019 CSC383 Lecture Notes Ch 1 2 3
27/38
API DefinitionAPI Definition await_contactawait_contact
A server callsA server calls await_contactawait_contact to waitto wait
for a contact from a client. The functionfor a contact from a client. The functionexpects one argument of typeexpects one argument of type
appnumappnum, and, and
returns areturns a connectionconnection which is then usedwhich is then used
inin sendsend,, recvrecv, and, and send_eofsend_eof functions.functions.
connection await_contactconnection await_contact
(appnum a)(appnum a)
8/7/2019 CSC383 Lecture Notes Ch 1 2 3
28/38
API DefinitionAPI Definition make_contactmake_contact
A client callsA client calls make_contactmake_contact to establishto establish
contact with a server. The argumentscontact with a server. The argumentsidentify theidentify the co
mputerco
mputeron which the serveron which the server
is running, and the application number to beis running, and the application number to be
contacted. The function returns acontacted. The function returns aconnection used forconnection used forsendsend,, recvrecv, and, and
send_eofsend_eofby the client.by the client.
connection make_contact (computerconnection make_contact (computer
c, appnum a)c, appnum a)
8/7/2019 CSC383 Lecture Notes Ch 1 2 3
29/38
API DefinitionAPI Definition appname_to_appnumappname_to_appnum
This function is used to translate from aThis function is used to translate from a
predefined humanpredefined human--readable name [characterreadable name [character
string] to a binary application number.string] to a binary application number.
Standard application names are defined inStandard application names are defined in
the /etc/services file on a UNIX system. Itthe /etc/services file on a UNIX system. It
takes a string argument and returns thetakes a string argument and returns the
binary application number.binary application number.
appnum appname_to_appnumappnum appname_to_appnum
(char *name)(char *name)
8/7/2019 CSC383 Lecture Notes Ch 1 2 3
30/38
API DefinitionAPI Definition cname_to_compcname_to_comp
This function translates a symbolicThis function translates a symboliccomputer name (computer name (cnamecname) to the equivalent) to the equivalent
binary form (which is returned) of typebinary form (which is returned) of typecomputercomputer..
computer cname_to_comp (charcomputer cname_to_comp (char
*cname)*cname)
8/7/2019 CSC383 Lecture Notes Ch 1 2 3
31/38
API DefinitionAPI Definition sendsend
SendSendarranges to transmit data (a sequencearranges to transmit data (a sequence
ofofnnbytes in a char arraybytes in a char array bufbuf) over an) over an
established connectionestablished connection cc, returning the, returning the
number of bytes actually transmitted. Thenumber of bytes actually transmitted. Thelast argument is alwayslast argument is always 00 in this simplifiedin this simplified
API.API.
int send (connection c, charint send (connection c, char
*buf,*buf,
int n, 0)int n, 0)
8/7/2019 CSC383 Lecture Notes Ch 1 2 3
32/38
API DefinitionAPI Definition recvrecv
RecvRecv receives at mostreceives at most nnbytes of data frombytes of data from
a connectiona connection cc, placingit in a char array, placingit in a char array
bufbuf, and returning the number of bytes, and returning the number of bytes
received and stored.received and stored. RecvRecvwill return 0will return 0
only when the end of file is reached, and aonly when the end of file is reached, and a
negative value when an error occurred (e.g.negative value when an error occurred (e.g.
recvrecvwithout a valid connection).without a valid connection).
int recv (connection c, charint recv (connection c, char
*buf,*buf,
8/7/2019 CSC383 Lecture Notes Ch 1 2 3
33/38
API DefinitionAPI Definition recvlnrecvln
RecvlnRecvln reads one line of data (terminatedreads one line of data (terminated
by an end of line character) from aby an end of line character) from aconnectionconnection cc into a char arrayinto a char array bufbuf; no; no
more thanmore than nn--1 bytes will be read (allowing1 bytes will be read (allowing
one byte for string termination).one byte for string termination). RecvlnRecvln
usesuses recvrecv to read one byte at a time.to read one byte at a time.
int recvln (connection c, charint recvln (connection c, char
*buf,*buf,
int n)int n)
8/7/2019 CSC383 Lecture Notes Ch 1 2 3
34/38
API DefinitionAPI Definition send_eofsend_eof
Send_eofSend_eof terminates the connectionterminates the connection cc,,
returning a negative numberif an errorreturning a negative numberif an error
occurred.occurred.
int send_eof (connection c)int send_eof (connection c)
8/7/2019 CSC383 Lecture Notes Ch 1 2 3
35/38
The ECHO ApplicationThe ECHO Application
The ECHO application server merely resends eachThe ECHO application server merely resends each
line it receives from a client. The serveris startedline it receives from a client. The serveris started
(from a command line) by typing the program(from a command line) by typing the program
name and a selected application number (usuallyname and a selected application number (usuallyin the range 1025 to 32767).in the range 1025 to 32767).
The client application is started by typingitsThe client application is started by typingits
name, the name of the computer on which thename, the name of the computer on which the
serveris running, and the same applicationserveris running, and the same application
number.number.
Lines are then read by the client, echoed by theLines are then read by the client, echoed by the
server, and displayed by the client, until an end ofserver, and displayed by the client, until an end of-- --
8/7/2019 CSC383 Lecture Notes Ch 1 2 3
36/38
8/7/2019 CSC383 Lecture Notes Ch 1 2 3
37/38
The CHAT ApplicationThe CHAT Application
The chat application is similar to the echoThe chat application is similar to the echo
application. Here, however, the serverapplication. Here, however, the server
displays the received data line and waits fordisplays the received data line and waits for
a response from the user on that machine,a response from the user on that machine,
which is then sent back to the client forwhich is then sent back to the client for
display.display.
Either the user at the server machine or theEither the user at the server machine or theuser at the client machine may terminate theuser at the client machine may terminate the
chat session by entering an end of file.chat session by entering an end of file.
IllustrationIllustration
8/7/2019 CSC383 Lecture Notes Ch 1 2 3
38/38
The WEB ApplicationThe WEB Application
Our final example is a simple textOur final example is a simple text--mode webmode web
server and browser. Only two web pages areserver and browser. Only two web pages are
provided by the server: / and /time. It is easy,provided by the server: / and /time. It is easy,
however, to extend this application to deliverhowever, to extend this application to deliverarbitrary pages stored as files on the serverarbitrary pages stored as files on the server
machine.machine.
The server and client both use the standard HTTPThe server and client both use the standard HTTP
protocol, and the server delivers HTMLprotocol, and the server delivers HTML
documents with appropriate headers. Thus adocuments with appropriate headers. Thus a
commercial web browser could be used to contactcommercial web browser could be used to contact
our server.our server.