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.
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,
Gursharan Singh Tatla SLIP and PPP 27-Mar
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.
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.
Network Concepts. Networks LAN WAN Main Concepts n Protocol n Media n Topology.
TDC 461 Basic Communications Systems Local Area Networks 29 May, 2001.
5: DataLink Layer – Ethernet, Hubs and Switches.
1 Interconnection ECS 152A. 2 Interconnecting with hubs r Backbone hub interconnects LAN segments r Extends max distance between nodes r But individual.
04/26/2004CSCI 315 Operating Systems Design1 Computer Networks.
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.
© Janice Regan, CMPT 128, CMPT 371 Data Communications and Networking Ethernet, ARP.
Point to Point protocol (PPP) Point to point, wired data link easier to manage than broadcast link: no Media Access Control Several Data Link Protocols:
SIMS-201 LAN Basics, MANs, WANs.
 It defines the format of the frame to be exchanged between devices.  It defines how two devices can negotiate the establishment of the link and the.
21.1 Chapter 21 Network Layer: Address Mapping, Error Reporting, and Multicasting Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction.
Chapter 5 outline 5.1 Introduction and services
The Network Layer. Network Projects Must utilize sockets programming –Client and Server –Any platform Please submit one page proposal Can work individually.
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.
CSCE 515: Computer Network Programming Chin-Tser Huang University of South Carolina.
Robert E. Meyers CCNA, CCAI Youngstown State University Cisco Regional Academy Instructor Cisco Networking Academy Program Semester 4, v Chapter.
1 Computer Communication & Networks Lecture 13 Datalink Layer: Local Area Network Waleed Ejaz
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.
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
Chapter 9 Hardware Addressing and Frame Type Identification 1.Delivering and sending packets 2.Hardware addressing: specifying a destination 3. Broadcasting.
1 Physical and Data Link Layer Computer Network System Sirak Kaewjamnong.
Lecture 4 Overview. Ethernet Data Link Layer protocol Ethernet (IEEE 802.3) is widely used Supported by a variety of physical layer implementations Multi-access.
5: DataLink Layer5-1 Chapter 5 Link Layer and LANs Computer Networking: A Top Down Approach Featuring the Internet, 3 rd edition. Jim Kurose, Keith Ross.
Ch 5. The Link Layer and Local Area Networks Myungchul Kim
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.
CSCE 515: Computer Network Programming Chin-Tser Huang University of South Carolina.
CS 457 – Lecture 3 Link Layer Protocols Fall 2011.
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.
Chapter 8 ARP(Address Resolution Protocol)
Ethernet Frame Structure
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:
Point to Point Data Link Control
Hubs Hubs are essentially physical-layer repeaters:
Multiplexing/Demux.
Presentation transcript:

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

1/27/20052 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/27/20053 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/27/20054 Class Thread Instance Methods void run() void setPriority(int newPriority) int getPriority() void start() void stop()

1/27/20055 Interface Runnable Method void run()

1/27/20056 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/27/20057 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/27/20058 Constructor MTEchoServer protected Socket socket; MTEchoServer (Socket socket) { this.socket = socket; }

1/27/20059 Method run public void run () { try { InputStream in = socket.getInputStream (); OutputStream out = socket.getOutputStream (); 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/27/ 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/27/ 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/27/ 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/27/ 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/27/ Ethernet Frame Dest. address Source address PreambleDataCRCType

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

1/27/ 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/27/ 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/27/ Point-to-Point Protocol (PPP) Three components Framing mechanism Link control protocol (LCP) Network control protocol (NCP) Fix deficiencies in SLIP

1/27/ Requirements of PPP Packet framing Transparency Multiple network-layer protocols Multiple types of links Error detection Connection liveness Network-layer address negotiation Simplicity

1/27/ PPP Data Framing Data Variable length 1 Flag Address Control Protocol 1 or Flag Check 2 or 4

1/27/ PPP Byte Stuffing When flag pattern appears in data, PPP stuffs a control escape byte before it PPP b b2 b4 b5 PPP b b4 b2 b1 b b4b5

1/27/ Loopback Interface Used for communication between client and server on the same host, and for functionality testing Class A network ID 127 reserved for lookback interface 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 addresses to loopback interface

1/27/ 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/27/ Next Class ARP RARP IP Read TI Ch. 3, 4, 5