blob: d747a5a1529190127f06df23fb8efde893d15d1f [file] [log] [blame]
Jeremy Ronquillob27ce4c2017-07-17 12:41:28 -07001"""
2Copyright 2016 Open Networking Foundation (ONF)
3
4Please refer questions to either the onos test mailing list at <onos-test@onosproject.org>,
5the System Testing Plans and Results wiki page at <https://wiki.onosproject.org/x/voMg>,
6or the System Testing Guide page at <https://wiki.onosproject.org/x/WYQg>
7
8 TestON is free software: you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation, either version 2 of the License, or
11 (at your option) any later version.
12
13 TestON is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with TestON. If not, see <http://www.gnu.org/licenses/>.
20"""
21
AntonySilvestera1080f22016-04-26 13:05:57 +053022#!/usr/bin/python # This is server.py file
23from scapy.all import *
24import socket # Import socket module
25import time # Import Time module
26import sys
27import os
28
29path = os.getcwd()
30sys.path.append('OnosSystemTest/TestON/tests/FUNC/FUNCbgpls/dependencies') #Setting the path for BgpLS
31from Nbdata import BgpLs
32
33obj = BgpLs()
34returnlist = obj.Constants()
35peerIp = returnlist[0][0]
36
37load_contrib('bgp')
38s = socket.socket() # Create a socket object
39host = peerIp # Get local machine name
40port = 179 # Reserve a port for your service.
41s.bind((host, port)) # Bind to the port
AntonySilvester02652382016-07-13 16:44:45 +053042pkts = rdpcap(path + "/OnosSystemTest/TestON/tests/FUNC/FUNCbgpls/dependencies/Bgpls_packets/bgpls.pcap")
43time.sleep(15)
44pkts[759][BGPOpen].bgp_id = peerIp
AntonySilvestera1080f22016-04-26 13:05:57 +053045
46s.listen(5) # Now wait for client connection.
47
48print("starting Connecting to ONOS peer")
49c, addr = s.accept() # Establish connection with client.
50print 'Got connection from ONOS :', addr
AntonySilvester02652382016-07-13 16:44:45 +053051c.send(str(pkts[759][BGPHeader])) # OPEN MESSAGE
AntonySilvestera1080f22016-04-26 13:05:57 +053052c.recv(4096)
AntonySilvester02652382016-07-13 16:44:45 +053053c.send(str(pkts[765][BGPHeader]))# KEEPALIVE MESSAGE
AntonySilvestera1080f22016-04-26 13:05:57 +053054c.recv(4096)
AntonySilvester02652382016-07-13 16:44:45 +053055c.send(str(pkts[768][BGPHeader])) # UPDATE MESSAGES
56c.send(str(pkts[771][BGPHeader]))
57c.send(str(pkts[773][BGPHeader]))
58c.send(str(pkts[775][BGPHeader]))
59c.send(str(pkts[778][BGPHeader]))
60c.send(str(pkts[765][BGPHeader]))
AntonySilvestera1080f22016-04-26 13:05:57 +053061
AntonySilvester02652382016-07-13 16:44:45 +053062time.sleep(15)
63c.send(str(pkts[1168][BGPHeader]))
64c.send(str(pkts[1250][BGPHeader]))
65c.send(str(pkts[1354][BGPHeader]))
AntonySilvestera1080f22016-04-26 13:05:57 +053066print ("Node Delete msg sent")
67
68
69while True:
70 c.recv(4096)
AntonySilvester02652382016-07-13 16:44:45 +053071 c.send(str(pkts[765][BGPHeader]))
AntonySilvestera1080f22016-04-26 13:05:57 +053072
73 # c.close() # Close the connection