CSCE 515: Computer Network Programming Chin-Tser Huang University of South Carolina.

Slides:



Advertisements
Similar presentations
1 Data Link Issues Relates to Lab 2. This module covers data link layer issues, such as local area networks (LANs) and point-to-point links, Ethernet,
Advertisements

Multiplexing/Demux. CPSC Transport Layer 3-2 Multiplexing/demultiplexing application transport network link physical P1 application transport network.
1 ICS 156: Lecture 2 (part 2) Data link layer protocols Address resolution protocol Notes on lab 2.
Computer Networks Ethernet I Professor Hui Zhang
1 Data Link Protocols Relates to Lab 2. This module covers data link layer issues, such as local area networks (LANs) and point-to-point links, Ethernet,
CSCE 515: Computer Network Programming Chin-Tser Huang University of South Carolina.
5/31/05CS118/Spring051 twisted pair hub 10BaseT, 100BaseT, hub r T= Twisted pair (copper wire) r Nodes connected to a hub, 100m max distance r Hub: physical.
Department of Computer Engineering University of California at Santa Cruz Networking Systems (1) Hai Tao.
CSCE 515: Computer Network Programming Chin-Tser Huang University of South Carolina.
CSCE 515: Computer Network Programming Chin-Tser Huang University of South Carolina.
CSCE 515: Computer Network Programming Chin-Tser Huang University of South Carolina.
CSCE 515: Computer Network Programming Chin-Tser Huang University of South Carolina.
Semester 4 - Chapter 4 – PPP WAN connections are controlled by protocols In a LAN environment, in order to move data between any two nodes or routers two.
CSCE 515: Computer Network Programming Chin-Tser Huang University of South Carolina.
CSCE 515: Computer Network Programming Chin-Tser Huang University of South Carolina.
TDC 461 Basic Communications Systems Local Area Networks 29 May, 2001.
5: DataLink Layer – Ethernet, Hubs and Switches.
04/26/2004CSCI 315 Operating Systems Design1 Computer Networks.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved L22 (Chapter 25) Networking.
5-1 Data Link Layer r Today, we will study the data link layer… r This is the last layer in the network protocol stack we will study in this class…
CSCE 515: Computer Network Programming Chin-Tser Huang University of South Carolina.
CSCE 515: Computer Network Programming Chin-Tser Huang University of South Carolina.
CSCE 515: Computer Network Programming Chin-Tser Huang University of South Carolina.
IST 228\Ch1\Internetworking1 Collision/Broadcast Domain The term collision domain defines the set of devices for which their frames could collide A broadcast.
Chapter 6 High-Speed LANs Chapter 6 High-Speed LANs.
Chapter 2 The Infrastructure. Copyright © 2003, Addison Wesley Understand the structure & elements As a business student, it is important that you understand.
Ethernet Two nodes transmit at the same time
Introduction1-1 Data Communications and Computer Networks Chapter 5 CS 3830 Lecture 27 Omar Meqdadi Department of Computer Science and Software Engineering.
1 Computer Communication & Networks Lecture 13 Datalink Layer: Local Area Network Waleed Ejaz
CMPT 471 Networking II Address Resolution IPv4 ARP RARP 1© Janice Regan, 2012.
Layer 2 Technologies At layer 2 we create and transmit frames over communications channels Format of frames and layer 2 transmission protocols are dependent.
School of Engineering and Computer Science Victoria University of Wellington Copyright: Peter Andreae david streader, VUW Echo Networking COMP
Practicum: - Client-Server Computing in Java Fundamental Data Structures and Algorithms Margaret Reid-Miller 13 April 2004.
1 Data Link Layer Lecture 22 Imran Ahmed University of Management & Technology.
Data Link Layer Moving Frames. Link Layer Protocols: ethernet, wireless, Token Ring and PPP Has node-to-node job of moving network layer.
5: DataLink Layer5-1 Link Layer r 5.1 Introduction and services r 5.2 Error detection and correction r 5.3Multiple access protocols r 5.4 Link-Layer Addressing.
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.
CSCE 515: Computer Network Programming Chin-Tser Huang University of South Carolina.
1 Network Programming and Java Sockets. 2 Network Request Result a client, a server, and network Client Server Client machine Server machine Elements.
School of Engineering and Computer Science Victoria University of Wellington Copyright: Peter Andreae, VUW Networking COMP # 22.
Networks Sockets and Streams. TCP/IP in action server ports …65535 lower port numbers ( ) are reserved port echo7 time13 ftp20 telnet23.
Networking Terminology: ISP (Internet service provider) – dialup, dsl, cable LAN (local area network) IP (internet protocol) address, eg
1 Physical and Data Link Layer Computer Network System Sirak Kaewjamnong.
Ch 5. The Link Layer and Local Area Networks Myungchul Kim
Slide #1 CIT 380: Securing Computer Systems TCP/IP.
UNIT-6. Basics of Networking TCP/IP Sockets Simple Client Server program Multiple clients Sending file from Server to Client Parallel search server.
EE 122: Lecture 6 Ion Stoica September 13, 2001 (* this talk is based in part on the on-line slides of J. Kurose & K. Rose)
1 CSCD 330 Network Programming Fall 2013 Some Material in these slides from J.F Kurose and K.W. Ross All material copyright Lecture 8a Application.
MT311 Java Application Development and Programming Languages Li Tak Sing ( 李德成 )
5: DataLink Layer5-1 Hubs Hubs are essentially physical-layer repeaters: m bits coming from one link go out all other links m at the same rate m no frame.
© Jörg Liebeherr (modified by M. Veeraraghavan) 1 Point-to-Point Protocol Data Link Layer Loopback ARP and RARP.
Spring/2002 Distributed Software Engineering C:\unocourses\4350\slides\DefiningThreads 1 Java API for distributed computing.
Data Link Protocols Relates to Lab 2.
Computer networks. Topologies Point to point Bus (rail) Ring Tree, star, etc.
CSCE 515: Computer Network Programming Chin-Tser Huang University of South Carolina.
Network Programming. These days almost all devices.
School of Engineering and Computer Science Victoria University of Wellington Copyright: Peter Andreae david streader, VUW Echo Networking COMP
Data Link Issues Relates to Lab 2.
Behrouz A. Forouzan TCP/IP Protocol Suite, 3rd Ed.
Link Layer 5.1 Introduction and services
Data Link Issues This module covers data link layer issues, such as local area networks (LANs) and point-to-point links, Ethernet, and the Point-to-Point.
Echo Networking COMP
Chapter 8 ARP(Address Resolution Protocol)
CS 280: Summary: A day in the life of a web request
ARP and RARP Objectives Chapter 7 Upon completion you will be able to:
Data Link Issues This module covers data link layer issues, such as local area networks (LANs) and point-to-point links, Ethernet, and the Point-to-Point.
Hubs Hubs are essentially physical-layer repeaters:
Hubs Hubs are essentially physical-layer repeaters:
Multiplexing/Demux.
Presentation transcript:

CSCE 515: Computer Network Programming Chin-Tser Huang University of South Carolina

1/29/20042 Write a Multithreaded Server Benefits of multithreaded server Exceptions and problems with a connection is limited to corresponding thread Implementation is cleaner Two ways of making your server multithreaded Extend Thread class Implement Runnable interface

1/29/20043 Class Thread Constructors Thread(String name) Thread(Runnable target) Static Methods static int activeCount() static Thread currentThread() static void sleep(long millis) throws InterruptedException static void yield()

1/29/20044 Class Thread Instance Methods void run() void setPriority(int newPriority) int getPriority() void start() void stop()

1/29/20045 Interface Runnable Method void run()

1/29/20046 A Multithreaded Echo Server Example Main thread accepts connections and launches a new handler thread for each connection Each handler thread echoes received data back to sender

1/29/20047 MTEchoServer.java /* * Java Network Programming, Second Edition * Merlin Hughes, Michael Shoffner, Derek Hamner * Manning Publications Company; ISBN X * * * * Copyright (c) Merlin Hughes, Michael Shoffner, Derek Hamner; * all rights reserved; see license.txt for details. */ import java.net.*; import java.io.*; public class MTEchoServer extends Thread { // MTEchoServer (Socket socket) … // public void run () … // public static void main (String[] args) throws IOException … }

1/29/20048 Constructor MTEchoServer protected Socket socket; MTEchoServer (Socket socket) { this.socket = socket; }

1/29/20049 Method run public void run () { try { InputStream in = socket.getInputStream (); OutputStream out = socket.getOutputStream (); out.write ("Welcome to the multithreaded echo server.\r\n".getBytes ("latin1")); byte[] buffer = new byte[1024]; int read; while ((read = in.read (buffer)) >= 0) out.write (buffer, 0, read); } catch (IOException ex) { ex.printStackTrace (); } finally { try { socket.close (); } catch (IOException ignored) { }

1/29/ Method main public static void main (String[] args) throws IOException { if (args.length != 1) throw new IllegalArgumentException ("Syntax: MTEchoServer "); System.out.println ("Starting on port " + args[0]); ServerSocket server = new ServerSocket (Integer.parseInt (args[0])); while (true) { Socket client = server.accept (); MTEchoServer echo = new MTEchoServer (client); echo.start (); }

1/29/ Link Layer Three purposes of link layer Send and receive IP datagrams for IP module Send and receive ARP requests and replies for ARP module Send and receive RARP requests and replies for RARP module

1/29/ Link Layer Channel Two types of link layer channels Broadcast: e.g. LAN, wireless LAN Point-to-point: e.g. between router and router or between dialup modem and ISP router Ethernet for broadcast channel SLIP and PPP for point-to-point link

1/29/ Ethernet Most popular LAN technology because of its simplicity Different flavors of Ethernet Bus topology, star topology Coaxial cable, twisted-pair copper wire, fiber optics 10Mbps, 100Mbps, 1Gbps, 10Gbps Use 48-bit addresses

1/29/ Ethernet Frame Dest. address Source address PreambleDataCRCType

1/29/ Ethernet Frame Demultiplexing Ethernet driver ARP IP RARP incoming frame

1/29/ CSMA/CD Carrier Sense: an adapter never transmits a frame when it senses that other adapter is transmitting Multiple access: any adapter can transmit at any time Collision detection: an adapter aborts its transmission as soon as it detects other adapter is also transmitting, and waits a random time to retransmit

1/29/ Serial Line IP (SLIP) A simple form of encapsulation for IP datagrams on serial lines Put delimiter bytes around both end of datagram, and use escape bytes to replace occurrences of delimiter bytes in datagram Some deficiencies of SLIP No negotiation of IP addresses No type field No checksum

1/29/ Point-to-Point Protocol (PPP) Three components High-level data link control protocol (HDLC) Link control protocol (LCP) Network control protocol (NCP) Fix deficiencies in SLIP

1/29/ Loopback Interface Used for communication between client and server on the same host, and for functionality testing Assigned the address and the name localhost Loopback interface puts every received datagram on IP input queue Make a copy of every datagram sent to multicast or broadcast addresses to loopback interface Forward any IP datagram sent to one of host’s own IP address to loopback interface

1/29/ Maximum Transmission Unit (MTU) Limit on Ethernet frame size If IP datagram is larger than MTU, IP needs to perform fragmentation Need to discover path MTU if communicating across networks

1/29/ Next Class ARP RARP IP Read TI Ch. 3, 4, 5