Example #1
0
#                'B' : [ ('node D', 'rtt=2, bw=9') ],
#
#                'C' : [],
#
#                'node D' : []
#        }
# The meaning is clear: you're specifying the links between nodes and their
# properties. In this example, the graph is:
#
#               A -- B -- D
#               |
#               C
#
#  Links are symmetric
#
N = Net()
N.net_file_load('net1')
N.net_dot_dump(open('net1.dot', 'w'))

# Activate the simulator
sim.sim_activate()


def run_sim():
    # Fill the options to pass to the nodes.
    s = Settings()
    s.SIMULATED = True
    s.IP_VERSION = 4
    s.NICS = []
    s.EXCLUDE_NICS = []
Example #2
0
import sys
sys.path.append('../../')

import md5
import random
from random import randint
import pdb

from ntk.sim.net import Net

random.seed(1)

# load from file
N = Net()
N.net_file_load('net1')
N.net_dot_dump(open('net1.dot', 'w'))

# rand net
N1 = Net()
N1.rand_net_build(16)
N1.net_dot_dump(open('net1-rand.dot', 'w'))

# mesh net
N2 = Net()
N2.mesh_net_build(4)
N2.net_dot_dump(open('net1-mesh.dot', 'w'))

# complete net
N3 = Net()
N3.complete_net_build(8)
N3.net_dot_dump(open('net1-complete.dot', 'w'))
Example #3
0
#                'B' : [ ('node D', 'rtt=2, bw=9') ],
#            
#                'C' : [],
#
#                'node D' : []
#        }
# The meaning is clear: you're specifying the links between nodes and their
# properties. In this example, the graph is:
#
#               A -- B -- D
#               |
#               C
#
#  Links are symmetric
#
N=Net()
N.net_file_load('net1')
N.net_dot_dump(open('net1.dot', 'w'))

# Activate the simulator
sim.sim_activate()

def run_sim():
        # Fill the options to pass to the nodes.
        s = Settings()
        s.SIMULATED = True
        s.IP_VERSION = 4
        s.NICS = []
        s.EXCLUDE_NICS = []

Example #4
0
sys.path.append("../../")
from ntk.sim.net import Net
import ntk.sim.sim as sim
from ntk.sim.wrap.sock import Sock
import ntk.sim.wrap.xtime as xtime
from socket import AF_INET, SOCK_DGRAM, SOCK_STREAM, SO_REUSEADDR, SOL_SOCKET
import ntk.sim.wrap.xtime as xtime
from ntk.lib.micro import micro, microfunc, allmicro_run

import ntk.lib.rpc as rpc
from ntk.lib.micro import micro, allmicro_run, micro_block
from ntk.network.inet import ip_to_str

seed(1)

N = Net()
N.net_file_load("net1")
N.net_dot_dump(open("net1.dot", "w"))


#
### The server remotable functions
#


class MyNestedMod:
    def __init__(self):
        self.remotable_funcs = [self.add]

    def add(self, x, y):
        return x + y