Skip to content

Commit

Permalink
added customization on virtual nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
kevin-w-du committed Aug 8, 2021
1 parent a5c1ca6 commit 81c16b2
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
11 changes: 11 additions & 0 deletions examples/B01-dns-component/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,17 @@ dns.getZone('twitter.com.').addRecord('@ A 1.1.1.1')
dns.getZone('google.com.').addRecord('@ A 2.2.2.2')
```

## Customization for visualization

When the nodes are displayed on the map, we would like to display a more
friendly name, instead of the unique name assigned to each virtual node.
We can do the following. When this virtual node is bound to a physical
node, the display name will be inherited by the physical node.

```
emu.getVirtualNode('a-root-server').setDisplayName('Root-A')
```

## Saving the DNS component to File

After adding the DNS layer to the emulator, we can save the entire DNS
Expand Down
16 changes: 16 additions & 0 deletions examples/B01-dns-component/dns-component.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,22 @@
dns.getZone('syr.edu.').addRecord('@ A 128.230.18.63')
dns.getZone('weibo.cn.').addRecord('@ A 5.5.5.5').addRecord('www A 5.5.5.6')

# Customize the display names (for visualization purpose)
emu.getVirtualNode('a-root-server').setDisplayName('Root-A')
emu.getVirtualNode('b-root-server').setDisplayName('Root-B')
emu.getVirtualNode('a-com-server').setDisplayName('COM-A')
emu.getVirtualNode('b-com-server').setDisplayName('COM-B')
emu.getVirtualNode('a-net-server').setDisplayName('NET')
emu.getVirtualNode('a-edu-server').setDisplayName('EDU')
emu.getVirtualNode('a-cn-server').setDisplayName('CN-A')
emu.getVirtualNode('b-cn-server').setDisplayName('CN-B')
emu.getVirtualNode('ns-twitter-com').setDisplayName('twitter.com')
emu.getVirtualNode('ns-google-com').setDisplayName('google.com')
emu.getVirtualNode('ns-example-net').setDisplayName('example.net')
emu.getVirtualNode('ns-syr-edu').setDisplayName('syr.edu')
emu.getVirtualNode('ns-weibo-cn').setDisplayName('weibo.cn')


###########################################################
emu.addLayer(dns)
emu.dump('dns-component.bin')

0 comments on commit 81c16b2

Please sign in to comment.