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
Hypertext Transfer PROTOCOL ----HTTP Sen Wang CSE5232 Network Programming.
Advertisements

Cosc 4755 Mobile networking Overview and Stream, Socket, and Datagram.
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
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.
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.
FTP File Transfer Protocol. Introduction transfer file to/from remote host client/server model  client: side that initiates transfer (either to/from.
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.
Simple Web Services. Internet Basics The Internet is based on a communication protocol named TCP (Transmission Control Protocol) TCP allows programs running.
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 Layer Protocols Simple Mail Transfer Protocol.
Application Protocols: ELECTRONIC MAIL (SMTP, POP) CSNB534 Semester 2, 2007/2008 Asma Shakil.
70-291: MCSE Guide to Managing a Microsoft Windows Server 2003 Network Chapter 3: TCP/IP Architecture.
FTP (File Transfer Protocol) & Telnet
Simple Web Services. Internet Basics The Internet is based on a communication protocol named TCP (Transmission Control Protocol) TCP allows programs running.
Rensselaer Polytechnic Institute Shivkumar Kalvanaraman, Biplab Sikdar 1 The Web: the http protocol http: hypertext transfer protocol Web’s application.
1 ELEN602 Lecture 2 Review of Last Lecture Layering.
9/15/2015© 2008 Raymond P. Jefferis IIILect Application Layer.
Simple Mail Transfer Protocol (SMTP)
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.
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.
Web Client-Server Server Client Hypertext link TCP port 80.
Data Communications and Computer Networks Chapter 2 CS 3830 Lecture 8 Omar Meqdadi Department of Computer Science and Software Engineering University of.
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.
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.
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.
70-291: MCSE Guide to Managing a Microsoft Windows Server 2003 Network, Enhanced Chapter 3: TCP/IP Architecture.
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
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.
World Wide Web r Most Web pages consist of: m base HTML page, and m several referenced objects addressed by a URL r URL has two components: host name and.
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.
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
Networking CS 3470, Section 1 Sarah Diesburg
Sockets and Beginning Network Programming
Module 23 (ftp and wireshark)
Internet transport protocols services
Chapter 2: Application layer
Networking CS 3470, Section 1 Sarah Diesburg
William Stallings Data and Computer Communications
The Application Layer: SMTP, FTP
Chapter 7 Network Applications
Chapter 2 Application Layer
File Transfer Protocol
Part II Application Layer.
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….

Blackberry Uses the JavaMe Generic Connection Framework (GCF) –The GCF is a straightforward hierarchy of interfaces and classes to create connections (such as HTTP, datagram, or streams) and perform I/O. Includes File IO And is being ported back to Java SE as JSR 197

Generic Connection Framework (JavaME/Blackberry)

Common Connections Connector class is the abstracted view –Like when we used for file access. Connection interface, generic connection –defines the close method DatagramConnection interface, defines actions for a datagram connection, like UDP –Datagram interface, abstract interface for a datagram, which are bidirectional, extending the DataInput and DataOutput interfaces StreamConnection, defines actions on a stream connection, such as TCP –bidirectional, uses the InputConnection and OutputConnection ContentConnection interface, supports passes content encoded through a well-known codec –Video, audio, images.

Common Connections URL SchemeProtocolGCF TypeDefined by Btl2capBluetoothL2CAPConnectionJSR 82 datagramDatagramDatagramConnectionCLDC, CDC, JSR 197 fileFile accessFileConnection, InputConnection JSR 75 httpHTTPHttpConnectionMIDP 1.0/2.0 httpsSecure HTTPHttpsConnectionMIDP 2.0 comSerial I/OCommConnectionMIDP 2.0 sms, mmsSMS, MMSMessageConnectionJSR 120, JSR 205 apduApplication Protocol Data Unit (encryption and smart cards) APDUConnectionJSR 177 socket, serversocketSocketSocketConnection, ServerSocketConnection MIDP 2.0 datagramUDPUDPDatagramConnectionMIDP 2.0

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.

typical Blackberry network code. String url = "socket:// try { //make the connection sock = (SocketConnection)Connector.open(url); in = new InputStreamReader(sock.openInputStream()); out = new OutputStreamWriter(sock.openOutputStream()); //send infomation writeLine("Hi from a phone."); //read a line of information String from = getLine(); System.out.println("Server said:"+from); } catch (ConnectionNotFoundException e) { //Something happened, ConnectionNotFoundException } catch (IllegalArgumentException e) { //Something happened, IllegalArgumentException } catch (IOException e) { //Something happened, IOExecption } finally { sock.close(); in.close(); out.close(); } public void writeLine(String to) { to +="\n"; if (in != null) { try { out.write(to.toCharArray(), 0, to.length()); } catch (IOException e) { //Failed to write" } public String getLine() { // read from network port and have default value String from = ""; char ch; int i; if (in != null) { try { // while(!in.ready()) {}; i = in.read(); while (i != -1 && (char) i != '\n') { from += (char) i; i = in.read(); } } catch (IOException e) { from = "AWGH!!!"; } return (from);

Blackberry Simulator Most networking does not work in the simulator by default. –You need to turn on the MDS-CS –The MDS-CS simulates the Network, via a proxy.

Blackberry networking One addition Use default MDS service –URL as shown before or URL = "socket://address:4444;deviceside=false"; Direct TCP –URL = "socket://address:4444;deviceside=true"; –You should not have to turn on the MDS-CS with Direct TCP.

Blackberry networking(2) Using Wifi directly socket://address:4444;deviceside=true;interface=wifi"; For more info on wifi and network connection see – verables/7693/Connections_508953_11.jsphttp://docs.blackberry.com/en/developers/deli verables/7693/Connections_508953_11.jsp – verables/7693/WiFi_connections_509011_11. jsphttp://docs.blackberry.com/en/developers/deli verables/7693/WiFi_connections_509011_11. jsp

Android Ignores the GCF and does it their way Networking is based on standard Java SE methods –And get the BufferedReader/PrintWriter –Most Java SE network code works with almost no modifications. Bluetooth uses it own, ignores the OBEX format. SMS must use the standard, other no android could receive/send TXT or MMS messages. –As we already saw with Files.

typical Android network code. try { InetAddress serverAddr = InetAddress.getByName(host); //make the connection Socket socket = new Socket(serverAddr, port); String message = "Hello from Client android emulator"; try { //receive a message PrintWriter out = new PrintWriter( new BufferedWriter( new OutputStreamWriter(socket.getOutputStream())), true); out.println(message); //send a message now BufferedReader in = new BufferedReader(new InputStreamReader(socket.getInputStream())); String str = in.readLine(); } catch(Exception e) { //error! } finally { socket.close(); in.close(); out.close(); } } catch (Exception e) { //unable to connect }

Android notes You will need to put – –In the AndroidManifest.xml file At this point you should be able to use it in both the simulator and on the phone.

Last Note. You must connect your phone to UW’s UWyo wireless network to talk to a local cosc machine. –See kitdocid=1769&parentid=1 for help. kitdocid=1769&parentid=1

Q A &