Skip to content

Commit c4980c0

Browse files
Merge pull request #3 from mangledbottles/readme
Readme
2 parents 4cf816e + 2bb6536 commit c4980c0

File tree

9 files changed

+141
-6
lines changed

9 files changed

+141
-6
lines changed

Assets/ClientApplication.png

136 KB
Loading

Assets/ClientSendingMessage.png

295 KB
Loading

Assets/Dockerfile.png

87.3 KB
Loading

Assets/FlowForwarding.png

74 KB
Loading

Assets/FlowForwardingGraphic.png

197 KB
Loading

Assets/Network.png

92.3 KB
Loading

Client/README.md

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,26 @@
1-
# Vue 3 + Typescript + Vite
1+
# Client ElectronJS Desktop Application
2+
This is the [ElectronJS](https://www.electronjs.org/) Desktop Application for the Client built using [VueJS](https://vuejs.org/) and [Typescript](https://www.typescriptlang.org).
23

3-
This template should help get you started developing with Vue 3 and Typescript in Vite. The template uses Vue 3 `<script setup>` SFCs, check out the [script setup docs](https://v3.vuejs.org/api/sfc-script-setup.html#sfc-script-setup) to learn more.
4+
The Client uses the Node.js UDP Datagram to communicate with the Switcher and send messages across the network of Routers to another another Client.
45

5-
## Recommended IDE Setup
6+
## Installation
7+
```bash
8+
npm install
69

7-
- [VSCode](https://code.visualstudio.com/) + [Volar](https://marketplace.visualstudio.com/items?itemName=johnsoncodehk.volar)
10+
# Start the Electron Application
11+
npm run electron:dev
812

9-
## Type Support For `.vue` Imports in TS
13+
# Build for production
14+
npm run app:build
15+
```
16+
## Application
17+
![Client Application](../Assets/ClientApplication.png)
18+
This application is started when the Client process is created. The Client attempts to connect to the Switcher and if successful, it will be allocated an IP address and port dependent on the network and available ports.
1019

11-
Since TypeScript cannot handle type information for `.vue` imports, they are shimmed to be a generic Vue component type by default. In most cases this is fine if you don't really care about component prop types outside of templates. However, if you wish to get actual prop types in `.vue` imports (for example to get props validation when using manual `h(...)` calls), you can enable Volar's `.vue` type support plugin by running `Volar: Switch TS Plugin on/off` from VSCode command palette.
20+
`./src/App.vue`
21+
22+
The GUI and main funcionality of the Client program is located in this file.
23+
24+
### Sending Messages
25+
![Client Sending Message](../Assets/ClientSendingMessage.png)
26+
Once the network has been established with an active Switcher and 3 connected Routers, the sending Client can send a message through the network to the receiving Client via a UDP Datagram.

README.md

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# OpenFlow UDP Socket Protocol
2+
![OpenFlow Network](Assets/Network.png)
3+
4+
This project is an implementation of the [OpenFlow Protocol](https://en.wikipedia.org/wiki/OpenFlow) using the [Node.js UDP Datagram Socket Library](https://nodejs.org/api/dgram.html). The core functionality of this system provides a front-end user interface for the client which connects to the OpenFlow Network.
5+
6+
The OpenFlow network consists of a number of **routers** that **forward message**s and are controlled by a centralised switcher.
7+
8+
The switcher is a simple device that allows the routers to communicate with each other. It also allows the routers to communicate with the network.
9+
10+
## Project Structure
11+
This project is divided into the following sections:
12+
- [/Server](/Server)
13+
- Writen in NodeJS using the [dgram](https://nodejs.org/api/dgram.html) module to create a Switcher and a number of Routers.
14+
- [/Client](/Client)
15+
- An [ElectronJS](https://www.electronjs.org/) desktop GUI application which provides a user interface that connects to the OpenFlow Network (in /Server).
16+
17+
## Downloading Repository
18+
```
19+
git clone https://github.com/mangledbottles/OpenFlow-Forwarding.git
20+
21+
cd OpenFlow-Forwarding
22+
23+
# See documentation inside /Client for installation of ElectronJS application
24+
# See documentation inside /Server for installation of NodeJS Switcher and Routers
25+
```
26+
27+
## Communication Protocol
28+
Communication between the Switcher, multiple Routers and multiple Clients is handled by a universal Protocol Type system.
29+
30+
| Protocol Type | Description | Components [Origin -> Destination] |
31+
| ------------- | ----------- | ---------- |
32+
| #0 | Switcher accepted this current Router on network | Switcher -> Router |
33+
| #1 | New Router Detected on Network by Switcher | Router -> Switcher |
34+
| #2 | Router querying Switcher for information about Clients from Forwarding Table | Router -> Switcher |
35+
| #3 | Client connecting to Router to get information about Forwarding Table | Client -> Router |
36+
| #4 | Router received information about a Client from Switcher via Flowtable | Switcher -> Router |
37+
| #5 | Router received message instructions from Client to send message over the network | Client -> Router |
38+
| #6 | Router received updated information about current Router | Switcher -> Router |
39+
40+
## Project Functionality
41+
![Flow Forwarding](Assets/FlowForwardingGraphic.png)
42+
1. Switcher is started to commence the network
43+
2. 3 Routers are started and join the network
44+
3. A client ("Alice") joins the network and is connected by the Switcher
45+
4. A secondary client ("Bob") joins the network and is connected by the Switcher
46+
5. Alice sends a message to Bob
47+
6. The message is forwarded from Alice to Router 1 to Router 2 to Router 3 and finally to Bob.
48+
49+
50+
## Wireshark
51+
The following diagram shows the communication between the Switcher, Routers and Clients.
52+
53+
### Example 1: Router connecting to Network via Switcher
54+
| No. | Time | Source | Destination | Protocol | Length | Info |
55+
| ---- | ---- | ------ | ----------- | -------- | ----- | ---- |
56+
| 5 | 10.382165 | 127.0.0.1 | 127.0.0.1 | UDP | 61 | 65469 -> 51510 |
57+
58+
| Hexadecimal Payload | Base10 Decoded |
59+
| ------------------- | -------------- |
60+
| 0000 0020 7b 22 74 79 70 65 22 3a 31 2c 22 6d 65 73 73 61 | {"type": 1, "messa |
61+
| 0010 67 65 22 3a 22 52 6f 75 74 65 72 22 7d | ge":"Router"} |
62+
63+
- Router on port 65469 is sending a message to the Switcher on port 51510 trying to join the network.
64+
- Type is set to 1, as seen in [Communication Table protocol type 1](#Communication-Protocol).
65+
66+
## References
67+
- [0] OpenFlow - https://en.wikipedia.org/wiki/OpenFlow
68+
- [1] Node Datagram Library - https://nodejs.org/api/dgram.html

Server/README.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Switcher and Router
2+
This folder is the source code for the Switcher and Routers on the OpenFlow Protocol Network.
3+
4+
## Installation
5+
```
6+
npm install
7+
8+
# Start the Switcher
9+
npm run switcher
10+
11+
# Start a Router (can start as many as you want)
12+
npm run router
13+
```
14+
15+
## Switcher
16+
`./src/Switcher.ts`
17+
18+
The Switcher is a NodeJS application that listens on port 51510 for OpenFlow messages. The Switcher is responsible for managing the Routers and Clients.
19+
20+
The Switcher contains a FlowTable that is used to control the flow of traffic between Clients and Routers.
21+
| Router | In | Out |
22+
|--------|----|-----|
23+
| R1 | E1 | R2 |
24+
| R2 | R1 | R2 |
25+
| R3 | R2 | E2 |
26+
27+
28+
## Router
29+
`./src/Router.ts`
30+
31+
The Router is a NodeJS application that can be started as many different processes to create multiple OpenFlow layers that connect together.
32+
33+
When a new Router process is created, it will send a message to the Switcher to connect and if successful, it will be added to the FlowTable.
34+
35+
If the Router is #1 on the network, its details will be stored and forwarded to the Client once they join the network.
36+
37+
When the network is filled out with 2 other Routers and a receiving Client, the initial Client can send a message to the receiving Client and the message will be forwarded the #1 Router.
38+
39+
Router #1 will then forward the message to Router #2 and Router #2 will forward the message to Router #3 and Router #3 will forward the message to the receiving Client.
40+
41+
![Flow Forwarding](../Assets/FlowForwarding.png)
42+
43+
## Dockerising the Switcher
44+
![Dockerfile](../Assets/Dockerfile.png)
45+
46+
```
47+
# Build the Docker image
48+
docker build -t dermot/openflow:1.0 .
49+
50+
# Run the Docker image inside a container
51+
docker run -it --rm --name openflow -p 51510:51510 dermot/openflow:1.0
52+
```

0 commit comments

Comments
 (0)