tcp-ip

Change TCP Payload with nfqueue/scapy

爷,独闯天下 提交于 2019-11-29 00:23:52
Hello I am using nfqueue and scapy and I my goal is to recieve packets at my NFQUEUE, change the payload and resend them. I can change fields like the TTL without any kind of problem, but when it comes to change the payload, I am encoutering problems. When I change the payload, I sniff the packet with wireshark and apparently I send the packet with the payload modified, but the server doesn't answer. This is my code: #!/usr/bin/env python import nfqueue from scapy.all import * def callback(payload): data = payload.get_data() pkt = IP(data) pkt[TCP].payload = str(pkt[TCP].payload).replace("ABC"

Dropping of connections with tcp_tw_recycle

我的未来我决定 提交于 2019-11-28 15:40:26
summary of the problem we are having a setup wherein a lot(800 to 2400 per second( of incoming connections to a linux box and we have a NAT device between the client and server. so there are so many TIME_WAIT sockets left in the system. To overcome that we had set tcp_tw_recycle to 1, but that led to drop of in comming connections. after browsing through the net we did find the references for why the dropping of frames with tcp_tw_recycle and NAT device happens. resolution tried we then tried by setting tcp_tw_reuse to 1 it worked fine without any issues with the same setup and configuration.

How to simulate boost::asio::write with a timeout

隐身守侯 提交于 2019-11-28 10:12:43
问题 I am trying to simulate boost::asio::write with timeout. Or you can say, I am trying to use boost::asio::async_write with a timeout. As I see, boost::asio::write blocks until all data has been written & read on the other side. This kind of functionality certainly requires a timeout. So, Reading through this simple answer here by Robert Hegner which demostrates how to do a boost::asio::async_read with timeout , I am trying adapt the same logic for write by doing so: size_t write_data_with_time

How much memory is consumed by the Linux kernel per TCP/IP network connection?

倾然丶 夕夏残阳落幕 提交于 2019-11-28 03:29:22
How much memory on average is consumed by the Linux kernel (in kernel address space) per TCP/IP network connection? daya For a TCP connection memory consumed depends on size of sk_buff (internal networking structure used by linux kernel) the read and write buffer for a connection the size of buffers can be tweaked as required root@x:~# sysctl -A | grep net | grep mem check for these variables these specify the maximum default memory buffer usage for all network connections in kernel net.core.wmem_max = 131071 net.core.rmem_max = 131071 net.core.wmem_default = 126976 net.core.rmem_default =

Error:The TCP/IP connection to the host has failed. java.net.ConnectException: Connection refused: connect

随声附和 提交于 2019-11-27 21:57:23
问题 I am using Windows 7 Netbeans IDE 7.1.2 SQL Server Management Studio Express 2005 JDK1.6 I am getting the below error while connecting to the database: com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP connection to the host has failed. java.net.ConnectException: Connection refused: connect My connection string is: Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver"); Connection connection = DriverManager.getConnection( "jdbc:sqlserver://127.0.0.1:1433;databaseName=dbcm;" +

Set socket timeout in Ruby via SO_RCVTIMEO socket option

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-27 18:50:33
I'm trying to make sockets timeout in Ruby via the SO_RCVTIMEO socket option however it seems to have no effect on any recent *nix operating system. Using Ruby's Timeout module is not an option as it requires spawning and joining threads for each timeout which can become expensive. In applications that require low socket timeouts and which have a high number of threads it essentially kills performance. This has been noted in many places including Stack Overflow . I've read Mike Perham's excellent post on the subject here and in an effort to reduce the problem to one file of runnable code

How to get all data from NetworkStream

倾然丶 夕夏残阳落幕 提交于 2019-11-27 13:44:09
I am trying to read all data present in the buffer of the Machine connected through TCP/IP but i don't know why i am not getting all data ,some data is getting Missed. Here is the code that i am using .. using (NetworkStream stream = client.GetStream()) { byte[] data = new byte[1024]; int numBytesRead = stream.Read(data, 0, data.Length); if (numBytesRead > 0) { string str= Encoding.ASCII.GetString(data, 0, numBytesRead); } } Please tell me what i am missing to get all the data from the machine. Thanks in advance.. The problem with your code is that you will not get all the data if the data

Dropping of connections with tcp_tw_recycle

限于喜欢 提交于 2019-11-27 09:18:02
问题 summary of the problem we are having a setup wherein a lot(800 to 2400 per second( of incoming connections to a linux box and we have a NAT device between the client and server. so there are so many TIME_WAIT sockets left in the system. To overcome that we had set tcp_tw_recycle to 1, but that led to drop of in comming connections. after browsing through the net we did find the references for why the dropping of frames with tcp_tw_recycle and NAT device happens. resolution tried we then tried

If BufReader takes ownership of a stream, how can I read and write lines on it?

别来无恙 提交于 2019-11-27 09:14:18
I want to read a line from a TCPStream , write another line to it, and then repeat. The issue is that BufReader::new takes ownership of my TCPStream variable: let stream = ...; // TCPStream let reader = BufReader::new(stream); // moved its value // can't use stream here anymore What is a simple solution to this? Solution: use references. let mut stream = ...; let reader = BufReader::new(&stream); let writer = BufWriter::new(&stream); Explanation If we take a closer look at BufReader::new , we see that it takes an argument inner of type R , where R is just any type that implements Read : impl<R

find all ip address in a network

ぐ巨炮叔叔 提交于 2019-11-27 08:56:59
I am trying to do this C#. I need to find all ip address that are active in my network and show them in a list. I can ping all available (1...255) ip address in a network. But I want to make this process faster. This code scans my network 255 D-class segments in about 1 sec. I wrote it in VB.net and translated it to C# (apologies if there are any errors). Paste it into a Console project and run. Modify as needed. Note: The code is not production ready and need improvements on especially the instance counting (try implement a TaskFactory with a BlockingCollection instead). Modify ttl (time-to