Internet Protocol. Chapter 5 Protocol Layering. Juho Kim Graduate School of Information & Technology Sogang University

Similar documents
Networking and Security

JAVA - NETWORKING (SOCKET PROGRAMMING)

Unit 1 Java Networking

CSCD 330 Network Programming Spring 2018

Outlines. Networking in Java. Internet hardware structure. Networking Diagram. IP Address. Networking in Java. Networking basics

JAVA Network API. 2 - Connection-Oriented vs. Connectionless Communication

TCP/IP THE TCP/IP ARCHITECTURE

AJP: Chapter 2 Networking: 18 marks

Chapter 2 Applications and

Socket Programming(TCP & UDP) Sanjay Chakraborty

Introduction to Socket Programming

Connecting to a Server Implementing Servers Making URL Connections Advanced Socket Programming

OBJECT ORIENTED PROGRAMMING

Basic Java Network Programming. CS211 July 30 th, 2001

C18: Network Fundamentals and Reliable Sockets

Transport Layer. Gursharan Singh Tatla. Upendra Sharma. 1

Advanced Java Programming. Networking

Lecture 3. Java Socket Programming. TCP, UDP and URL

CS 4390 Computer Networks. Transport Services and Protocols

Networking Basics. network communication.

NT1210 Introduction to Networking. Unit 10

ET4254 Communications and Networking 1

Concept Questions Demonstrate your knowledge of these concepts by answering the following questions in the space that is provided.

COMP 213. Advanced Object-oriented Programming. Lecture 20. Network Programming

Object-Oriented Programming in Java

Network Layer (1) Networked Systems 3 Lecture 8

ECE4110 Internetwork Programming. Introduction and Overview

Transport Layer. The transport layer is responsible for the delivery of a message from one process to another. RSManiaol

The TCP Protocol Stack

ICS 351: Networking Protocols

SUBJECT: DATA COMMUNICATION AND NETWORK SEMESTER: V SEMESTER COURSE: BCA SUBJECT TEACHER: Dr.K.Chitra Assistant Professor, Department of Computer


Java Networking (sockets)

Chapter 6. What happens at the Transport Layer? Services provided Transport protocols UDP TCP Flow control Congestion control

TCP connections. Fundamentals of Internet Connections Objectives. Connect to an Echo port. java.net.socket

Network Architecture Models

UDP and TCP. Introduction. So far we have studied some data link layer protocols such as PPP which are responsible for getting data

Introduction. IP Datagrams. Internet Service Paradigm. Routers and Routing Tables. Datagram Forwarding. Example Internet and Conceptual Routing Table

CS 355. Computer Networking. Wei Lu, Ph.D., P.Eng.

Info 408 Distributed Applications programming 2 nd semester of 2017/2018 Credits: 5 Lecturer: Dr. Antoun Yaacoub

Operating Systems CS 571

Previous lecture: threads G51PRG: Introduction to Programming Second semester Lecture 12 URL

APPENDIX F THE TCP/IP PROTOCOL ARCHITECTURE

05 Transmission Control Protocol (TCP)

CS September 2017

Chapter 2 Network Models 2.1

TSIN02 - Internetworking

Computer Networks with Internet Technology William Stallings. Chapter 2 Protocols and the TCP/IP Protocol Suite

User Datagram Protocol

Data and Computer Communications. Chapter 2 Protocol Architecture, TCP/IP, and Internet-Based Applications

SC/CSE 3213 Winter Sebastian Magierowski York University CSE 3213, W13 L8: TCP/IP. Outline. Forwarding over network and data link layers

TSIN02 - Internetworking

Need For Protocol Architecture

Need For Protocol Architecture

TCP/IP protocol suite

Computer Networks (Introduction to TCP/IP Protocols)

Internetwork Protocols

Socket 101 Excerpt from Network Programming

CS 640: Introduction to Computer Networks. Today s Lecture. Page 1

cs144 Midterm Review Fall 2010

Defining Networks with the OSI Model. Module 2

Distributed Systems COMP 212. Lecture 8 Othon Michail

C19: User Datagram and Multicast

TSIN02 - Internetworking

Chapter 7 Internet Protocol Version 4 (IPv4) Kyung Hee University

Unix Network Programming

Networking with java (socket programming) a brief study

CSCI-GA Operating Systems. Networking. Hubertus Franke

COMP750. Distributed Systems. Network Overview

TRANSMISSION CONTROL PROTOCOL. ETI 2506 TELECOMMUNICATION SYSTEMS Monday, 7 November 2016

Java.net Package and Classes(Url, UrlConnection, HttpUrlConnection)

Distributed Systems Recitation 2. Tamim Jabban

Introduction to TCP/IP networking

CSCI Computer Networks

Introduction to Protocols

Transport Layer. Chapter 3: Transport Layer

Chapter 2 - Part 1. The TCP/IP Protocol: The Language of the Internet

IP - The Internet Protocol. Based on the slides of Dr. Jorg Liebeherr, University of Virginia

Communication in Distributed Systems: Sockets Programming. Operating Systems

Chapter 3 Protocols and the TCP/IP Suite

Introduction to Sockets 9/25/14

UNIT IV -- TRANSPORT LAYER

Networking: IPv6, UDP and TCP. Network Programming in Java UDP and TCP

User Datagram Protocol (UDP):

03 The Internet Model and TCP/IP

Distributed Systems Recitation 2. Tamim Jabban

SERVER/CLIENT NETWORKING AT JAVA PLATFORM

EE 610 Part 2: Encapsulation and network utilities

UNIT IV TRANSPORT LAYER

Networking for Data Acquisition Systems. Fabrice Le Goff - 14/02/ ISOTDAQ

UDP: Datagram Transport Service

Introduction to Open System Interconnection Reference Model

Lecture 2 Communication services The Trasport Layer. Antonio Cianfrani DIET Department Networking Group netlab.uniroma1.it

Operating Systems. 16. Networking. Paul Krzyzanowski. Rutgers University. Spring /6/ Paul Krzyzanowski

Distributed Systems. 02. Networking. Paul Krzyzanowski. Rutgers University. Fall 2017

Chapter 23 Process-to-Process Delivery: UDP, TCP, and SCTP 23.1

ch02 True/False Indicate whether the statement is true or false.

The ASP Virtual Networking (VNET) Component. 23 July Abstract

Computer Communication & Networks / Data Communication & Computer Networks Week # 03

CS 428/528 Computer Networks Lecture 01. Yan Wang

Transcription:

Internet Protocol Chapter 5 Protocol Layering Juho Kim Graduate School of Information & Technology Sogang University Department of of Computer Science and and Engineering, Sogang University Page 1 CAD & VLSI Lab. Page Youse 1 Kim / 35

Protocol Layering The structure of the software found in hosts and routers that carries out network communication. Layering makes the internet software easier to build and trace The need for multiple protocols The conceptual layers of protocol software Functionality of the layers: ISO 7-layer reference model TCP/IP Internet layering model Difference between X.25 and internet layering Protocol layering principle Layering in the presence of network substructure Two important boundaries in the TCP/IP model Disadvantage of layering Basic idea behind multiplexing and demultiplexing Department of of Computer Science and and Engineering, Sogang University Page 2 CAD & VLSI Lab. Page Youse 2 Kim / 35

The Need For Multiple Protocols Protocol Layering Problems when machines communicate over a data network Hardware failure: A host or router => A protocol software needs to detect such failures and recover from them if possible. Network congestion: The protocol software needs to arrange ways that a congested machine can suppress further traffic. Packet delay or loss: The protocol software needs to learn or adapt to long delay Data corruption: The protocol software needs to detect and recover from errors Data duplication or sequence errors: The protocol software need to reorder or remove any duplicates. No single protocol can handle all of the problems Among layers of protocols, they must agree on formats. Department of of Computer Science and and Engineering, Sogang University Page 3 CAD & VLSI Lab. Page Youse 3 Kim / 35

Protocol Layering Conceptual Layers of Protocol Software The path of a message traversing the Internet from the sender through two intermediate machines to the receiver. Intermediate machines only send the datagram to the IP software layer. Department of of Computer Science and and Engineering, Sogang University Page 4 CAD & VLSI Lab. Page Youse 4 Kim / 35

OSI 7-Layer Reference Model Developed by the International Organization for Standardization protocol standards OSI Model (open systems interconnection) Application; provides access to OSI environment for users and also provides distributed information Presentation; provides application processes from data representation (syntax) Session; provides the control structure for communication between applications Transport; provides reliable, transparent transfer of data between end points (error recovery, flow control) Network; provides data transmission and switching techniques to connect systems Data link; provides for the reliable transfer of information across physical link Physical; transmission of unstructured bit stream over physical medium Department of of Computer Science and and Engineering, Sogang University Page 5 CAD & VLSI Lab. Page Youse 5 Kim / 35

TCP/IP Internet Layering Model Application layer ; support user application Transport layer ; transmission control protocol (TCP) provides reliability of exchanging data, flow control, and packets Internet layer ; internet protocol (IP) provides routing function across multiple networks. Encapsulating packet in an IP datagram (fills header and uses routing alg.) Network access layer ; circuit switching, packet switching (e.g., X.25), local area network (Ethernet) Physical layer ; physical interface between devices and a transmission medium or network Department of of Computer Science and and Engineering, Sogang University Page 6 CAD & VLSI Lab. Page Youse 6 Kim / 35

Layering in a TCP/IP Internet Environment Layering principle when a router is used. The frame delivered to router R is exactly the frame sent from host A, but differs from the frame sent between R and B Department of of Computer Science and and Engineering, Sogang University Page 7 CAD & VLSI Lab. Page Youse 7 Kim / 35

Layering In The Presence Of Network Substructure A set of point-to-point connections among routers Independent network: Serial Line IP (SLIP) or Point to Point Protocol (PPP) Causing too many networks (large routing table) Single IP network small routing table for intranet (a) Conceptual position of an internet protocol for point-to-point connections when IP treats them as a single IP network (b) Detailed diagram of corresponding software modules. Each arrow corresponds to one physical device. Department of of Computer Science and and Engineering, Sogang University Page 8 CAD & VLSI Lab. Page Youse 8 Kim / 35

Two Important Boundaries In The TCP/IP Model Protocol address boundary Operating system boundary Department of of Computer Science and and Engineering, Sogang University Page 9 CAD & VLSI Lab. Page Youse 9 Kim / 35

Disadvantages of Layering Strict layering prevents from the higher-level knowing the lowerlevel For example, the transport layer accepts a stream of bytes from an application program, divide the stream into packets, and send each packet across the internet. To optimize the transfer, the transport layer finds the largest packet size for that network. However, the transport layer does not know the routing and traffic. Relaxing the strict layering : passing information such as route selection, MTU (maximum transfer unit) to higher layer protocols. Department of of Computer Science and Engineering, Sogang University Page 10 CAD & VLSI Lab. Page Youse 10 / Kim 35

Demultiplexing at Network Interface Layer Demultiplexing of incoming frames based on the type field found in the frame header Department of of Computer Science and Engineering, Sogang University Page 11 CAD & VLSI Lab. Page Youse 11 / Kim 35

Demultiplexing at the Internet Layer Demultiplexing at the Internet layer. IP software chooses an appropriate procedure to handle a datagram based on the protocol type field in the datagram header Department of of Computer Science and Engineering, Sogang University Page 12 CAD & VLSI Lab. Page Youse 12 / Kim 35

User Datagram Protocol User Datagram Protocol (UDP) UDP message format UDP Encapulation and Protocol Layering UDP Multiplexing, Demultiplexing, and Ports Reserved and Available UDP Port Numbers Sockets Department of of Computer Science and Engineering, Sogang University Page 13 CAD & VLSI Lab. Page Youse 13 / Kim 35

User Datagram Protocol (UDP) Distinguishing multiple destinations within a given host: allowing multiple application programs executing on a given computer to send and receive datagrams independently. use different port number to identify different application protocol port : abstract destination port buffering port for late processing Sender needs to know both IP address and the protocol port number User Datagram Protocol : The primary mechanism that application programs use to send datagrams to other application programs. Department of of Computer Science and Engineering, Sogang University Page 14 CAD & VLSI Lab. Page Youse 14 / Kim 35

UDP Message Format UDP header UDP SOURCE PORT : optional UDP DESTINATION PORT : 16-bit protocol port number LENGTH : a count of octets in the UDP datagram (header + data) CHECKSUM : optional Department of of Computer Science and Engineering, Sogang University Page 15 CAD & VLSI Lab. Page Youse 15 / Kim 35

UDP Encapsulation and Protocol Layering The IP layer is responsible only for transferring data between a pair of hosts on an internet, while the UDP layer is responsible only for differentiating among multiple sources or destinations within one host. Department of of Computer Science and Engineering, Sogang University Page 16 CAD & VLSI Lab. Page Youse 16 / Kim 35

UDP Demultiplexing and Ports Example of demultiplexing one layer above IP. UDP uses the UDP destination port number to select an appropriate destination port for incoming datagrams. When port is full, UDP discards the incoming datagram and sends back port unreachable ICMP message back to the sender. Department of of Computer Science and Engineering, Sogang University Page 17 CAD & VLSI Lab. Page Youse 17 / Kim 35

Ports To identify different applications, tag each datagram with a port number. The UDP(or TCP) decides which application should receive the datagram by comparing the port number with ports currently in use. Each application program negotiates to obtain a protocol field and associated port number before it sends a UDP(TCP) datagram. Usually the port number points to an internal queue created by the Operating System Application as client should know in advance the port number for the particular application in the server. Application as a server can obtain the port number of the client on receiving the first request. Department of of Computer Science and Engineering, Sogang University Page 18 CAD & VLSI Lab. Page Youse 18 / Kim 35

Reserved Port Numbers Department of of Computer Science and Engineering, Sogang University Page 19 CAD & VLSI Lab. Page Youse 19 / Kim 35

Socket Interface Interface between application programs and TCP/IP protocols. Interface depends on operating systems. Socket is not considered as protocols (just an application, not standard). Used for network I/O: similar to file descriptor for file I/O in UNIX File I/O in UNIX: Open-Read-Write-Close paradigm Open returns an integer file descriptor --> user process uses the number for accessing the file Read transfers data into user process. Write transfers data from the user process to the file or device. Close is called by the user process to terminate the process. With file access application programs request the operating system to create a socket The system returns a small integer that the application program uses to reference the newly created socket. Department of of Computer Science and Engineering, Sogang University Page 20 CAD & VLSI Lab. Page Youse 20 / Kim 35

Networking with java.net Internet Address and URL InetAddress class java.lang.object + -- java.net.inetaddress public final class InetAddress extends Object implements Serializable This class represents an Internet Protocol (IP) address. Applications should use the methods getlocalhost, getbyname, or getallbyname to create a new InetAddress instance. Department of of Computer Science and Engineering, Sogang University Page 21 CAD & VLSI Lab. Page Youse 21 / Kim 35

Department of of Computer Science and Engineering, Sogang University Page 22 CAD & VLSI Lab. Page Youse 22 / Kim 35

Example) AddressTest.java import java.net.*; class AddressTest { public static void main(string args[]) } throws UnknownHostException { InetAddress Address = InetAddress.getLocalHost(); } System.out.println("Local Host Name : " + Address.getHostName()); System.out.println("Local Host IP Address : " + Address.getHostAddress()); Address = InetAddress.getByName("sogang.ac.kr"); System.out.println("sogang.ac.kr's computer name and IP Address : " + Address); InetAddress sw[] = InetAddress.getAllByName("www.ibm.com"); for (int i = 0; i < sw.length; i++) System.out.println(sw[i]); Department of of Computer Science and Engineering, Sogang University Page 23 CAD & VLSI Lab. Page Youse 23 / Kim 35

URL class Class URL represents a Uniform Resource Locator, a pointer to a "resource" on the World Wide Web. A resource can be something as simple as a file or a directory, or it can be a reference to a more complicated object, such as a query to a database or to a search engine. More information on the types of URLs and their formats can be found at: http://www.ncsa.uiuc.edu/demoweb/url-primer.html In general, a URL can be broken into several parts. The previous example of a URL indicates that the protocol to use is http (HyperText Transport Protocol) and that the information resides on a host machine named www.ncsa.uiuc.edu. The information on that host machine is named demoweb/url-primer.html. The exact meaning of this name on the host machine is both protocol dependent and host dependent. The information normally resides in a file, but it could be generated on the fly. This component of the URL is called the file component, even though the information is not necessarily in a file. Department of of Computer Science and Engineering, Sogang University Page 24 CAD & VLSI Lab. Page Youse 24 / Kim 35

A URL can optionally specify a "port", which is the port number to which the TCP connection is made on the remote host machine. If the port is not specified, the default port for the protocol is used instead. For example, the default port for http is 80. An alternative port could be specified as: http://www.ncsa.uiuc.edu:8080/demoweb/urlprimer.html A URL may have appended to it an "anchor", also known as a "ref" or a "reference". The anchor is indicated by the sharp sign character "#" followed by more characters. For example, http://java.sun.com/index.html#chapter1 This anchor is not technically part of the URL. Rather, it indicates that after the specified resource is retrieved, the application is specifically interested in that part of the document that has the tag chapter1 attached to it. The meaning of a tag is resource specific. An application can also specify a "relative URL", which contains only enough information to reach the resource relative to another URL. Relative URLs are frequently used within HTML pages. For example, if the contents of the URL: http://java.sun.com/index.html contained within it the relative URL: FAQ.html it would be a shorthand for: http://java.sun.com/faq.html The relative URL need not specify all the components of a URL. If the protocol, host name, or port number is missing, the value is inherited from the fully specified URL. The file component must be specified. The optional anchor is not inherited. Department of of Computer Science and Engineering, Sogang University Page 25 CAD & VLSI Lab. Page Youse 25 / Kim 35

Department of of Computer Science and Engineering, Sogang University Page 26 CAD & VLSI Lab. Page Youse 26 / Kim 35

Department of of Computer Science and Engineering, Sogang University Page 27 CAD & VLSI Lab. Page Youse 27 / Kim 35

Example) urltest.java import java.net.*; class urltest { public static void main(string args[]) throws MalformedURLException { URL location = new URL("http://sogang.ac.kr"); System.out.println("protocol : " + location.getprotocol()); System.out.println("port : " + location.getport()); System.out.println("host : " + location.gethost()); System.out.println("file : " + location.getfile()); System.out.println("URL " + location.toexternalform()); } } Department of of Computer Science and Engineering, Sogang University Page 28 CAD & VLSI Lab. Page Youse 28 / Kim 35

URLConnection class The abstract class URLConnection is the superclass of all classes that represent a communications link between the application and a URL. Instances of this class can be used both to read from and to write to the resource referenced by the URL. The following methods are used to access the header fields and the contents after the connection is made to the remote object: getcontent getheaderfield getinputstream getoutputstream Certain header fields are accessed frequently. The methods: getcontentencoding getcontentlength getcontenttype getexpiration getdate getlastmodifed provide convenient access to these fields. The getcontenttype method is used by the getcontent method to determine the type of the remote object; subclasses may find it convenient to override the getcontenttype method. Department of of Computer Science and Engineering, Sogang University Page 29 CAD & VLSI Lab. Page Youse 29 / Kim 35

Example urlconnectiontest.java import java.util.date; class urlconnectiontest { public static void main(string args[]) throws Exception { int c; URL addr = new URL("http://www.sogang.ac.kr/wwwnew/index2.html"); URLConnection addrconnection = addr.openconnection(); System.out.println("Document Type : " + addrconnection.getcontenttype()); System.out.println("Last Modified : " + new Date(addrConnection.getLastModified())); int len = addrconnection.getcontentlength(); System.out.println("Document Length : " + len + "byte"); if (len > 0) { System.out.println(" ===== Contents ======= "); InputStream input = addrconnection.getinputstream(); int i = len; while (((c = input.read())!= -1) && (--i > 0)) { System.out.print((char) c); } input.close(); } else { System.out.println("No Contents"); } }} Department of of Computer Science and Engineering, Sogang University Page 30 CAD & VLSI Lab. Page Youse 30 / Kim 35

Department of of Computer Science and Engineering, Sogang University Page 31 CAD & VLSI Lab. Page Youse 31 / Kim 35

Department of of Computer Science and Engineering, Sogang University Page 32 CAD & VLSI Lab. Page Youse 32 / Kim 35

Socket ServerSocket class ServerSocket(int port) Creates a server socket on a specified port. ServerSocket(int port, int backlog) Creates a server socket and binds it to the specified local port number. ServerSocket(int port, int backlog, InetAddress bindaddr) Create a server with the specified port, listen backlog, and local IP address to bind to. Department of of Computer Science and Engineering, Sogang University Page 33 CAD & VLSI Lab. Page Youse 33 / Kim 35

Example) ServerSide.java import java.io.*; import java.net.*; class ServerSide { public static void main(string args[]) { try { int port = Integer.parseInt(args[0]); ServerSocket ss = new ServerSocket(port); while(true) { Socket s = ss.accept(); OutputStream os = s.getoutputstream(); DataOutputStream dos = new DataOutputStream(os); for (int i = 1; i <= 10; i++) dos.writeint(i); s.close(); }} catch(exception e) { System.out.println("Exception: " + e); }}} Department of of Computer Science and Engineering, Sogang University Page 34 CAD & VLSI Lab. Page Youse 34 / Kim 35

Example) ClientSide.java import java.io.*; import java.net.*; class ClientSide { public static void main(string args[]) { try { String server = args[0]; int port = Integer.parseInt(args[1]); Socket c = new Socket(server, port); InputStream is = c.getinputstream(); DataInputStream dis = new DataInputStream(is); for (int i = 1; i <= 10; i++) { int j = dis.readint(); System.out.println("data from server " + j); } c.close();} catch(exception e) { System.out.println("Exception: " + e); }}} Department of of Computer Science and Engineering, Sogang University Page 35 CAD & VLSI Lab. Page Youse 35 / Kim 35