Cosc 5/4730 Networking Overview and protocols. Basic networking Networking coding is based on a client and server model. – Even if the code you are writing.

Slides:



Advertisements
Similar presentations
Application Layer 2-1 Chapter 2 Application Layer Computer Networking: A Top Down Approach 6 th edition Jim Kurose, Keith Ross Addison-Wesley March 2012.
Advertisements

By: E. Susheel Chandar M. Guna Sekaran Intranet Mail Server.
World Wide Web Basics Original version by Carolyn Watters (Dalhousie U. Computer Science)
Hypertext Transfer Protocol Kyle Roth Mark Hoover.
2: Application Layer1 ECE5650 FTP, , DNS, and P2P.
1 Java Networking – Part I CS , Spring 2008/9.
CPSC 441: FTP & SMTP1 Application Layer: FTP & Instructor: Carey Williamson Office: ICT Class.
File Transfer: FTP and TFTP
Cosc 5/4730 Networking Overview and protocols. Basic networking Networking coding is based on a client and server model. – Even if the code you are writing.
Introduction 1 Lecture 7 Application Layer (FTP, ) slides are modified from J. Kurose & K. Ross University of Nevada – Reno Computer Science & Engineering.
File Transfer Protocol (FTP)
Lecturer : Ms.Trần Thị Ngọc Hoa Chapter 8 File Transfer Protocol – Simple Mail Transfer Protocol.
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.
TCP Sockets Reliable Communication. TCP As mentioned before, TCP sits on top of other layers (IP, hardware) and implements Reliability In-order delivery.
2: Application Layer1 Chapter 2 Application Layer These slides derived from Computer Networking: A Top Down Approach, 6 th edition. Jim Kurose, Keith Ross.
SMTP, POP3, IMAP.
1 Application Layer Lecture 5 Imran Ahmed University of Management & Technology.
Simple Web Services. Internet Basics The Internet is based on a communication protocol named TCP (Transmission Control Protocol) TCP allows programs running.
Chapter 17 Networking Dave Bremer Otago Polytechnic, N.Z. ©2008, Prentice Hall Operating Systems: Internals and Design Principles, 6/E William Stallings.
CSE401N: Computer Networks Lecture-5 Electronic Mail S. M. Hasibul Haque Lecturer Dept. of CSE, BUET.
IT 424 Networks2 IT 424 Networks2 Ack.: Slides are adapted from the slides of the book: “Computer Networking” – J. Kurose, K. Ross Chapter 2: Application.
Intro to Computer Networks Bob Bradley The University of Tennessee at Martin.
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 Protocols: ELECTRONIC MAIL (SMTP, POP) CSNB534 Semester 2, 2007/2008 Asma Shakil.
Networking Basics TCP/IP TRANSPORT and APPLICATION LAYER Version 3.0 Cisco Regional Networking Academy.
FTP (File Transfer Protocol) & Telnet
1 ELEN602 Lecture 2 Review of Last Lecture Layering.
Simple Mail Transfer Protocol (SMTP)
Jozef Goetz, Application Layer PART VI Jozef Goetz, Position of application layer The application layer enables the user, whether human.
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.
FTP Client Application CSC 8560 Brian Jorgage 4/27/2004.
File Transfer Protocol (FTP)
1 INFO 321 Server Technologies II FTP Material adapted from Dr. Randy Kaplan.
Krerk Piromsopa. Application Protocols & System Services. 1 Krerk Piromsopa. Department of Computer Engineering. Chulalongkorn University.
Dr. John P. Abraham Professor University of Texas Pan American Internet Applications and Network Programming.
1 SMTP - Simple Mail Transfer Protocol –RFC 821 POP - Post Office Protocol –RFC 1939 Also: –RFC 822 Standard for the Format of ARPA Internet Text.
TFTP: Trivial file transfer protocol
TCP Sockets Reliable Communication. TCP As mentioned before, TCP sits on top of other layers (IP, hardware) and implements Reliability In-order delivery.
2: Application Layer1 Chapter 2 Application Layer Computer Networking: A Top Down Approach Featuring the Internet, 3 rd edition. Jim Kurose, Keith Ross.
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.
Socket Programming Introduction. Socket Definition A network socket is one endpoint in a two-way communication flow between two programs running over.
2: Application Layer 1 Chapter 2: Application layer r 2.1 Principles of network applications  app architectures  app requirements r 2.2 Web and HTTP.
Internet Applications (Cont’d) Basic Internet Applications – World Wide Web (WWW) Browser Architecture Static Documents Dynamic Documents Active Documents.
SMTP - Simple Mail Transfer Protocol RFC 821
Overview of Servlets and JSP
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.
Application Layer 2-1 Chapter 2 Application Layer Computer Networking: A Top Down Approach 6 th edition Jim Kurose, Keith Ross Addison-Wesley March 2012.
Data Communications and Computer Networks Chapter 2 CS 3830 Lecture 7 Omar Meqdadi Department of Computer Science and Software Engineering University of.
COMP 431 Internet Services & Protocols
Simple Web Services. Internet Basics The Internet is based on a communication protocol named TCP (Transmission Control Protocol) TCP allows programs running.
1 Network Communications A Brief Introduction. 2 Network Communications.
@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.
Spring 2006 CPE : Application Layer_ 1 Special Topics in Computer Engineering Application layer: Some of these Slides are Based on Slides.
درس مهندسی اینترنت – مهدی عمادی مهندسی اینترنت برنامه‌نویسی در اینترنت 1 SMTP, FTP.
SMTP - Simple Mail Transfer Protocol POP - Post Office Protocol
Tiny http client and server
Block 5: An application layer protocol: HTTP
Networking CS 3470, Section 1 Sarah Diesburg
Sockets and Beginning Network Programming
Application layer 1 Principles of network applications 2 Web and HTTP
Module 23 (ftp and wireshark)
Chapter 2: Application layer
Networking CS 3470, Section 1 Sarah Diesburg
William Stallings Data and Computer Communications
Chapter 7 Network Applications
Process-to-Process Delivery: UDP, TCP
Chapter 2 Application Layer
File Transfer Protocol
Part II Application Layer.
Exceptions and networking
Presentation transcript:

Cosc 5/4730 Networking Overview and protocols

Basic networking Networking coding is based on a client and server model. – Even if the code you are writing is not a client server model, like p2p code and others. – This is just enough to allow you write code and understand the terms.

Some quick definitions Server: Offers it's services and "listens" for a request Client: Requests services from a server by initiating a "connection" to the server. Socket (refers both the Sockets API and a communication endpoint.). There are 2 kinds: – stream (SOCK_STREAM), which provide a bidirectional, sequenced, and reliable channel of communication Used in major network applications TCP connection – datagram (SOCK_DGRAM), which do not guarantee sequenced or reliable delivery, but are lightweight Used as broadcast applications, and "steaming video/audio" applications – Think about as radio or TV UDP connection – Port numbers are used to determine which program on a computer you want to talk to. Web servers usually use port 80, mail port 25, ftp port 23. RFC 1700 lists well know port numbers.

Writing Client code The code requests a socket from the O/S – Specify: Internet or UNIX socket, TCP or UDP, and other flags for the socket. Specify the remote host and remote port to use – Use functions to convert the name and port number for use by the O/S And finally initiates a connection.

Writing Server code Request a socket – Specify: Internet or UNIX socket, TCP or UDP, and other flags for the socket. Now build up the socket address information – Specify port number and address allowed to connect. Most use INADDR_ANY, meaning any body can connect Bind the address info to the socket Establish a listen queue with the O/S for the socket. Finally, the sever issues the accept command to accept a connection from a client. – The accept command can be used multiple times to accept more than one client (parallel connections or one after another.)

Once the socket has connected The client and server communicate with each other using a protocol. – Protocol is defined syntax that both the client and server use Similar in nature to human language, such an English There are lots of protocols: ftp, httpd, telnet, smtp, and hundreds more. – Some protocols will specify multiple sockets to used at the same time, such as the FTP protocol.

Once finished When the server and client have finished talking to each other Both the client and the server will issue command to close the socket.

Communication Sending information back and forth between two phones/devices – Once the connection has been created We spend a lot next couple of lectures covering how those connections are opened, used, and closed. – It all about the protocol IE how do they talk to each other. – Most network communication uses strings of text – SMS using a messaging object, since the information is delivered in a binary format. – Bluetooth can use string communication as well as a OPEX object.

Protocol This the type of messages and syntax of those methods are that sent. – Also defines what a response message (or set of messages sent back and forth) will be. – Example HTTP Protocol Client make requests in HTTP request message format Server responds, interpret, and return the relevant information in a HTTP Response message

HTTP Protocol We take a brief and very limited look at the HTTP protocol – we mostly focus on version 1.0 Both the Blackberry BrowserField and Android WebView hide of the details from the application.

HTTP Message format HTTP message all fit a generic message format – Which is pretty close to SMTP message format using for . [ ]

HTTP Message format (2) Start-line is nature of the message – Normally a request or response message Headers are all optional except one – In 1.1, the host header must be present – There are dozens of headers Message body is optional – Since it mostly used by the server, but clients use it for errors messages Message trailers are used for persistent connections – Mark where one message ends and the next begins.

Request Message Example

Request message start-line: Request line – Method – Three common methods are GET, HEAD, POST Request-uri – If the user was going to – Then the request-uri is /page.html GET /page.html HTTP/1.1 And the host header would be: HOST HTTP/version is – HTTP/0.9, HTTP/1.0, or HTTP/1.1

Request message (2) Headers – General headers Are about the message itself and are used to control processing or give extra info the server. – Request headers – Only in request messages Give the server more information about the request and control for the client over how the request is handled. – Entity headers Describe info in the body of the request, if any

Response Message Example

Response Message Start-line: Status line – HTTP-version, same as in request message But the version the server can handle, if the request is for a higher version than the server users. – Status code and reason phrase Results of request. The status code is a three digit code We’ll get back to status codes later on. – You’ll find they are similar in nature to FTP codes.

Response message (2) Headers – General headers Are about the message itself and are used to control processing or give extra info the client. – Response headers – Only in response messages Provide more information about the response. May contain more info about the body of the message. – Entity headers Describes info in the body of message.

HTTP Methods Get – Most general, get a resource to be returned to client It functionality can be changed by headers, for caching (if- Modified-Since header) and many others HEAD – Similar to get, only return header information, including entity header. Server will not send the actual body of the message. POST – Allows client the client to send a body message for processing by server (ie web forms and such)

FTP Protocol The FTP Protocol is far more complex since it sends commands and responses back and forth. – Brief list of the command set User, Pass, Acct, CWD, CDUP, SMT, REIN, QUIT, Port, PASV, TYPE, STRU, Mode, Retr, Stor, Stou, Appe, Allo, Rest, Rnfr, Rnto, Abor, Dele, Rmd, Mkd, Pwd, List, Nlst, Site, Syst, Stat, Help, Noop – Next slides are brief over of the protocol

Connection Establishment

Normal (Active) data connection

SMTP Protocol The protocol. –There are several versions. –The basic standard protocol is RFC 821, which we are going to look at. Including some headers so standard mail reader understand the message better. –By default, the smtp server uses port 25

SMTP Protocol commands SMTP is command based. The client issues a series of commands to the server. Opening a connection. client opens port 25, then –client: HELO example: HELO laptop.cs.uwyo.edu –Server: 250 Ok [may contain extra info] example: 250 alameda.cs.uwyo.edu HELLO laptop.cs.uwyo.edu [IP number], pleased to meet you

SMTP Protocol commands (2) clients issues from command –MAIL FROM: –example: MAIL FROM: server responses –250… sender ok –OR –5XX can't accept from sender.

SMTP Protocol commands (3) Next, who the message is for client: –RCPT TO: –example: RCPT TO: server responses: –250 … Recipient ok –OR –5XX user unknown The client can issue the RCPT command several times to send the same message to multiple addresses.

SMTP Protocol commands (4) The data section, which were we enter to bulk of the mail message. Client –data server responses. –354 enter mail, end with "." on a line by itself client –Enter message, headers, extra information, then enter period on a line by itself example: bah.. bah.. bah….

SMTP Protocol commands (5) Server responses –250 … message accepted for delivery. Finally, the client issues the quit command –quit Server closes the connection.

smtp example C: HELO laptop.cs.uwyo.edu S: 250: HELO laptop C: MAIL FROM: S: 250 ok C: RCPT edu S: 250 ok C: Data S: 354 … C: blah… blah… blah… C: etc…. C:. S: 250 OK C: quit S: closing connection

smtp example (2) From Mon Nov 3 19:10: Return-Path: Received: from localhost (localhost [ ]) by meru.cs.uwyo.edu (SGI /8.12.5) with SMTP id hA42A4R for ; Mon, 3 Nov :10: (MST) Date: Mon, 3 Nov :10: (MST) From: Message-Id: blah… blah… blah… etc….

URL syntax Where –scheme is the protocol (ie http, file, etc) –user is the username, which is optional –password is the password for the username, also optional –host is the fully qualified domain name or address –port is the optional port number, scheme provides the default –path is the path on the remote end the format varies by scheme. –Parameters are optional parameters, depends on scheme.

Overview of networking. In general network code will do the following Client perspective: 1.Make a connection to the server 2.Send a “request/data” to the server 3.Wait for a response Process the data. 4.If more data is needed go to 2. 5.Close the connection when finished.

More detail. Sending and receiving data –When you read data, it is (normally) a blocking read. So the program will stop until it has received data. If the interface doesn’t need to respond, then this is not a problem. Otherwise, we need threads. –Writing is NOT a blocking function. So when you write to a network socket, it will come back very quickly and the program will continue Remember protocols though. Just because you can write, doesn’t mean you should write.

Threading read/writing. In the case where a blocking read is a problem, we use threads. –Normally we create a reader thread. The thread is a loop, which reads, processes data and then returns to top of loop. –The main thread will likely issue writes.

example Main thread After the connection is made, it starts the reader thread It continues to respond to the user requests Has a section of code that responds when it is signaled, when new data has been received –It would update the interface with the new data. –Android: think handlers! Reader thread While (true or !stop) { Blocking read process the data just read –More reads as necessary and process that data as well signal the main thread we have received data. }

Additionally. Since we still must follow the protocol –The reader thread is the one that sets a variable for the writer. If the protocol says the client must wait for the server to send data before the client can make another request –Then the reader thread sets a variable saying it is ok to write data now. –The main thread will always check that variable before issuing a write.

Another Option In the previous example, the main thread had to check variable to determine when to write. Another option is have the reader write at the bottom of the loop. –The main thread uses a array in which it adds data to it that is to be written, but doesn’t actually issue a write. –The reader thread then removes the first item off the array, sends it, then goes back to read. –If the array is empty, it may have to wait for data or skip the write. Now the reader thread ensures the protocol is followed correctly. –You will need locking and synchronization is order to make sure the “array” is access correctly by the main and reader thread.

Q A &