Some slides are in courtesy of J. Kurose and K. Ross Review of Previous Lecture Principles of app layer protocols –clients and servers –app requirements.

Slides:



Advertisements
Similar presentations
Introduction to Sockets Jan Why do we need sockets? Provides an abstraction for interprocess communication.
Advertisements

 This Class  Chapter 9  Next Class  Wrap up this semester  Demo/discuss programming assignments  Review what we have learned  Questionnaire/Feedback.
1 Electronic Mail u Three major components: u user agents u mail servers u simple mail transfer protocol: SMTP u User Agent u a.k.a. “mail reader” u composing,
Domain Name System (or Service) (DNS) Computer Networks Computer Networks Term B10.
1 Outline r Principles of network applications m App architectures m App requirements r Web and HTTP m Objects vs. root files m Persistent, pipelining,
Layer Aplikasi Risanuri Hidayat. Applications and application-layer protocols Application: communicating, distributed processes –e.g., , Web, P2P.
2: Application Layer1 FTP, SMTP and DNS. 2: Application Layer2 FTP: separate control, data connections r FTP client contacts FTP server at port 21, specifying.
1 Domain Name System (DNS). 2 DNS: Domain Name System Internet hosts, routers: –IP address (32 bit) - used for addressing datagrams –“name”, e.g., gaia.cs.umass.edu.
Introduction to Socket Programming April What is a socket? An interface between application and network –The application creates a socket –The socket.
CPSC 441: FTP & SMTP1 Application Layer: FTP & Instructor: Carey Williamson Office: ICT Class.
Some slides are in courtesy of J. Kurose and K. Ross Review of Previous Lecture Principles of app layer protocols –clients and servers –app requirements.
Chapter 2: Application layer  2.1 Web and HTTP  2.2 FTP 2-1 Lecture 5 Application Layer.
2: Application Layer1 Chapter 2 Application Layer Computer Networking: A Top Down Approach, 4 th edition. Jim Kurose, Keith Ross Addison-Wesley, July 2007.
Application Layer session 1 TELE3118: Network Technologies Week 12: DNS Some slides have been taken from: r Computer Networking: A Top Down Approach.
Electronic Mail and SMTP
Introduction to Project 1 Web Client and Server Jan 2006.
2: Application Layer FTP, , and DNS. 2: Application Layer 2 Chapter 2 Application Layer Computer Networking: A Top Down Approach Featuring.
1 Application layer r Electronic Mail m SMTP, POP3, IMAP r DNS r P2P file sharing.
Computer Communication Digital Communication in the Modern World Application Layer cont. DNS, SMTP
1 An Overview of Applications Xin Liu ECS 152A Ref: slides by J. Kurose and K. Ross.
CPSC 441: DNS1 Instructor: Anirban Mahanti Office: ICT Class Location: ICT 121 Lectures: MWF 12:00 – 12:50 Notes derived.
Esimerkki: Sähköposti. Lappeenranta University of Technology / JP, PH, AH Electronic Mail Three major components: user agents mail servers simple mail.
Simple Mail Transfer Protocol
Introduction 1 Lecture 7 Application Layer (FTP, ) slides are modified from J. Kurose & K. Ross University of Nevada – Reno Computer Science & Engineering.
Mail Server Fitri Setyorini. Content SMTP POP3 How mail server works IMAP.
Electronic Mail Three major components: SMTP user agents mail servers
Introduction 1-1 Chapter 2 FTP & Computer Networking: A Top Down Approach 6 th edition Jim Kurose, Keith Ross Addison-Wesley March 2012 IC322 Fall.
2: Application Layer1 Chapter 2 Application Layer These slides derived from Computer Networking: A Top Down Approach, 6 th edition. Jim Kurose, Keith Ross.
CS 4396 Computer Networks Lab
SMTP, POP3, IMAP.
1 Application Layer Lecture 5 Imran Ahmed University of Management & Technology.
Operating Systems Chapter 9 Distributed Communication.
Data Communications and Computer Networks Chapter 2 CS 3830 Lecture 9
CSE401N: Computer Networks Lecture-5 Electronic Mail S. M. Hasibul Haque Lecturer Dept. of CSE, BUET.
Review: –How do we address “a network end-point”? –What services are provided by the Internet? –What is the network logical topology observed by a network.
Application Layer Protocols Simple Mail Transfer Protocol.
05 - FTP, , and DNS 2: Application Layer.
1 Computer Communication & Networks Lecture 27 Application Layer: Electronic mail and FTP Waleed.
DNS,SMTP,MIME.
Fall 2005 By: H. Veisi Computer networks course Olum-fonoon Babol Chapter 7 The Application Layer.
21-1 Last time □ Finish HTTP □ FTP This time □ SMTP ( ) □ DNS.
2: Application Layer1 Chapter 2 Application Layer Computer Networking: A Top Down Approach Featuring the Internet, 2 nd edition. Jim Kurose, Keith Ross.
1 DNS: Domain Name System People: many identifiers: m SSN, name, Passport # Internet hosts, routers: m IP address (32 bit) - used for addressing datagrams.
1 Application Layer Lecture 6 Imran Ahmed University of Management & Technology.
1 DNS: Domain Name System People: many identifiers: m SSN, name, Passport # Internet hosts, routers: m IP address (32 bit) - used for addressing datagrams.
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,
File Transfer Protocol (FTP)
CS 3830 Day 9 Introduction 1-1. Announcements r Quiz #2 this Friday r Demo prog1 and prog2 together starting this Wednesday 2: Application Layer 2.
Lecture 5: Web Continued 2-1. Outline  Network basics:  HTTP protocols  Studies on HTTP performance from different views:  Browser types [NSDI 2014]
Chapter 2 Application Layer Computer Networking: A Top Down Approach, 4 th edition. Jim Kurose, Keith Ross Addison-Wesley, July 2007.
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,
2: Application Layer 1 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,
Slides based on Carey Williamson’s: FTP & SMTP1 File Transfer Protocol (FTP) r FTP client contacts FTP server at port 21, specifying TCP as transport protocol.
COMP 431 Internet Services & Protocols
EECS340 Recitation 1: Very helpful to your project Hongyu Gao 1.
Important r On Friday, could you ask students to please me their groups (one per group) for Project 2 so we can assign IP addresses. I’ll send.
@Yuan Xue A special acknowledge goes to J.F Kurose and K.W. Ross Some of the slides used in this lecture are adapted from their.
@Yuan Xue A special acknowledge goes to J.F Kurose and K.W. Ross Some of the slides used in this lecture are adapted from their.
@Yuan Xue A special acknowledge goes to J.F Kurose and K.W. Ross Some of the slides used in this lecture are adapted from their.
Dr. Adil Yousif University of Alneelian – Master of CS - IT Electronic Mail.
Spring 2006 CPE : Application Layer_ 1 Special Topics in Computer Engineering Application layer: Some of these Slides are Based on Slides.
درس مهندسی اینترنت – مهدی عمادی مهندسی اینترنت برنامه‌نویسی در اینترنت 1 SMTP, FTP.
Data Communications and Computer Networks Chapter 2 CS 3830 Lecture 9
Chapter 2: Application layer
CSE 4213: Computer Networks II
DNS: Domain Name System
FTP, SMTP and DNS 2: Application Layer.
Sockets Programming Socket to me!.
Sockets Programming Socket to me!.
Chapter 2 Application Layer
Presentation transcript:

Some slides are in courtesy of J. Kurose and K. Ross Review of Previous Lecture Principles of app layer protocols –clients and servers –app requirements Web and HTTP FTP

Announcement All got partners and IP addresses ? Should complete at least part I by the end of this week Networking research project available (preferably with OS background)

Outline Electronic Mail: SMTP, POP3, IMAP DNS Socket programming with TCP

Electronic Mail Three major components: user agents mail servers simple mail transfer protocol: SMTP User Agent a.k.a. “mail reader” composing, editing, reading mail messages e.g., Eudora, Outlook, elm, Netscape Messenger outgoing, incoming messages stored on server user mailbox outgoing message queue mail server user agent user agent user agent mail server user agent user agent mail server user agent SMTP

Electronic Mail: mail servers Mail Servers mailbox contains incoming messages for user message queue of outgoing (to be sent) mail messages SMTP protocol between mail servers to send messages –client: sending mail server –“server”: receiving mail server mail server user agent user agent user agent mail server user agent user agent mail server user agent SMTP

Electronic Mail: SMTP [RFC 2821] uses TCP to reliably transfer message from client to server, port 25 direct transfer: sending server to receiving server three phases of transfer –handshaking (greeting) –transfer of messages –closure command/response interaction –commands: ASCII text –response: status code and phrase messages must be in 7-bit ASCII

Scenario: Alice sends message to Bob 1) Alice uses UA to compose message and “to” 2) Alice’s UA sends message to her mail server; message placed in message queue 3) Client side of SMTP opens TCP connection with Bob’s mail server 4) SMTP client sends Alice’s message over the TCP connection 5) Bob’s mail server places the message in Bob’s mailbox 6) Bob invokes his user agent to read message user agent mail server mail server user agent

SMTP: final words SMTP uses persistent connections SMTP requires message (header & body) to be in 7-bit ASCII SMTP server uses CRLF.CRLF to determine end of message Comparison with HTTP: HTTP: pull SMTP: push both have ASCII command/response interaction, status codes

Mail message format SMTP: protocol for exchanging msgs RFC 822: standard for text message format: header lines, e.g., –To: –From: –Subject: different from SMTP commands! body –the “message”, ASCII characters only header body blank line

Message format: multimedia extensions MIME: multimedia mail extension, RFC 2045, 2056 additional lines in msg header declare MIME content type From: To: Subject: Picture of yummy crepe. MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Type: image/jpeg base64 encoded data base64 encoded data multimedia data type, subtype, parameter declaration method used to encode data MIME version encoded data

MIME types Content-Type: type/subtype; parameters Seven top-level types defined Text example subtypes: plain, html Image example subtypes: jpeg, gif Application other data that must be processed by reader before “viewable” example subtypes: msword, octet-stream

Mail access protocols SMTP: delivery/storage to receiver’s server Mail access protocol: retrieval from server –POP: Post Office Protocol [RFC 1939] authorization (agent server) and download –IMAP: Internet Mail Access Protocol [RFC 1730] more features (more complex) manipulation of stored msgs on server –HTTP: Hotmail, Yahoo! Mail, etc. user agent sender’s mail server user agent SMTP access protocol receiver’s mail server

Outline Electronic Mail: SMTP, POP3, IMAP DNS Socket programming with TCP

DNS: Domain Name System People: many identifiers: –SSN, name, passport # Internet hosts, routers: –IP address (32 bit) - used for addressing datagrams –“name”, e.g., home1.cs.nwu.edu - used by humans Q: map between IP addresses and name ? Domain Name System: distributed database implemented in hierarchy of many name servers application-layer protocol host, routers, name servers to communicate to resolve names (address/name translation) –note: core Internet function, implemented as application- layer protocol –complexity at network’s “edge” Run on UDP, port 53

DNS name servers no server has all name-to-IP address mappings local name servers: –each ISP, company has local (default) name server –host DNS query first goes to local name server authoritative name server: –for a host: stores that host’s IP address, name –can perform name/address translation for that host’s name Why not centralize DNS? single point of failure traffic volume distant centralized database maintenance doesn’t scale!

DNS: Root name servers contacted by local name server that can not resolve name root name server: –contacts authoritative name server if name mapping not known –gets mapping –returns mapping to local name server b USC-ISI Marina del Rey, CA l ICANN Marina del Rey, CA e NASA Mt View, CA f Internet Software C. Palo Alto, CA i NORDUnet Stockholm k RIPE London m WIDE Tokyo a NSI Herndon, VA c PSInet Herndon, VA d U Maryland College Park, MD g DISA Vienna, VA h ARL Aberdeen, MD j NSI (TBD) Herndon, VA 13 root name servers worldwide

Simple DNS example host surf.eurecom.fr wants IP address of 1. contacts its local DNS server, dns.eurecom.fr 2. dns.eurecom.fr contacts root name server, if necessary 3. root name server contacts authoritative name server, dns.umass.edu, if necessary requesting host surf.eurecom.fr root name server authorititive name server dns.nwu.edu local name server dns.eurecom.fr

DNS example Root name server: may not know authoritative name server may know intermediate name server: who to contact to find authoritative name server requesting host surf.eurecom.fr root name server local name server dns.eurecom.fr authoritative name server dns.cs.nwu.edu intermediate name server dns.nwu.edu 7 8

DNS: iterated queries recursive query: puts burden of name resolution on contacted name server heavy load? iterated query: contacted server replies with name of server to contact “I don’t know this name, but ask this server” requesting host surf.eurecom.fr gaia.cs.umass.edu root name server local name server dns.eurecom.fr authoritative name server dns.cs.umass.edu intermediate name server dns.umass.edu 7 8 iterated query

DNS: caching and updating records once (any) name server learns mapping, it caches mapping –cache entries timeout (disappear) after some time update/notify mechanisms under design by IETF –RFC 2136 –

DNS records DNS: distributed db storing resource records (RR) Type=NS –name is domain (e.g. foo.com) –value is IP address of authoritative name server for this domain RR format: (name, value, type, ttl) Type=A –name is hostname –value is IP address Type=CNAME –name is alias name for some “cannonical” (the real) name is really servereast.backup2.ibm.com –value is cannonical name Type=MX –value is name of mailserver associated with name

Outline Electronic Mail: SMTP, POP3, IMAP DNS Socket programming with TCP

Socket programming Socket API introduced in BSD4.1 UNIX, 1981 explicitly created, used, released by apps two types of transport service via socket API: –unreliable datagram –reliable, byte stream a host-local, application-created, OS-controlled interface (a “door”) into which application process can both send and receive messages to/from another application process socket Goal: learn how to build client/server application that communicate using sockets

Socket-programming using TCP Socket: a door between application process and end- end-transport protocol (UCP or TCP) TCP service: reliable transfer of bytes from one process to another process TCP with buffers, variables socket controlled by application developer controlled by operating system host or server process TCP with buffers, variables socket controlled by application developer controlled by operating system host or server internet

Socket programming with TCP Client must contact server server process must first be running server must have created socket (door) that welcomes client’s contact Client contacts server by: creating client-local TCP socket specifying IP address, port number of server process When client creates socket: client TCP establishes connection to server TCP When contacted by client, server TCP creates new socket for server process to communicate with client –allows server to talk with multiple clients –source port numbers used to distinguish clients (more in Chap 3) TCP provides reliable, in-order transfer of bytes (“pipe”) between client and server application viewpoint

socket() bind() listen() accept() read() write() read() close() Socket() connect() write() read() close() TCP Client TCP Server Well-known port blocks until connection from client process request Connection establishment Data(request) Data(reply) End-of-file notification

Client – high level view Create a socket Setup the server address Connect to the server Read/write data Shutdown connection

Creating a Socket int socket(int family,int type,int proto); family specifies the protocol family ( PF_INET for TCP/IP). type specifies the type of service ( SOCK_STREAM, SOCK_DGRAM ). protocol specifies the specific protocol (usually 0, which means the default).

socket() The socket() system call returns a socket descriptor (small integer) or -1 on error. socket() allocates resources needed for a communication endpoint - but it does not deal with endpoint addressing. Sockets API is generic. TCP/IP requires an IP address and a port number for each endpoint address. Other protocol suites (families) may use other schemes.

Necessary Background Information: POSIX data types int8_t signed 8bit int uint8_t unsigned 8 bit int int16_t signed 16 bit int uint16_t unsigned 16 bit int int32_t signed 32 bit int uint32_t unsigned 32 bit int u_char, u_short, u_int, u_long

More POSIX data types sa_family_t address family socklen_t length of struct in_addr_t IPv4 address in_port_t IP port number

Address and port byte-ordering Address and port are stored as integers –u_short sin_port; (16 bit) –in_addr sin_addr; (32 bit) struct in_addr { u_long s_addr; }; r Problem: m different machines / OS’s use different word orderings little-endian: lower bytes first big-endian: higher bytes first m these machines may communicate with one another over the network Big-Endian machine Little-Endian machine WRONG!!!

Solution: Network Byte-Ordering Defs: –Host Byte-Ordering: the byte ordering used by a host (big or little) –Network Byte-Ordering: the byte ordering used by the network – always big-endian Any words sent through the network should be converted to Network Byte-Order prior to transmission (and back to Host Byte-Order once received) Q: should the socket perform the conversion automatically? r Q: Given big-endian machines don’t need conversion routines and little-endian machines do, how do we avoid writing two versions of code?

Network Byte Order Functions u_long htonl(u_long x); u_short htons(u_short x); u_long ntohl(u_long x); u_short ntohs(u_short x); r On big-endian machines, these routines do nothing r On little-endian machines, they reverse the byte order r Same code would have worked regardless of endian- ness of the two machines Big-Endian machine Little-Endian machine htonl ntohl

Network Byte Order Functions ‘ h ’ : host byte order ‘ n ’ : network byte order ‘ s ’ : short (16bit) ‘ l ’ : long (32bit) uint16_t htons(uint16_t); uint16_t ntohs(uint_16_t); uint32_t htonl(uint32_t); uint32_t ntohl(uint32_t);

connect() int connect( int sockfd, const struct sockaddr *server, socklen_t addrlen); sockfd is an already created TCP socket. server contains the address of the server (IP Address and TCP port number) connect() returns 0 if OK, -1 on error

int connect_ socket( char *hostname, int port) { int sock; struct sockaddr_in sin; struct hostent *host; sock = socket( AF_ INET, SOCK_ STREAM, 0); if (sock == -1) return sock; host = gethostbyname( hostname); if (host == NULL) { close( sock); return -1; } memset (& sin, 0, sizeof( sin)); sin. sin_ family = AF_ INET; sin. sin_ port = htons( port); sin. sin_ addr. s_ addr = *( unsigned long *) host-> h_ addr_ list[ 0]; if (connect( sock, (struct sockaddr *) &sin, sizeof( sin)) != 0) { close (sock); return -1; } return sock; } Resolve the host struct hostent *gethostbyname( const char *hostname); /*Return nonnull pointer if OK, NULL on error */ Setup up the struct unit16_t htons(unit16_t host16bitvaule) /*Change the port number from host byte order to network byte order */ Connect connect(int socketfd, const struct sockaddr * servaddr, socket_t addrlen) /*Perform the TCP three way handshaking*/ Hostent structure struct hostent{ char * h_name/*official name of host*/ char ** h_aliases; /* pointer ot array of\ pointers to alias name*/ int h_addrtype /* host address type*/ int h_length/* length of address */ char ** h_addr_list/*prt to array of ptrs with \ IPv4 or IPv6 address*/ } Ipv4 socket address structure struct socketaddr_in{ uint8_t sin_len; /*length of the structure (16)*/ sa_falimily_t sin_family /* AF_INT*/ in_port_t sin_port /* 16 bit TCP or UDP port number*/ struct in_addr sin_addr/* 32 bit Ipv4 address */ char sin_zero(8)/* unused*/ } Make the socket Socket(int family, int type, in t protocol); return nonnegative value for OK, -1 for error