From a54d88dc70edc874c189529a6140dea884fb71f2 Mon Sep 17 00:00:00 2001 From: cdez Date: Fri, 24 Jan 2025 14:36:36 -0700 Subject: [PATCH] Create the first assignment: 'timeserver' --- timeserver/Makefile | 20 ++++++++++++++++++++ timeserver/README.md | 16 ++++++++++++++++ timeserver/timeserver | Bin 0 -> 15784 bytes timeserver/timeserver.c | 33 +++++++++++++++++++++++++++++++++ timeserver/timeserver.h | 23 +++++++++++++++++++++++ timeserver/timeserver.o | Bin 0 -> 1240 bytes 6 files changed, 92 insertions(+) create mode 100644 timeserver/Makefile create mode 100644 timeserver/README.md create mode 100755 timeserver/timeserver create mode 100644 timeserver/timeserver.c create mode 100644 timeserver/timeserver.h create mode 100644 timeserver/timeserver.o 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 0000000000000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<&Q|D3=>KYoiab^#yr z!s>DMRw^BwH%{O~u8}FsuM;{o2lb!?@Sv|#hB4HSc~naHQGdA{&{Y!wjEQ?42mhWr zqBG!!CHg+>nwA1BX&B$fJVwzTJpcH;1#J)WFY^lrrJtc9tp;tCY#{h{X~ci1PkZgY G1^?f2hoKMv literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..93f9eca28428ef9931671ccb0241b5bf22834902 GIT binary patch literal 1240 zcmbVLJ4*vW5T1+gcYGj%BC%3Im-s|19 z;GeLxu~+Ow(3!j4xGb@8V0LD{nQvwvcURe!#e`*n5(^gKH&Q6Tvj*A`Y(p!wz(>d6 zXKuOtTE6&NE{AUql-hcNrA%f%HImDRo(NMDQ*4T*$7jPRoV=WzX6fls2}ivEYSAW9 z>rj{0a*zOcB&-INq$f6Dov(v+nzZ^`8yfF$PXmaPlJwG&ZBO1LGHvy%SU~X~LdU6v z_wQ=ynkqNYj)h$s9?c@MICOcy{S)r90=Ukh7k5m>hRzYG3;|eh<_af|R`{_!P@dqY z0@$u29ANn%09GivF82`gih?t|mhnJ1g(Dg7dm$_N#S-_$88Dw8JB%M}@A;0)E7Sh% z^dpn*sNU#c%eZoW8Ec*-%H+{w91(LO-#`LW2*vbH|0kA zWZZ<7_Nn*^uQr<~FSMZSL@PiuT6!asPkqg|BZ@8OcT=E=geyoVde!(PS-4-Rj2)Bz E1JTS=c>n+a literal 0 HcmV?d00001