#!/usr/bin/env python
# test our rate per second
__author__ = 'Ben Smith'
import sys
from scapy.all import *

def main():
    a = 1
    conf.iface = "mon1"
    data = "A" * 255
    f = open("/sys/class/net/mon1/statistics/tx_packets",'r')
    oldRX = 0
    while(a):
        newRX = f.read()
        tempRX = int(newRX) - oldRX
        print "[*] sending %s packets per second (pps)" % tempRX
        oldRX = int(newRX)
        SendRates(data,"Test SSID")
        time.sleep(1)


def SendRates(rates, ssid):
    frame=RadioTap()/\
    Dot11(addr1="ff:ff:ff:ff:ff:ff",addr2=RandMAC(),addr3=RandMAC())/\
    Dot11Beacon(cap="ESS")/\
    Dot11Elt(ID="SSID",len=len(ssid),info=ssid)/\
    Dot11Elt(ID="Rates",info=rates)/\
    Dot11Elt(ID="DSset",info="\x03")/\
    Dot11Elt(ID="TIM",info="\x00\x01\x00\x00")
    sendp(frame, verbose=1)



if __name__ == "__main__":
    main()
