Exemplo n.º 1
0
    "cozb_rtr",
    "goza_rtr",
    "gozb_rtr",
    "poza_rtr",
    "pozb_rtr",
    "roza_rtr",
    "rozb_rtr",
    "soza_rtr",
    "sozb_rtr",
    "yoza_rtr",
    "yozb_rtr",
]

ports = [
    "te7/4", "te7/4", "te3/3", "te3/3", "te3/3", "te3/3", "te3/3", "te3/3",
    "te3/3", "te3/3", "te3/3", "te3/3", "te3/3", "te3/3", "te1/4", "te1/4"
]

r = NetPlumberReachabilityPolicyGenerator(16, in_path)

commands = {"commands": []}

for i in range(len(rtr_names)):
    (src, data) = r.put_source(rtr_names[i] + ".in", ports[i])
    commands["commands"].extend(data)

print "number of commands ", len(commands["commands"])
f = open("policy.json", 'w')
f.write(json.dumps(commands, indent=1))
f.close()
Exemplo n.º 2
0
def send_command(s,data):
    for d in data:
        command = json.dumps(d, indent=1)
        print "sending command ",command
        s.send(command)
        response = s.recv(1024)
        print "received response:", response

TCP_IP = '127.0.0.1'
TCP_PORT = 6543
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((TCP_IP, TCP_PORT))

#r = NetPlumberReachabilityPolicyGenerator(11,"../google/google_sdn_tfs")
r = NetPlumberReachabilityPolicyGenerator(16,"../stanford/stanford_json_rules")

sources = {}

while (True):
    input = raw_input("Enter command:")
    if input == "reachability":
        src = raw_input("Enter source:")
        src_port = raw_input("Enter source port:")
        dst = raw_input("Enter destination:")
        dst_port = raw_input("Enter destination port:")

        if src not in sources:
            sources[src] = {}
        if src_port not in sources[src]:
            if src_port == "all":
Exemplo n.º 3
0
def send_command(s, data):
    for d in data:
        command = json.dumps(d, indent=1)
        print "sending command ", command
        s.send(command)
        response = s.recv(1024)
        print "received response:", response


TCP_IP = '127.0.0.1'
TCP_PORT = 6543
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((TCP_IP, TCP_PORT))

#r = NetPlumberReachabilityPolicyGenerator(11,"../google/google_sdn_tfs")
r = NetPlumberReachabilityPolicyGenerator(16,
                                          "../stanford/stanford_json_rules")

sources = {}

while (True):
    input = raw_input("Enter command:")
    if input == "reachability":
        src = raw_input("Enter source:")
        src_port = raw_input("Enter source port:")
        dst = raw_input("Enter destination:")
        dst_port = raw_input("Enter destination port:")

        if src not in sources:
            sources[src] = {}
        if src_port not in sources[src]:
            if src_port == "all":
Exemplo n.º 4
0
ports = ["te7/4",
        "te7/4",
        "te3/3",
        "te3/3",
        "te3/3",
        "te3/3",
        "te3/3",
        "te3/3",
        "te3/3",
        "te3/3",
        "te3/3",
        "te3/3",
        "te3/3",
        "te3/3",
        "te1/4",
        "te1/4"
        ]

r = NetPlumberReachabilityPolicyGenerator(16,in_path)

commands = {"commands": []}

for i in range(len(rtr_names)):
    (src,data) = r.put_source(rtr_names[i] + ".in", ports[i])
    commands["commands"].extend(data)

print "number of commands ",len(commands["commands"])
f = open("policy.json",'w')
f.write(json.dumps(commands, indent=1))
f.close()