Multiplexing/Demux. CPSC 441 - Transport Layer 3-2 Multiplexing/demultiplexing application transport network link physical P1 application transport network.

Slides:



Advertisements
Similar presentations
Socket Programming ENTERPRISE JAVA. 2 Content  Sockets  Streams  Threads  Readings.
Advertisements

Transport Layer3-1 Transport Overview and UDP. Transport Layer3-2 Goals r Understand transport services m Multiplexing and Demultiplexing m Reliable data.
Introduction 1-1 Chapter 3 Transport Layer Intro and Multiplexing Computer Networking: A Top Down Approach 6 th edition Jim Kurose, Keith Ross Addison-Wesley.
CPSC 441: Intro, UDP1 Transport Layer Instructor: Carey Williamson Office: ICT Class Location:
EEC-484/584 Computer Networks Lecture 12 Wenbing Zhao (Part of the slides are based on Drs. Kurose & Ross ’ s slides for their Computer.
Computer Communication Digital Communication in the Modern World Transport Layer Multiplexing, UDP
Chapter 3: Transport Layer
2: Application Layer1 Data Communication and Networks Lecture 12 Java Sockets November 30, 2006.
Introduction to Transport Layer. Transport Layer: Motivation A B R1 R2 r Recall that NL is responsible for forwarding a packet from one HOST to another.
Transport Layer3-1 Transport Layer Our goals: r understand principles behind transport layer services: m multiplexing/demultipl exing m reliable data transfer.
Lecture 8 Chapter 3 Transport Layer
CPSC 441: Intro, UDP1 Instructor: Anirban Mahanti Office: ICT Class Location: ICT 121 Lectures: MWF 12:00 – 12:50 Notes.
TCP Socket Programming CPSC 441 Department of Computer Science University of Calgary.
Some slides are in courtesy of J. Kurose and K. Ross Review of Previous Lecture Electronic Mail: SMTP, POP3, IMAP DNS Socket programming with TCP.
3-1 Transport services and protocols r provide logical communication between app processes running on different hosts r transport protocols run in end.
1 Computer Networks Transport Layer Protocols. 2 Application-layer Protocols Application-layer protocols –one “piece” of an app –define messages exchanged.
8-1 Transport Layer Our goals: r understand principles behind transport layer services: m multiplexing/demultipl exing m reliable data transfer m flow.
EEC-484/584 Computer Networks Lecture 6 Wenbing Zhao (Part of the slides are based on Drs. Kurose & Ross ’ s slides for their Computer.
Transport Layer Transport Layer. Transport Layer 3-2 Chapter 3 Transport Layer Computer Networking: A Top Down Approach Featuring the Internet,
CS4273: Distributed System Technologies and Programming I Lecture 5: Java Socket Programming.
Review: –What is AS? –What is the routing algorithm in BGP? –How does it work? –Where is “policy” reflected in BGP (policy based routing)? –Give examples.
Data Communications and Computer Networks Chapter 3 CS 3830 Lecture 12 Omar Meqdadi Department of Computer Science and Software Engineering University.
CS 1652 The slides are adapted from the publisher’s material All material copyright J.F Kurose and K.W. Ross, All Rights Reserved Jack Lange.
Network LayerII-1 RSC Part III: Transport Layer 1. Basic Concepts Redes y Servicios de Comunicaciones Universidad Carlos III de Madrid These slides are,
REVIEW On Friday we explored Client-Server Applications with Sockets. Servers must create a ServerSocket object on a specific Port #. They then can wait.
Transport Layer 3-1 Chapter 3 Transport Layer Computer Networking: A Top Down Approach 6 th edition Jim Kurose, Keith Ross Addison-Wesley March 2012 Part.
Chapter 3 Transport Layer
Transport Layer3-1 Chapter 3: Transport Layer Our goals: r understand principles behind transport layer services: m multiplexing/demultipl exing m reliable.
Transport Layer 3-1 Chapter 3 Transport Layer Computer Networking: A Top Down Approach 6 th edition Jim Kurose, Keith Ross Addison-Wesley March 2012 A.
Transport Layer3-1 Chapter 3 Transport Layer Computer Networking: A Top Down Approach Featuring the Internet, 2 nd edition. Jim Kurose, Keith Ross Addison-Wesley,
Transport Layer3-1 Chapter 3: Transport Layer Our goals: r understand principles behind transport layer services: m multiplexing/demultipl exing m reliable.
Transport Layer1 Ram Dantu (compiled from various text books)
Lecture91 Administrative Things r Return homework # 1 r Review some problems in homework # 1 r Questions about grading? Yona r WebCT for CSE245 is working!
Li Tak Sing COMPS311F. Case study: consumers and producers A fixed size buffer which can hold at most certain integers. A number of producers which generate.
CS 3830 Day 13 Introduction 1-1. Announcements r Quiz 3: Wednesday, Oct 10 r Prog3 due Wednesday, Oct 10 Transport Layer 3-2.
Transport Layer3-1 Chapter 3 Transport Layer Computer Networking: A Top Down Approach 4 th edition. Jim Kurose, Keith Ross Addison-Wesley, July A.
Transport Layer 3-1 Chapter 3 Outline r 3.1 Transport-layer services r 3.2 Multiplexing and demultiplexing r 3.3 Connectionless transport: UDP.
Chapter 3: Transport Layer Our goals: r understand principles behind transport layer services: m multiplexing/demultipl exing m reliable data transfer.
Transport Layer3-1 Chapter 3 Transport Layer Computer Networking: A Top Down Approach Featuring the Internet, 3 rd edition. Jim Kurose, Keith Ross Addison-Wesley,
Part 4: Network Applications Client-server interaction, example applications.
Prof. Younghee Lee 1 1 Computer Networks u Lecture 5: Transport services and protocols Prof. Younghee Lee * Some part of this teaching materials are prepared.
MULTIPLEXING/DEMULTIPLEXING, CONNECTIONLESS TRANSPORT.
MT311 Java Application Development and Programming Languages Li Tak Sing ( 李德成 )
Transport Layer3-1 Chapter 3: Transport Layer Our goals: r understand principles behind transport layer services: m multiplexing/demultipl exing m reliable.
Introduction 1-1 source application transport network link physical HtHt HnHn M segment HtHt datagram destination application transport network link physical.
Spring 2006 CPE : Transport Layer Overview2-1 Special Topics in Computer Engineering The Transport Layer in the Internet: Overview Some of these.
CSEN 404 Transport Layer I Amr El Mougy Lamia Al Badrawy.
Transport Layer3-1 Transport Layer Never take life seriously. Nobody gets out alive anyway.
Chapter 3 Transport Layer
Introduction to Networks
Chapter 3 Transport Layer
Transport Layer Slides are originally from instructor: Carey Williamson at University of Calgary Very minor modification are made Notes derived from “Computer.
Chapter 3 outline 3.1 Transport-layer services
06- Transport Layer Transport Layer.
CS 1652 Jack Lange University of Pittsburgh
Introduction to Networks
Transport Layer Our goals:
September 19th, 2013 CS1652 Jack Lange University of Pittsburgh
Transport Protocols Relates to Lab 5. An overview of the transport protocols of the TCP/IP protocol suite. Also, a short discussion of UDP.
Transport Layer Our goals:
Chapter 3 Transport Layer
CSCD 330 Network Programming
Chapter 5 Transport Layer Introduction
Multiplexing/Demux.
Computer Networks Protocols
Chapter 3 Transport Layer
Transport Layer Our goals:
Presentation transcript:

Multiplexing/Demux

CPSC Transport Layer 3-2 Multiplexing/demultiplexing application transport network link physical P1 application transport network link physical application transport network link physical P2 P3 P4 P1 host 1 host 2 host 3 = process= socket delivering received segments to correct socket Demultiplexing at rcv host: gathering data from multiple sockets, enveloping data with header (later used for demultiplexing) Multiplexing at send host:

CPSC Transport Layer 3-3 How demultiplexing works r host receives IP datagrams m each datagram has source IP address, destination IP address m each datagram carries 1 transport-layer segment m each segment has source, destination port number r host uses IP addresses & port numbers to direct segment to appropriate socket source port #dest port # 32 bits application data (message) other header fields TCP/UDP segment format

CPSC Transport Layer 3-4 Connectionless demultiplexing r Create sockets with port numbers: DatagramSocket mySocket1 = new DatagramSocket(12534); DatagramSocket mySocket2 = new DatagramSocket(12535); r UDP socket identified by two-tuple: ( dest IP address, dest port number) r When host receives UDP segment: m checks destination port number in segment m directs UDP segment to socket with that port number r IP datagrams with different source IP addresses and/or source port numbers directed to same socket

CPSC Transport Layer 3-5 Connectionless demux (cont) DatagramSocket serverSocket = new DatagramSocket(6428); Client IP:B P2 client IP: A P1 P3 server IP: C SP: 6428 DP: 9157 SP: 9157 DP: 6428 SP: 6428 DP: 5775 SP: 5775 DP: 6428 SP provides “return address”

CPSC Transport Layer 3-6 Connection-oriented demux r TCP socket identified by 4-tuple: m source IP address m source port number m dest IP address m dest port number r recv host uses all four values to direct segment to appropriate socket r Server host may support many simultaneous TCP sockets: m each socket identified by its own 4-tuple r Web servers have different sockets for each connecting client m non-persistent HTTP will have different socket for each request

CPSC Transport Layer 3-7 Connection-oriented demux (cont) Client IP:B P1 client IP: A P1P2P4 server IP: C SP: 9157 DP: 80 SP: 9157 DP: 80 P5P6P3 D-IP:C S-IP: A D-IP:C S-IP: B SP: 5775 DP: 80 D-IP:C S-IP: B

CPSC Transport Layer 3-8 Connection-oriented demux: Threaded Web Server Client IP:B P1 client IP: A P1P2 server IP: C SP: 9157 DP: 80 SP: 9157 DP: 80 P4 P3 D-IP:C S-IP: A D-IP:C S-IP: B SP: 5775 DP: 80 D-IP:C S-IP: B

Java Threads

Introduction r TCP echo server shown in earlier tutorial handles one client at a time. r This server is known as iterative server. r Iterative servers handle clients sequentially, finishing with one client before servicing the next. r Java threads: Helps servers handle many client simultaneously.

11 Threading Mechanisms  Create a class that extends the Thread class  Create a class that implements the Runnable interface Thread MyThread Runnable MyClass Thread (objects are threads) (objects with run() body) [a][b]

12 1st method: Extending Thread class r Create a class by extending Thread class and override run() method: class MyThread extends Thread { public void run() { // thread body of execution }  Create a thread: MyThread thr1 = new MyThread();  Start Execution of threads: thr1.start(); r Create and Execute: new MyThread().start();

13 Template class MyThread extends Thread { public void run() { System.out.println(" this thread is running... "); } class ThreadEx1 { public static void main(String [] args ) { MyThread t = new MyThread(); t.start(); }

14 2nd method: Threads by implementing Runnable interface r Create a class that implements the interface Runnable and override run() method: class MyThread implements Runnable {..... public void run() { // thread body of execution } r Creating Object: MyThread myObject = new MyThread(); r Creating Thread Object: Thread thr1 = new Thread( myObject ); r Start Execution: thr1.start();

15 Template class MyThread implements Runnable { public void run() { System.out.println(" this thread is running... "); } class ThreadEx2 { public static void main(String [] args ) { Thread t = new Thread(new MyThread()); t.start(); }

Example of Java Threads public class ThreadExample implements Runnable { private String greeting; public ThreadExample(String greeting) { this.greeting = greeting; } public void run( ) { while(true) { System.out.println(Thread.currentThread( ).getName( ) + ": "+greeting); try { TimeUnit.MILLISECONDS.sleep(((long) Math.random( ) * 100)); } catch(InterruptedException e) { } public static void main(String [ ] args) { new Thread(new ThreadExample(“Greeting 1")).start( ); new Thread(new ThreadExample(“Greeting 2")).start( ); new Thread(new ThreadExample(“Greeting 3")).start( ); } Each instance of ThreadExample contains own greeting string ThreadExample implements Runnable interface; it can be passed to the constructor of Thread Returns reference to current thread Returns name of thread as string Suspend the thread; Thread sleeps for random amount of time. 1.Create new instance of ThreadExample with different greeting 2.Passes new instance to the constructor of Thread. 3.Calls new Thread instance's start() Each thread independently executes run() of ThreadExample, while the main thread terminates. Upon execution an interleaving of three greeting messages is printed

Multithreaded Java Server import java.io.*; import java.net.*; public class MultiThreadServer implements Runnable { Socket csocket; MultiThreadServer(Socket csocket) { this.csocket = csocket; } public static void main(String args[]) throws Exception { ServerSocket ssock = new ServerSocket(1234); System.out.println("Listening"); while (true) { Socket sock = ssock.accept(); System.out.println("Connected"); new Thread(new MultiThreadServer(sock)).start(); } public void run() { try { PrintStream pstream = new PrintStream(csocket.getOutputStream()); for (int i = 100; i >= 0; i--) { pstream.println(i + " counts"); } pstream.close(); csocket.close(); } catch (IOException e) { System.out.println(e); }