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