1 CS3516 Project 3 Help Session (A15) Dongqing Xiao Sep 30th,2015.

Slides:



Advertisements
Similar presentations
Echo server The client reads a line of text from its standard input and writes the line to the server The server reads the line from its network input.
Advertisements

Introduction to Sockets Jan Why do we need sockets? Provides an abstraction for interprocess communication.
Introduction 1 Lecture 13 Transport Layer (Transmission Control Protocol) slides are modified from J. Kurose & K. Ross University of Nevada – Reno Computer.
TFTP (Trivial File Transfer Protocol)
Lab tutorial Lab assignment 2 Fall 2006
I/O Multiplexing Road Map: 1. Motivation 2. Description of I/O multiplexing 3. Scenarios to use I/O multiplexing 4. I/O Models  Blocking I/O  Non-blocking.
Today’s topic Issues about sending structures with TCP. Server design alternatives: concurrent server and multiplexed server. I/O multiplexing.
CSCE 515: Computer Network Programming TCP Details Wenyuan Xu Department of Computer Science and Engineering.
Global Employee Location Server Jeff Zhou 3/19/2011 CS4516 HELP Session 1 Modified based on CS4514 B05 slides.
Computer Networks Sockets. Sockets and the OS F An end-point for Internet connection –What the application “plugs into” –OS provides Application Programming.
Client 1 Client 2 Server Child Process1 Child Process2 (1) (2) (3) serverbase.txt Note: each child process keeps a separate copy of the DB.
Client 1 Client 2 Server Child Process1 Child Process2 (1) (2) (3) serverbase.txt Note: each child process keeps a separate copy of the DB.
Reliable Networking Tom Roeder CS sp. Last minute questions on Part II?
CS4514-Help Session By Huahui Wu. Description In this project, you are supposed to implement a PAR (Positive Acknowledgement with Retransmission)
Cs4411 – Operating Systems Practicum November 4, 2011 Zhiyuan Teo Supplementary lecture 4.
CS4514 HELP Session 3 Concurrent Server Using Go-Back-N Song Wang 12/08/2003.
Concurrent Server Using Selective Repeat Data Link Layer Mingzhe Li 12/05/2005 CS4514 HELP Session 3.
CS4514 Assignment 2 Help Session – Data Link Layer Client and Server Processes Speaker: Hao Shang Date: Nov. 11th, 2004.
Signal Signal : - is a notification sent to a process to notify it of some event - interrupts whatever the process is doing and force it to handle a signal.
CS4514 HELP Session 3 Concurrent Server Using Go-Back-N Song Wang 02/17/2004.
Introduction to Project 1 Web Client and Server Jan 2006.
1 CS4514 – B03 Project 2 Help Session Choong-Soo Lee November 24, 2003.
1 CCNA 2 v3.1 Module Intermediate TCP/IP CCNA 2 Module 10.
1 Diagnostics Project Introduction Matt Morgan. 2 Diagnostic ’ s Project Purpose Develop the Network layer services for diagnostics on CAN for road vehicle.
Network LayerDatalink LayerPhysical LayerNetwork LayerDatalink LayerPhysical Layer ClientServer Framework.
TCP. Learning objectives Reliable Transport in TCP TCP flow and Congestion Control.
WXES2106 Network Technology Semester /2005 Chapter 8 Intermediate TCP CCNA2: Module 10.
3-1 Transport services and protocols r provide logical communication between app processes running on different hosts r transport protocols run in end.
1 CS4514 Project 2 Help Session (B05) Mingzhe Li Nov 10, 2005.
IP Multiplexing Ying Zhang EECS 489 W07.
Process-to-Process Delivery:
CS4516: Medical Examiner Client/Server Evan Frenn 1.
1 Semester 2 Module 10 Intermediate TCP/IP Yuda college of business James Chen
CS 4396 Computer Networks Lab
1 CS3516 Project 3 Help Session (B14) Dongqing Xiao Dec 04, 2014.
TCP1 Transmission Control Protocol (TCP). TCP2 Outline Transmission Control Protocol.
Transport Layer Moving Segments. Transport Layer Protocols Provide a logical communication link between processes running on different hosts as if directly.
Review: How to create a TCP end point? What is the right format for sin_port and sin_addr in the sockaddr_in data structure? How many different ways we.
Chapter 5 Peer-to-Peer Protocols and Data Link Layer PART I: Peer-to-Peer Protocols ARQ Protocols and Reliable Data Transfer Flow Control.
TELE 402 Lecture 4: I/O multi … 1 Overview Last Lecture –TCP socket and Client-Server example –Source: Chapters 4&5 of Stevens’ book This Lecture –I/O.
CSCE 515: Computer Network Programming TFTP + Errors Wenyuan Xu Department of Computer Science and Engineering.
CSCE 515: Computer Network Programming Select Wenyuan Xu Department of Computer Science and Engineering.
Networking Basics CCNA 1 Chapter 11.
Forward Error Correction vs. Active Retransmit Requests in Wireless Networks Robbert Haarman.
I/O Multiplexing. What is I/O multiplexing? When an application needs to handle multiple I/O descriptors at the same time –E.g. file and socket descriptors,
Today’s topic: UDP Reliable communication over UDP.
Transport Layer: Sliding Window Reliability
© 2002, Cisco Systems, Inc. All rights reserved..
CS 145A Reliable Communication Netlab.caltech.edu/course.
@Yuan Xue CS 283Computer Networks Spring 2013 Instructor: Yuan Xue.
Computer Networking Lecture 16 – Reliable Transport.
The Transport Layer (TCP)
Review: TCP Client-Server Interaction
Concurrent Server Using Go-Back-N
Introduction of Transport Protocols
Transport Layer Our goals:
Overview Jaringan Komputer (2)
Chapter 5 (part 1) TCP Client /Server Example By: Lim Meng Hui.
CS4516 Program 2 Help Session (C10)
Chapter 5 Peer-to-Peer Protocols and Data Link Layer
CS4470 Computer Networking Protocols
CS4514 Project 2 Help Session (B07)
CSS432 (Link Level Protocols) Reliable Transmission Textbook Ch 2.5
CS4470 Computer Networking Protocols
Getting Connected (Chapter 2 Part 3)
Concurrent Server (in APP) Using Go-Back-N (in DLL)
The Transport Layer Reliability
Simulation of Datalink Layer Communication Speaker: Jae Chung
Chapter 5 Peer-to-Peer Protocols and Data Link Layer
Lecture 4 Peer-to-Peer Protocols and Data Link Layer
Presentation transcript:

1 CS3516 Project 3 Help Session (A15) Dongqing Xiao Sep 30th,2015

2 Outline  Framework  Data Structure  Packet  Frame  Implementation  Timer  File IO /image related  Fork  XOR: Error Detection

2 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  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.wpi.edu ” ccc.wpi.edu

3 Framework Network LayerData Link LayerPhysical LayerNetwork LayerData Link LayerPhysical Layer ClientServer Do NOT attempt to put everything in one big main()

4 Network Layer ClientServer Photonew[i].jpg Network Layer read (block) Network Layer nwl_recv(pkt) Photo[i].jpg pkt write (block) pkt Network layer ACK nwl_recv(ack) Network layer ACK Packet payload: 256 bytes

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

6 Physical Layer TCP Connection ClientServer Datalink Layer Physical Layer phl_send() phl_recv() Physical Layer phl_send() phl_recv() Datalink Layer frmack

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

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

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

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

11 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

12 Select: Monitor Given FDs (SDs) # include int select(int nfds, fd_set *readfds, fd_set *writefds,fd_set *exceptfds, struct timeval *timeout); struct timeval { long tv_sec;/* seconds */ long tv_usec;/* microseconds */ }

13 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(); }

14 Signal and Timer: Soft Interrupt  Head files #include  Register a function to TIMEOUT signal int sigaction(int signum, const struct sigaction *act, struct sigaction *oldact);  Create a timer and begin to run int setitimer(int which, const struct itimerval *new_value, struct itimerval *old_value);

15 Example: Signal and Timer #include void timer_handler (int signum){ printf ("timer expired for %d", signum); exit(0); } int main () { struct sigaction sa; struct itimerval timer; /* Install timer_handler as the signal handler for SIGVTALRM. */ memset (&sa, 0, sizeof (sa)); sa.sa_handler = &timer_handler; sigaction (SIGVTALRM, &sa, NULL); /* Configure the timer to expire after 250 ms*/ timer.it_value.tv_sec = 0; timer.it_value.tv_usec = ; timer.it_interval.tv_sec = 0; timer.it_interval.tv_usec = 0; setitimer (ITIMER_VIRTUAL, &timer, NULL); /* Do busy work. */ while (1); return 1;

17 Toy Example Run: /Users/dongqingxiao/cEX/Timer Code:

16 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); }

17 File Read  Read from file while ((rd_size = read(rfile, buf, 256)) > 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"); }

18 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);

19 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-10].wpi.edu if (fork() == 0) { execl("/usr/local/bin/xv", "xv", “image.jpg”, NULL); } else { wait(NULL); printf("Done display! \n"); }

19 Multpile Clients—fork f or ( ; ; ) { clilen = sizeof(cliaddr); connfd = accept(listenfd, (SA *) &cliaddr, &clilen); if ( (childpid = fork()) == 0) { /* child process */ close(listenfd); /* close listening socket */ str_echo_dq(connfd); /* process the request */ exit(0); } close(connfd); /* parent closes connected socket */ exit(0); }

23 XOR: Error Detection 2 Bytes N ….. XOR 2 Bytes N + ….. XOR

20 Thanks! and Questions?