SSC - Communication and Networking Java Socket Programming (II)



Similar documents
Chapter 11. User Datagram Protocol (UDP)

Network-based Applications. Pavani Diwanji David Brown JavaSoft

Network layer: Overview. Network layer functions IP Routing and forwarding

Data Communication & Networks G

Indian Institute of Technology Kharagpur. TCP/IP Part I. Prof Indranil Sengupta Computer Science and Engineering Indian Institute of Technology

The difference between TCP/IP, UDP/IP and Multicast sockets. How servers and clients communicate over sockets

Network Programming using sockets

IP Network Layer. Datagram ID FLAG Fragment Offset. IP Datagrams. IP Addresses. IP Addresses. CSCE 515: Computer Network Programming TCP/IP

NAT & IP Masquerade. Internet NETWORK ADDRESS TRANSLATION INTRODUCTION. NAT & IP Masquerade Page 1 of 5. Internal PC

Chapter 3. TCP/IP Networks. 3.1 Internet Protocol version 4 (IPv4)

User Datagram Protocol - Wikipedia, the free encyclopedia

Network Layer IPv4. Dr. Sanjay P. Ahuja, Ph.D. Fidelity National Financial Distinguished Professor of CIS. School of Computing, UNF

IP - The Internet Protocol

IP Subnetting and Addressing

Lecture 2-ter. 2. A communication example Managing a HTTP v1.0 connection. G.Bianchi, G.Neglia, V.Mancuso

Mobile IP Network Layer Lesson 02 TCP/IP Suite and IP Protocol

Network Communication

NETWORKING FEATURES OF THE JAVA PROGRAMMING LANGUAGE

Transport layer protocols. Message destination: Socket +Port. Asynchronous vs. Synchronous. Operations of Request-Reply. Sockets

IP addressing and forwarding Network layer

Subnetting,Supernetting, VLSM & CIDR

Chapter 3. Internet Applications and Network Programming

Slide 1 Introduction cnds@napier 1 Lecture 6 (Network Layer)

Internet Packets. Forwarding Datagrams

Basic Networking Concepts. 1. Introduction 2. Protocols 3. Protocol Layers 4. Network Interconnection/Internet

Socket Programming in Java

Network-Oriented Software Development. Course: CSc4360/CSc6360 Instructor: Dr. Beyah Sessions: M-W, 3:00 4:40pm Lecture 2

EITF25 Internet Techniques and Applications L5: Wide Area Networks (WAN) Stefan Höst

Gary Hecht Computer Networking (IP Addressing, Subnet Masks, and Packets)

Network Layer: Network Layer and IP Protocol

CS 457 Lecture 19 Global Internet - BGP. Fall 2011

Note! The problem set consists of two parts: Part I: The problem specifications pages Part II: The answer pages

Socket Programming. Announcement. Lectures moved to

Chapter 9. IP Secure

Module 7 Internet And Internet Protocol Suite

IP Multicasting. Applications with multiple receivers

Transport Layer. Chapter 3.4. Think about

Network Layer. Introduction Datagrams and Virtual Circuits Routing Traffic Control. Data delivery from source to destination.

Transport Layer Protocols

First Workshop on Open Source and Internet Technology for Scientific Environment: with case studies from Environmental Monitoring

DNS: Domain Names. DNS: Domain Name System. DNS: Root name servers. DNS name servers

ICOM : Computer Networks Chapter 6: The Transport Layer. By Dr Yi Qian Department of Electronic and Computer Engineering Fall 2006 UPRM

Scaling the Network: Subnetting and Other Protocols. Networking CS 3470, Section 1

8.2 The Internet Protocol

NETWORK LAYER/INTERNET PROTOCOLS

Course Overview: Learn the essential skills needed to set up, configure, support, and troubleshoot your TCP/IP-based network.

Ethernet. Ethernet. Network Devices

ICT SEcurity BASICS. Course: Software Defined Radio. Angelo Liguori. SP4TE lab.

04 Internet Protocol (IP)

Network Programming TDC 561

Internet Protocol (IP) IP - Network Layer. IP Routing. Advantages of Connectionless. CSCE 515: Computer Network Programming IP routing

How To Understand The Internet Of S (Netware)

Overview. Securing TCP/IP. Introduction to TCP/IP (cont d) Introduction to TCP/IP

Technical Support Information Belkin internal use only

IP address format: Dotted decimal notation:

Encapsulating Voice in IP Packets

Understanding TCP/IP. Introduction. What is an Architectural Model? APPENDIX

PART OF THE PICTURE: The TCP/IP Communications Architecture

Transport and Network Layer

CS335 Sample Questions for Exam #2

What is CSG150 about? Fundamentals of Computer Networking. Course Outline. Lecture 1 Outline. Guevara Noubir noubir@ccs.neu.

Tutorial on Socket Programming

Компјутерски Мрежи NAT & ICMP

Layer Four Traceroute (and related tools) A modern, flexible path-discovery solution with advanced features for network (reverse) engineers

(Refer Slide Time: 02:17)

Lecture 15. IP address space managed by Internet Assigned Numbers Authority (IANA)

Multiple Choice Questions

NETWORK PROGRAMMING IN JAVA USING SOCKETS

Lecture 28: Internet Protocols

Objectives of Lecture. Network Architecture. Protocols. Contents

Improved Digital Media Delivery with Telestream HyperLaunch

Internet Control Protocols Reading: Chapter 3

Network Layer: and Multicasting Copyright The McGraw-Hill Companies, Inc. Permission required for reproduction or display.

Network Address Translation (NAT)

Overview of TCP/IP. TCP/IP and Internet

Internet Infrastructure Measurement: Challenges and Tools

4m. MONITORING OF ETHERNET/IP NETWORK TRAFFIC.

VoIP Bandwidth Calculation

Generalised Socket Addresses for Unix Squeak

Note! The problem set consists of two parts: Part I: The problem specifications pages Part II: The answer pages

Protocols and Architecture. Protocol Architecture.

IP addressing. Interface: Connection between host, router and physical link. IP address: 32-bit identifier for host, router interface

Computer Networks UDP and TCP

Network Intrusion Detection Systems. Beyond packet filtering

Per-Flow Queuing Allot's Approach to Bandwidth Management

ICS 351: Today's plan. IP addresses Network Address Translation Dynamic Host Configuration Protocol Small Office / Home Office configuration

Internet Protocols. Background CHAPTER

Computer Networks 1 (Mạng Máy Tính 1) Lectured by: Dr. Phạm Trần Vũ

The OSI and TCP/IP Models. Lesson 2

Java Programming: Sockets in Java

Protocol Data Units and Encapsulation

APPENDIX B. Routers route based on the network number. The router that delivers the data packet to the correct destination host uses the host ID.

TCP/IP Fundamentals. OSI Seven Layer Model & Seminar Outline

Networking Test 4 Study Guide

[Prof. Rupesh G Vaishnav] Page 1

Access Control: Firewalls (1)

Internetworking. Problem: There is more than one network (heterogeneity & scale)

Transcription:

SSC - Communication and Networking Java Socket Programming (II) Shan He School for Computational Science University of Birmingham Module 06-19321: SSC

Outline Outline of Topics Multicast in Java

User Datagram Protocol (UDP) Sends independent packets of data (called datagrams) between computers without guarantees about arrival and sequencing. Transaction-oriented: suitable for simple query-response protocols, Examples: clock server, Domain Name System,... Not connection-oriented (point-to-point) like TCP: suitable for very large numbers of clients Examples: streaming media applications, e.g., IPTV Faster: no acknowledge of receiving packets, no flow control and very simple error control (only check errors but no correction). Examples: Voice over IP, online games,...

Datagrams Datagrams: an independent, self-contained message sent over the network whose arrival, arrival time, and content are not guaranteed. UDP header consists of 4 fields, each of which is 16 bits Table : UDB datagram Bit 0-15 16-35 0 Source port Destination port 32 Length Checksum... Data

Datagrams: checksum Used for error-checking of the UDP header and data Also include IP address to prevent misrouting Basic idea: the complement of a 16-bit sum calculated over an IP pseudo-header and the actual UDP data. A pseudo-header: the IP header and the UDP header without checksum field At the receiver end: all the 16-bit words of the headers plus data area are added together = Sum Sum + Checksum = 11111111 11111111

Datagrams: checksum calculation Source IP address UDP total length Protocol Destination IP address Source port number Data Destination port number

UDP datagram communication in Java Two packages in java.net package: DatagramPacket : contains several constructors for creating datagram packet object Example: DatagramPacket(byte[] buf, int length, InetAddress address, int port); DatagramSocket : provides various methods for transmitting or receiving datagrams over the network Example: void send(datagrampacket p) or void receive(datagrampacket p)

Example 1: UDP word counting server We will create a simple UDP server waits for clients requests and then accepts the message (datagram) and send back the number of words in the message. Since DatagramPacket only accept byte array as its argument, we need to convert String to byte[]

Multicast in Java Multicast Imaging you need to send data to a group of 1,000 clients What s wrong with TCP? Connection-based: you need 1,000 connections which consume a lot of processing power on sender! Flow control: The arrival time is not the same for every clients Multicast is a special feature of UDP protocol that enable programmer to send data to a group of receivers on a specific multicast IP address and port. One-to-many and many-to-many real-time communication over internet Send data only once to any number of any receivers The data is also called multicast packets

Multicast in Java Multicast: Java example A multicast group is specified by a class-d IP address and by a standard UDP port number. Class-D IP addresses are in the range 224.0.0.0 to 239.255.255.255, inclusive. Receivers must join multicast group to receive data Multicast IP address Sender Joint to receive multicast message Receivers

Multicast in Java Multicast: Java example MulticastSocket class: sending and receiving multicast packets MulticastSocket class is inherited from the DatagramSocket class, with additional capabilities for joining groups of other multicast hosts on the internet. For Android App development, you can also use MulticastSocket class More information can be found at Oracle s webpage

Multicast in Java Multicast: Java example Steps of using MulticastSocket to receive data Step 1: create a MulticastSocket object with the desired port Step 2: join a group using the joingroup(inetaddress groupaddr) Step 3: leave the group using leavegroup(inetaddress addr) method. method

Multicast in Java Multicast: Java example Steps of using MulticastSocket to send data Step 1: create a MulticastSocket Step 2: create a DatagramPacket object for data Step 3: set Time-To-Live (TTL) using method Step 4: send data using send() method settimetolive Step 5: close the MulticastSocket using close() method Note: Time-To-Live (TTL): a value between zero and 255. Every time a router forwards the packet, it decrements the TTL field in the packet header. The packet will dropped if the value reaches zero. Used to avoid packages being looped forever due to routing errors.