/* File: client.c */ /* ********************************************************************* ALTERNATING BIT AND GO-BACK-N NETWORK EMULATOR Revised version of code by J.F. Kurose From the companion website for _Computer Networking: A Top-Down Approach Featuring the Internet_ by J.F. Kurose and K. W. Ross (c) 2001 by Addison Wesley Longman Based on document at (as of 02 July 2002) ********************************************************************* */ #include #include "message.h" #include "payload.h" #include "packet.h" #include "client.h" #include "KRnet.h" /* prototypes for private functions */ static void startTimer(float howlong); static void cancelTimer(void); static void sendToNWSlayer(packet_t packet); static void deliverToAppLayer(char datasent[]); /* ****************** */ /* Client functions */ /* ****************** */ void sendToNWSlayer(packet_t packet) { toNWSlayer(Client, packet); } /* sendToNWSlayer() */ void deliverToAppLayer(char datasent[]) { toAppLayer(Client, datasent); } /* deliverToAppLayer() */ void startTimer(float howlong) { startClientTimer(howlong); } /* startTimer() */ void cancelTimer(void) { stopClientTimer(); } /* cancelTimer() */ /******** STUDENTS WRITE THESE NEXT FOUR ROUTINES ********/ /*-------------*/ /* clientInit */ /* *---------------------------------------------------*/ /* Called only once, before any other Client (entity A) routines */ /* are called. You can use it to do any initialization. */ /*-----------------------------------------------------------------*/ void clientInit(void) { }/* clientInit() */ /*------------*/ /* clientEnd */ /* *----------------------------------------------------*/ /* Called only once, after all other Client (entity A) routines */ /* are called. You can use it to print any final output. */ /*-----------------------------------------------------------------*/ void clientEnd(void) { }/* clientEnd() */ /*-------------*/ /* clientInput */ /* *---------------------------------------------------*/ /* */ /* called from layer 3 (Network Services), when a packet arrives */ /* for layer 4 (Transport) at Client (entity A) */ /*-----------------------------------------------------------------*/ void clientInput(packet_t packet) { } /* ClientInput() */ /*-----------------------*/ /* clientOutput */ /* *-----------------------------------------*/ /* */ /* called from the application layer (layer 5). Passed the data */ /* to be sent to server (entity B) */ /*-----------------------------------------------------------------*/ void clientOutput(message_t message) { } /* clientOutput() */ /*----------------------*/ /* clientTimerInterrupt */ /* *------------------------------------------*/ /* */ /* Called when the client's timer goes off */ /*-----------------------------------------------------------------*/ void clientTimerInterrupt(void) { } /* clientTimerInterrupt() */ /*--------------------------*/ /* clientCanSendMorePkt */ /* *--------------------------------------*/ /* */ /* called from the application layer (layer 5) , before passing */ /* data to ABP layer. return true(nonzero) if ABP layer is not */ /* in stop status, else return false(zero). */ /*-----------------------------------------------------------------*/ int clientCanSendMorePkt() { return 0; } /* EOF (client.c) */