Project 3. Reliable Data Transfer over UDP. NTU CSIE Computer Networks 2011 Spring

Similar documents
The BSD UNIX Socket Interface (CS 640 Lecture) Assignment 1. Interprocess Communication (IPC) Work Individually (no groups)

CSC209H Lecture 9. Dan Zingaro. March 11, 2015

Programming Internet with Socket API. Hui Chen, Ph.D. Dept. of Engineering & Computer Science Virginia State University Petersburg, VA 23806

Socket Programming for TCP and UDP

Socket Programming. What is a socket? Using sockets. Types (Protocols) Associated functions Styles

NETWORK PROGRAMMING. Instructor: Junaid Tariq, Lecturer, Department of Computer Science

Types (Protocols) Associated functions Styles We will look at using sockets in C Java sockets are conceptually quite similar

Oral. Total. Dated Sign (2) (5) (3) (2)

SOCKET PROGRAMMING. What is a socket? Using sockets Types (Protocols) Associated functions Styles

Socket Programming TCP UDP

Group-A Assignment No. 6

Hybrid of client-server and P2P. Pure P2P Architecture. App-layer Protocols. Communicating Processes. Transport Service Requirements

Network Programming in C: The Berkeley Sockets API. Networked Systems 3 Laboratory Sessions

sottotitolo Socket Programming Milano, XX mese 20XX A.A. 2016/17 Federico Reghenzani

Sockets 15H2. Inshik Song

CSE 124 Discussion Section Sockets Programming 10/10/17

Socket Programming. Dr. -Ing. Abdalkarim Awad. Informatik 7 Rechnernetze und Kommunikationssysteme

Εργαστήριο 9 I/O Multiplexing

Network Programming in C. Networked Systems 3 Laboratory Sessions and Problem Sets

A Socket Example. Haris Andrianakis & Angelos Stavrou George Mason University

Ports under 1024 are often considered special, and usually require special OS privileges to use.

CS4514 (C04) HELP Session 1 Introduction to Network Programming (v1.3)

Unix Network Programming

CLIENT-SIDE PROGRAMMING

Elementary TCP Sockets

CSC209H Lecture 10. Dan Zingaro. March 18, 2015

CS 640: Computer Networking

CSE 333 Section 8 - Client-Side Networking

Socket Programming(2/2)

UNIX Sockets. Developed for the Azera Group By: Joseph D. Fournier B.Sc.E.E., M.Sc.E.E.

Chapter 6. The Transport Layer. Transport Layer 3-1

EEC-484/584 Computer Networks

UDP. Networked Systems (H) Lecture 15

The Berkeley Sockets API. Networked Systems Architecture 3 Lecture 4

Socket Programming 2007/03/28

Programming Ethernet with Socket API. Hui Chen, Ph.D. Dept. of Engineering & Computer Science Virginia State University Petersburg, VA 23806

Network Communication

Lecture 5 Overview! Last Lecture! This Lecture! Next Lecture! I/O multiplexing! Source: Chapter 6 of Stevens book!

9/13/2007. Motivations for Sockets What s in a Socket? Working g with Sockets Concurrent Network Applications Software Engineering for Project 1

Outline. Distributed Computer Systems. Socket Basics An end-point for a IP network connection. Ports. Sockets and the OS. Transport Layer.

Sockets. Dong-kun Shin Embedded Software Laboratory Sungkyunkwan University Embedded Software Lab.

Announcements. CS 5565 Network Architecture and Protocols. Queuing. Demultiplexing. Demultiplexing Issues (1) Demultiplexing Issues (2)

TCP: Three-way handshake

Outline. Operating Systems. Socket Basics An end-point for a IP network connection. Ports. Network Communication. Sockets and the OS

Socket Programming. CSIS0234A Computer and Communication Networks. Socket Programming in C

CPS 214: Computer Networks. Slides by Adolfo Rodriguez

Network Socket Programming - 3 BUPT/QMUL

CS4514 B08 HELP Session 1

Programming Ethernet with Socket API. Hui Chen, Ph.D. Dept. of Engineering & Computer Science Virginia State University Petersburg, VA 23806

CS 43: Computer Networks. 05: Socket Programming September 12-14, 2018

The User Datagram Protocol

Processes communicating. Network Communication. Sockets. Addressing processes 4/15/2013

MSc Integrated Electronics Networks Assignment. Investigation of TCP/IP Sockets and Ports. Gavin Cameron

Socket Programming. #In the name of Allah. Computer Engineering Department Sharif University of Technology CE443- Computer Networks

Topics for this Week

Networked Applications: Sockets. End System: Computer on the Net

Network Socket Programming - 3 BUPT/QMUL

Outline. Distributed Computing Systems. Socket Basics (1 of 2) Socket Basics (2 of 2) 3/28/2014

Lecture 24. Thursday, November 19 CS 375 UNIX System Programming - Lecture 24 1

CSMC 412. Computer Networks Prof. Ashok K Agrawala Ashok Agrawala Set 2. September 15 CMSC417 Set 2 1

UDP CONNECT TO A SERVER

Tutorial on Socket Programming

Context. Distributed Systems: Sockets Programming. Alberto Bosio, Associate Professor UM Microelectronic Departement

Reliable Data Transmission

Department of Computer Science

Introduction to Socket Programming

Ken French HELP Session 1 CS4514

UNIX Sockets. COS 461 Precept 1

Hyo-bong Son Computer Systems Laboratory Sungkyunkwan University

Computer Networks Prof. Ashok K. Agrawala

1.2 The first Internet (i.e., one of the first packet switched networks) was referred to as the ARPANET.

STUDY OF SOCKET PROGRAMMING

CS118 Discussion 1B, Week 1. Taqi Raza BUNCHE 1209B, Fridays 12:00pm to 1:50pm

Lab 0. Yvan Petillot. Networks - Lab 0 1

Review. Preview. Closing a TCP Connection. Closing a TCP Connection. Port Numbers 11/27/2017. Packet Exchange for TCP Connection

Networked Applications: Sockets. Goals of Todayʼs Lecture. End System: Computer on the ʻNet. Client-server paradigm End systems Clients and servers

Computer Network Programming

How do we Communicate? Introduction to Unix Network Programming. What does Alice do? What does Bob do? Two simplest networking programs

Server-side Programming

Network Programming. Multicast on a LAN 1/4. Sending & Receiving Multicast Messages. Multicasting II. Dr. Thaier Hayajneh

Sockets. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

Network programming(ii) Lenuta Alboaie

A. Basic Function Calls for Network Communications

Interprocess Communication

Client-server model The course that gives CMU its Zip! Network programming Nov 27, Using ports to identify services.

Introduction to Network Programming using C/C++

Systems software design NETWORK COMMUNICATIONS & RPC SYSTEMS

PA #2 Reviews. set_name, get_name, del_name. Questions? Will be modified after PA #4 ~

Programming with TCP/IP. Ram Dantu

CMPSC 311- Introduction to Systems Programming Module: Network Programming

Communication. Communication. Distributed Systems. Networks and protocols Sockets Remote Invocation Messages Streams. Fall /10/2001 DoCS

WinSock. What Is Sockets What Is Windows Sockets What Are Its Benefits Architecture of Windows Sockets Network Application Mechanics

Communication Networks ( ) / Spring 2011 The Blavatnik School of Computer Science, Tel-Aviv University. Allon Wagner

Multicast on a LAN 3/4. Multicast on a LAN 2/4. Multicast on a WAN. Multicast on a LAN 4/4

CS4700/CS5700 Fundamentals of Computer Networking

Sockets Sockets Communication domains

Server-side Programming

NETWORK AND SYSTEM PROGRAMMING

Lecture 2. Outline. Layering and Protocols. Network Architecture. Layering and Protocols. Layering and Protocols. Chapter 1 - Foundation

last time redo logging copy-on-write filesystems / snapshots distributed systems motivation, etc.

Transcription:

Project 3 Reliable Data Transfer over UDP NTU CSIE Computer Networks 2011 Spring

Project Goal In Project 3, students are asked to understand and implement reliable data transfer mechanism over UDP.

UDP UDP is a simple transport-layer protocol No connections and hand-shaking No guarantee of reliability, packet order, and may lose packets or have duplicate ones Only packet integrity is checked (but corrupt packets are simply dropped without autoretransmission)

Goal: Reliable data transmission Send data from client to server The channel is not perfect: packet may be lost or corrupted Make sure the data received by the server IS EXACTLY THE SAME as it is on the client

Bonus Flow control Managing the rate of data transmission between two nodes to prevent a fast sender from over running a slow receiver --http://en.wikipedia.org/wiki/flow_control Congestion control Control the traffic when network congestion occurs

Project Scenario Server Internet Packets may be lost, corrupted, or re-ordered UDP pkt Client

Requirements The client will send a file to the server using UDP. The file received should be EXACTLY THE SAME as the original one You can use any means, including mimicking TCP mechanism Although performance is not required, your program should run in reasonable time Taking hours to send kilobytes is not acceptable

Requirements We ll use proxy that drops packets to test your implementation Write your programs on R217 workstations Test them across real Internet, not only in LAN

Score Basic function 60% Makefile and command 10% make clean // clean obj(*.o) and executable make // compile source code./client ip port path_to_file // Run client./server port file_to_save // Run server Report (.pdf) 30% FSM of your RDT mechanism and explain why it is reliable Other features you implement Bonus (flow, congestion control ) +10%

File format Max. 2 people in one group Please tell TA if you change group members: freetempo17@gmail.com Tar your file tar zcvf bxxxxxxxx_boooooooo_prj3.tar.gz Makefile report.pdf file1 file2 Use bxxxxxxxx_prj3.tar.gz if you do not team with others DO NOT have any directory in.tar file; all files should be extract to current directory when using tar zxvf bxxxxxxxx_prj3.tar.gz Upload your file to FTP server 140.112.29.99:21 cn2011/cn20115566

Deadline 2011/6/15 23:59 There WOULD BE penalty for late submission. The penalty for the first day is 10 points, the second day is 20 points, etc. Please turn in your code in time.

Socket Programming Create a UDP socket Bind a UDP socket Send and receive datagrams

Create a UDP socket #define ERROR -1... int sock; // create a socket if((sock = socket(af_inet, SOCK_DGRAM, 0)) == ERROR) { perror("server socket: "); exit(-1); }...

Bind a UDP socket UDP socket doesn t need listen() and connect() If you bind() it to a port, you can send and receive datagrams through that port Or, it would be assigned a random port when it s first used

Bind a UDP socket... struct sockaddr_in server; bzero(&server, sizeof(server)); server.sin_family = AF_INET; server.sin_port = htons(1234); server.sin_addr.s_addr = INADDR_ANY; // bind a socket if(bind(sock, (struct sockaddr *)&server, sizeof(server)) == ERROR) { perror("bind : "); exit(-1); }...

Send and receive datagrams UDP sockets are not connected to remote sockets You designate the destination every time you send datagrams You ll get the source information when receiving datagrams

Send datagrams ssize_t sendto( int sockfd, const void *buf, size_t len, int flags, const struct sockaddr *dest_addr, socklen_t addrlen) First 3 parameters are just like write() flags: control the behavior, you can simply use 0 here dest_addr and addrlen: like the ones you use in connect(); they designate the destination of the datagram Returns the number of characters sent

Send datagrams... struct sockaddr_in addr; bzero(&addr, sizeof(addr)); addr.sin_family = AF_INET; addr.sin_port = htons(1234); addr.sin_addr.s_addr = inet_addr( 140.112.30.41 ); char data[buf_size]; size_t data_len;... sendto(sock, data, data_len, 0, (struct sockaddr *)&addr, sizeof(addr));...

Receive datagrams ssize_t recvfrom( int sockfd, void *buf, size_t len, int flags, struct sockaddr *src_addr, socklen_t *addrlen) First 3 parameters are just like read() flags: control the behavior, you can simply use 0 here src_addr and addrlen: retrieves the source of the datagram, you should initialize addrlen before recvfrom() Returns the number of bytes received

Receive datagrams... struct sockaddr_in addr; socklen_t addrlen = sizeof(addr); bzero(&addr, sizeof(addr)); char data[buf_size];... recvfrom(sock, data, BUF_SIZE, 0, (struct sockaddr *)&addr, &addrlen);...

How to implement timeout? Get current time (in microsecond (us)) int gettimeofday ( struct timeval *tv, struct timezone *tz) tv: a timeval structure to record the number of seconds and microseconds since the Epoch tz: timezone info., can be NULL man gettimeofday to get more information

How to implement timeout? int select( int maxfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout) Use timeout to designate how long select() can block

How to implement timeout? Example Current time is 1000ms, we know that a timeout event is scheduled on 1200ms struct timeval tv; tv.tv_sec = 0; tv.tv_usec = (1200-1000) * 1000; // in microsecond select(..., &tv); Select would return if Some descriptors are ready, or Time is up (200ms), and the return value would be 0