Jeremy Ronquillo | b27ce4c | 2017-07-17 12:41:28 -0700 | [diff] [blame^] | 1 | """ |
| 2 | Copyright 2016 Open Networking Foundation (ONF) |
| 3 | |
| 4 | Please refer questions to either the onos test mailing list at <onos-test@onosproject.org>, |
| 5 | the System Testing Plans and Results wiki page at <https://wiki.onosproject.org/x/voMg>, |
| 6 | or 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 | |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 22 | #!/usr/bin/python # This is server.py file |
| 23 | from scapy.all import * |
| 24 | import socket # Import socket module |
| 25 | import time # Import Time module |
| 26 | import sys |
| 27 | import os |
| 28 | |
| 29 | path = os.getcwd() |
| 30 | sys.path.append('OnosSystemTest/TestON/tests/FUNC/FUNCbgpls/dependencies') #Setting the path for BgpLS |
| 31 | from Nbdata import BgpLs |
| 32 | |
| 33 | obj = BgpLs() |
| 34 | returnlist = obj.Constants() |
| 35 | peerIp = returnlist[0][0] |
| 36 | |
| 37 | load_contrib('bgp') |
| 38 | s = socket.socket() # Create a socket object |
| 39 | host = peerIp # Get local machine name |
| 40 | port = 179 # Reserve a port for your service. |
| 41 | s.bind((host, port)) # Bind to the port |
| 42 | pkts = rdpcap(path + "/OnosSystemTest/TestON/tests/FUNC/FUNCbgpls/dependencies/Bgpls_packets/bgpls_all.pcap") |
| 43 | pkts[69][BGPOpen].bgp_id = peerIp |
| 44 | |
| 45 | s.listen(5) # Now wait for client connection. |
| 46 | |
| 47 | print("starting Connecting to ONOS peer") |
| 48 | c, addr = s.accept() # Establish connection with client. |
| 49 | print 'Got connection from ONOS :', addr |
| 50 | c.send(str(pkts[69][BGPHeader])) # OPEN MESSAGE |
| 51 | c.recv(4096) |
| 52 | c.send(str(pkts[71][BGPHeader]))# KEEPALIVE MESSAGE |
| 53 | c.recv(4096) |
| 54 | c.send(str(pkts[72][BGPHeader])) # UPDATE MESSAGES |
| 55 | c.send(str(pkts[74][BGPHeader])) |
| 56 | c.send(str(pkts[71][BGPHeader])) |
| 57 | |
| 58 | time.sleep(10) # Waiting for 120 seconds for update message. |
| 59 | |
| 60 | c.send(str(pkts[298][BGPHeader])) |
| 61 | c.send(str(pkts[860][BGPHeader])) # UPDATE MESSAGES with new node |
| 62 | c.send(str(pkts[865][BGPHeader])) |
| 63 | print ("New Node update msg sent") |
| 64 | |
| 65 | while True: |
| 66 | c.recv(4096) |
| 67 | c.send(str(pkts[71][BGPHeader])) |
| 68 | |
| 69 | # c.close() # Close the connection |