Networking. The Network is the Computer Client-Server computing Peer-to-Peer The Web Today’s networking is wonderful, but  How is it done?

Slides:



Advertisements
Similar presentations
Taekyung Kim 0x410 ~ 0x International Standards Organization (ISO) is a multinational body dedicated to worldwide agreement on international.
Advertisements

CCNA – Network Fundamentals
© 2007 Cisco Systems, Inc. All rights reserved.Cisco Public ITE PC v4.0 Chapter 1 1 OSI Transport Layer Network Fundamentals – Chapter 4.
CS3505 The Internet and Info Hiway transport layer protocols : TCP/UDP.
Spring 2003CS 4611 Introduction, Continued COS 461.
Sockets. Socket Berkeley Software Distribution Handle-like data structure for communicating A socket is an endpoint  Send and receive  Attach a protocol.
Network Architectures Professor Jinhua Guo CIS 527 Fall 2002.
Sockets Programming CS144 Review Session 1 April 4, 2008 Ben Nham.
Socket Programming.
Socket Programming: a Primer Socket to me!. Feb. 23, 2001EE122, UCB2 Why does one need sockets? application network protocol sockets network.
Tutorial 8 Socket Programming
Gursharan Singh Tatla Transport Layer 16-May
CS 356 Systems Security Spring Dr. Indrajit Ray
1 TCP/IP architecture A set of protocols allowing communication across diverse networks Out of ARPANET Emphasize on robustness regarding to failure Emphasize.
Domain Name System (DNS) Ayitey Bulley Session-1: Fundamentals.
UNIX Sockets COS 461 Precept 1.
Process-to-Process Delivery:
Fall 2009COSC 6501 Welcome to COSC650 Towson University Yanggon Kim.
Operating Systems Chapter 9 Distributed Communication.
Fall 2000Datacom 11 Lecture 4 Socket Interface Programming: Service Interface between Applications and TCP.
Socket Programming. Introduction Sockets are a protocol independent method of creating a connection between processes. Sockets can be either – Connection.
CS345 Operating Systems Φροντιστήριο Άσκησης 2. Inter-process communication Exchange data among processes Methods –Signal –Pipe –Sockets.
1 Chapter 1 OSI Architecture The OSI 7-layer Model OSI – Open Systems Interconnection.
TCP/IP Essentials A Lab-Based Approach Shivendra Panwar, Shiwen Mao Jeong-dong Ryoo, and Yihan Li Chapter 5 UDP and Its Applications.
Server Sockets: A server socket listens on a given port Many different clients may be connecting to that port Ideally, you would like a separate file descriptor.
Chap 9 TCP/IP Andres, Wen-Yuan Liao Department of Computer Science and Engineering De Lin Institute of Technology
Protocols 1 Objective: Build a protocol foundation for Client / Server programming in an Internet Environment Note: RFCs available from
Fall 2005 By: H. Veisi Computer networks course Olum-fonoon Babol Chapter 6 The Transport Layer.
Review the key networking concepts –TCP/IP reference model –Ethernet –Switched Ethernet –IP, ARP –TCP –DNS.
Internetworking Internet: A network among networks, or a network of networks Allows accommodation of multiple network technologies Universal Service Routers.
Internetworking Internet: A network among networks, or a network of networks Allows accommodation of multiple network technologies Universal Service Routers.
Remote Shell CS230 Project #4 Assigned : Due date :
Network Protocols n ISO OSI 7-layer model n TCP/IP suite l TCP/UDP l IP l Ethernet/Token Ring l ICMP.
CSE 6590 Department of Computer Science & Engineering York University 111/9/ :26 AM.
Networking Tutorial Special Interest Group for Software Engineering Luke Rajlich.
CPSC 441 TUTORIAL – FEB 13, 2012 TA: RUITNG ZHOU UDP REVIEW.
1 Computer Networks An Introduction to Computer Networks University of Tehran Dept. of EE and Computer Engineering By: Dr. Nasser Yazdani Lecture 3: Sockets.
1 Pre-Introduction What is computer network?. 2 Pre-Introduction Suppose you want to build a computer network The question is: –What available technologies.
UNIX Sockets COS 461 Precept 1. Socket and Process Communication The interface that the OS provides to its networking subsystem application layer transport.
CSE 331: Introduction to Networks and Security Fall 2000 Instructor: Carl A. Gunter Slide Set 5.
Lecture 4 Overview. Ethernet Data Link Layer protocol Ethernet (IEEE 802.3) is widely used Supported by a variety of physical layer implementations Multi-access.
Spring 2002CS 4611 Introduction Outline Statistical Multiplexing Inter-Process Communication Network Architecture Performance Metrics Implementation Issues.
Socket Programming Lab 1 1CS Computer Networks.
1 OSI and TCP/IP Models. 2 TCP/IP Encapsulation (Packet) (Frame)
CS 6401 Introduction to Computer Networks 09/21/2010 Outline - UNIX sockets - A simple client-server program - Project 1 - LAN bridges and learning.
Requirements Connectivity Resource Sharing Support for Common Services Performance.
2: Application Layer1 Chapter 2: Application layer r 2.1 Principles of network applications r 2.2 Web and HTTP r 2.3 FTP r 2.4 Electronic Mail  SMTP,
1 Bus topology network. 2 Data is sent to all computers, but only the destination computer accepts 02608c
CSCI 330 UNIX and Network Programming Unit XV: Transmission Control Protocol.
S OCKET P ROGRAMMING IN C Professor: Dr. Shu-Ching Chen TA: HsinYu Ha.
S OCKET P ROGRAMMING IN C Professor: Dr. Shu-Ching Chen TA: Hsin-Yu Ha.
1 Introduction Outline Statistical Multiplexing Inter-Process Communication Network Architecture Performance Metrics Implementation Issues.
CSCI 330 UNIX and Network Programming Unit XIV: User Datagram Protocol.
1 Spring Semester 2008, Dept. of Computer Science, Technion Internet Networking recitation #7 Socket Programming.
1 Network Architecture Section Network Architecture Challenge –Fill the gap between hardware capabilities and application expectations, and to.
McGraw-Hill Chapter 23 Process-to-Process Delivery: UDP, TCP Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
TCP/IP1 Address Resolution Protocol Internet uses IP address to recognize a computer. But IP address needs to be translated to physical address (NIC).
1 Socket Interface. 2 Client-Server Architecture The client is the one who speaks first Typical client-server situations  Client and server on the same.
Socket Programming(1/2). Outline  1. Introduction to Network Programming  2. Network Architecture – Client/Server Model  3. TCP Socket Programming.
1 Socket Interface. 2 Basic Sockets API Review Socket Library TCPUDP IP EthernetPPP ARP DHCP, Mail, WWW, TELNET, FTP... Network cardCom Layer 4 / Transport.
Introduction to TCP/IP networking
Socket Programming in C
Transport layer API: Socket Programming
Process-to-Process Delivery:
TCP/IP Protocol Suite: Review
Socket Programming(1/2)
Introduction to Computer Networks
Internet Networking recitation #8
Outline Communications in Distributed Systems Socket Programming
Process-to-Process Delivery: UDP, TCP
Presentation transcript:

Networking

The Network is the Computer Client-Server computing Peer-to-Peer The Web Today’s networking is wonderful, but  How is it done?

Ethernet Frame Format Addresses: Unique, 48-bit unicast address assigned to each adaptor Example: 8:0:2b:e4:b1:2 Broadcast: all 1 Multicast: first bit is 1

Layering Use abstractions to hide complexity Abstraction naturally leads to layering Application Programs Process-to-process Host-to-Host Connectivity Hardware Protocol Stack

Host1 High Level Object Protocol Protocols Building blocks of a network architecture Each protocol object has two different interfaces  service interface: defines operations on this protocol  peer-to-peer interface: defines messages exchanged with peer Host2 High Level Object Protocol Service Interface Peer to peer

Protocol Graph collection of protocols and their dependencies most peer-to-peer communication is indirect peer-to-peer is direct only at hardware level FTP Telnet Video RRPMSP HHP FTP Telnet Video RRPMSP HHP

Communication Encapsulation (header/body) Application RRP HHP data RRP data HHP RRP data Application RRP HHP data RRP data

Standard Architectures Open Systems Interconnect (OSI) Architecture  International Standards Organization (ISO)  International Telecommunications Union (ITU); formerly CCITT  “X dot” series: X.25, X.400, X.500  Reference Model

Seven Layer Model Application Presentation Session Transport Network Data Link Physical Network Data Link Physical Network Data Link Physical Application Presentation Session Transport Network Data Link Physical , FTP, www cinteger size, big endian synchronization, name space reliability, congestion control Routing address framing errors electrical signals

Internetworking

A Simple Internetwork H1H2H3 Hn = Host Rn = Router Network 2 (Ethernet) H4 Network 3 (Token Ring) H5 H6 R1 R2 Network 4 (point-to-point) H7H8 Network 1 (Ethernet) R3

The Internet

Internet Engineering Task Force (IETF) Application Protocol (FTP, HTTP) – Not applications TCP – Transmission Control Protocol - Reliable Transport IP – Internet Protocol – Connect Local Area Networks Internet Architecture NET n 2 1 TCPUDP IP.. TFTP NV FTPHTTP TCPUDP IP Network Application

Internet Protocol (IP)

IP Service Model Global Addressing Scheme  IP Addresses Packet Delivery Model  Connectionless (datagram-based)  Best-effort delivery (unreliable service)  packets are often lost  packets are often delivered out of order  duplicate copies of a packet are often delivered  packets can be delayed for a long time

Datagram format  Version (4): currently 4  Hlen (4): number of 32-bit words in header  TOS (8): type of service (not widely used QoS)  Length (16): number of bytes in this datagram  Ident (16): different for each datagram  Flags/Offset (16): used by fragmentation  TTL (8): Time to live  # hops this datagram has traveled  Protocol (8):  demux key (TCP=6, UDP=17)  Checksum (16): of the header only  DestAddr & SrcAddr (32)

Datagram Forwarding Strategy every datagram contains destination's address if directly connected to destination network, then forward to host if not directly connected to destination network, then forward to some router each host has a default router each router maintains a forwarding table forwarding table maps network number into next hop

My machine C:\>netstat -r Network destination Netmask Gateway Interface Metric Default Gateway:

Reliable Byte-Stream (TCP)

Overview Byte-stream  sending process writes some number of bytes  TCP breaks into segments and sends via IP  receiving process reads some number of bytes  Full duplex Connection-oriented (Reliable)  Every segment is numbered & acknowledged Flow control:  keep sender from overrunning receiver Congestion control:  keep sender from overrunning network

TCP Stream segment... Transmit Segments... Appl Process Write Bytes Appl Process... Read Bytes TCP send buffer TCP receive buffer

Issues Potentially long delay in network  need to be prepared for arrival of very old packets  (limit 60 seconds) Potentially different capacity at destination  need to accommodate different amounts of buffering  (end hosts may have hundreds of applications) Potentially different network capacity  need to be prepared for network congestion

Segment Format Each connection identified with 4-tuple:  Sliding window + flow control  Acknowledgment, SequenceNum, AdvertisedWindow Flags:  SYN, FIN, RESET, PUSH, URG, ACK Checksum: pseudo header + tcp header + data Src PortDest Port Advertised Window Acknowledgement SequenceNum CheckSum Flags options UrgPtr 0 (4)(6) (variable) data HdrLen

TCP Flow SenderReceiver Data (SequenceNum) Acknowledgement + AdvertisedWindow

DNS (Domain Name Service)

DNS People don’t remember 32-bit numbers very well Instead of using IP addresses, map the IP address to a name  People remember names better Translation of names to IP addresses is done by name servers  Originally done by files on each host

DNS Basically, it is a distributed database  Distributed administration  Distributed load  Distributed security problems Robustness and performance through  Replication  Caching

DNS Hierarchical You can give away control of part of the tree beneath you Process  Issue request  If found, return  If not  Ask higher edu Education level Name Server UofU BYU Region Name Server ACS CS Local Name Server etc Root Name Server

DNS Name Space

DNS Lookup flits.cs.vu.nl  linda.cs.yale.edu

DNS Client-Server application Normally uses UDP (port 53) Three Roles  Resolver – takes request from application, formats it into UDP packet, sends to cache  Caching Nameserver  Returns answer if it is known, otherwise searches for authoritative server  Caches results for further queries  Authoritative Nameserver  Contains the actual Resource Record put into the DNS by the domain owner

dig tiscali.co.uk. -- defaults to query type "A" dig tiscali.co.uk. mx -- specified query type tiscali.co.uk. mx -- send to particular cache (overrides /etc/resolv.conf) Testing DNS with "dig" "dig" is a program which just makes DNS queries and displays the result Trailing dot (for name lookups only)  Prevents lookups using the default domain

# dig a ; > DiG > a ;; global options: printcmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 2462 ;; flags: qr aa rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 4, ADD'L: 4 ;; QUESTION SECTION: ; IN A ;; ANSWER SECTION: IN CNAME waib.gouv.bj. waib.gouv.bj IN A ;; AUTHORITY SECTION: gouv.bj IN NS rip.psg.com. gouv.bj IN NS ben02.gouv.bj. gouv.bj IN NS nakayo.leland.bj. gouv.bj IN NS ns1.intnet.bj. ;; ADDITIONAL SECTION: ben02.gouv.bj IN A nakayo.leland.bj IN A ns1.intnet.bj IN A rip.psg.com IN A ;; Query time: 200 msec ;; SERVER: #53( ) ;; WHEN: Tue Dec 28 19:50: ;; MSG SIZE rcvd: 237

Interpreting the results STATUS  NOERROR: 0 or more resource records (RRs) returned  NXDOMAIN: non-existent domain  SERVFAIL: cache could not locate answer FLAGS  AA: Authoritative answer (not from cache)  You can ignore the others  QR: Query/Response (1 = Response)  RD: Recursion Desired  RA: Recursion Available

Interpreting the results Answer section (RRs requested)  Each record has a Time To Live (TTL)  Says how long the cache will keep it Authority section  Which nameservers are authoritative for this domain Additional section  More RRs (typically IP addresses for the authoritative nameservers) Total query time Check which server gave the response!  If you make a typing error, the query may go to a default server Note: RR = Resource Record

Socket Berkeley Software Distribution Handle-like data structure for communicating A socket is an endpoint  Send and receive  Attach a protocol  UDPuser datagram (best effort)  TCPtransmission control (reliable stream)

Sockets Programming

Sockets Sockaddr  struct sockaddr { u_short sa_family; char sa_data[14];};  designed to work with all protocols  sockaddr_in is used with TCP/IP Sockaddr_in  struct sockaddr_in { short sin_family; u_short sin_port; struct inaddr sin_addr; char sin_zero[8];};

A situation Client can determine IP address of server  But how can it know the socket id?  Socket is a handle – different number on each machine  Name server can’t deal with all the handles BSD provides a way to map a socket to a port that exists in the network name space.  Bind  A Port is an address  Many are well known

Client-Server Client  Create the socket  Get the address of the server  Fill in the sockaddr_in structure  Connect to server Server  Create the socket  Fill in the sockaddr_in structure  Bind to a port  Listen  Accept connections

Sockets Created by OS.  int socket(int af, int type, int protocol)  afAF_INET  typeSOCK_STREAM or SOCK_DGRAM  protocolIPPROTO_TCP (determined by type)

Client filling in sockaddr_in char *serverHostName = “orion-16”; struct sockaddr_in addr; memset(&addr, 0, sizeof(sockaddr_in)); addr.sin_family = AF_INET addr.sin_port = htons((u_short) port) struct hostent *host; host = gethostbyname(serverHostName); memcpy(&addr.sin_addr, host->h_addr_list[0], host->h_length);

Server filling in sockaddr_in struct sockaddr_in addr; memset(&addr, 0, sizeof(SOCKADDR_IN)); addr.sin_family = AF_INET addr.sin_port = htons((u_short) port) addr.sin_addr.s_addr = INADDR_ANY

Server Map to the network port  int bind(int sock, const struct sockaddr *name, int namelen)  name is pointer to sockaddr_in structure from previous  namelen is size of sockaddr_in Set socket to listen mode  int listen(int sock, int backlog)  backlogmax number of pending connections

Connections Client initiate a connection  int connect(int sock, const struct sockaddr *name, int namelen); Server accepting a connection  SOCKET accept(int sock, struct sockaddr *addr, int *addrlen);  creates a new socket for the communication  Server is free to accept another connection on that socket  best to fire off a thread to handle the connection. send the new socket as an argument to the thread.

Socket Communication Sending data  send(int sock, char *buffer, int bufflen, int flags)  If you are sending strings, remember the ‘\0’  flags is generally 0 Receiving data  recv(int sock, char *buffer, int bufflen, int flags)  Make sure you have enough room  flags is generally 0

Socket Overview sc=socket(..) ss=socket(..) Client Server bind(ss,..) listen(ss,..) foo=accept(ss,..) connect(sc,..) write(sc,buf,len) read(foo,buf,len)

#include client() { int skt; struct sockaddr_in name; skt = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); // Fill in the name data structure sockaddr_in connect(skt, &name, sizeof(name)); // Communicate using send and recv close(skt); }

#include server() { SOCKET listenSkt, newSkt; struct sockaddr_in serverName, clientName; listenSkt = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); //Fill in serverName bind(listenSkt, &serverName, sizeof(serverName)); listen(listenSkt, 5); newSkt = accept(listenSkt, &clientName, sizeof(clientName)); // Fire off a thread to do communication using send and recv on newSkt // Loop back and accept another connection close(skt); }

Recv bool isWhitespace(char c) { switch (c) { case '\r': case '\n': case ' ': case '\0': return true; default: return false; } void chomp(char *line) { int len = strlen(line); while (isWhitespace(line[len])) { line[len--] = '\0'; } char * GetLine(int fds) { char tline[MAX_MSG_SZ]; char *line; int messagesize = 0; int amtread = 0; //Read one byte at a time looking for a \n while((amtread = read(fds, tline + messagesize, 1)) < MAX_MSG_SZ) { if (amtread > 0) messagesize += amtread; else { perror("Socket Error is:"); fprintf(stderr, "Read Failed on file descriptor %d messagesize = %d\n", fds, messagesize); exit(2); } //fprintf(stderr,"%d[%c]", messagesize,message[messagesize-1]); if (tline[messagesize - 1] == '\n') break; } tline[messagesize] = '\0'; chomp(tline); line = (char *)malloc((strlen(tline) + 1) * sizeof(char)); strcpy(line, tline); //fprintf(stderr, "GetLine: [%s]\n", line); return line; }