blob: 15c5757a47f774bc24ee2fe468cfe6ddd2ac08a4 [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
AntonySilvester02652382016-07-13 16:44:45 +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
42pkts = rdpcap(path + "/OnosSystemTest/TestON/tests/FUNC/FUNCbgpls/dependencies/Bgpls_packets/bgpls.pcap")
43time.sleep(15)
44pkts[759][BGPOpen].bgp_id = peerIp
45
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
51c.send(str(pkts[759][BGPHeader])) # OPEN MESSAGE
52c.recv(4096)
53c.send(str(pkts[765][BGPHeader]))# KEEPALIVE MESSAGE
54c.recv(4096)
55c.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]))
61
62while True:
63 c.recv(4096)
64 c.send(str(pkts[765][BGPHeader]))
65
66 # c.close() # Close the connection