Skip to content
Snippets Groups Projects
DataVis_README.md 32 KiB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636
# Data Visualization
* Takes the most recent G2 Snapshot and shows geolocation data of the nodes, as well as the network data that flows between them.
* Allows for node data to be added or replaced; changes are saved in the Netbox database and do not need to be re-added every time the game is run.
* Problematic or missing information can easily be brought to the attention of a user by applying different effects to the spawned actors based on their metadata, such as color, size, shape, gravity, transparency, and particle effects
* Two different levels -- global and abstract -- provide unique methods of visualization.


# Table of Contents
- [Installation](#installation)
- [How to use](#how-to-use)
    - [Setup](#setup)
    - [Earth G2 View](#earth-g2-view)
        - [Movement](#movement)
        - [User Interaction](#user-interaction)
    - [Abstract View](#abstract-view)
        - [Movement](#movement)
        - [User Interaction](#user-interaction)
- [How it works](#how-it-works)
    - [Downloading and Parsing the Data](#downloading-and-parsing-the-data)
        - [Multi Threading](#multi-threading)
        - [G2 API](#g2-api)
            - [Obtaining the Bearer Token](#obtaining-the-bearer-token)
            - [Finding the Most Recent Snapshot](#finding-the-most-recent-snapshot)
            - [Parsing the Snapshot](#parsing-the-snapshot)
        - [UE4](#ue4)
            - [Pulling the UE4 Data](#pulling-the-ue4-data)
            - [Parsing the UE4 Data](#parsing-the-ue4-data)
        - [Netbox](#netbox)
            - [Pulling the Netbox Data](#pulling-the-netbox-data)
            - [Parsing and Comparing the Netbox Data](#parsing-and-comparing-the-netbox-data)
            - [Updating Netbox](#updating-netbox)
    - [Displaying G2 data](#diplaying-g2-data)
        - [G2 Setup](#g2-setup)
        - [G2 Nodes](#g2-nodes)
        - [G2 Links](#g2-links)
        - [G2 Multi Body Forces Simulation](#g2-multi-body-forces-simulation)
    - [Abstract View](#abstract-view)
        - [Moving to Abstract View](#moving-to-abstract-view)
        - [Abstract View Setup](#abstract-view-setup)
        - [Abstract View Nodes](#abstract-view-nodes)
        - [Abstract View Links](#abstract-view-links)
        - [Abstract View Node System](#abstract-view-node-system)
    - [User Interface](#user-interface)
        - [Sliders](#sliders)
        - [Editing Node Data](#editing-node-data)
        - [Viewing Node and Link Data](#viewing-node-and-link-data)
        - [Node Click and Drag](#node-click-and-drag)
- [Troubleshooting](#troubleshooting)
- [Resources](#resources)


## Installation
Note: As of now this project is part of the ARNOC-Alpha project, so the full repository must be installed.
1. Install Plugins to Unreal Engine: VARest and EasyJsonParser .
2. Download Repository.
3. Open project from "arnocMain.uproject" file.

## How to Use

### Setup
1. Navigate to the Content/G2Visualization/ directory
2. Drag a BP_G2_Topology_Controller object into the map. The location does not matter.
3. Then drag in or spawn one or more BP_G2_Topology actors.

### Earth G2 View
**Movement**
* Left Mouse Button (Hold) - rotate the global Earth view.
* Right Mouse Button (Click) - select a node or link, and display its related metadata (Note: in order to click on links, the physics must be paused; see below.)
* Middle Mouse Button (Scroll) - zoom in and out.

**User Interaction**
* P - pause the physics and movement of the nodes and splines.
* T - toggle the visibility of the nodes and links.
* F - toggle sliders
* G - enter Grab Mode. In Grab Mode:
    * Left Mouse Button (Hold) - drag a node to a new location. This will not update the node’s geolocation data in Netbox and is for visualization purposes only. 
* C - move to the Cesium level
* A - move to the Abstract View
* Center Force Slider -  controls the resting radial distance of an untethered node
* Center Friction Force Slider - controls “bouncing” when node radius is changed
* Tangent Friction Force - controls how quickly nodes will move to their resting positions on the surface of the Earth
* Link Force Slider - controls how strongly links pull on Untethered nodes
* Link Opacity Slider - makes links more solid or translucent

### Abstract View
**Movement**
* W - move forward
* S - move backward
* A - move left
* D - move right
* Spacebar - move up
* Left-shift - move down
* Mouse - look around


**User Interaction**
* P - pause the physics and movement of the nodes and splines.
* C - move to the Cesium level
* B - move to the Global View once in the Abstract View
* Left Mouse Button (Hold) - drag a node to a new location. After releasing the node will once again be affected by physics.

## How it works

### Downloading and Parsing the Data
This part of the Data Visualization utilizes the G2 API Helper plugin, which contains structs and functions designed for parsing G2, UE4 Nautilus, and Netbox requests. The repo can be found here: https://gitlab.nrp-nautilus.io/ar-noc/g2apihelper.

Most of the functions have been converted from Blueprints to C++. The pertinent functions are in the following classes:
```
- arnocMain/Source/
    - Private/
        - G2Node.cpp
        - G2Snapshot.cpp
        - G2TopologyController.cpp
    - Public/
        - G2Node.h
        - G2Snapshot.h
        - G2TopologyController.h
```

The flow of the request functions can be found in G2TopologyController.cpp. These are comprised of mainly functions that make requests, handle request responses, and process the data from request responses. G2Node.h and G2Snapshot.h define UObjects for holding node and snapshot data, respectively. They were implemented as an UObjects instead of a UStructs so pointers could be used to  reference the data quickly.  

**G2 Topology Controller**
The G2 Topology Controller is responsible for interacting the various REST APIs and as well as parsing and storing the network data. It is designed to allow use of multiple G2 Topology actors without having to make the same REST API calls multiple times. Only one G2 Topology Controller should be in use at a time.

First the G2 Topology Controller makes all the REST API calls and processes the data. There are more details on the these processes below. Next, the processed data is used to update all of the G2 Topology actors. G2 Topology actors that already had data will refresh their visualization with the updated data.

**Multi Threading**

All the request and response functions are implemented using AsyncTask functions. These work by placing the code to run in a separate thread in the AsyncTask function. Additionally, AsyncTasks require a thread to run on and the parameters that may be used in the AsyncTask. The ENamedThreads::AnyBackgroundHiPriTask thread seems to run the fastest. 

Here is an example AsyncTask Taken from G2TopologyController.cpp:
```
void AG2TopologyController::OnBearerTokenResponse(FHttpRequestPtr Request, FHttpResponsePtr Response, bool bWasSuccessful) {

	AsyncTask(ENamedThreads::AnyBackgroundHiPriTask, [Response, bWasSuccessful, this] ()
	{
		TSharedPtr<FJsonObject> JsonResponse;
		if (bWasSuccessful) {
			UE_LOG(LogTemp, Warning, TEXT("Login Successful"));

			const FString ResponseBody = Response->GetContentAsString();
			TSharedRef<TJsonReader<>> Reader = TJsonReaderFactory<>::Create(ResponseBody);
			if (FJsonSerializer::Deserialize(Reader, JsonResponse))
			{
				this->G2Token = JsonResponse->GetStringField("token");
			}

			RequestSnapshotRange();
		}
		else {
			UE_LOG(LogTemp, Warning, TEXT("Login Unsuccessful"));
		}
	});
}
```

**G2 API**
1. Obtaining the Bearer Token

   Using VARest, send GET request with a JSON to https://g2api.nautilus.optiputer.net/api/auth/login with the following format:
    ```
    {
        "username": "USERNAME",
        "password": "PASSWORD"
    }
    ```
   Replace USERNAME and PASSWORD respectively with the username and password of the G2 account.

   If the G2 account credentials are valid, VARest will receive a JSON in the following format:
    ```
    {
        "admin": BOOLEAN,
        "token": "BEARER_TOKEN",
        "username": "USERNAME"
    }
    ```
    | JSON Key Name | Value Meaning | 
    | ------------- | ------------- |
    | admin | BOOLEAN: whether the provided account has admin status. |
    | token | BEARER_TOKEN: newly generated bearer token, which is used for Authorization when interacting with the G2 API.  |
    | username | USERNAME: username of the account. Should be the same as the username provided when sending credentials. |
    
    Here we parse and store the BEARER_TOKEN for the next step.

2. Finding the Most Recent Snapshot

   Using VARest, send a GET request to https://g2api.nautilus.optiputer.net//api/tsrange/-1/0 with the "Authorization" header set to "Bearer        BEARER_TOKEN", where BEARER_TOKEN is replaced with the BEARER_TOKEN found in the previous step.
   If this request was successful, then VARest will receive a JSON in the following format:
    ```
    [
        [
            TIME_STAMP1,
            ID1
        ],
        [
            TIME_STAMP2,
            ID2
        ],
        ...
    ]
    ```

    This is an array of (int, float) pairs, which represent the available Snapshots in G2 which can be pulled. 

    Note: Neither VARest nor EasyJsonParser can handle JSONs in this format, so parsing is done manually by converting the JSON into a string and then searching the string. Then the values are stored within an array of STimeStampSnapshotIDPair structs called AvailableSnapshots.

    The last element of this list is considered the most recent and pullable Snapshot. Since some Snapshots are not pullable, we attempt to pull Snapshot represented by the last element of AvailableSnapshots, until we are successful. Otherwise we remove the last element from the list if it is not successful. Currently the case where no Snapshots are valid is not properly handeled. 

    Note: A valid JSON response is one which has the fields data.snapshots[0].flows.flowgroups and data.snapshots[0].topo.topology.

    To attempt to pull a snapshot, use send a GET request to https://g2api.nautilus.optiputer.net//api/snapshot?id=ID, where ID is the ID of the requested snapshot and the "Authorization" header set to "Bearer BEARER_TOKEN", where BEARER_TOKEN is replaced with the BEARER_TOKEN found in the previous steps.

3. Parsing the Snapshot

    Since the Snapshot JSON contains Arrays within fields, we use the EasyJsonParser. 

    The Node data (data.snapshots[0].topo.topology.nodes) and the Link data (data.snapshots[0].topo.topology.links) are parsed and BP_G2_Node and BP_G2_Link actors are created for each respective node and link entry, with all of the available meta data saved within the actors. These newly created actors begin with their default attributes and start at location (0, 0, 0) and will be properly updated later.

    Note: The Flow data (data.snapshots[0].flows.flowgroups) is not currently parsed because the Flow data is missing IP values for the Start and End nodes, which would allow us to connect them to the Node data. The Start and End nodes are given host ID, which start with 'h', while the Nodes in the Node data all start with 's'.

**UE4**
1. Pulling the UE4 Data

    Using VARest, send GET request to https://ue4-data.nautilus.optiputer.net, which is referred to as the UE4 Link. Note: The Authorization header is set but is does not matter what the Bearer Key is because it is not needed.

    VARest will receive a JSON in the following format:
    ```
    {
        "nodes": 
            [
                "paths": [...],
                "hostname": "HOSTNAME",
                "ip": "IP_ADDRESS",
                "latitude": LATITUDE,
                "longitude": LONGITUDE,
                "primary": BOOLEAN
            ],
            ...
        "edges": ...
    }
    ```

    The "nodes" field, which is an array of data pertaining to each node, contains the data we need.
2. Parsing the UE4 Data

    For each UE4 Link "nodes" element, parse the "ip" field and search through the array of G2 Node Actors for a node with a matching IP. If a matching node is found, then check if the "latitude"/"longitude" values is the "Kansas Point", which is an incorrect default location in Kansas that many nodes are given in the UE4 Link. If the location is not the Kansas Point, then parse and set the actor's Latitude, Longitude, and Primary variables, according to the UE4 Link.

**Netbox**

Note: This occurs after the G2 Setup.
1. Pulling the Netbox Data

    Using VARest, send GET request to https://netbox.nrp-nautilus.io/api/dcim/sites/?cf_g2_node=true&limit=0&offset=0 with the "Authorization" header set to "Token TOKEN", where TOKEN is a token string generated on the netbox website.

    If the token is valid, VARest will receive a JSON in the following format:
    ```
    {
        "count": NUM_NODES,
        "next": "https://netbox.nrp-nautilus.io/api/dcim/sites/?limit=50&offset=50",
        "previous": null,
        "results":
            [
                {
                ...,
                "custom_fields": {
                    "g2_node": BOOLEAN,
                    "g2_node_name": "NAME",
                    "node_id": "ID",
                    "info": "INFO",
                    "ip": "IP",
                    "latitude": "LATITUDE",
                    "longitude": "LONGITUDE",
                    "mtu": "MTU",
                    "override_location": BOOLEAN,
                    "primary": BOOLEAN,
                    ...
                },
                ...
            ]
    }
    ```
    
    Many of the fields have been omitted for brevity. The main focus is the array contained within the results field. The neccessary fields are within the "custom_fields" field. Note: Go to https://netbox.nrp-nautilus.io/admin/extras/customfield/ to configure the custom field settings. Also netbox does not support float values, so we use strings instead.
    
2. Parsing and Comparing the Netbox Data

    For each BP_G2_Node actor, search through the "results" field for the corresponding entry, using the "node_id" field and then parse the custom fields, which are shown above. Then if the actor's MTU is 0, override it with the Netbox MTU. Likewise, if the the "override_location" field from Netbox is true, override the actor's Latitude and Longitude with the values from Netbox respectively, while also putting the actor on a list of LERPing nodes, which will be explained more in the G2 Multi Body Forces Simulation section.

3. Updating Netbox

    If any of the info was changed between G2 and Netbox, send a PUT request to https://netbox.nrp-nautilus.io/api/dcim/sites/ID/, where ID is replaced with the actor's id. Once again  the "Authorization" header is set to "Token TOKEN", where TOKEN is a token string generated on the netbox website. Also, attach a JSON in the following format:
    ```
    {
        "name": "ID",
        "slug": "ID",
        "custom_fields":
            {
                "g2_node": true,
                "g2_node_name": "NAME",
                "info": "INFO",
                "ip": "IP",
                "latitude": "LATITUDE",
                "longitude": "LONGITUDE",
                "mtu": MTU,
                "primary": BOOLEAN,
                "node_id": ID
            }
    }
    ```
    
    The values in all CAPS are replaced by the actor's current data.

    Then for every BP_G2_Node actor that does not have a corresponding entry in Netbox, we do the same as above but instead use a POST request. The only difference is that we include "site" field with the value as the highest Netbox ID we have found plus 1. This can be placed before the "name" field in the JSON.

### Displaying G2 data
**G2 Setup**
1. Setup GUI

    Create the user interface widgets. These widgets include the Node Info Display and Link Info Display, which display the metadata of any node that is selected with the Right Mouse Button. The widgets contain editable text which is updated with the relevant metadata of whichever node or link is selected; this text can also be manually manipulated by the user. If a manual update is made, the user will be prompted by the Confirm Change Widget, which is also created in this step, before the update is saved (and, in certain cases, saved to Netbox. Currently, only the MTU, latitude, and longitude sections of the Node Info Display are capable of sending updates to Netbox). The final widget is the Force Sliders Display, which contains sliders that allow for manipulation of link opacity and the simulated physics forces acting between nodes and links. 

2. Setup G2 Nodes

    Assign a physical form and visual parameters to each node, according to its metadata. If a node does not have associated latlong data, add to array of "Untethered Nodes;" if its geolocation is known, bypass this step. Assign a static mesh and a color to the node depending on its primary status and MTU value, respectively. 

3. Setup G2 Links

    Create a spline correlating to each link, to be positioned later. For each link, add a Spline Component (the immaterial path to be followed). Add a single spline point to allow for a bend rather than a straight line. Add two spline mesh components (the material meshes that follow the path designated by the Spline Component). 

    Next, set color of Spline Mesh Components according to Delay value of link.

    Finally, update position and rotation of spline. Set start & end points of spline as the locations of the source and target node, respectively. Set height of middle Spline Point, proportional to the distance between the start and end points. Set rotation and tangents of spline points in order to ensure that their orientations are correct. Set start and end points of each Spline Mesh Component according to these specifications.

**G2 Nodes**
| Visual Attribute | Node Meaning | 
| --------------- | -------------- |
| Shape | Nodes with the "primary" are composed a cylinder-shaped mesh. Non-primaries are rectangular prisms. |
| Color | Green coloring indicate that the node has an associated MTU value of 9000. Black indicates an MTU of less than 9000 but greater than 0. Red indicates that the MTU value is unknown and defaults to 0. |
| Distance from center | Nodes which have both unknown MTU values and a non-primary designation will appear to "float" above the Earth rather than remaining on the surface. |
| Glow | Indicates that the node is currently selected and that its related metadata is being displayed. |

**G2 Links**
| Visual Attribute | Link Meaning | 
| --------------- | -------------- |
| Color | Blue colored links indicate an associated "Delay" value of less than 10 seconds; red links are greater than 10 seconds. Green means that nodes is currently selected. |
| Distance from center | Flows across longer distances will generally have larger arches and peak at distances farther from the surface of the Earth model. |
| Glow | Indicates that the link is currently selected and that its related metadata is being displayed. |

Manipulation of further parameters, such as size of links and nodes, will be implemented in coming months. Many visualization decisions are purely aesthetic decisions, and future updates will allow for the manipulation of parameters by a user to suit their needs (for example, a user specifying that the cutoff for the Delay value should be 20 seconds, rather than 10, and that the anomalous links should appear as orange, rather than red.)

**G2 Multi Body Forces Simulation**
1. Tethered Nodes
    
    Nodes that will not be affected by any of the Simulation forces, and therefore will node move on their own.
2. Untethered Nodes
    
    Nodes that will are affected by the Simulation forces. All Untethered Nodes are affected by a Center Force, which cause nodes to move to the surface of the Earth if MTU is 9000 and higher if MTU is less than 9000, and a Friction force which is proportional to the node’s current speed and has different strengths for the Center directed velocity component and the Tangent directed velocity component. Finally, only nodes with a Latitude and Longitude value of (0, 0) will be pulled along the Links that connect it.
3. LEARPing Nodes
    
    Nodes that are traveling directly to a new location. These nodes have been given a new Latitude and Longitude value, which is used to calculate this target location. Once the node has reached a certain distance from the target location, it jumps to that target location and then can become a Tethered or Untethered node.
4. Updating Visualization
    
    Nodes are updated by moving them to their calculated new location and changing the rotation accordingly. Links are updated according to their nodes locations and then updating the rest of the actor.


### Abstract View
**Moving to Abstract View**
1. User Presses A to go to Abstract View
2. Send G2 Snapshot data to Abstract View

    Actors and Object are not saved between levels, so the way to send data to the Abstract View is the to use the BP_Game_Instance, which exists across all levels, to convert and store G2 Snapshot data into a struct.

    The data is converted and stored in the BP_Game_Instance G2 Snapshot variable, which is a SSnapshot struct. Contained within that are lists of SG2Node, SG2Link, and SFlow structs. From what we know only primitive types can be used in this situation, so the structs are necessary as supposed to the existing actors.

3. Setup Abstract View

**Abstract View Setup**
1. Set Data in BP_Abstract_Visualization from BP_Game_Instance G2 Snapshot field.

    Convert the SG2Node, SG2Link, and SFlow structs into BP_Abstract_Node, BP_Abstract_Link, and BP_Abstract_Flow actors respectively. The ConnectedNodes field will be set when the Abstract Links are set up.

2. Setup Abstract Nodes

    For each Abstract Node, spawn a BP_Abstract_Node actor, which has AbstractNode as the parent, in random location within a certain radius. Then initialize all of its variables from the structs. 

    C++ Interface
    ```
    AbstractNode.h
    AbstractNode.cpp

    AAbstractNode : AActor

    FString ID;
    FString IP;
    FString Info;
    FString Name;

    float Latitude;
    float Longitude;

    int NumInLinks;
    int NumOutLinks;

    bool Primary;

    FVector Acceleration = FVector(0.0f, 0.0f, 0.0f);
    FVector Velocity = FVector(0.0f, 0.0f, 0.0f);
    float Radius = 500.0f;

    TArray<AAbstractNode*> ConnectedNodes;

    virtual void Tick(float DeltaTime) override;
    void Init(FString IDIn, FString IPIn, FString InfoIn, FString NameIn,
            float LatitudeIn, float LongitudeIn, int NumLinksIn,
            int NumLinksOut, bool PrimaryIn);
    void ApplyAcceleration(FVector Force);
    void Move(float TimeDelta);
    ```

3. Setup Abstract Links

    For each Abstract Link, spawn a BP_Abstract_Link actor, which has AbstractLink as the parent, and setup the spline like the BP_G2_Link splines, but only use 2 spline points so the Link is straight. Using this Link's Source and Target Node data, add the respective Node to each other Node's ConnectedNodes array

    C++ Interface
    ```
    AbstractLink.h
    AbstractLink.cpp

    AAbstractLink : AActor

    FString ID;
    FString Info;
    FString MaxQueueSize;
    FString UseHTB;

    float Bandwidth;
    float Delay;

    int Group;
    int Loss;

    AAbstractNode* Source;
    AAbstractNode* Target;

    virtual void Tick(float DeltaTime) override;

    void Init(FString IDIn, FString InfoIn, FString MaxQueueSizeIn,
            FString UseHTBIn, float BandwidthIn, float DelayIn, int GroupIn,
            int LossIn, AAbstractNode* SourceIn, AAbstractNode* TargetIn);
    ```
4. Setup Abstract Flows

    For each Abstract Flow, spawn a BP_Abstract_Flow actor, which has AbstractFlow as the parent. The process is the same as above, but should be changed in the future, depending on the desired visualization for the Abstract Flows. At this point, the SFlows struct array should be empty, because we do not parse the Flows from G2 at this time.

    C++ Interface
    ```
    AbstractFlow.h
    AbstractFlow.cpp

    struct FFlowLink
    {
        FString ID;
        FString SourceNodeID;
        FString TargetNodeID;

        int Group;
    };

    struct FFlowInfo
    {
        FString SourceIP;
        FString SourcePort;
        FString DestinationIP;
        FString DestinationPort;
        FString SourceNS;
        FString SourcePod;
        FString SourceContainers;
        FString DestinationNS;
        FString DestinationPod;
        FString DestinationContainers;
    };

    AAbstractFlow : AActor

    FString ID;

    float ExpShare;
    float StartTime;

    int NumBytes;
    int NumFlows;

    AAbstractNode* Start;
    AAbstractNode* End;

    FFlowInfo Info;
    TArray<FFlowLink> Links;

    void Init(FString IDIn, float ExpShareIn, float StartTimeIn, int NumBytesIn, 
            int NumFlowsIn, AAbstractNode* StartIn, AAbstractNode* EndIn, 
            FFlowInfo InfoIn, TArray<FFlowLink> LinksIn);

    ```
5. Setup Node System

    Use the Construct Object Blueprint Node, with Node System as the class to create a Node System object. Then use the Init function to set all of the data. This class, which is all C++ will control the Multi Body Forces Simulation. 

    Everytime the Update function is called, the Node System will calculate one iteration of the Simulation. The Algorithm is as follows:

    ```
    // Parameters are omitted for brevity
    Update() 
    {
        CalculateAccelerations()
        {
            For each Node
                CalculateCenterForce();     // This force acts from and away toward (0, 0, 0), with nodes with more links being further out.
                CalculateFrictionForce();   // Works the same as the G2 Simulation, just with different constants.
                CalculateNodeToNodeForce(); // Nodes that are linked attract and nodes that are not linked repel each other.
        };

        MoveNodes(); // Moves nodes to calculated new location
    }
    ```
    Note: Many constants are used in the algorithm to balance the simulation. These will probably need to be changed in the future.

    C++ Interface
    ```
    NodeSystem.h
    NdoeSystem.cpp

    UNodeSystem : UObject

    void Init(TArray<AAbstractNode*> NodesIn, TArray<AAbstractLink*> LinksIn,
            TArray<AAbstractFlow*> FlowsIn);
    void Update(float TimeDelta);
    ```
6. Setup Rings

    There are two part to spwaning rings, the first is the Setup Ring function, and the second is the update ring function. The setup ring function spawns a static mesh component in the shape of the ring after the spline mesh is created, so that at run time they will appear. The number of rings is currently set to three for testing sake, but in the future would be spawned according to length of splines. The mesh rings are then added to a mesh array to be transformed in later function. 

    The second function is update ring. This function is called in the update spline function so that when abstract view is called, the rings will move along the splines as the physics of the splines is changing. The update ring function uses a for loop to call each ring mesh stored previously, then transformation is applied to the rings using get location at distance along spline function and get rotation at distance along spline function. 

    Note that accessing values of links require accessing the spline components variable of the links.

**Abstract View Nodes**
| Visual Attribute | Node Meaning | 
| --------------- | -------------- |
| Size | The greater the size, the greater the exp_share value associated with it. There is a min and max size for the nodes. |
| Color | Red colored nodes indicate a node temperature greater than 75 degrees Fahrenheit. Green means that nodes is currently selected. |
| Distance from center | The more flows a node has associated with it, the farther for the center the node will be. |

**Abstract View Links**
| Visual Attribute | Link Meaning | 
| --------------- | -------------- |
| Size | The greater the size, the greater the exp_share value associated with it. There is a min and max size for the nodes. |
| Color | Red colored nodes indicate a node temperature greater than 75 degrees Fahrenheit. Green means that nodes is currently selected. |
| Glow | Glowing links represent outstanding value for user to select. |
| Distance from center | The more flows a node has associated with it, the farther for the center the node will be. |

**Abstract View Rings**
| Visual Attribute | Ring Meaning | 
| --------------- | -------------- |
| Opacity | Rings are only visible when selected value is outstanding for links. |
| Number | Rings will spawn along the distance of links, thus the number will depend on the length of the links.(Note: currently only 3 rings are spawned per link but this will be changed later on) |


### User Interface
**Sliders**

1. Node Info Display

    Appears when a node is selected using the Right Mouse Button. Displays associated metadata, including node name, MTU, IP address, ID, latitude, and longitude.

2. Link Info Display

    Appears when a link is selected using the Right Mouse Button, IF the game is also paused (by pressing "P") at the time of selection (this is due to the computing power necessary for both physics and collision calculations is too large, thus only one maybe be activated at a time). Displays associated metadata, including link source, target, bandwidth, delay, group, ID, loss, and max queue size.

3. Confirm Change Display

    Appears when a user attempts to make a change to a text box within the first two widgets. The "Confirm" button must be selected in order for the change to go through.

4. Sliders Display

    Contains a set of sliders. 
    "Center Force" slider controls the elevation of anomalous nodes (in the current build, non-primary nodes with unknown MTU values).
    "Link Force" controls the strength of the many-body forces between link splines. 
    "Center Friction Force" controls the rate at which nodes come to rest after their radial distance is changed. 
    "Tangent Friction Force" controls the rate at which nodes come to rest after their position on the Earth model is changed. 
    "Spline Height" controls the distance of spline vertices from the center of the Earth model.
    "Link Opacity" controls the opacity of the static meshes making up the link splines. 

**Viewing Node and Link Data**

    To view node data, right-click on the node (a red, green, or black cylinder or rectangular prism).

    To view link data, first ensure that the game is paused by pressing "P." Then, right-click on the link spline.

**Editing Node Data**

    Right-click on a node or link, then left-click on any of the text contained within the associated Node Indo Display or Link Info Display widget. Delete the existing data and input your own.

    NOTE: In the current build, only the MTU, latitude, and longitude text boxes are connected to the Netbox database; thus, only changes to the data in those text boxes will be saved after the game is closed. 

**Node Click and Drag**

    Drag Mode allows for the temporary movement of nodes, easing visibility without saving the position changes. 

    Press G to enter Grab Mode. Then, left-click and hold to drag a node to a new location.

## Troubleshooting
* If the Earth G2 View takes a while to load and display the G2 Snapshot:
1. Move to the Cesium Earth view or Abstract View and then return the the Earth G2 View.
2. Or exit and rerun the project.
Note: This issue is due to VARest not being able to recieve responses quickly sometimes, due to poor network connection. The quickest way is often to try again.

* If there are issue with cloning or pulling from the repo, preform the following steps:
Note: many of these steps will take a long time because of the size of the repo.
1. Save any changes to another location and delete the local repo.
2. In Command Line, navigate to the desired location, download the the repo from Gitlab as a zip file, and preform the following commands.
```
$ mkdir ARNoc-Alpha
$ git clone --bare https://gitlab.nrp-nautilus.io/ar-noc/ARNoc-Alpha.git ARNoc-Alpha
$ mkdir ARNoc-Alpha/.git
$ mv ARNoc-Alpha/* ARNoc-Alpha/.git
$ unzip ARNoc-Alpha-main.zip
$ mv ARNoc-Alpha-main/* ARNoc-Alpha/
$ cd ARNoc-Alpha
$ git init
$ git pull
$ git reset HEAD
```
----------------------------
3. Add the changes back into the repository.

## Resources
VARest plugin documentation: https://docs.google.com/document/d/1MBqpK_24tVeUejG78jNS-0ciem-AptBaXOlp83iWUak/edit?usp=sharing