CS4514-Help Session 2 ---- By Huahui Wu. Description In this project, you are supposed to implement a PAR (Positive Acknowledgement with Retransmission)

Slides:



Advertisements
Similar presentations
Introduction 1 Lecture 13 Transport Layer (Transmission Control Protocol) slides are modified from J. Kurose & K. Ross University of Nevada – Reno Computer.
Advertisements

Lab tutorial Lab assignment 2 Fall 2006
I/O Models Satish Krishnan. I/O Models Blocking I/O Non-blocking I/O I/O Multiplexing Signal driven I/O Asynchronous I/O.
Chapter 7 – Transport Layer Protocols
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.
Global Employee Location Server Jeff Zhou 3/19/2011 CS4516 HELP Session 1 Modified based on CS4514 B05 slides.
Elementary TCP Sockets Computer Networks Computer Networks Term B10 UNIX Network Programming Vol. 1, Second Ed. Stevens Chapter 4.
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.
TDC561 Network Programming Camelia Zlatea, PhD Week 3: Unix Asynchronous Events; Signals and Alarms API.
Reliable Networking Tom Roeder CS sp. Last minute questions on Part II?
Page: 1 Director 1.0 TECHNION Department of Computer Science The Computer Communication Lab (236340) Summer 2002 Submitted by: David Schwartz Idan Zak.
I/O Multiplexing© Dr. Ayman Abdel-Hamid, CS4254 Spring CS4254 Computer Network Architecture and Programming Dr. Ayman A. Abdel-Hamid Computer Science.
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.
I/O Multiplexing Capability of tell the kernel that wants to be notified when one or more I/O conditions are ready. For example, I/O data is available.
CS4514 Assignment 2 Help Session – Data Link Layer Client and Server Processes Speaker: Hao Shang Date: Nov. 11th, 2004.
CS4514 HELP Session 3 Concurrent Server Using Go-Back-N Song Wang 02/17/2004.
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.
Network LayerDatalink LayerPhysical LayerNetwork LayerDatalink LayerPhysical Layer ClientServer Framework.
WXES2106 Network Technology Semester /2005 Chapter 8 Intermediate TCP CCNA2: Module 10.
Lecture 8 UDP Sockets & I/O Multiplexing
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.
Project 2: A P2P Chat Application Review Ananth Rao.
Process-to-Process Delivery:
CS4516: Medical Examiner Client/Server Evan Frenn 1.
CS/EE 145A Reliable Transmission over Unreliable Channel Netlab.caltech.edu/course.
1 CS3516 Project 3 Help Session (B14) Dongqing Xiao Dec 04, 2014.
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.
Remote Shell CS230 Project #4 Assigned : Due date :
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.
CS 453 Computer Networks Lecture 9 Layer 2 – Data Link Layer.
Socket Programming Lec 2 Rishi Kant. Review of Socket programming Decide which type of socket – stream or datagram. Based on type create socket using.
1 I/O Multiplexing We often need to be able to monitor multiple descriptors:We often need to be able to monitor multiple descriptors: –a generic TCP client.
CSCE 515: Computer Network Programming Select Wenyuan Xu Department of Computer Science and Engineering.
Networking Tutorial Special Interest Group for Software Engineering Luke Rajlich.
I/O Multiplexing. TCP Echo Client: I/O operation is sequential !! tcpcliserv/tcpcli01.c: lib/str_cli.c: TCP Client TCP Server stdin stdout fgets fputs.
Networking Basics CCNA 1 Chapter 11.
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,
Cs423-cotter1 Concurrency Issues in Client/Server Applications Chapters 15,16, 28.
University of Texas at Austin CS 378 – Game Technology Don Fussell CS 378: Computer Game Technology SDL_net Client-Server Example Spring 2012.
Single Process, Concurrent, Connection-Oriented Servers (TCP) (Chapter 12)
Today’s topic: UDP Reliable communication over UDP.
CMPT 471 Networking II Network Programming © Janice Regan,
Socket Programming. Computer Science, FSU2 Interprocess Communication Within a single system – Pipes, FIFOs – Message Queues – Semaphores, Shared Memory.
1 CS3516 Project 3 Help Session (A15) Dongqing Xiao Sep 30th,2015.
Data Link Layer. Data link layer The communication between two machines that can directly communicate with each other. Basic property – If bit A is sent.
Chapter 3 Transport Layer
I/O Multiplexing.
Review: TCP Client-Server Interaction
Concurrent Server Using Go-Back-N
Transport Layer Our goals:
Overview Jaringan Komputer (2)
Lecture 4 Socket Programming Issues
CS4516 Program 2 Help Session (C10)
Process-to-Process Delivery:
CS4514 Project 2 Help Session (B07)
CSS432 (Link Level Protocols) Reliable Transmission Textbook Ch 2.5
CS4470 Computer Networking Protocols
TCP/IP Socket Programming in C
Concurrent Server (in APP) Using Go-Back-N (in DLL)
Simulation of Datalink Layer Communication Speaker: Jae Chung
I/O Multiplexing We often need to be able to monitor multiple descriptors: a generic TCP client (like telnet) need to be able to handle unexpected situations,
Presentation transcript:

CS4514-Help Session By Huahui Wu

Description In this project, you are supposed to implement a PAR (Positive Acknowledgement with Retransmission) Protocol on top of an emulated physical layer (It is actually the TCP here)

Framework Network LayerDatalink LayerPhysical LayerNetwork LayerDatalink LayerPhysical Layer ClientServer Threads? Don’t put everything in one Super main()

Physical Layer PHL TCP Connection Client Server 2. phl_send(…) 3. phl_recv(…) 1. phl_connect(…) 4. phl_close(…) NOTE: Real TCP does the actual transmission for your PHL.

Network Layer ClientServer NWL 3. dll_send(… pkt …)4. dll_recv(… pkt …) 2. read packets from file “testdata.raw” 5. write packets to file “server.out” 1. phl_connect(…) 6. phl_close(…)

Testdata File Pkt_numthe number of packets Packet_i_lenthe byte number of the i-th packet. Packet_ithe i-th packet in raw byte form …… 2 {one byte} 38 {one byte} CS4514, computer network course, FL320 {38 bytes} 31 Worcester Polytechnic Institute

EX1: Read testdata.raw #include main(int argc, char* argv[]){ int fp, i; unsigned char packets[205]; unsigned char byteNum; unsigned char p; char if ((fp = open(argv[1], O_RDONLY)) < 0) { fprintf(stderr, "Open testData file error!"); printf("Usage: %s filename\n", argv[0]); exit(-1); }

EX1: Read testdata.raw (Cont) read(fp, &p, 1); printf("The total number of packets is: %d\n\n", p); for (i = 0; i < p; i++) { read(fp, &byteNum, 1); printf("The length of %dth packet : %d\n", i+1,byteNum); read(fp, packets, byteNum); packets[byteNum] = '\0'; printf("The content of %dth packet : %s\n\n", i+1,packets); } close(fp); } //Raw file: /cs/cs4514/pub/C02_proj2/miniData.raw

Client: dll_send(…Pkt…) 1. Split a packet into payloads 2. Create a new frame 4. Send the frame to PHL 5. Wait for receiving a ACK frame 6. Retransmit it if timeout !! 3. Start a Timer 7. Receive a ACK frame phl_send(…) phl_recv(…) Force some error Every 5-th Frame client.log Correct Ack Frm? Yes No

Create a new frame Datafield Seq 1. Generate the payload from the packet 2.compute sequence number and end-of-packet byte 3. Compute Error-Detection byte (Using XOR on Seq+EOP+Data) 4. Byte Stuffing on Seq+EOP+ED+Data 5. Add Start-flag&End-flag EOP DatafieldSeqEOPED Bytes after stuffing SFEF EOP: End of PacketED: Error Detection SF: Start-flagEF: End-flag

Creating a new Ack frame 1.Compute sequence number 2. Compute Error-Detection byte by XOR (ED=Seq) 3. Byte Stuffing on Seq+ED 4. Add Start-flag&End-flag Seq ED Bytes after stuffing SFEF

1. Receive a frame from PHL 3. Compute ED and check it 4. Drop it if there’s an ED error 6. Reassemble the packet 7. If end-of-packet, return and forward the packet to the Network Layer. phl_send(…) phl_recv(…) 2. Unstuffing the frame server.log 5. Check whether it’s duplicate. If yes, drop it. Send ACK frame Force some error Every 8-th ACK Frame Server dll_recv(…pkt…)

Timer The client can’t wait the server’s response forever. It will retransmit when timeout. Two kinds of timer can be used in proj2 –1. select(): Easy to use –2. signal: need to use in proj3, maybe you want start using it now.

System call: select() In this assignment, you can call select and tell the kernel to return only when: - the socket descriptor in physical layer is ready for reading, or - a preset timer timeout

System call: select() # include int select ( int maxfdp1, fd_set *readset, fd_set *writeset, fd_set *exceptset, const struct timeval *timeout);

Struct timeval struct timeval { long tv_sec; /* seconds */ long tv_usec; /* microseconds */ }

EX2: how to use select() { fd_set bvfdRead; FD_SET(sockfd, &bvfdRead); int readyNo; readyNo = select(sockfd+1, struct timeval timeout; &bvfdRead, 0, 0, &timeout); int sockfd; if(readyNo < 0) //some errors error_handler; while (true) { else if(readyNo = = 0) // timeout timeout.tv_sec = 0; timeout_handler; timeout.tv_usec = 500; else // receive data from socket FD_ZERO(&bvfdRead); receive_handler; } }

Time signal Head files #include Register a function to TIMEOUT signal signal (SIGALRM, timeout); Create a timer and begin to run timer_create(); timer_settime();

EX3: How to use Time Signal #include timer_t timer_id; void timeout(){ printf("\n Time out!!!!\n"); exit(0);} void start_timer(){ struct itimerspec time_value; signal (SIGALRM, timeout); timer_create( CLOCK_REALTIME, NULL, &timer_id); //set timeout to 1 second time_value.it_value.tv_sec = 1; time_value.it_value.tv_nsec = 0; time_value.it_interval.tv_sec = 0; time_value.it_interval.tv_nsec = 0; timer_settime( timer_id, 0, &time_value, NULL); } main(){ start_timer(); for(;;);}