How can I refer to a Radius attribute in the below packet in scapy? My intention is to capture packet and modify values in few attributes using scapy. I can modify Radius fields above the attribute list...
>>> org_pkt[1][Radius].show()
###[ RADIUS ]###
code= Access-Challenge
id= 5
len= 109
authenticator= f050649184625d36f14c9075b7a48b83
\attributes\
|###[ Radius Attribute ]###
| type= Framed-IP-Address
| len= 6
| value= 255.255.255.254
|###[ Framed-MTU ]###
| type= Framed-MTU
| len= 6
| value= 576
|###[ Service-Type ]###
| type= Service-Type
| len= 6
| value= Framed
|###[ Radius Attribute ]###
| type= Reply-Message
| len= 11
| value= 'Hello, %u'
|###[ EAP-Message ]###
| type= EAP-Message
| len= 24
| \value\
| |###[ EAP-MD5 ]###
| | code= Request
| | id= 1
| | len= 22
| | type= MD5-Challenge
| | value_size= 16
| | value= 266b0e9a58322f4d01ab25b35f879464
| | optional_name= ''
|###[ Message-Authenticator ]###
| type= Message-Authenticator
| len= 18
| value= 11b5043c8a288758173133a5e07434cf
|###[ State ]###
| type= State
| len= 18
| value= c6d195032fdc30240f7313b231ef1d77
>>>
In the above example, I can modify
>>> org_pkt[1][Radius].id = 6
>>> org_pkt[1][Radius].id = 5
but not the values of attributes. Is it possible? If not please suggest another tool for easy modification of packet. I tried Wire-edit but the free version does not have Radius protocol.
Related
I am trying to make a 4-bit adder using the CARRY4 primitive in the 7 series using verilog.
The module I wrote was the following:
module fast_4adder(
input wire [3:0] a,
input wire [3:0] b,
input wire c_in,
input wire subtract,
output wire [3:0] sum,
output wire c_out);
wire [3:0] b_sub;
wire [3:0] carry;
wire [3:0] prop;
wire [3:0] gen;
assign b_sub = b ^ {4{subtract}};
assign gen = a & b_sub;
assign prop = a ^ b_sub;
assign c_out = carry[3];
CARRY4 CARRY4_inst(
.CO(carry),
.O(sum),
.CI(1'b0),
.CYINIT(c_in),
.DI(gen),
.S(prop));
endmodule
I found the code for CARRY4 in the "7 series Libraries Guide".
Now I thought this would be implemented in a single slice and use 4 LUT's.
But after implementation, it is using 20 LUT's.
Is there a way to make it use the single slice and use the 4 LUT's?
Started a new project in Vivado, targetting an Artix 7-50 FPGA, with this sole module and defaults for synthesis and implementation, yields me this result (report_utilization):
1. Slice Logic
--------------
+-------------------------+------+-------+-----------+-------+
| Site Type | Used | Fixed | Available | Util% |
+-------------------------+------+-------+-----------+-------+
| Slice LUTs | 4 | 0 | 32600 | 0.01 |
| LUT as Logic | 4 | 0 | 32600 | 0.01 |
| LUT as Memory | 0 | 0 | 9600 | 0.00 |
| Slice Registers | 0 | 0 | 65200 | 0.00 |
| Register as Flip Flop | 0 | 0 | 65200 | 0.00 |
| Register as Latch | 0 | 0 | 65200 | 0.00 |
| F7 Muxes | 0 | 0 | 16300 | 0.00 |
| F8 Muxes | 0 | 0 | 8150 | 0.00 |
+-------------------------+------+-------+-----------+-------+
1.1 Summary of Registers by Type
--------------------------------
+-------+--------------+-------------+--------------+
| Total | Clock Enable | Synchronous | Asynchronous |
+-------+--------------+-------------+--------------+
| 0 | _ | - | - |
| 0 | _ | - | Set |
| 0 | _ | - | Reset |
| 0 | _ | Set | - |
| 0 | _ | Reset | - |
| 0 | Yes | - | - |
| 0 | Yes | - | Set |
| 0 | Yes | - | Reset |
| 0 | Yes | Set | - |
| 0 | Yes | Reset | - |
+-------+--------------+-------------+--------------+
2. Slice Logic Distribution
---------------------------
+------------------------------------------+------+-------+-----------+-------+
| Site Type | Used | Fixed | Available | Util% |
+------------------------------------------+------+-------+-----------+-------+
| Slice | 1 | 0 | 8150 | 0.01 |
| SLICEL | 1 | 0 | | |
| SLICEM | 0 | 0 | | |
| LUT as Logic | 4 | 0 | 32600 | 0.01 |
| using O5 output only | 0 | | | |
| using O6 output only | 0 | | | |
| using O5 and O6 | 4 | | | |
| LUT as Memory | 0 | 0 | 9600 | 0.00 |
| LUT as Distributed RAM | 0 | 0 | | |
| LUT as Shift Register | 0 | 0 | | |
| Slice Registers | 0 | 0 | 65200 | 0.00 |
| Register driven from within the Slice | 0 | | | |
| Register driven from outside the Slice | 0 | | | |
| Unique Control Sets | 0 | | 8150 | 0.00 |
+------------------------------------------+------+-------+-----------+-------+
* * Note: Available Control Sets calculated as Slice * 1, Review the Control Sets Report for more information regarding control sets.
By the way... shouldn't
assign b_sub = b ^ {4{subtract}};
be actually
assign b_sub = b ^ {4{subtract}} + subtract;
?
I have a dataframe which contains negative numbers, with accountancy notation i.e.:
df.select('sales').distinct().show()
+------------+
| sales |
+------------+
| 18 |
| 3 |
| 10 |
| (5)|
| 4 |
| 40 |
| 0 |
| 8 |
| 16 |
| (2)|
| 2 |
| (1)|
| 14 |
| (3)|
| 9 |
| 19 |
| (6)|
| 1 |
| (9)|
| (4)|
+------------+
only showing top 20 rows
The numbers wrapped in () are negative. How can I replace them to have minus values instead i.e. (5) becomes -5 and so on.
Here is what I have tried:
sales = (
df
.select('sales')
.withColumn('sales_new',
sf.when(sf.col('sales').substr(1,1) == '(',
sf.concat(sf.lit('-'), sf.col('sales').substr(2,3)))
.otherwise(sf.col('sales')))
)
sales.show(20,False)
+---------+---------+
|salees |sales_new|
+---------+---------+
| 151 | 151 |
| 134 | 134 |
| 151 | 151 |
|(151) |-151 |
|(134) |-134 |
|(151) |-151 |
| 151 | 151 |
| 50 | 50 |
| 101 | 101 |
| 134 | 134 |
|(134) |-134 |
| 46 | 46 |
| 151 | 151 |
| 134 | 134 |
| 185 | 185 |
| 84 | 84 |
| 188 | 188 |
|(94) |-94) |
| 38 | 38 |
| 21 | 21 |
+---------+---------+
The issue is that the length of sales can vary so hardcoding a value into the substring() won't work in some cases.
I have tried using regexp_replace but get an error that:
PatternSyntaxException: Unclosed group near index 1
sales = (
df
.select('sales')
.withColumn('sales_new', regexp_replace(sf.col('sales'), '(', ''))
)
This can be solved with a case statement and regular expression together:
from pyspark.sql.functions import regexp_replace, col
sales = (
df
.select('sales')
.withColumn('sales_new', sf.when(sf.col('sales').substr(1,1) == '(',
sf.concat(sf.lit('-'), regexp_replace(sf.col('sales'), '\(|\)', '')))
.otherwise(sf.col('sales')))
)
sales.show(20,False)
+---------+---------+
|sales |sales_new|
+---------+---------+
|151 |151 |
|134 |134 |
|151 |151 |
|(151) |-151 |
|(134) |-134 |
|(151) |-151 |
|151 |151 |
|50 |50 |
|101 |101 |
|134 |134 |
|(134) |-134 |
|46 |46 |
|151 |151 |
|134 |134 |
|185 |185 |
|84 |84 |
|188 |188 |
|(94) |-94 |
|38 |38 |
|21 |21 |
+---------+---------+
You can slice the string from the second character to the second last character, and then convert it to float, for example:
def convert(number):
try:
number = float(number)
except:
number = number[1:-1]
number = float(number)
return number
You can iterate through all the elements and apply this function.
I am trying to create a pivot table that displays the number of projects ongoing per month. I have start and end dates for the project, the project number, and the employee responsible for the project. I would like to delineate the pivot table by month, showing the total number of projects, and then being able to drop that down even further with the projects in that month. I have low experience with pivot tables so I appreciate any help.
Here is a table of the data.
+---------+----------+------------+------------+
| Project | Employee | Start Date | End Date |
+---------+----------+------------+------------+
| BT 1 | Jack | 9/16/2019 | 12/13/2019 |
| BT 2 | Jack | 9/22/2019 | 12/20/2019 |
| BT 3 | Jack | 9/23/2019 | 12/20/2019 |
| BT 4 | Jack | 9/29/2019 | 12/20/2019 |
| BT 5 | Jack | 9/23/2019 | 1/9/2020 |
| BT 6 | Jack | 9/16/2019 | 1/10/2020 |
| BT 7 | Jane | 9/30/2019 | 12/13/2019 |
| BT 8 | Jack | 10/3/2019 | 1/24/2020 |
| BT 9 | Jane | 10/7/2019 | 1/17/2020 |
| BT 10 | Jane | 11/4/2019 | 3/13/2020 |
| BT 11 | Jim | 11/12/2019 | 3/20/2020 |
| BT 12 | Jim | 12/1/2019 | 2/20/2020 |
| BT 13 | Jane | 12/2/2019 | 3/4/2020 |
| BT 14 | Jim | 12/2/2019 | 3/27/2020 |
| BT 15 | Jim | 12/9/2019 | 4/3/2020 |
| BT 16 | Jack | 1/5/2020 | 2/27/2020 |
| BT 17 | Jim | 12/16/2019 | 4/17/2020 |
| BT 18 | Jack | 1/2/2020 | 3/25/2020 |
| BT 19 | Jack | 1/12/2020 | 3/27/2020 |
| BT 20 | Jack | 12/15/2019 | 4/2/2020 |
| BT 21 | Jack | 1/6/2020 | 4/10/2020 |
| BT 22 | Jack | 1/6/2020 | 4/10/2020 |
| BT 23 | Jack | 1/13/2020 | 4/10/2020 |
| BT 24 | Jack | 1/13/2020 | 4/24/2020 |
| BT 25 | Shane | 1/19/2020 | 3/20/2020 |
| BT 26 | Jack | 2/3/2020 | 5/8/2020 |
| BT 27 | Jack | 2/24/2020 | 5/15/2020 |
| BT 28 | Jack | 2/17/2020 | 5/22/2020 |
| BT 29 | Jack | 4/13/2020 | 5/22/2020 |
| BT 30 | Jack | 2/9/2020 | 5/29/2020 |
| BT 31 | Jack | 2/17/2020 | 5/29/2020 |
| BT 32 | Jack | 4/19/2020 | 5/29/2020 |
| BT 33 | Jack | 3/16/2020 | 6/5/2020 |
| BT 34 | Jack | 3/1/2020 | 6/18/2020 |
| BT 35 | Jack | 4/13/2020 | 7/10/2020 |
| BT 36 | Jack | 4/13/2020 | 7/10/2020 |
| BT 37 | Jack | 6/8/2020 | 7/24/2020 |
| BT 38 | Jack | 3/30/2020 | 7/31/2020 |
| BT 39 | Jack | 4/13/2020 | 8/7/2020 |
| BT 40 | Jack | 4/20/2020 | 8/7/2020 |
| BT 41 | Jack | 5/11/2020 | 8/7/2020 |
| BT 42 | Jack | 7/5/2020 | 9/30/2020 |
| BT 43 | Jack | 7/12/2020 | 9/30/2020 |
| BT 44 | Jack | 6/8/2020 | 10/2/2020 |
| BT 45 | Jack | 7/13/2020 | 10/2/2020 |
| BT 46 | Jack | 7/6/2020 | 10/9/2020 |
| BT 47 | Jack | 6/14/2020 | 10/22/2020 |
| BT 48 | Jack | 7/6/2020 | 10/23/2020 |
| BT 49 | Jack | 8/3/2020 | 10/30/2020 |
| BT 50 | Jack | 7/13/2020 | 11/13/2020 |
| BT 51 | Jack | 7/27/2020 | 11/13/2020 |
| BT 52 | Jack | 9/14/2020 | 12/11/2020 |
| BT 53 | Jack | 11/2/2020 | 2/19/2021 |
+---------+----------+------------+------------+
Thanks.
On a new excel sheet, i am trying to list all rows for a specific drivers name from this sheet.
I want all the rows where the drivers name is NS (or cell A1 on my new sheet). I have over 1000 rows of data and more columns than below but this gives you an idea.
The first line of data is A4:M4
Tried index/match function but unable to get it to work.
+------------+-------------------------------+----------------+-------------+
| Date | Vehicle | Driver | Drops Taken |
+------------+-------------------------------+----------------+-------------+
| 01/04/2019 | LCG - DAF 7.5 Tonner | RL | |
| 01/04/2019 | GXO - Merc 3.5T Dropside | KA | 9 |
| 01/04/2019 | KDZ - DAF 12 Tonner | NS | 12 |
| 01/04/2019 | RYZ - DAF 12 Tonner | MM | 10 |
| 02/04/2019 | GXO - Merc 3.5T Dropside | KA | 8 |
| 02/04/2019 | KDZ - DAF 12 Tonner | NS | 12 |
| 02/04/2019 | LCG - DAF 7.5 Tonner | RL | |
| 02/04/2019 | RYZ - DAF 12 Tonner | MM | 9 |
| 03/04/2019 | KDV - DAF 12 Tonner | NS | |
| 03/04/2019 | GXO - Merc 3.5T Dropside | KA | 8 |
| 03/04/2019 | Hire Vehicle | RL | |
| 03/04/2019 | KDZ - DAF 12 Tonner | NS | 8 |
| 03/04/2019 | RYZ - DAF 12 Tonner | MM | 7 |
+------------+-------------------------------+----------------+-------------+
I successfully installed armbian, WiringOP, I can access gpio.
How can I access gpio from nodejs on orange pi zero?
Here is the gpio output:
hygy#orangepizero:~/WiringOP/gpio$ sudo ./gpio readall
[sudo] password for hygy:
+-----+-----+----------+------+---+-Orange Pi+---+---+------+---------+-----+--+
| BCM | wPi | Name | Mode | V | Physical | V | Mode | Name | wPi | BCM |
+-----+-----+----------+------+---+----++----+---+------+----------+-----+-----+
| | | 3.3v | | | 1 || 2 | | | 5v | | |
| 12 | 8 | SDA.0 | ALT5 | 0 | 3 || 4 | | | 5V | | |
| 11 | 9 | SCL.0 | ALT5 | 0 | 5 || 6 | | | 0v | | |
| 6 | 7 | GPIO.7 | ALT3 | 0 | 7 || 8 | 0 | ALT3 | TxD3 | 15 | 13 |
| | | 0v | | | 9 || 10 | 0 | ALT3 | RxD3 | 16 | 14 |
| 1 | 0 | RxD2 | ALT5 | 0 | 11 || 12 | 0 | ALT3 | GPIO.1 | 1 | 110 |
| 0 | 2 | TxD2 | ALT5 | 0 | 13 || 14 | | | 0v | | |
| 3 | 3 | CTS2 | ALT3 | 0 | 15 || 16 | 0 | ALT3 | GPIO.4 | 4 | 68 |
| | | 3.3v | | | 17 || 18 | 0 | ALT3 | GPIO.5 | 5 | 71 |
| 64 | 12 | MOSI | ALT4 | 0 | 19 || 20 | | | 0v | | |
| 65 | 13 | MISO | ALT4 | 0 | 21 || 22 | 0 | ALT3 | RTS2 | 6 | 2 |
| 66 | 14 | SCLK | ALT4 | 0 | 23 || 24 | 0 | ALT4 | CE0 | 10 | 67 |
| | | 0v | | | 25 || 26 | 0 | ALT3 | GPIO.11 | 11 | 21 |
| 19 | 30 | SDA.1 | ALT4 | 0 | 27 || 28 | 0 | ALT4 | SCL.1 | 31 | 18 |
| 7 | 21 | GPIO.21 | ALT3 | 0 | 29 || 30 | | | 0v | | |
| 8 | 22 | GPIO.22 | ALT3 | 0 | 31 || 32 | 0 | ALT3 | RTS1 | 26 | 200 |
| 9 | 23 | GPIO.23 | ALT3 | 0 | 33 || 34 | | | 0v | | |
| 10 | 24 | GPIO.24 | OUT | 1 | 35 || 36 | 0 | ALT3 | CTS1 | 27 | 201 |
| 20 | 25 | GPIO.25 | OUT | 1 | 37 || 38 | 0 | ALT5 | TxD1 | 28 | 198 |
| | | 0v | | | 39 || 40 | 0 | ALT5 | RxD1 | 29 | 199 |
+-----+-----+----------+------+---+----++----+---+------+----------+-----+-----+
| BCM | wPi | Name | Mode | V | Physical | V | Mode | Name | wPi | BCM |
+-----+-----+----------+------+---+-Orange Pi+---+------+----------+-----+-----+
You can use the standard streams.
If, for example, you are accessing the GPIO with Python, you can redirect the standard output of that Python process to your Node.js app.
I found this nice tutorial that explains how to do it: http://www.sohamkamani.com/blog/2015/08/21/python-nodejs-comm/