## 6 Network Reconfigurations
* Adding an application entity: Two main cases arise, according to whether the new entity belongs to an existing equivalence class or whether instead, it will be in a new equivalence class (in other words, whether it has an existing label or a new one). * The first case is easily treated. For the implementation configuration, the new entity will be connected to the _App Router_. The new entity will access the same data entities as the other entities in its class. For the labeling table, a new entry must be created for the new entity, its name must be added to the _Holds_ lists of all entities in its equivalence class, and the _Holds_ list
of the new entity must be the same as the _Holds_ lists of these entities. The name of the new entity should be added to the _Holds_ lists of all entities that dominate it in the partial order (that should receive data from it). B. The second case is the case of the addition of an application entity with a new label, which creates a new equivalence class. In this scenario, we must add at least a corresponding storage entity for this new entity with the same label. For the implementation configuration, the new entity must be connected to the _App Router_ and the new storage entity must be connected to the _Cloud Router_. For the labeling tables, new entries must be created for each of the two new entities. The _Holds_ lists of these two entities must be identical and must contain the names of all entities from which they should receive data. The names of these two entities must be added to the _Holds_ lists of the entities where they should send data. The following pseudocode summarizes the steps for adding entities to our configurations (Algorithm 1). ```
Input: Initial implementation configuration Output: Updated implementation configuration
1: Procedure AddEntity(Entity E)
2: If E is a sensor, then
3: AddSensorEntity
4: Else if E is a storage entity (database), then
5: AddStorageEntity(E)
6: Else if E is a workstation, then
7: AddWorkstationEntity(E)
8: End if
9: End procedure
10: Procedure AddSensorEntity(Entity E)
11: Entity(E)
12: AddConnectionToAccessPoint(E)
13: UpdateRoutingTablesForSensor(E)
14: End procedure
15: Procedure AddStorageEntity(Entity E)
16: AddEntity(E)
17: AddConnectionToCloudRouter(E)
18: UpdateCloudRouterLabelingTable(E)
19: UpdateAppRouterLabelingTable(E)
20: End procedure
21: Procedure AddWorkstationEntity(Entity E)
22: If E has an equivalent storage entity,Then
23: AddEntity(E)
24: AddConnectionToAppRouter(E)
25: UpdateAppRouterLabelingTable(E)26: UpdateCloudRouterLabelingTableForAuthorizedEntities(
27: Else
28: AddEntity(E)
29: AddEquivalentStorageEntity(E)
30: RepeatAddWorkstationEntity(E) // Recursive call
31: End if
32: End procedure 33: Function UpdateCloudRouterLabelingTable(Entity E)
34: // Add a line in the cloud router's labeling table for the new entity E
35: End function
36: Function UpdateAppRouterLabelingTable(Entity E)
37: // Add a line in AppRouter's labeling table for the new entity E
38: End function
39: Function UpdateCloudRouterLabelingTableForAuthorizedEntities(Entity E)
40: // Add IP address of E into labeling table of cloud router for authorized entities only
41: End function
42: Function AddEntity(Entity E)
43: // Add entity E to the implementation configuration
44: End function
45: Function AddConnectionToAccessPoint(Entity E)
46: // Add connection between entity E and the Access Point
47: End function
48: Function AddConnectionToCloudRouter(Entity E)
49: // Add connection between entity E and the cloud router
50: End function
51: Function AddConnectionToAppRouter(Entity E)
52: // Add connection between entity E and AppRouter
53: End function
54: Input: Initial implementation configuration
55: Output: Updated implementation configuration
56: For each Entity E in InitialConfiguration do
57: AddEntity(E)
58: End for
59: Return UpdatedConfiguration
* Removing a sensor: The sensor must be removed from the implementation configuration. All occurrences of the name of the sensor must be removed from the labeling tables.