CS4516: Medical Examiner Client/Server Evan Frenn 1.

Slides:



Advertisements
Similar presentations
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.
Advertisements

Today’s topic Issues about sending structures with TCP. Server design alternatives: concurrent server and multiplexed server. I/O multiplexing.
Go-Back-N Improve Stop-and-Wait by not waiting!
CSCE 515: Computer Network Programming TCP Details Wenyuan Xu Department of Computer Science and Engineering.
ELEN 602 Lecture 5 Review of last lecture –Error Detection -- parity/CRC etc. Automatic Retransmission Request (ARQ) Reading: Chap
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)
1 Socket Interfaces Professor Jinhua Guo CIS527 Fall 2003.
CS4514 HELP Session 3 Concurrent Server Using Go-Back-N Song Wang 12/08/2003.
Programming with Berkeley Sockets Presented by Chris GauthierDickey Written by Daniel Stutzbach (I think!) for CIS 432/532 Useful References: ● man pages.
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.
CSCE 515: Computer Network Programming TCP Details Wenyuan Xu Department of Computer Science and Engineering.
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.
WXES2106 Network Technology Semester /2005 Chapter 8 Intermediate TCP CCNA2: Module 10.
1 CS4514 Project 2 Help Session (B05) Mingzhe Li Nov 10, 2005.
IP Multiplexing Ying Zhang EECS 489 W07.
Process-to-Process Delivery:
Socket Programming References: redKlyde ’ s tutorial set Winsock2 for games (gamedev.net)
資 管 Lee Application Layer and Client-Server Model A3.
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.
1 COMP/ELEC 429/556 Introduction to Computer Networks Creating a Network Application Some slides used with permissions from Edward W. Knightly, T. S. Eugene.
Socket Programming Lec 2 Rishi Kant. Review of Socket programming Decide which type of socket – stream or datagram. Based on type create socket using.
CSCE 515: Computer Network Programming Select Wenyuan Xu Department of Computer Science and Engineering.
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.
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.
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.
CSCI 330 UNIX and Network Programming Unit XVII: Socket Programming Detail.
COSC 3213: Computer Networks I Instructor: Dr. Amir Asif Department of Computer Science York University Section M Topics: 1.Flow Control and ARQ Protocols.
TCP/IP1 Address Resolution Protocol Internet uses IP address to recognize a computer. But IP address needs to be translated to physical address (NIC).
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.
ECE 297 Concurrent Servers Process, fork & threads ECE 297.
Data Link Layer Flow Control.
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:
Chapter 5 Peer-to-Peer Protocols and Data Link Layer
CS4514 Project 2 Help Session (B07)
Socket Programming.
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,
System Programming: Process Management
Presentation transcript:

CS4516: Medical Examiner Client/Server Evan Frenn 1

Overview Objective: Implement both a client and concurrent server with an overlay network emulating four layers of the TCP/IP stack.  Application Layer: Medical Examiner functionality (Messages)  Network Layer: Converts messages to packets; Handles sequencing (Packets)  Data Link Layer: Go Back N sliding window; Error Detection (Frames)  Physical Layer: Handles sockets and error creation 2

System Structure 3 ClientServer

Application Layer  Minimum of six client request types. Must include: Input of a photo  Must include message to distinguish user type (authoritative vs. query only)  It is optional to implement application layer separately or as part of the network layer 4

Network Layer 5 Packets App Layer Packet Structure 2 Byte Seq # Message Payload dl_send(packet) dl_rcv(packet) dl_send(packet) dl_rcv(packet) Msg Payload Size <=256 Bytes Note: The NL may pass packets to the DLL until the sliding window is full App Layer

Data Link Layer 6 Network Layer Frame Structure Payload 2 Bytes Sequence # 2 Byte Error Detection 1 Byte End-of-Frame 1 Byte Frame Type pl_send(frame) pl_rcv(frame) pl_send(frame) pl_rcv(frame) Msg Payload Size <=150 Bytes Network Layer Sliding Window >= 4 ARQ Go-Back N ACK or NACK? Piggyback the ACK? Frame

Go-Back N ARQ 7 A B fr 0 time fr 1 fr 2 fr 3 fr 4 fr 5 fr 6 fr 3 ACK1ACK1 error Out-of-sequence frames Go-Back-4: fr 5 fr 6 fr 4 fr 7 fr 8 fr 9 ACK2ACK2 ACK3ACK3 ACK4ACK4 ACK5ACK5 ACK6ACK6 AC K7 ACK8ACK8 ACK9ACK9 ACKing next frame expected Timeout Occurs for frame 3 !! 4 outstanding frames so go back 4 Leon-Garcia & Widjaja: Communication Networks

Physical Layer 8 Data Link Layer Forced Single Bit Error Every 6 th data frame Every 8 th ACK frame recv(sockfd,data, len, …) send(sockfd, data, …) Data Link Layer Data recv(sockfd,data, len, …) send(sockfd, data, …)

Concurrent Server Server must be able to process multiple clients in parallel A few ways to achieve concurrency:  Use fork() – separate processes, no shared memory  Use threads (pthreads) 9

Concurrent Server (using fork) pid_t pid, id; int listenfd, connfd; /* 1. create a socket socket() */ if ((listenfd = socket(AF_INET, SOCK_STREAM, 0)) < 0 ){ perror("Error creating socket"); exit(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, 5); while(1){ connfd = accept(listenfd,... ); if(( pid = fork()) == 0){ close(listenfd); /* child closes listening socket */ doit(connfd); /* process the request. this is where the work is done. */ close(connfd); /* done with this client */ exit(0); } close(listenfd); /* parent closes the socket */ exit(0); 10

Data Link Layer: dl_send(packet,…) 11 Split packet into frame payloads Create frame (set params then EC) Start a timer pl_send(frame) Timeout Handler Go-Back N

Frame Structure 12 DatafieldSeq 1. Compute Seq Number, Frame Type and End-Of-Frame (EOF) bytes EOP ED 2. Error-Detection (ED) bytes (XOR on Seq + FT + EOF + Data) Datafield EOF: End of FrameED: Error Detection FT: Frame Type Seq: Sequence Num 2 Bytes <= 150 Bytes 1 Byte DatafieldSeqEOP 2 Bytes FT 1 Byte

Data Link Layer: Frame Reception 13 Compute Error Detection value ED Ok? ACK/FRAME pl_send(ACK frame) Reassemble Packet (store for dl_recv()) SEQ Right? Return Drop Packet Update window/timer No ACK Frame Yes

Timers Timers will be used by the data link layer to detect frame loss.  DLL sets a timer when transmitting a frame  When the timer expires, DDL handles retransmit of send window up to lost frame  With Go Back N, it is possible to use a single timer and keep track of time intervals between transmission of frames. Two options for timers:  Select  Signals and Timers 14

Example Using select() -Can be used to both send/recv at same time and/or as a timer for the data link layer int select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout); 15 int main(void) { fd_set rfds; struct timeval tv; int retval; /* Watch stdin (fd 0) to see when it has input. */ FD_ZERO(&rfds); FD_SET(0, &rfds); /* Wait up to five seconds. */ tv.tv_sec = 5; tv.tv_usec = 0; retval = select(1, &rfds, NULL, NULL, &tv); if (retval == -1) perror("select()"); else if (retval) printf("Data is available now.\n"); else // retval == 0 here printf("No data within five seconds.\n"); exit(EXIT_SUCCESS); }

Signal Example #include 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); } 16

Send/Recv “concurrently” One option mention earlier is to use select() Another option is to use fcntl() to have the socket not block during recv() int fcntl(int s, int cmd, long arg);  Example: #include fctnl(socketFD, F_SETFL, O_NONBLOCK); 17

Questions? 18