How to use Scapy library in Robot framework?

1,039 views
Skip to first unread message

balu

unread,
Feb 13, 2015, 1:04:27 PM2/13/15
to robotframe...@googlegroups.com

I am using Robot framework (RFW) to test protocol testing stuff. I am planning to send Protocol (BGP, OSPF, DNS, DHCPv6, STP, SIP etc) traffic to my device under test (DUT).

I have analyzed "Rammbock Library". But I am familiar with Scapy to send protocol traffic. So I am planning to use Scapy library in RFW.

I got following links:

But I am not getting idea on how to use this in RFW. I mean the keywords.

Anybody have idea on following questions.

  1. How to build a packet in this library?

  2. How to view the packet?

  3. How to send that packet?


Could anyone please guide me on this.


Thanks in advance.

David

unread,
Feb 13, 2015, 6:36:56 PM2/13/15
to robotframe...@googlegroups.com
Maybe you could try contacting the author of those libraries, although Github doesn't provide an easy way to do that. Maybe file an issue on those projects asking for help and maybe they will respond and add/update documentation.

Siva

unread,
Feb 17, 2015, 11:31:42 AM2/17/15
to robotframe...@googlegroups.com
Hi,

   Hope you are aware that, its also possible to import scapy modules in python scripts. So whatever packet crafting achieved via scapy terminal could be done through scripts. I haven't come across any library in robot framework supporting scapy, but you can always create a python function with scapy commands and import them as a external library.

Here is a simple example:

vi /home/siva/test.py

import os
from scapy.all import *

def Test_ping_command_in_scapy_where(host="127.0.0.1", count=3):
  packet = IP(dst=host)/ICMP()
  for x in range(count):
     ans = sr1(packet)
     ans.show2()

vi /home/siva/dummy.txt and import above library

*** Settings ***
Library           /home/siva/test.py

*** Variables ***

*** Test Case ***
Test_Ping_Command_Using_Scapy
    [Documentation]    Aim of this testcase is to test ping command
    Test ping command in scapy where     host=1.1.1.1   count=4


Creating a python module instead of function will give you more flexibility while importing within a test suite.

--Siva

Shajiya Shaik

unread,
Jun 25, 2018, 4:50:49 AM6/25/18
to robotframework-users
Hi,

There are multiple robot keywords available for scapy functions. Use can use the below keywords and can compose your packet and then using sr() or srloop() or Send And Receive At Layer2 [*Based on your requirement] you can send the traffic.

Keywords:
To compose a L2 packet:
----------------------------------
Create L2 Pkt:

    ${eth}    Ether    dst=${dst_mac}    src=${smac}
    ${PACKET}    Compose Packet    ${eth}   ${padding}
    Log    ${PACKET}
    ${reply} Send And Receive At Layer2  ${PACKET}

Reply all
Reply to author
Forward
0 new messages