blob: 259f8460499227137bf215549703da0af466caef [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
AntonySilvester02652382016-07-13 16:44:45 +053021pkts = rdpcap(path + "/OnosSystemTest/TestON/tests/FUNC/FUNCbgpls/dependencies/Bgpls_packets/bgpls.pcap")
22time.sleep(15)
23pkts[759][BGPOpen].bgp_id = peerIp
AntonySilvestera1080f22016-04-26 13:05:57 +053024
25s.listen(5) # Now wait for client connection.
26
27print("starting Connecting to ONOS peer")
28c, addr = s.accept() # Establish connection with client.
29print 'Got connection from ONOS :', addr
AntonySilvester02652382016-07-13 16:44:45 +053030c.send(str(pkts[759][BGPHeader])) # OPEN MESSAGE
AntonySilvestera1080f22016-04-26 13:05:57 +053031c.recv(4096)
AntonySilvester02652382016-07-13 16:44:45 +053032c.send(str(pkts[765][BGPHeader]))# KEEPALIVE MESSAGE
AntonySilvestera1080f22016-04-26 13:05:57 +053033c.recv(4096)
AntonySilvester02652382016-07-13 16:44:45 +053034c.send(str(pkts[768][BGPHeader])) # UPDATE MESSAGES
35c.send(str(pkts[771][BGPHeader]))
36c.send(str(pkts[773][BGPHeader]))
37c.send(str(pkts[775][BGPHeader]))
38c.send(str(pkts[778][BGPHeader]))
39c.send(str(pkts[765][BGPHeader]))
AntonySilvestera1080f22016-04-26 13:05:57 +053040
AntonySilvester02652382016-07-13 16:44:45 +053041time.sleep(15)
42c.send(str(pkts[1168][BGPHeader]))
43c.send(str(pkts[1250][BGPHeader]))
44c.send(str(pkts[1354][BGPHeader]))
AntonySilvestera1080f22016-04-26 13:05:57 +053045print ("Node Delete msg sent")
46
47
48while True:
49 c.recv(4096)
AntonySilvester02652382016-07-13 16:44:45 +053050 c.send(str(pkts[765][BGPHeader]))
AntonySilvestera1080f22016-04-26 13:05:57 +053051
52 # c.close() # Close the connection