Skip to content

Commit

Permalink
Merge pull request #86 from wonkr/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
kevin-w-du authored Jul 13, 2022
2 parents 7b0a2fa + 748f31b commit 1f88843
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 14 deletions.
13 changes: 7 additions & 6 deletions examples/A20-nano-internet/nano-internet.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,13 @@

# Create the WebService layer
web = WebService()
dhcp = DHCPService()

# Create web service nodes (virtual nodes)
dhcp.install('dhcp01')
web.install('web01')
web.install('web02')

# Bind the virtual nodes to physical nodes
emu.addBinding(Binding('dhcp01', filter = Filter(nodeName = 'host0', asn = 151)))
emu.addBinding(Binding('web01', filter = Filter(nodeName = 'host0', asn = 151)))
emu.addBinding(Binding('web02', filter = Filter(nodeName = 'host0', asn = 152)))


Expand All @@ -117,7 +116,7 @@
emu.addLayer(base)
emu.addLayer(ebgp)
emu.addLayer(web)
emu.addLayer(dhcp)

emu.addLayer(Routing())
emu.addLayer(Ibgp())
emu.addLayer(Ospf())
Expand All @@ -131,18 +130,20 @@

###############################################################################
# Rendering: This is where the actual binding happens

emu.render()

# Change the display name for the nodes hosting the web services
emu.getBindingFor('dhcp01').setDisplayName('dhcp-1')
emu.getBindingFor('web01').setDisplayName('Web-1')
emu.getBindingFor('web02').setDisplayName('Web-2')


###############################################################################
# Compilation

# Generate the Docker files
emu.compile(Docker(), './output', override=True)
emu.compile(Docker(), './output')

# Generate other type of outputs
#emu.compile(Graphviz(), './others/graphs')
#emu.compile(DistributedDocker(), './others/distributed-docker')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
emuB = Emulator()

# Load the pre-built components and merge them
emuA.load('../C00-hybrid-internet/base-component.bin')
emuB.load('../C01-hybrid-dns-component/hybrid-dns-component.bin')
emuA.load('../00-hybrid-internet/base-component.bin')
emuB.load('../01-hybrid-dns-component/hybrid-dns-component.bin')
emu = emuA.merge(emuB, DEFAULT_MERGERS)


Expand Down
Empty file.
13 changes: 7 additions & 6 deletions examples/C03-bring-your-own-internet/bring-your-own-internet.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,17 @@
emu = Emulator()

# Load the pre-built component
emu.load('../C02-hybrid-internet-with-dns/hybrid_base_with_dns.bin')
emu.load('../02-hybrid-internet-with-dns/hybrid_base_with_dns.bin')

base:Base = emu.getLayer('Base')

# Create a DHCP server (virtual node).
dhcp = DHCPService()

# Default DhcpIpRange : x.x.x.101 ~ x.x.x.120
# Set DhcpIpRange : x.x.x.125 ~ x.x.x.140
# Set DhcpIpRange : x.x.x.125 ~ x.x.x.140
dhcp.install('dhcp-01').setIpRange(125, 140)
dhcp.install('dhcp-02').setIpRange(125, 140)

# Customize the display name (for visualization purpose)
emu.getVirtualNode('dhcp-01').setDisplayName('DHCP Server 1')
Expand All @@ -34,8 +35,8 @@
# Create new host in AS-151, use it to host the Host which use dhcp instead of static ip
as151.createHost('dhcp-client').joinNetwork('net0', address = "dhcp")

# Defulat HostIpRange : x.x.x.71 - x.x.x.99
# Set HostIpRange : x.x.x.90 - x.x.x.99
# Default HostIpRange : x.x.x.71 - x.x.x.99
# Set HostIpRange : x.x.x.90 - x.x.x.99
# We can also change DhcpIpRange and RouterIpRange with the same way.
as151.getNetwork('net0').setHostIpRange(90, 99, 1)

Expand All @@ -49,5 +50,5 @@
# Render the emulation
emu.render()

# Compil the emulation
emu.compile(Docker(), './output', override=True)
# Compile the emulation
emu.compile(Docker(clientEnabled = True), './output', override=True)

0 comments on commit 1f88843

Please sign in to comment.