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
0
votes
1 answer

What's the most efficient way to transfer data/packets between native code and Java code in Android

I'm going to write an Android App to read raw packet from native code with raw socket interface. My phone is rooted so my native code can access to the native code by using runtime.exec("su"). But I don't know how to efficient transfer packets…
0
votes
0 answers

How to get root privilege for Android NDK code on a rooted phone

I'm trying to use raw socket in Android NDK C code. While accessing raw socket in Linux needs root privilege. I know that we can get root privilege for shell process by using Java code in a rooted phone: Runtime.exec("su") But the problem is how to…
Andong Zhan
  • 12,608
  • 4
  • 24
  • 24
0
votes
1 answer

Building UDP packet in Python

There's already a code in the internet which shows how to build and send a TCP packet in Python using raw sockets, but I desperately need an example of how building a UDP one. I read this link http://www.ietf.org/rfc/rfc768.txt and understands that…
Jjang
  • 11,250
  • 11
  • 51
  • 87
0
votes
1 answer

Is it possible to send and receive packets through different sockets?

I googled for a while and read related questions here about sending and receiving through sockets, but couldn't find an answer to my question: Can I send and receive packets through different sockets? I would like to implement something like…
Jjang
  • 11,250
  • 11
  • 51
  • 87
0
votes
1 answer

Raw Socket send TCP SYN-FIN-.. in c++

My teacher want us to do an exercise on raw socket in c ++ on Windows (for learning tcp communication). I have got a problem with it. I saw a lot of documentation but I don't know how to solve it. int raw() { WSADATA WSAData; SOCKET sock; …
user1778354
  • 323
  • 2
  • 14
0
votes
1 answer

Spoof source IP address in ICMP ECHO REQUEST packet

I get two wireless devices A and B, and an AP. The IP address of A is 1.2.3.4 and that of B is 1.2.3.5. If A send an ICMP ECHO REQUEST packet to the AP, in which the source IP address is spoofed to 1.2.3.5, will B receive an ICMP ECHO REPLY from the…
is.magl
  • 315
  • 1
  • 3
  • 8
0
votes
1 answer

Code Explanation of IP Checksum function by Mixter (C & Linux)

I was reading the famous networking tutorial on raw UDP sockets by Mixter, and while reading source code I became confused with this function: unsigned short /* this function generates header checksums */ csum (unsigned short *buf, int…
trifork
  • 57
  • 1
  • 10
0
votes
1 answer

How to ping localhost using raw socket?

The program got misc ethernet traffic from some source, change ip and should redirect it to localhost(for example, it should be used for ssh connection) and send answers from localhost back. I used following code: int bind_if(int raw , char…
0
votes
1 answer

Raw Sockets - Sending IP & TCP Headers before Payload

Is it possible to send the IP & TCP headers before sending the payload (so there are two calls to the socket's send function)? While I'm sure you can 'do it' with raw sockets, I'm not sure if the network devices (e.g., switches) will be able to…
user2189700
0
votes
2 answers

Read raw socket ip header? c++

I'm trying to figure out what an IP packet contains using raw sockets. I'm writing in C++ and so far I've been able to print out an entire packet using the following code: int CreateRawSocket(int protocol_to_sniff) { int s if(s =…
Zeliax
  • 4,987
  • 10
  • 51
  • 79
0
votes
1 answer

c# raw socket ip header total length

I am using udp raw sockets. I wish to read only the first, for example, 64 bytes of every packet. ipaddr = IPAddress.Parse( "10.1.2.3" ); sock = new Socket(AddressFamily.InterNetwork, SocketType.Raw, ProtocolType.IP); sock.Bind(new…
Massimo
  • 3,171
  • 3
  • 28
  • 41
0
votes
1 answer

How can i avoid mulitple raw socket bind to the same ip address?

Actually, if i create multiple RAW sockets with the same IP Address. I could bind all of them, and consequently packets are received by all the sockets. Is there any way that could be avoided, such that the other process trying to bind the same ip…
innosam
  • 427
  • 1
  • 5
  • 18
0
votes
2 answers

Accessing data link layer packets

I want to create a socket for accessing IPv4 packets from data link layer. From unix network programming V1, socket(PF_PACKET, SOCK_DGRAM, htons(ETH_P_IP)) 1)I am implementing a dhcp client, is this the correct way of doing that? (means without…
avd
  • 13,993
  • 32
  • 78
  • 99
0
votes
2 answers

Receive raw ethernet packets in c

I'm wirting two programms for sending and receiving raw ethernet packets. I can send packets and I can receive, but I have two problems with my receiver. First: All packtes are duplicated, it means all in comming packets are shown twice. It's only…
Patzde
  • 11
  • 2
  • 6
0
votes
0 answers

C Raw Sockets send HTTP Request

I have a question. So what I am trying to accomplish is sending and HTTP request. I have looked into raw sockets and such, but I cannot see how I would send an HTTP request in which I can set the source address / port, etc. Thanks!
user2484067
  • 109
  • 1
  • 3
  • 10