diff --git a/timeserver/Makefile b/timeserver/Makefile new file mode 100644 index 0000000..728ddbf --- /dev/null +++ b/timeserver/Makefile @@ -0,0 +1,20 @@ +CC = gcc -Wall -std=c99 -pedantic +SOURCES = timeserver.c +OBJECTS = timeserver.o + +all: timeserver + +timeserver: $(OBJECTS) + $(CC) $(OBJECTS) -o timeserver + +timeserver.o: timeserver.c + $(CC) -c timeserver.c -o timeserver.o + +clean: + rm -f $(OBJECTS) timeserver timeserver.out + +clean_objects: + rm -f $(OBJECTS) + +run: + ./timeserver diff --git a/timeserver/README.md b/timeserver/README.md new file mode 100644 index 0000000..b9d8b6a --- /dev/null +++ b/timeserver/README.md @@ -0,0 +1,16 @@ +# Running the timeserver +Use `make` to compile the timeserver. +Use `make run` to run the timeserver. This will run on an infinite loop. +Use `Ctrl+C` to stop the timeserver. + +## timeserver communication +Communicating with the server can happen using netcat in UDP mode (-u flag). + +## timeserver information +The timeserver runs on UDP port 8888. +The timeserver will wait for `time\r\n` to be sent on this port, and if received, +will send back a response of the time (in ms) since January 1st, 1970 (UNIX Epoch). + +## pcap information +A demonstration of the timeserver has been captured with Wireshark in the +included `demo.pcap` file. \ No newline at end of file diff --git a/timeserver/timeserver b/timeserver/timeserver new file mode 100755 index 0000000..b4c265b Binary files /dev/null and b/timeserver/timeserver differ diff --git a/timeserver/timeserver.c b/timeserver/timeserver.c new file mode 100644 index 0000000..c33effd --- /dev/null +++ b/timeserver/timeserver.c @@ -0,0 +1,33 @@ +// header files +#include "timeserver.h" + +// constants +// timeserver port is 8888 +#define TIMEPORT "8888" + +// prototypes + +// main function +int main(int argc, char **argv) +{ + // initialize program (variables and structs) + // define a UDP socket + // bind the UDP socket to port 8888 / TIMEPORT + // while loop to see if the "time\r\n" has been received (recv call?) + // if "time\r\n" is received, then send() back the linux epoch. + // profit??? + return 0; +} + +// function definitions + +/* +Name: ??? +Process: ??? +Function Input/Parameters: ??? +Function Output/Parameters: ??? +Function Output/Returned: ??? +Device Input/Device: ??? +Device Output/Device: ??? +Dependencies: ??? +*/ \ No newline at end of file diff --git a/timeserver/timeserver.h b/timeserver/timeserver.h new file mode 100644 index 0000000..1a8135b --- /dev/null +++ b/timeserver/timeserver.h @@ -0,0 +1,23 @@ +#ifndef TIMESERVER +#define TIMESERVER + +// included libraries +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// data structures + +// function prototypes + +#endif // TIMESERVER \ No newline at end of file diff --git a/timeserver/timeserver.o b/timeserver/timeserver.o new file mode 100644 index 0000000..93f9eca Binary files /dev/null and b/timeserver/timeserver.o differ