CS4514 HELP Session 3 Concurrent Server Using Go-Back-N Song Wang 12/08/2003.

Slides:



Advertisements
Similar presentations
Chapter 7 – Transport Layer Protocols
Advertisements

Elementary TCP Sockets© Dr. Ayman Abdel-Hamid, CS4254 Spring CS4254 Computer Network Architecture and Programming Dr. Ayman A. Abdel-Hamid Computer.
1 Elementary TCP Sockets socket function connect function bind function listen function accept function fork and exec functions Concurrent servers close.
Flow and Error Control. Flow Control Flow control coordinates the amount of data that can be sent before receiving acknowledgement It is one of the most.
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.
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.
Socket Programming.
CS4514-Help Session By Huahui Wu. Description In this project, you are supposed to implement a PAR (Positive Acknowledgement with Retransmission)
A CHAT CLIENT-SERVER MODULE IN JAVA BY MAHTAB M HUSSAIN MAYANK MOHAN ISE 582 FALL 2003 PROJECT.
Concurrent Server Using Selective Repeat Data Link Layer Mingzhe Li 12/05/2005 CS4514 HELP Session 3.
1 Data Communications and Networking Socket Programming Part II: Design of Server Software Reference: Internetworking with TCP/IP, Volume III Client-Server.
CS 311 – Lecture 18 Outline IPC via Sockets – Server side socket() bind() accept() listen() – Client side connect() Lecture 181CS Operating Systems.
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.
Network LayerDatalink LayerPhysical LayerNetwork LayerDatalink LayerPhysical Layer ClientServer Framework.
Advanced UDP Sockets© Dr. Ayman Abdel-Hamid, CS4254 Spring CS4254 Computer Network Architecture and Programming Dr. Ayman A. Abdel-Hamid Computer.
TCP: Software for Reliable Communication. Spring 2002Computer Networks Applications Internet: a Collection of Disparate Networks Different goals: Speed,
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.
Chapter 26 Client Server Interaction Communication across a computer network requires a pair of application programs to cooperate. One application on one.
Process-to-Process Delivery:
CS4516: Medical Examiner Client/Server Evan Frenn 1.
Socket Programming References: redKlyde ’ s tutorial set Winsock2 for games (gamedev.net)
Assignment 3 A Client/Server Application: Chatroom.
Elementary TCP Sockets
UNIX Network Programming1 UNIX Network Programming 2nd Edition.
LWIP TCP/IP Stack 김백규.
1 CS3516 Project 3 Help Session (B14) Dongqing Xiao Dec 04, 2014.
Server Sockets: A server socket listens on a given port Many different clients may be connecting to that port Ideally, you would like a separate file descriptor.
Elementary TCP Sockets
Programming with TCP – III 1. Zombie Processes 2. Cleaning Zombie Processes 3. Concurrent Servers Using Threads  pthread Library Functions 4. TCP Socket.
Chapter 5 Peer-to-Peer Protocols and Data Link Layer PART I: Peer-to-Peer Protocols ARQ Protocols and Reliable Data Transfer Flow Control.
CS 453 Computer Networks Lecture 9 Layer 2 – Data Link Layer.
CSCE 515: Computer Network Programming Select Wenyuan Xu Department of Computer Science and Engineering.
CSCE 515: Computer Network Programming UDP Socket Wenyuan Xu Department of Computer Science and Engineering.
Networking Basics CCNA 1 Chapter 11.
Socket Programming Lab 1 1CS Computer Networks.
Client/Server Socket Programming Project
Today’s topic: UDP Reliable communication over UDP.
Transport Layer: Sliding Window Reliability
Fork(), Concurrent Server, Normal Termination ( 금 ) 김 희 준
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.
COSC 3213: Computer Networks I Instructor: Dr. Amir Asif Department of Computer Science York University Section M Topics: 1.Flow Control and ARQ Protocols.
DATA LINK CONTROL. DATA LINK LAYER RESPONSIBILTIES  FRAMING  ERROR CONTROL  FLOW CONTROL.
@Yuan Xue CS 283Computer Networks Spring 2013 Instructor: Yuan Xue.
Computer Networking Lecture 16 – Reliable Transport.
Data Link Layer.
ECE 297 Concurrent Servers Process, fork & threads ECE 297.
Assignment 3 A Client/Server Application: Chatroom
Sockets and Beginning Network Programming
Review: TCP Client-Server Interaction
Concurrent Server Using Go-Back-N
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)
Process-to-Process Delivery:
Chapter 5 Peer-to-Peer Protocols and Data Link Layer
CS4514 Project 2 Help Session (B07)
CSS432 (Link Level Protocols) Reliable Transmission Textbook Ch 2.5
Getting Connected (Chapter 2 Part 3)
Concurrent Server (in APP) Using Go-Back-N (in DLL)
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:

CS4514 HELP Session 3 Concurrent Server Using Go-Back-N Song Wang 12/08/2003

Computer Science Session 3-2 Description You are supposed to implement a simple concurrent server and client having four emulated network protocol stack. –Application layer: Read and execute commands –Network layer: Message  Packet (send&recv) –Datalink layer: Packet  Frame and Go-Back- N sliding window protocol –Physical layer: TCP connection. Your programs should compile and work on any one of ccc.WPI.EDU.

12/08/2003 Computer Science Session 3-3 (1) (2) fork() (3) serverbase.txt Note: each child process keeps a separate copy of the DB. we do not keep data consistency for the serverbase we do not keep data consistency for the serverbase Client1Client2 Server Child Process1 Child Process2 (4) fork() System Overview script1.txtscript2.txt

12/08/2003 Computer Science Session 3-4 System Framework NW Layer DLLPHL ClientServer APP Layer TCP Connection NW Layer DLLPHLAPP Layer

12/08/2003 Computer Science Session 3-5 Concurrent Server (fork()) fork() will make a child process with memo ry copy. –The initial serverbase will be copied to each c hild process. –fork() will return child pid in parent process an d 0 in child process. –Remember to close socket after using.

12/08/2003 Computer Science Session 3-6 Concurrent TCP Server Example pid_t pid; int listenfd, connfd; /* 1. create a socket socket() */ if ((listenfd = socket(AF_INET, SOCK_STREAM, 0)) < 0 ) err_quit("build server socket error\n", -1); /* 2. fill in sockaddr_in{ } with server's well-known port */ … /* 3. bind socket to a sockaddr_in structure bind() */ bind (listenfd,...); /* 4. specify the backlog of incoming connection requests listen() */ listen (listenfd, LISTENQ); while(1){ connfd = accept(listenfd,... ); /* probably blocks */ if(( pid = fork()) == 0){ close(listenfd); /* child closes listening socket */ doit(connfd); /* process the request */ close(connfd); /* done with this client */ exit(0); } close(connfd); /* parent closes connected socket */ }

12/08/2003 Computer Science Session 3-7 ClientiServer Read “scripted action” from file “scripti.txt” Read/Write a message Client Request: cmd No. [msg] Note: The max_size of a message is 290 bytes The number referring to tuple position is 1 to 14 nwl_send (… msg …) nwl_recv (… msg …) APP Child Process i How the System Works: Layer by Layer ACK cmd::r q w msg1::r[6](2 bytes) msg2::w[4]Duke… msg3::q(1 byte) No sequence no. for msg Stop-Wait msg1::Duke…msg2::[ACK]msg3::[ACK]

12/08/2003 Computer Science Session 3-8 ClientiServer dll_send (… pkt …) dll_recv (… pkt …) NWL message End of Message Can be an special packet, a special position in each packet, eg. 1 st byte Note: The max_size of a packet is 72 bytes The network layer will send packets until blocked by the Data Link Layer How the System Works: Layer by Layer n_packets Tasks for NWL Disassemble and assemble packets from Msg. No response in this layer No sequence no. for packets

12/08/2003 Computer Science Session 3-9 ClientiServer phl_send (… frm …) phl_recv (… frm …) DLL packet  End of Packet  Error Detection  Byte Stuffing  Go-Back-N Note: The max_size of a frame payload is 48 bytes Sliding window size >=3 How the System Works: Layer by Layer n_frames ACK Go-Back-N

12/08/2003 Computer Science Session 3-10 ClientiServer read (… data …) write (… data …) PHL frame  Identify client when start  Force Single Bit Errors - Client: 5 th frames - Server: 6 th frames TCP Connection How the System Works: Layer by Layer

12/08/2003 Computer Science Session 3-11 client APP Read script file Pick a command Yes q cmd? Build Msg nwl_send(…msg…) No server child process APP How the Functions Work: Layer by Layer nwl_recv(…ack…) fork() nwl_recv( …… ) Yes q cmd? Build Msg nwl_send(…msg…) No

12/08/2003 Computer Science Session 3-12 nwl_send (… msg …) Split msg into pkts Pick a pkt Yes Last pkt? Add sth, ‘\0’ dll_send(…pkt…) No dll_recv (… pkt …) Return msg to APP Reassemble pkts into msg Last pkt? No Yes nwl_recv (… msg …) How the Functions Work: Layer by Layer

12/08/2003 Computer Science Session 3-13 dll_send (… pkt … ) Split a packet into payloads Create a new frame Send a frame to PHL Start a Timer Receive a ACK frame correctly, then continue... phl_send (…) phl_recv (…)Wait for receiving a ACK frame Retransmit frames if timeout or error ACK frame! How the Functions Work: Layer by Layer Sliding window size =1

12/08/2003 Computer Science Session 3-14 Receive a frame from PHL Compute ED byte and check error Reassemble the packet If EOP, forward the packet to NWL phl_send (…) phl_recv (…) Unstuffing the frame Drop if duplicate, else send ACK Drop if error detected dll_recv (… pkt … ) How the Functions Work: Layer by Layer

12/08/2003 Computer Science Session 3-15 client i.log server i.log Performance Timing Frame received in error …… Packet Sent Log Significant Events

12/08/2003 Computer Science Session 3-16 Project Tips Sliding Window Protocol: Go-Back-N (N>3) –Try to implement Go-Back-1 first –Then implement Go-Back-N (multiple timers) Maybe easier to merge PHL and DLL How to terminate client process: –When the client gets the response to the quit message –A “clean” way to terminate the server child process?

12/08/2003 Computer Science Session 3-17 Relative Timer Example /* example for start_timer, stop_timer, send_packet */ /* you SHOULD modify this to work for project 3, this is just a TIMER EXAMPLE */ #include #define TIMER_RELATIVE 0 #define MAX_SEQ 3 extern int errno; typedef unsigned int seq_nr; typedef enum {frame_arrival, cksum_err, timeout, network_layer_ready} event_type; timer_t timer_id[MAX_SEQ];

12/08/2003 Computer Science Session 3-18 void timeout() { printf(“time out!\n”); } void start_timer(seq_nr frame_nr) { struct itimerspec time_value; signal(SIGALRM, timeout); time_value.it_value.tv_sec = 1; /* timeout value */ time_value.it_value.tv_nsec = 0; time_value.it_interval.tv_sec = 0; /* timer goes off just once */ time_value.it_interval.tv_nsec = 0; timer_create(CLOCK_REALTIME, NULL, &timer_id[frame_nr]); /* create timer */ timer_settime(timer_id[frame_nr], TIMER_RELATIVE, &time_value, NULL); /* set timer */ } void stop_timer(seq_nr ack_expected) { timer_delete(timer_id[ack_expected]); } void send_packet(packet *p) { fd_set readfds; int sockfd;

12/08/2003 Computer Science Session 3-19 while(packet hasn’t been finished sending) { /* send frame if we can */ while(there’s place left in sliding window) { /* construct a frame from the packet */ /* send this frame; start timer; update sliding window size */ } /* check data from physical layer */ FD_ZERO(&readfds); FD_SET(sockfd, &readfds); if (select(sockfd+1, &readfds, (fd_set *)NULL, (fd_set *)NULL, (struct timeval*)NULL) < 0) { if (errno == EINTR) { /* receive timeout signal */ /* timeout handler should have resent all the frames that haven’t been acknowledged */ continue; } else { perror("select error"); /* select error */ exit(1); }

12/08/2003 Computer Science Session 3-20 if (FD_ISSET(sockfd, &readfds)) { /* a frame come from socket */ /* read a frame from the socket */ if (cksum() == FALSE) { /* error check */ continue; /* do nothing, wait for timer time out */ } else { /* check to see if this frame is a data or ACK frame, and do corresponding processing */ continue; }