Questions tagged [raw-sockets]

An internet socket that allows direct sending and receiving of raw network packets that contain all headers. They differ from protocols like TCP/IP or UDP.

Raw sockets differ from standard sockets where the payload is encapsulated according to the transport layer protocol (TCP, UDP, HTTP, ..). Raw sockets can be used to implement completely new transport-layer protocols or to send messages through some less common protocol like ICMP.

Most socket APIs, especially those based on Berkeley sockets, support raw sockets. Support under Windows XP is intentionally limited due security concerns.

490 questions
4
votes
3 answers

How can I extract mac address from a icmp reply in c on linux

I am trying to find out mac address of a machine in a switched environment after sending it a raw packet. I am trying to implement traceroute command . I want to know when i receive a ICMP time exceeded message how can I extract the mac address of…
j10
  • 2,009
  • 3
  • 27
  • 44
4
votes
1 answer

Man in the Middle attack in C with ping echo request

I'm implementing man in the middle attack in C. There are three docker containers: Host A (sender), Host B (receiver), and Host M (attacker). My objective is to ping from Host A to Host B but sniffing the echo request from A at M and then relay the…
3N4N
  • 570
  • 5
  • 21
4
votes
1 answer

Reading a TCP header and managing a TCP connection with RAW_SOCKET

I'm trying to get the TCP header of a TCP connection in C++11. Reading through already existing StackOverflow questions (here, here, here and here) it seems like I have to open a RAW_SOCKET or to write a Linux Kernel Module (LKM) to have access to…
Polpetta
  • 495
  • 1
  • 3
  • 13
4
votes
1 answer

Send an UDP packet and receive an ICMP response from router in C

I'm trying write a C program that sends an UDP packet to a given IP adress and waits for an ICMP response of a router telling that the time to live expired. It's kept very simple because I just want to understand the mechanism at first. What I need…
d.hill
  • 669
  • 3
  • 9
  • 16
4
votes
2 answers

connecting to OrientDB from PHP

I would like to write an adapter for PHP for the binary API of OrientDB. But I need a bit of help from someone who has experience with raw socket communications in PHP - I can't seem to even get past the first hurdle of connecting PHP to OrientDB. I…
mindplay.dk
  • 7,085
  • 3
  • 44
  • 54
4
votes
0 answers

Getting a copy of any received ICMP packet with boost asio

My goal is to write a little program in c++ with boost asio that notifies me whenever an ICMP packet is received on any network interface. The program doesn't print any errors and there are no exceptions. But it also doesn't receive any ICMP packets…
4
votes
3 answers

TCP handshake using python RAW sockets

I am implementing a TCP handshake using python RAW sockets. The Linux kernel is however being quite annoying because it attempts to handle certain aspects of this protocol. For example, when I send a SYN packet, the server responded with a SYN, ACK…
SivaDotRender
  • 1,581
  • 4
  • 21
  • 37
4
votes
2 answers

How to set the Don't Fragment (IP_DF) flag in C

I want to set the Don't Fragment flag on a IP packet. Is there a way to do so via the setsockopt() function or via the flags of the sendto() function? Can I do this with "normal" sockets or do i have to use raw sockets and build the entire IP header…
j00hi
  • 5,420
  • 3
  • 45
  • 82
4
votes
7 answers

How to detect a timeout when using asynchronous Socket.BeginReceive?

Writing an asynchronous Ping using Raw Sockets in F#, to enable parallel requests using as few threads as possible. Not using "System.Net.NetworkInformation.Ping", because it appears to allocate one thread per request. Am also interested in using…
James Hugard
  • 3,232
  • 1
  • 25
  • 36
4
votes
1 answer

How to workaround the "Limitations on Raw Sockets" under Windows 7?

I am developing a TCP protocol fuzzing software under Windows 7. I wanna to send self constructed TCP packet using Raw Sockets. But it seems that Microsoft forbid this for some security reasons.…
hsluoyz
  • 2,739
  • 5
  • 35
  • 59
4
votes
1 answer

python sockets: make sure that TCP packets are send before closing connection

I am working with a relay that is controlled via TCP. As far as I understood the following code is supposed to work: s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect(('192.168.0.200', 17494)) s.send(chr(101)) s.close() However, I…
P.R.
  • 3,785
  • 1
  • 27
  • 47
4
votes
1 answer

Possible to safely run multiple Android emulators on the same machine and communicate using sockets?

I would like to simulate a small cluster of Android devices either on one laptop (worst-case), or on several machines on a private network. This is for testing communications and process migration on Android. Is there a safe way to identify and…
Will Gillick
  • 41
  • 1
  • 3
4
votes
0 answers

Duplicate TCP traffic on a port to another

I have a program that connects using TCP to a server and communicates with it. I would now want to duplicate the packets sent by the server to me and redirect them to another port for processing. Thus I have a two-fold problem : 1.) Do…
4
votes
3 answers

recvfrom not returning -1 after signal

I am writing a ping program using raw sockets but recvfrom is not returning -1 with EINTR even though a SIGALRM is being handled.This SIGALRM is produced by my alarm(1).I want recvfrom to return so that i can decide that the packet has indeed been…
Sr1n4th
  • 251
  • 2
  • 8
4
votes
1 answer

Properly send a RST packet to a TCP client and server as a gateway

I am programming a gateway which one of the functionality is to destroy connections when enough packets have been exchanged. I would like to know how to properly form RST packets to send to both the client and server to terminate the connection. To…
Olivier Trahan
  • 95
  • 1
  • 1
  • 5