blob: 332a0ef23de76ecabbb7eadae39f13e7ad81a04d [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
42pkts = rdpcap(path + "/OnosSystemTest/TestON/tests/FUNC/FUNCbgpls/dependencies/Bgpls_packets/bgpls_all.pcap")
43pkts[69][BGPOpen].bgp_id = peerIp
44
45s.listen(5) # Now wait for client connection.
46
47print("starting Connecting to ONOS peer")
48c, addr = s.accept() # Establish connection with client.
49print 'Got connection from ONOS :', addr
50c.send(str(pkts[69][BGPHeader])) # OPEN MESSAGE
51c.recv(4096)
52c.send(str(pkts[71][BGPHeader]))# KEEPALIVE MESSAGE
53c.recv(4096)
54c.send(str(pkts[72][BGPHeader])) # UPDATE MESSAGES
55c.send(str(pkts[74][BGPHeader]))
56c.send(str(pkts[71][BGPHeader]))
57
58while True:
59 c.recv(4096)
60 c.send(str(pkts[71][BGPHeader]))
61
62 # c.close() # Close the connection