network
36 Pages

network

Course Number: CS 322, Fall 2009

College/University: CSU Northridge

Word Count: 2250

Rating:

Document Preview

Networks networks 1 Multiple processors (SMP) w/in a system communicate with shared memory (message queues, named queues) Multiple processors across computer systems communicate via networks Resource sharing sharing and printing files at remote sites processing information in a distributed database using remote specialized hardware devices Computation speedup load sharing Reliability detect and recover from...

Unformatted Document Excerpt
Coursehero >> California >> CSU Northridge >> CS 322

Course Hero has millions of student submitted documents similar to the one
below including study guides, practice problems, reference materials, practice exams, textbook help and tutor support.

Course Hero has millions of student submitted documents similar to the one below including study guides, practice problems, reference materials, practice exams, textbook help and tutor support.

processors Networks networks 1 Multiple (SMP) w/in a system communicate with shared memory (message queues, named queues) Multiple processors across computer systems communicate via networks Resource sharing sharing and printing files at remote sites processing information in a distributed database using remote specialized hardware devices Computation speedup load sharing Reliability detect and recover from site failure, function transfer, reintegrate failed site Communication message passing networks 2 client @ site B appears to have a "direct" connection to a server @ site A. The client could be using resources (NFS, samba) that exist on site C and are managed by the server. Local-Area Network (LAN) designed to cover small geographical area. Multi-access bus, ring, or star network. Speed 10 megabits/second (10baseT)\ 100 MBPS(100baseT). wireless 11, 54, 108 MBPS fiber / optical 200 MBPS gigabit speeds Broadcast is fast and cheap. Nodes: usually workstations and/or personal computers a few "mainframes" . networks 3 networks 4 Gateway computer connects (translates) LANs static address to hosts on LANs, router to WAN 2+ network connections Wide-Area Network (WAN) links geographically separated sites. Point-to-point connections over long-haul lines networks 5 large company to ISP, ISP to internet T1 1.544 MBPS T1C 3.152 Mbps T3 (28 TIs) 45 MBPS E1 (european T1) 2.048 Mbps E3 (16 E1s) 34.368 Mbps Internet backbone (fiber optical optical carrier) : OC48 622.08 Mbps OC192 10 Gbps Broadcast usually requires multiple messages. Nodes: usually a high percentage of "mainframes" Interlinked w/ routers to form World Wide Web Router -- device that determines the path messages will take. (or computer routing program) 2+ network connections dedicated routers (firmware program and battery based route table) networks 6 Naming and Name Resolution If all systems are known Name all systems in the network Address messages with the system name Identify processes on remote systems by <host-name, identifier> networks 7 $ nslookup k200.ecs.csun.edu Resolve the name to an address. semantically valid name k200.ecs.csun.edu numerical address 130.166.12.13 Domain name service (DNS) specifies the naming structure of the hosts, as well as name to address resolution (Internet). routers (or gateways) have known address of name servers name servers take part of name resolve an address edu name server resolves *.edu csun name server resolves *.csun.edu ecs name server resolves *.ecs.csun.edu gethostname(...) computer's host name $ uname // not always computer's name $ hostname // commonly used w/ sockets // hostname placed in name int gethostname(char * name, int len); networks 8 Domain Names by country de, mx (germany, mexico...) domains should be under us but aren't because we made the internet. *.edu *.gov *.mil *.com *.org education government military companies organizations www.csun.edu www.ssa.gov www.army.mil www.sun.com www.opengl.org USA social security USA Army Sun openGL site Network number networks 9 Network names have a network number and host-id class A 1.0.0.0 to 127.0.0.0 1.6 million hosts class B 128.0.0.0 to 191.255.0.0 16320 nets, 65024 hosts class C 192.0.0.0 to 223.255.255.0 2 million nets, 254 hosts network number is assigned to site csun 130.166 WAN Message is routed from source network to destination network LAN message is routed w/in local network (host or router to receiver) Network device address == MAC == Medium Access Control (physical address of card) LANs communicate MAC to MAC ARP - address resolution protocol packet broadcast on LAN network device w/ IP address in ARP request replies w/ MAC IP-MAC pairs are "cached" w/ aging for message transmission. gateways block ARP requests ipconfig networks 10 Window XP command line IP configuration ipconfig /all << show>> Linux / unix systems ifconfig [root@ginger:~]# ifconfig lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:16436 Metric:1 RX packets:1990 errors:0 dropped:0 overruns:0 frame:0 TX packets:1990 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:2257208 (2.1 MiB) TX bytes:2257208 (2.1 MiB) wlan0 Link encap:Ethernet HWaddr 00:80:C8:0A:8E:F9 inet addr:192.168.1.100 Bcast:192.168.1.255 Mask:255.255.255.0 inet6 addr: fe80::280:c8ff:fe0a:8ef9/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:84 errors:0 dropped:0 overruns:0 frame:0 TX packets:91 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:26875 (26.2 KiB) TX bytes:7868 (7.6 KiB) Interrupt:201 Base address:0xcca0 netstat shows network load and status. networks 11 try man netstat on K200 $ netstat -r edited results to fit slide Routing tables Dest/Netmask Gateway Interface localhost localhost lo0 ka-lan1.ecs.csun.edu ka-lan1.ecs.csun.edu lan3 hp-ka.ecs.csun.edu hp-ka.ecs.csun.edu lan2 ka.ecs.csun.edu ka.ecs.csun.edu lan0 ecs1.ecs.csun.edu ecs1.ecs.csun.edu lan1 130.166.2.0 ka.ecs.csun.edu lan0 130.166.68.0 ecs1.ecs.csun.edu lan1 130.166.12.0 hp-ka.ecs.csun.edu lan2 130.166.45.0 ka-lan1.ecs.csun.edu lan3 127.0.0.0 localhost lo0 default cisco.ecs.csun.edu lan0 shows info w/ all ip numbers nslookup, host, are net utilities for going from names to ip numbers $ netstat -rn Host Addresses networks 12 Translation between host names and host addresses /etc/hosts table for local area addresses or, Network Information Service (NIS or yellow pages)<< see netstuff>> # # # # include include include include <sys/types.h> <sys/socket.h> <netdb.h> <netinet/in.h> struct hostent * gethostent(void); struct hostent * gethostbyname(const char *name); struct hostent * gethostbyaddr(const char *addr, int len, int type); // keep network database open int sethostent(int stayopen); // close network database int endhostent(void); networks 13 struct hostent { char *h_name; // official host name char **h_aliases; // * to other names, aliases for computer int h_addrtype; // type of address int h_length; // byte length class of address {A, B, C} char *h_addr_list; // list of addresses for host }; Routing networks 14 Fixed routing. A path from A to B is specified in advance; path changes only if a hardware failure disables it. Since the shortest path is usually chosen, communication costs are minimized. Fixed routing cannot adapt to load changes. Ensures that messages will be delivered in the order in which they were sent. Virtual circuit. A path from A to B is fixed for the duration of one session. Different sessions involving messages from A to B may have different paths. Partial remedy to adapting to load changes. Ensures that messages will be delivered in the order in which they were sent. networks 15 Dynamic routing The path used to send a message form site A to site B is chosen only when a message is sent. Usually a site sends a message to another site on the link least used at that particular time. Adapts to load changes by avoiding routing messages on heavily used path. Messages may arrive out of order. This problem can be remedied by appending a sequence number to each message. Fixed routing to gateways (and local servers) Dynamic routing to WAN. Packets messages variable length packet transmission fixed length part of message message is reassembled after transmission networks 16 Connection Strategies Circuit switching. A permanent physical link is established for the duration of the communication (i.e., telephone system). (TCP) Message switching. A temporary link is established for the duration of one message transfer (i.e., post-office mailing system). (UDP) Packet switching. Messages of variable length are divided into fixedlength packets which are sent to the destination. Each packet may take a different path through the The network. packets must be reassembled into messages as they arrive. Most efficient use of network bandwidth (! media audio || video) Circuit switching requires setup time, but incurs less overhead for shipping each message, and may waste network bandwidth. Message and packet switching require less setup time, but incur more overhead per message. TCP/IP networks 17 TCP/IP protocol layers ISO layers Ethernet Packet networks 18 Sockets An endpoint in communication. networks 19 Pair of sockets is a low level mechanism (unstructured data) for communication: client - server -- (see socket.pdf notes) Servers implement well known services on ports < 1024 ssh 22, telnet 23, ftp 21, smtp 25, http 80, 123 ntp ... Servers must satisfy concurrent requests for service threaded servers -java sockets in text process servers -- inetd, many servers (next 2 slides) home socket 209.179.128.189 / 1625 ventanas socket 130.166.2.31 / 2317 csun's Web Server socket 130.166.1.63 / 80 csun's Web Server socket 130.166.1.63 / 80 csun's Web Server socket 130.166.1.63 / 80 Client -Server HGS pages 251 to 268, or man Server 1 2 3 4 socket bind listen accept read / write or recv / send 7 8 close networks 20 We cover the functions next... Client 5 socket 6 connect write / read or send / recv close Create Socket networks 21 int socket(int domain, int type, int protocol); internet address domain is AF_INET type is SOCK_STREAM bi-directional, virtual circuit continuous stream, reliable data delivered in order. Implemented in TCP protocol is 0, let system figure it out (PF_INET) Name the socket (bind) int bind (int s, const struct sockaddr * name, int addrlen); struct sockaddr_in { short sin_family; // AF_INET u_short sin_port; // port number struct in_addr sin_addr; // INADDR_ANY }; // name of socket's address addrlenlength of name, function of address family networks 22 Wait for a client's connection request int listen (int s, int backlog); waits for connect on socket s backlog (system sets to 5) # pending requests Accept a client's connection int accept (int s, struct sockaddr *name, int *addrlen); return new socket descriptor when request arrives on socket s Connect to a server int connect (int s, struct sockadr *name, int addrlen); returns -1 on error Transferring data networks 23 int recv (int s, char *buf, int len, int flags); int send (int s, const char *buf, int len, int flags); char *buf buffer to hold received data const char *buf buffer of data to send flags: MSG_DONTROUTE for diagnostics, don't send data MSG_OOB w/ send data out-of-band, interrupt data MSG_PEEK w/ recv copy data to buf don't consume Attempt to read or recv from a closed connection returns 0 Shutdown channel int close (int s); // blocks until all data transferred == 2 !read !write or int shutdown (int s, int how); how == 0 !read, == 1 ! write, networks 24 Connection server (many servers). Server forks socket handler to handle new connections When server dies must terminate socket handler server fork exec wait socket handler ... close SIGCHLD SIGTERM client ... close SIGPIPE attempt to write / send to closed socket Connection servers (srcIP, port#, destIP, port#) ServerManager pids[n] socket bind for( n servers) pids[i] = fork-exec server for(;;;) wait() pid[i] = fork child exec server (socket) on SIGTERM kill all servers in pids[] close socket exit networks 25 Server (socket) listen accept while recv / send terminate client (serverHost) socket connect while send / receive close terminate Java server 5 steps for using stream socket server networks 26 // 1. bind server to port ServerSocket s = new ServerSocket(port, nClients); // 2. wait for accept, creates && returns socket Socket connection = s.accept(); // 3. set up input and output streams ObjectInputStream in = new ObjectInputStream( connection.getInputStream()); ObjectOutputStream out = new ObjectOutputStream( connection.getOutputStream()); // 4. communicate w/ input and output streams out.writeObject(anObj); // inside try catch ClassNotFoundException in.readObject(anObj); // 5. close the connection output.close(); input.close(); connection.close(); Java client 4 steps for using stream sockets client networks 27 // 1. create socket Socket client = new Socket(InetAddress.getbyName("hostname"), port); // 2. set up input and output streams ObjectInputStream in = new ObjectInputStream( client.getInputStream()); ObjectOutputStream out = new ObjectOutputStream( client.getOutputStream()); // 3. communicate w/ input and output streams out.writeObject(anObj); // inside try catch ClassNotFoundException in.readObject(anObj); // 4. close the connection output.close(); input.close(); connection.close(); Threaded servers Allow multiple connections (threads) to share data possible Critical Section synchronize Consider a multi--player game w/ classes: GameServer, n PlayerServers, and n clientPlayers networks 28 data // GameServer server = new ServerSocket(port, nPlayers); client client ... client // for i = 0 to nPlayers player[i] = new PlayerServer = (server.accept(), args); player[i].start(); // PlayerServer extends Thread public PlayerServer(Socket s, args) { // set up input and output streams... } // handle each player's moves until game over // close streams and socket run() {...} Unix service sockets make socket() for all services bind() each service socket to port address listen() for all service socket streams select() accept() if stream socket fork() child close socket if stream networks 29 close all files & sockets except "service socket" dup2 socket to fd 0, 1, 2 close "service" socket setgid and setuid (if ! root) exec() server RPC / RMI remote procedure / method call networks 30 Process (thread) invokes procedure (method) on distributed system. A higher level of communication: structured data and transparent communication channel. client RPC call kernel RPC message to server rendezvous daemon (known port) returns port of RPC daemon kernel sends RPC RPC daemon processes request returns results client receives results CORBA Common Object Request Broker Architecture middleware heterogenous client - server language independent RMI IDL Interface Definition Language generic programming specification interface & services provided eg distributed dbms ORB Object Request Broker client ORB server ORB Object Registration service RMI rmiregistry Naming.lookup() CORBA server ORB networks 31 client reference CORBA object stub ORB server CORBA object skeleton ORB NFS Sun's Networked File System consider 3 independent file systems: U, S1, S2 networks 32 networks 33 In `a' S1:/usr/shared is mounted over on U over /usr/local can access dir1 /usr/local/dir1 can't access original U:/usr/local S1:/usr/shared == U:/usr/local In `b' S2:/usr/dir2 is mounted on U over /usr/local/dir1 On U: S2:/usr/dir2 is U:/usr/local/dir1 NFS networks 34 + connect heterogeneous file systems + VFS (virtual file system) layer 1 vnode / inode + RPC maps file access into file system specific local requests + XDR external data representation protocol + sharing between any pair of machines -- client / server + don't need dedicated file servers + transparent -- uses TCP or UDP protocols + high performance via cached services + stateless - concurrency control should be outside of NFS - packet size (1500 bytes) < file block size (8K) NFS writes are atomic (packet writes) + user mobility -- account accessible w/ any login NFS architecture networks 35 N-tier client-server application architecture networks 36 Client User Interface (graphical) application: MS Windows, Macintosh, X Windows, ... thin client: browser -- html, applet Server httpd, RPC, RMI, CORBA, .NET connection manager API to remote services MiddleWare CGI-bin, JSP, ASP, PHP, .NET remote applications Centralized Resources relational DBMS, flat files
MOST POPULAR MATERIALS FROM CSU Northridge