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.

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

Lab tutorial Lab assignment 2 Fall 2006
1 Elementary TCP Sockets socket function connect function bind function listen function accept function fork and exec functions Concurrent servers close.
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.
Data Link Layer as a Reliable Data Transport Protocol Computer Networks Computer Networks Term B10.
Data Link Layer Review Advanced Computer Networks.
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.
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)
Networks: Data Link Layer1 Data Link Layer. Networks: Data Link Layer2 Data Link Layer Provides a well-defined service interface to the network layer.
Cs4411 – Operating Systems Practicum November 4, 2011 Zhiyuan Teo Supplementary lecture 4.
Computer Networks: Data Link Layer 1 Data Link Layer.
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.
1 Data Communications and Networking Socket Programming Part II: Design of Server Software Reference: Internetworking with TCP/IP, Volume III Client-Server.
Concurrent vs. iterative servers
CS4514 Assignment 2 Help Session – Data Link Layer Client and Server Processes Speaker: Hao Shang Date: Nov. 11th, 2004.
Computer Networks Transport Layer. Topics F Introduction  F Connection Issues F TCP.
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.
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.
CS4516: Medical Examiner Client/Server Evan Frenn 1.
Elementary TCP Sockets
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.
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.
CSCE 515: Computer Network Programming TFTP + Errors Wenyuan Xu Department of Computer Science and Engineering.
CS 453 Computer Networks Lecture 9 Layer 2 – Data Link Layer.
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.
CSCE 515: Computer Network Programming UDP Socket Wenyuan Xu Department of Computer Science and Engineering.
Networking Basics CCNA 1 Chapter 11.
CSE 123 Discussion 10/05/2015 Updated from Anup and Narendran’s excellent notes.
Client/Server Socket Programming Project
PA3: Improving Performance with I/O Multiplexing Part 1-1: Nov. 7, Part 1-2: Nov. 10 Part 2-1: Nov. 17, Part 2-2: Nov.20.
Today’s topic: UDP Reliable communication over UDP.
Concurrent Servers. Idea Behind Concurrent Servers Server Client 1 Server 1 X.
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.
Data Link Layer as a Reliable Data Transport Protocol Advanced Computer Networks Advanced Computer Networks Term D11.
Computer Networking Lecture 16 – Reliable Transport.
ECE 297 Concurrent Servers Process, fork & threads ECE 297.
Powerpoint Templates Page 1 Powerpoint Templates CS Networks Laboratory HANDLED BY, A.MAHESH PRIYA L/IT.
More Project 1 and HW 1 stuff! Athula Balachandran Wolfgang Richter
Review: TCP Client-Server Interaction
Concurrent Server Using Go-Back-N
Data Link Layer as a Reliable Data Transport Protocol
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
CS4514 Project 2 Help Session (B07)
CSS432 (Link Level Protocols) Reliable Transmission Textbook Ch 2.5
Issues in Client/Server Programming
Elementary UDP Sockets connectionless, unreliable, datagram
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
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:

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.

APP LayerDLLPHLAPP LayerDLLPHL ClientServer NW Layer TCP Connection

Clienti Server APP Read “scripted action” from file “scripti.txt” Read/Write a message Client Request: cmd No. [msg] Child Process i Note: The max_size of a message is 360 bytes nwl_send(… msg …) nwl_recv(… msg …)

Client Server NWL dll_send(… pkt …) dll_recv(… pkt …) message Last Packet ? Note: The max_size of a packet is 50 bytes The network layer will send packets until blocked by the Data Link Layer

nwl_send(… msg …)nwl_recv(… msg …) Split the msg into pkts Last Pkt? dll_send(…pkt…) Pick a pkt Add sth, ‘\0’ dll_recv(…pkt…) Last Pkt? Forward msg to APP Y Reassemble pkts into msg N

Client dll_send(… pkt … ) Split a packet into payloads Create a new frame Send a frame to PHL Wait for receiving a ACK frame Retransmit frms if timeout or error frame!! Start a Timer Receive a ACK frame correctly, then continue... phl_send(…) phl_recv(…) Force some error: 7 th frame from client 9 th frame from server client i.log

Create a new frame 1. Put a payload in a frame 2. End-of-packet byte = ? 3. Compute CRC 4. Byte-stuffing struct frame { unsigned char start-flag; unsigned char seq; unsigned char crc; unsigned char data[MAXSIZE ]; unsigned char end-of-pkt; unsigned char end-flag; } Note: The max_size of a frame payload is 35 bytes

Server dll_recv(…pkt…) 1. Receive a frame from PHL 3. Compute CRC and check it 4. Drop it if there’s an CRC error 6. Reassemble the packet 7. If end-of-packet, return the packet to forward it the NWL. phl_send(…) phl_recv(…) 2. Unstuffing the frame server i.log 5. Check whether it’s duplicate. If yes, drop; otherwise, send ACK frame Force some error

Performance Timing client i.log Packet Sent Frame received in error ……

More Sliding Window Protocol: Go back NSliding Window Protocol: Go back N –Try to implement the simplest first: One-bit sliding window A single timer –Then implement a sending window size of 3 or more frames How to terminate a client process:How to terminate a client process: –When the client gets the response to the quit message –A “clean” way to terminate the server child process ?

Concurrent Server Example Code pid_t pid; int listenfd, connfd; listenfd = socket(... ); /* fill in sockaddr_in{ } with server's well-known port */ bind (listenfd,...); listen (listenfd, LISTENQ); for(;;){ 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 */ }

Timer Example /* example for start_timer, stop_timer, send_packet */ /* you MAY need to modify to work for project 3, this is just an example of the TIMER,not your protocol */ #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]; void timeout(int x){ printf(“time out!\n”);

/* you MAY need to modify to work for project 3, this is just an example of the TIMER,not your protocol */ } 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]); } Timer Example(cont)

/* you MAY need to modify to work for project 3, this is just an example of the TIMER,not your protocol */ void send_packet(packet *p){ fd_set readfds; int sockfd; 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, resend all frames that haven’t been acknowledged continue; } else{ perror("select error"); /* select error */ exit(1); Timer Example(cont)

/* you MAY need to modify to work for project 3, this is just an example of the TIMER,not your protocol */ } if(FD_ISSET(sockfd, &readfds)){ /* a frame come from socket */ cksum_function(); /* error check */ } if(cksum error){ continue; // do nothing, wait for timer time out } else{ // read the frame from socket, check to see if this frame is a data frame // or ack frame, doing corresponding processing continue;; } Timer Example(cont)