blob: abd1cfceeb2ae6ccd0ffbe30b4a52c6fa3b0119e [file] [log] [blame]
AntonySilvestera1080f22016-04-26 13:05:57 +05301#!/usr/bin/python # This is server.py file
2from scapy.all import *
3import socket # Import socket module
4import time # Import Time module
5import sys
6import os
7
8path = os.getcwd()
9sys.path.append('OnosSystemTest/TestON/tests/FUNC/FUNCbgpls/dependencies') #Setting the path for BgpLS
10from Nbdata import BgpLs
11
12obj = BgpLs()
13returnlist = obj.Constants()
14peerIp = returnlist[0][0]
15
16load_contrib('bgp')
17s = socket.socket() # Create a socket object
18host = peerIp # Get local machine name
19port = 179 # Reserve a port for your service.
20s.bind((host, port)) # Bind to the port
21pkts = rdpcap(path + "/OnosSystemTest/TestON/tests/FUNC/FUNCbgpls/dependencies/Bgpls_packets/bgpls_all.pcap")
22pkts[69][BGPOpen].bgp_id = peerIp
23
24s.listen(5) # Now wait for client connection.
25
26print("starting Connecting to ONOS peer")
27c, addr = s.accept() # Establish connection with client.
28print 'Got connection from ONOS :', addr
29c.send(str(pkts[69][BGPHeader])) # OPEN MESSAGE
30c.recv(4096)
31c.send(str(pkts[71][BGPHeader]))# KEEPALIVE MESSAGE
32c.recv(4096)
33c.send(str(pkts[72][BGPHeader])) # UPDATE MESSAGES
34c.send(str(pkts[74][BGPHeader]))
35c.send(str(pkts[71][BGPHeader]))
36
37time.sleep(10) # Waiting for 120 seconds for update message.
38
39c.send(str(pkts[298][BGPHeader]))
40c.send(str(pkts[860][BGPHeader])) # UPDATE MESSAGES with new node
41c.send(str(pkts[865][BGPHeader]))
42print ("New Node update msg sent")
43
44time.sleep(5)
45c.send(str(pkts[890][BGPHeader]))
46print ("Node Delete msg sent")
47
48
49while True:
50 c.recv(4096)
51 c.send(str(pkts[71][BGPHeader]))
52
53 # c.close() # Close the connection