|
1 | 1 | # UDP Network Socket Protocol
|
2 | 2 |
|
| 3 | + |
| 4 | + |
3 | 5 | ## Installation
|
4 | 6 | ```
|
5 | 7 | git clone https://github.com/mangledbottles/Network-Socket-Protocol.git
|
@@ -35,7 +37,44 @@ npm run client
|
35 | 37 | > 
|
36 | 38 | > Starting the Client sends a message to the Server and the Server response with the current time
|
37 | 39 |
|
| 40 | +# Topology |
| 41 | +## Dockerfile |
| 42 | +This project has been [dockerized](./Dockerfile) |
| 43 | +>  |
| 44 | +
|
| 45 | +## Server.ts |
| 46 | +The Server.ts file contains 4 main functionalities |
| 47 | +1. Create UDP server with the dgram library |
| 48 | +2. Read user IO from the CLI |
| 49 | +3. Listen to incomining messages from Clients |
| 50 | +4. Send messages to Client(s) |
| 51 | + |
38 | 52 | ## Broadcasting
|
39 |
| -The Server can send a message to all Clients. The user types into the CLI and the Server manages the IO and broadcasts the message to all connected Clients |
| 53 | +The Server can send a message to all Clients. The user types into the CLI and the Server manages the IO and broadcasts the message to all connected Clients. To broadcast a message to all Clients, run the Docker container ([as seen above](#dockerizing-server)), then type a message into the CLI and press enter. |
40 | 54 | > 
|
41 |
| -> When a Client connects to the Server, their address and port are saved. When a broadcast is called, the message is sent to all addresses and ports connected |
| 55 | +> When a Client connects to the Server, their address and port are saved. When a broadcast is called, the message is sent to all addresses and ports connected. An Typescript interface has been created for Client and all Client's are stored in a Set to prevent duplicates. |
| 56 | +
|
| 57 | +## Client.ts |
| 58 | +The Client.ts file connects to the Server, sends a message to the Server and listens for messages from the Server. |
| 59 | + |
| 60 | +## Wireshark |
| 61 | +[Wireshark](https://www.wireshark.org/) is a network packet analyzer. |
| 62 | + |
| 63 | +Sample intercepted request (taken from [Wireshark PCAP File](./Misc/2ClientsConnectToServerAndServerBroadcast.pcapng)) |
| 64 | + |
| 65 | + |
| 66 | +| No. | Time | Source | Destination | Protocol | Length | Info | |
| 67 | +| --- | ---- | ------ | ----------- | -------- | ------ | ---- | |
| 68 | +| 2 | 0.010357778 | 127.0.0.1 | 127.0.0.1 | UDP | 137 | 8080 → 60137 Len=95 | |
| 69 | + |
| 70 | +--- |
| 71 | +| Hexadecimal Payload | Base10 Decoded | |
| 72 | +|-|-| |
| 73 | +| 0000 48 65 6c 6c 6f 20 33 35 35 39 31 2c 20 79 6f 75 | Hello 35591, you | |
| 74 | +| 0010 20 61 72 65 20 23 30 2c 20 74 69 6d 65 20 69 73 | are #0, time is | |
| 75 | +| 0020 20 54 75 65 20 4f 63 74 20 32 36 20 32 30 32 31 | Tue Oct 26 2021 | |
| 76 | +| 0030 20 31 38 3a 32 35 3a 35 34 20 47 4d 54 2b 30 30 | 18:25:54 GMT+00 | |
| 77 | +| 0040 30 30 20 28 43 6f 6f 72 64 69 6e 61 74 65 64 20 | 00 (Coordinated | |
| 78 | +| 0050 55 6e 69 76 65 72 73 61 6c 20 54 69 6d 65 29 | Universal Time) | |
| 79 | + |
| 80 | +This is one request taken from the PCAP file which intercepted a message from the Server to the Client sending the current date. The payload is send in hexadecimal format. In the Info tab, you can see the request is being sent from port 8080 (Server) to port 60137 (generated port for given Client). |
0 commit comments