CS4514 Project 2 Help Session (B07) Feng Li Nov 8, 2007

Similar documents
CS4514 HELP Session 2 Simulation of Datalink Layer Communication

CS4514 HELP Session 3. Concurrent Server (in APP) Using Go-Back-N (in DLL)

serverbase.txt (1) Server Client1 (3) (2) Client2 Child Process1 Child Process2 Note: each child process keeps a separate copy of the DB.

Concurrent Server Using Selective Repeat Data Link Layer

Global Employee Location Server

Any of the descriptors in the set {1, 4} have an exception condition pending

Programming Assignment 2

CS3516 Computer Networks. Program 3 {October 27, 2014} 55 points

file:///c:/users/hpguo/dropbox/website/teaching/fall 2017/CS4470/H...

UNIT III - APPLICATION DEVELOPMENT. TCP Echo Server

Programming Assignment 2 (50 pts) Due: 9 a.m. Friday, February 8, Data Link Layer Client and Server Processes Using Tanenbaum s PAR Protocol

I/O Models. Kartik Gopalan

ISA 563: Fundamentals of Systems Programming

Processes. Processes (cont d)

Overview. POSIX signals. Generation of signals. Handling signals. Some predefined signals. Real-time Systems D0003E 3/3/2009

User-Space Debugging Simplifies Driver Development

More Network Programming

An Issue in NewReno After Fast Recovery. Yoshifumi Nishida

Network Programming TDC 561

IC221: Systems Programming 12-Week Written Exam [SOLUTIONS]

Interrupt Timer I/O operations

Lab 2: Implementing a Reliable Transport Protocol (30 points)

File Descriptors and Piping

Computer Networks. Project 2. Project Assigned: November 14 Checkpoint: November 21 12:01 AM Due: December 04 12:01 AM. Networks - Project 2 1

Lab 1 - Reliable Data Transport Protocol

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

CSC209H Lecture 10. Dan Zingaro. March 18, 2015

CSCE 313 Introduction to Computer Systems. Instructor: Dezhen Song

CS118 Discussion 1A, Week 3. Zengwen Yuan Dodd Hall 78, Friday 10:00 11:50 a.m.

The Transport Layer Reliability

CS242: Object-Oriented Design and Programming

Programming Assignment 5: Implementing a Reliable Transport Protocol

Preview. System Call. System Call. System Call. System Call. Library Functions 9/20/2018. System Call

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

Ricardo Rocha. Department of Computer Science Faculty of Sciences University of Porto

CSE123 Discussion. Oct 17th 2017

Lecture 3. Introduction to Unix Systems Programming: Unix File I/O System Calls

Asynchronous Events on Linux

CPSC 3600 HW #4 Fall 2017 Last update: 11/9/2017 Please work together with your project group (3 members)

NWEN 243. Networked Applications. Layer 4 TCP and UDP

CMSC 216 Introduction to Computer Systems Lecture 17 Process Control and System-Level I/O

CSC209H Lecture 6. Dan Zingaro. February 11, 2015

CSE434 Computer Networks (FALL, 2009) Programming Assignment 3 Due: Wed, December 2, 2009

Inter-process Communication using Pipes

CPSC 427a: Object-Oriented Programming

CS 33. More Network Programming. CS33 Intro to Computer Systems XXXI 1 Copyright 2017 Thomas W. Doeppner. All rights reserved.

CSC209H Lecture 9. Dan Zingaro. March 11, 2015

Total Points 100 (One Hundred)

Announcements Computer Networking. Outline. Transport Protocols. Transport introduction. Error recovery & flow control. Mid-semester grades

C Structures in Practice

F28HS Hardware-Software Interface: Systems Programming

System Calls and Signals: Communication with the OS. System Call. strace./hello. Kernel. Context Switch

PROBLEMSAND EXERCISES

How do we define pointers? Memory allocation. Syntax. Notes. Pointers to variables. Pointers to structures. Pointers to functions. Notes.

CSC 271 Software I: Utilities and Internals

Signals. POSIX defines a variety of signal types, each for a particular

ECE4110, Internetwork Programming, QUIZ 2 - PRACTICE Spring 2006

CS4516 Advanced Computer Networks. Program 1 {February 4, 2013} 70 points

Assignment 2 Group 5 Simon Gerber Systems Group Dept. Computer Science ETH Zurich - Switzerland

CONCURRENCY MODEL. UNIX Programming 2014 Fall by Euiseong Seo

OS COMPONENTS OVERVIEW OF UNIX FILE I/O. CS124 Operating Systems Fall , Lecture 2

CSE 489/589 Programming Assignment 2

Operating systems. Lecture 7

Computer Networking. Reliable Transport. Reliable Transport. Principles of reliable data transfer. Reliable data transfer. Elements of Procedure

Hyo-bong Son Computer Systems Laboratory Sungkyunkwan University

Inter-Process Communication. Disclaimer: some slides are adopted from the book authors slides with permission 1

CSCI Topics: Internet Programming Fall 2008

Processes COMPSCI 386

Systems Programming. COSC Software Tools. Systems Programming. High-Level vs. Low-Level. High-Level vs. Low-Level.

File I/0. Advanced Programming in the UNIX Environment

Altering the Control Flow

COMP/ELEC 429/556 Introduction to Computer Networks

CS 455. Week Data Communications and Networking - Behrouz A Forouzan Edition: 4.

10. I/O System Library

CSE 333 SECTION 3. POSIX I/O Functions

Process Creation in UNIX

CSci 4061 Introduction to Operating Systems. (Advanced Control Signals)

CS118 Discussion Week 2. Taqi

Principles of Reliable Data Transfer

Section #6 Handout. B has processed this packet and updated its position of its sliding window. Everything is in terms of bytes.

Computer Networking : Principles, Protocols and Practice

Chapter 10. The UNIX System Interface

UNIX I/O. Computer Systems: A Programmer's Perspective, Randal E. Bryant and David R. O'Hallaron Prentice Hall, 3 rd edition, 2016, Chapter 10

CS240: Programming in C

TCP over Wireless PROF. MICHAEL TSAI 2016/6/3

Internet transport-layer protocols. Transport services and protocols. Sending and receiving. Connection-oriented (TCP) Connection-oriented

15-213/18-243, Spring 2011 Exam 2

CS 640 Introduction to Computer Networks Spring 2009

Odds and Ends. Data and File Structures Laboratory. DFS Lab (ISI) Odds and Ends 1 / 8

Section 3: File I/O, JSON, Generics. Meghan Cowan

Programming Assignment 3: Transmission Control Protocol

The Transport Layer. The need for the transport layer

Lecture 8: Unix Pipes and Signals (Feb 10, 2005) Yap

Network programming(ii) Lenuta Alboaie

CS 201. Files and I/O. Gerson Robboy Portland State University

A read or write being atomic means that its effect is as if it happens instantaneously.

Persistence Schemes. Chakchai So-In Department of Computer science Washington University

Chapter 3 Transport Layer

CMPSC 311- Introduction to Systems Programming Module: Input/Output

Today: VM wrap-up Select (if time) Course wrap-up Final Evaluations

Transcription:

CS4514 Project 2 Help Session (B07) Feng Li Nov 8, 2007 1

Description The goal is to implement a Positive Acknowledgement with Retransmission (PAR) protocol on top of an emulated physical layer. The receiver acknowledges only the correctly received segments and the sender uses timeout to detect and send the lost segment. Physical layer is emulated by a TCP connection plus an error module. Your programs should compile and work on ccc[1-6].wpi.edu 2

Framework Client Network Layer Server Network Layer Data Link Layer Data Link Layer Physical Layer Physical Layer Do NOT attempt to put everything in one big main() 3

Network Layer Client photo[1-5].jpg Server photonew[1-5].jpg read (block) write (block) Network layer ack Network Layer nwl_recv(ack) pkt Packet size: 180 bytes Network Layer Network layer ack nwl_recv(pkt) pkt 4

Data Link Layer Client Network Layer Network layer ack Data Link Layer ack/frm (Network Layer ack) dll_send(pkt) dll_recv(frm) frm Client link layer does not need to ACK Network Layer ACK frame! Server Network Layer Network layer ack pkt dll_send(pkt) Data Link Layer frm dll_recv(frm) ack/frm (Network Layer ack) 5

Physical Layer Client Datalink Layer ack phl_send() Physical Layer phl_recv() Server Datalink Layer frm phl_send() Physical Layer phl_recv() TCP Connection 6

Client: dll_send(pkt, ) 1. Read a block and split into payloads 2. For each payload phl_send(frm, ): Force bit error every 7-th Frame 2.1 Create Frame (frm) 2.2 Start a Timer 2.2.1 Timeout Handler: phl_send(frm, ) 2.3 phl_send(frm, ) 2.4 phl_recv(ack/frm, ) ack/frm? ack frm 2.4.1 nwl_ack received no ack ok? yes client.log 3. Waiting for Network Layer ack: if (!nwl_ack) phl_recv(frm, ) 7

Create Frame Datafield 1. Compute Seq Number, Frame Type and End-Of-Packet (EOP) bytes Seq FT EOP Datafield 2. Error-Detection (ED) bytes (XOR on Seq + FT + EOP + Data) Seq FT EOP Datafield ED 1 Byte 2 Bytes 2 Bytes 1 Byte <=100 Bytes EOP: End of Packet FT: Frame Type ED: Error Detection Seq: Sequence Num 8

Server: dll_recv(frm, ) 1. Compute ED byte ED ok? yes no Return phl_send(ack, ): Force bit error every 11-th Frame Dup? yes no 2. Create ACK Frame (ack) 3. phl_send(ack, ) 4. Reassemble the packet 5. nwl_recv(pkt, ) Drop frm no EOP? yes server.log 9

Create ACK Frame 1. Compute Seq Number and Frame Type Seq FT 2. Error-Detection (ED) bytes (ED = Seq) Seq FT ED 2 Bytes 2 Bytes 1 Byte EOP: End of Packet FT: Frame Type ED: Error Detection Seq: Sequence Num 10

Timers The client uses a timer to detect a frame loss. The client sets a timer when it transmits a frame. When the timer expires, the client retransmits the frame. Two kinds of timer Select : easier to use Signal and Timer : nicer implementation 11

Select: Monitor Given FDs (SDs) # include <sys/select.h> # include <sys/time.h> int select (int maxfdp1, fd_set *readset, fd_set *writeset, fd_set *exceptset, const struct timeval *timeout); struct timeval { long tv_sec; /* seconds */ long tv_usec; /* microseconds */ 12

Example: Select fd_set bvfdread; int readyno; struct timeval timeout; int sockfd; while (1) { timeout.tv_sec = 0; timeout.tv_usec = 500; FD_ZERO(&bvfdRead); FD_SET(sockfd, &bvfdread); readyno = select(sockfd+1, &bvfdread, 0, 0, &timeout); if(readyno < 0) error_handler(); else if(readyno == 0) timeout_handler(); else { FD_ZERO(&bvfdRead); receive_handler(); 13

Signal and Timer: Soft Interrupt Head files #include <signal.h> #include <time.h> Register a function to TIMEOUT signal signal (SIGALRM, timeout); Create a timer and begin to run timer_create(); timer_settime(); Compile with option -lrt (link runtime library) 14

Example: Signal and Timer timer_t timer_id; void timeout(int signal_number){ printf("\n SIGNUM: %d\n", signal_number); exit(0); void start_timer(){ struct itimerspec time_val; signal (SIGALRM, timeout); timer_create( CLOCK_REALTIME, NULL, &timer_id); /* set timeout to 1 second */ time_val.it_value.tv_sec = 1; time_val.it_value.tv_nsec = 0; time_val.it_interval.tv_sec = 0; time_val.it_interval.tv_nsec = 0; timer_settime(timer_id, 0, &time_val, NULL); main(){ start_timer(); while(1); 15

Open a File Open a file for read: int rfile; if ((rfile = open( filename1, O_RDONLY)) < 0) { perror("input File Open Error"); exit(1); Open a file for write (create if not exist): int ofile; if ((ofile = open( filename2, O_WRONLY O_CREAT O_TRUNC, S_IRUSR S_ IWUSR S_IRGRP S_IWGRP)) < 0) { perror("output File Open Error"); exit(1); 16

File Read Read from file while ((rd_size = read(rfile, buf, 180)) > 0) { do something with buf here if (rd_size < 0) { perror("file Read Error"); exit(1); else { printf ("Reach the end of the file n"); 17

File Write/Close Write to File if ((wr_size = write(ofile, buf, rd_size)) < 0) { perror("write Error:"); exit(1); Close files close(rfile); close(ofile); 18

Display Image in Linux Make sure you have X forwarding with your ssh client And you need have an Xserver (X-Win32 or etc.) running on you windows computer. The image display is not required for the Project. These code tested on ccc[1-6].wpi.edu if (fork() == 0) { execl("/usr/local/bin/xv", "xv", image.jpg, NULL); else { wait(null); printf("done display! \n"); 19

Thanks! and Questions? 20