32
CS- 492 : Distributed system & CS- 492 : Distributed system & Parallel Processing Parallel Processing Lecture 2: 9/4/1435 Lecture 2: 9/4/1435 Sun. 8- 11 Sun. 8- 11 networking . networking . internetworking essentials. internetworking essentials. overview of network overview of network programming programming Lecturer: Kawther Abas Lecturer: Kawther Abas

CS- 492 : Distributed system & Parallel Processing Lecture 2: 9/4/1435 Sun. 8- 11 networking. internetworking essentials. overview of network programming

Embed Size (px)

Citation preview

CS- 492 : Distributed system & Parallel CS- 492 : Distributed system & Parallel ProcessingProcessing

Lecture 2: 9/4/1435Lecture 2: 9/4/1435Sun. 8- 11Sun. 8- 11

networking .networking . internetworking essentials.internetworking essentials.

overview of network programmingoverview of network programming

Lecturer: Kawther AbasLecturer: Kawther Abas

What is a “NetworkWhat is a “Network?”?”

A network is a way to get “stuff” between A network is a way to get “stuff” between 2 or more “things2 or more “things””

Examples: Mail, phone system, Examples: Mail, phone system, conversations, railroad system, highways conversations, railroad system, highways and roadsand roads..

Fundamental Network ClassificationsFundamental Network Classifications

Local Area Networks (LANs):Local Area Networks (LANs): A A local area network (LAN)local area network (LAN)

Wide Area Networks (WANs):Wide Area Networks (WANs): Wide Area NetworkWide Area Network ( (WANWAN) )

Metropolitan Area Network (MAN):Metropolitan Area Network (MAN):

Network topologyNetwork topology

A A topology topology is a way of “laying out” the is a way of “laying out” the network. Topologies can be either physical network. Topologies can be either physical or logical. or logical.

Physical topologies Physical topologies describe how the cables describe how the cables are run. are run.

Logical topologies Logical topologies describe how the network describe how the network messages travelmessages travel

Type of Network topologyType of Network topology

Bus (can be both logical and physical)Bus (can be both logical and physical) Star (physical only)Star (physical only) Ring (can be both logical and physical)Ring (can be both logical and physical) Mesh (can be both logical and physical)Mesh (can be both logical and physical)

Network ProtocolsNetwork Protocols

Network protocols are layered such that Network protocols are layered such that each one relies on the protocols that each one relies on the protocols that underlie itunderlie it

Sometimes referred to as a Sometimes referred to as a protocol stackprotocol stack

Internetwork

An Internetwork is the connection of two or more distinct computer networks or network segments via a common routing technology.

Any interconnection among or between public, private, commercial, industrial, or governmental networks may also be defined as an internetwork.

InternetworkInternetwork Intranet

– An intranet is a set of networks, using the Internet Protocol and IP-based tools such as web browsers and file transfer applications, that is under the control of a single administrative entity.

Extranet– An extranet is a network or internetwork that is limited in scope to a single

organization or entity but which also has limited connections to the networks of one or more other usually, but not necessarily, trusted organizations or entities

– by definition, an extranet cannot consist of a single LAN; it must have at least one connection with an external network.

Internet– The Internet consists of a worldwide interconnection of governmental, academic,

public, and private networks based upon the networking technologies of the Internet Protocol Suite.

– It is the successor of the Advanced Research Projects Agency Network (ARPANET) developed by DARPA of the U.S. Department of Defense.

– The Internet is also the communications backbone underlying the World Wide Web (WWW).

Advantages of networkingAdvantages of networking

Connectivity and CommunicationConnectivity and Communication Data SharingData Sharing Hardware SharingHardware Sharing Internet AccessInternet Access Internet Access SharingInternet Access Sharing Data Security and ManagementData Security and Management Performance Enhancement and BalancingPerformance Enhancement and Balancing EntertainmentEntertainment

The Disadvantages (Costs) of NetworkingThe Disadvantages (Costs) of Networking

Network Hardware, Software and Setup CostsNetwork Hardware, Software and Setup Costs Hardware and Software Management and Hardware and Software Management and

Administration CostsAdministration Costs Undesirable SharingUndesirable Sharing Illegal or Undesirable BehaviorIllegal or Undesirable Behavior Data Security ConcernsData Security Concerns

TCP/IPTCP/IP

TCP stands for TCP stands for Transmission Control ProtocolTransmission Control Protocol

TCP software breaks messages into packets, TCP software breaks messages into packets, hands them off to the IP software for delivery, hands them off to the IP software for delivery, and then orders and reassembles the packets and then orders and reassembles the packets at their destinationat their destination

IP stands for IP stands for Internet ProtocolInternet Protocol

IP software deals with the routing of packets IP software deals with the routing of packets through the maze of interconnected networks to through the maze of interconnected networks to their final destinationtheir final destination

TCP/IP (cont.)TCP/IP (cont.)

UDP stands for UDP stands for User Datagram ProtocolUser Datagram Protocol

– It is an alternative to TCPIt is an alternative to TCP

– The main difference is that TCP is highly The main difference is that TCP is highly reliable, at the cost of decreased performance, reliable, at the cost of decreased performance, while UDP is less reliable, but generally fasterwhile UDP is less reliable, but generally faster

High-Level ProtocolsHigh-Level Protocols

Other protocols build on the foundation Other protocols build on the foundation established by the TCP/IP protocol suiteestablished by the TCP/IP protocol suite

– Simple Mail Transfer Protocol (SMTP)Simple Mail Transfer Protocol (SMTP)

– File Transfer Protocol (FTP)File Transfer Protocol (FTP)

– TelnetTelnet

– Hyper Text Transfer Protocol (http)Hyper Text Transfer Protocol (http)

FirewallsFirewalls

FirewallFirewall A machine and its software that A machine and its software that serve as a special gateway to a network, serve as a special gateway to a network, protecting it from inappropriate accessprotecting it from inappropriate access

– Filters the network traffic that comes in, Filters the network traffic that comes in, checking the validity of the messages as much checking the validity of the messages as much as possible and perhaps denying some as possible and perhaps denying some messages altogethermessages altogether

– Enforces an organization’s Enforces an organization’s access control access control policypolicy

Network AddressesNetwork Addresses

HostnameHostname A unique identification that A unique identification that specifies a particular computer on the specifies a particular computer on the InternetInternet

For exampleFor examplematisse.csc.villanova.edumatisse.csc.villanova.edu

condor.develocorp.comcondor.develocorp.com

Network AddressesNetwork Addresses

Network software translates a hostname into Network software translates a hostname into its corresponding IP addressits corresponding IP address

For exampleFor example205.39.145.18205.39.145.18

Network AddressesNetwork Addresses

An An IP addressIP address can be split into can be split into–network addressnetwork address, which specifies a specific network, which specifies a specific network–host numberhost number, which specifies a particular machine in , which specifies a particular machine in

that networkthat network

An IP address is stored in four bytes

Domain Name SystemDomain Name System

A hostname consists of the computer name A hostname consists of the computer name followed by followed by the domain namethe domain name

csc.villanova.edu is the domain namecsc.villanova.edu is the domain name– A domain name is separated into two or more sections A domain name is separated into two or more sections

that specify the organization, and possibly a subset of that specify the organization, and possibly a subset of an organization, of which the computer is a partan organization, of which the computer is a part

– Two organizations can have a computer named the Two organizations can have a computer named the same thing because the domain name makes it clear same thing because the domain name makes it clear which one is being referred towhich one is being referred to

1919

Domain Name SystemDomain Name System

The very last section of the domain is called its The very last section of the domain is called its top-level domain (TLD)top-level domain (TLD) name name

Top-level domains, including some relatively new ones

Domain Name SystemDomain Name System

The The domain name systemdomain name system (DNS) is chiefly (DNS) is chiefly used to translate hostnames into numeric IP used to translate hostnames into numeric IP addressesaddresses

– DNS is an example of a distributed database DNS is an example of a distributed database

– If that server can resolve the hostname, it does If that server can resolve the hostname, it does soso

– If not, that server asks another domain name If not, that server asks another domain name serverserver

Client and Server computer role in Client and Server computer role in networkingnetworking

ServerServer computer is a core component of the computer is a core component of the network, providing a link to the resources network, providing a link to the resources necessary to perform any task.necessary to perform any task.

The link it provides could be to a resource existing The link it provides could be to a resource existing on the server itself or a resource on a client on the server itself or a resource on a client computer.computer.

ClientClient computers normally request and receive computers normally request and receive information over the network information over the network client. Client client. Client computers alsocomputers also depends primarily on the central depends primarily on the central server for processing activities server for processing activities

A Client-Server TransactionA Client-Server Transaction

Clientprocess

Serverprocess

1. Client sends request

2. Server handlesrequest

3. Server sends response4. Client handles

response

Resource

Every network application is based on the client-server Every network application is based on the client-server model:model:– A A serverserver process and one or more process and one or more clientclient processesprocesses– Server manages some Server manages some resourceresource..– Server providesServer provides serviceservice by manipulating resource for clients. by manipulating resource for clients.

Note: clients and servers are processes running on hosts (can be the same or different hosts).

A Programmer’s View of the InternetA Programmer’s View of the Internet

1. Hosts are mapped to a set of 32-bit 1. Hosts are mapped to a set of 32-bit IP IP addressesaddresses..– 128.2.203.179128.2.203.179

2. The set of IP addresses is mapped to a set of 2. The set of IP addresses is mapped to a set of identifiers called Internet identifiers called Internet domain namesdomain names..– 128.2.203.179 is mapped to www.cs.cmu.edu 128.2.203.179 is mapped to www.cs.cmu.edu

3. A process on one Internet host can 3. A process on one Internet host can communicate with a process on another communicate with a process on another Internet host over a Internet host over a connectionconnection..

11 . .IP AddressesIP Addresses3232--bit IP addresses are stored in an bit IP addresses are stored in an IP address structIP address struct

–IP addresses are always stored in memory in network byte order (big-endian byte IP addresses are always stored in memory in network byte order (big-endian byte order)order)

–True in general for any integer transferred in a packet header from one machine to anotherTrue in general for any integer transferred in a packet header from one machine to another..E.g., the port number used to identify an Internet connectionE.g., the port number used to identify an Internet connection..

33 . .Internet ConnectionsInternet Connections

Connection socket pair(128.2.194.242:51213, 208.216.181.15:80)

Server(port 80)

Client

Client socket address128.2.194.242:51213

Server socket address208.216.181.15:80

Client host address128.2.194.242

Server host address208.216.181.15

Clients and servers communicate by sending streams of Clients and servers communicate by sending streams of bytes over bytes over connectionsconnections..

Connections are point-to-point, full-duplex (2-way Connections are point-to-point, full-duplex (2-way communication), and reliablecommunication), and reliable..

Note: 51213 is anephemeral port allocated

by the kernel

Note: 80 is a well-known portassociated with Web servers

ClientsClients Examples of client programsExamples of client programs

– Web browsers, Web browsers, ftpftp, , telnettelnet, , sshssh

How does a client find the server?How does a client find the server?– The IP address in the server socket address identifies The IP address in the server socket address identifies

the hostthe host (more precisely, an adapter on the host) (more precisely, an adapter on the host)– The (well-known) port in the server socket address identifies the The (well-known) port in the server socket address identifies the

service, and thus implicitly identifies the server process that service, and thus implicitly identifies the server process that performs that service.performs that service.

– Examples of well know portsExamples of well know ports Port 7: Echo serverPort 7: Echo server Port 23: Telnet serverPort 23: Telnet server Port 25: Mail serverPort 25: Mail server Port 80: Web serverPort 80: Web server

Using Ports to Identify ServicesUsing Ports to Identify Services

Web server(port 80)

Client host

Server host 128.2.194.242

Echo server(port 7)

Service request for128.2.194.242:80

(i.e., the Web server)

Web server(port 80)

Echo server(port 7)

Service request for128.2.194.242:7

(i.e., the echo server)

Kernel

Kernel

Client

Client

ServersServers Servers are long-running processes (daemons).Servers are long-running processes (daemons).

– Created at boot-time (typically) by the init process Created at boot-time (typically) by the init process (process 1)(process 1)

– Run continuously until the machine is turned off.Run continuously until the machine is turned off.

Each server waits for requests to arrive on a well-Each server waits for requests to arrive on a well-known port associated with a particular service.known port associated with a particular service.– Port 7: echo serverPort 7: echo server– Port 23: telnet serverPort 23: telnet server– Port 25: mail serverPort 25: mail server– Port 80: HTTP serverPort 80: HTTP server

A machine that runs a server process is also often A machine that runs a server process is also often referred to as a “server.”referred to as a “server.”

Server ExamplesServer Examples

Web server (port 80)Web server (port 80)– Resource: files/compute cycles (CGI programs)Resource: files/compute cycles (CGI programs)– Service: retrieves files and runs CGI programs on behalf of the Service: retrieves files and runs CGI programs on behalf of the

clientclient FTP server (20, 21)FTP server (20, 21)

– Resource: filesResource: files– Service: stores and retrieve filesService: stores and retrieve files

Telnet server (23)Telnet server (23)– Resource: terminalResource: terminal– Service: proxies a terminal on the server machineService: proxies a terminal on the server machine

Mail server (25)Mail server (25)– Resource: email “spool” fileResource: email “spool” file– Service: stores mail messages in spool file Service: stores mail messages in spool file

See /etc/services for a comprehensive list of the services available on a Linux machine.

SocketsSockets

What is a socket?What is a socket?– To the kernel, a socket is an endpoint of To the kernel, a socket is an endpoint of

communication.communication.– To an application, a socket is a file descriptor that lets To an application, a socket is a file descriptor that lets

the application read/write from/to the network.the application read/write from/to the network. Remember: All Unix I/O devices, including networks, are Remember: All Unix I/O devices, including networks, are

modeled as files.modeled as files.

Clients and servers communicate with each by reading Clients and servers communicate with each by reading from and writing to socket descriptors.from and writing to socket descriptors.

The main distinction between regular file I/O and socket I/O The main distinction between regular file I/O and socket I/O is how the application “opens” the socket descriptors.is how the application “opens” the socket descriptors.

Sockets InterfaceSockets Interface

Created in the early 80’s as part of the original Berkeley Created in the early 80’s as part of the original Berkeley distribution of Unix that contained an early version of the distribution of Unix that contained an early version of the Internet protocols.Internet protocols.

Provides a user-level interface to the network.Provides a user-level interface to the network.

Underlying basis for all Internet applications.Underlying basis for all Internet applications.

Based on client/server programming model.Based on client/server programming model.

Overview of the Sockets InterfaceOverview of the Sockets InterfaceClient Server

socket socket

bind

listen

accept

rio_readlineb

rio_readlineb

rio_writen

close

rio_readlineb

connect

rio_writen

close

Connectionrequest

EOF

Await connectionrequest fromnext client

open_listenfd

open_clientfd