ip - Raw tcp send and recv -
I am making an application using raw sockets and need your advice:
The application is one. What kind of TCP / IP stack tester should I do that I have an application that connects to remote server and transmits some data to ID. Says - I can not open chairs with my application - I have TCP / IP buffer with all the headers.
For testing, I want to create 2 raw sockets - 1 buffers to send and receive IPs.
I get this code to get:
int saddr_size, data_size; Structured Socrator Saddar; Unsigned four * buffer = (unsigned char *) molk (65536); // It's big! Printf ("start ... \ n"); // Create a raw socket that will smell sock_raw = socket (AF_INET, SOCK_RAW, IPPROTO_TCP); If (sock_raw <0) {printf ("socket error \ n"); Return 1; } While (1) {saddr_size = sizeof saddr; // Get a packet data_sakecode = recovery form (sock_eur, buffer, 65536, 0, and soar, and sdr_size); If (data_us ize & lt; 0) {printf ("RecoverForm error, package failed to receive \ n"); Return 1; } Printf ("Size of data =% d", data_ size); } Closed (sock_raw); Printf ("finished"); Return 0;
And as I can see that it works - it all gets TCP / IP packets.
I tried this for the sender
static constant unsigned four pkt6 [60] = {0x32, 0x04, 0x34, 0x, 0xf3, 0xab, 0x01, 0x02, / * 2.4 ..... * / 0x03, 0x04, 0x05, 0x06, 0x08, 0x00, 0x45, 0x00, / * ...... E. * / 0x00, 0x2e, 0x00, 0x02, 0x00, 0x00, 0xff, 0x06, / * ........ * / 0x44, 0xc5, 0xc0, 0xa8, 0x01, 0x02, 0xac, 0x11, / * d ...... * / 0x0 9, 0x47, 0x00, 0x08, 0x1a, 0x0b, 0x00, 0x00, / *. ...... * / 0x19, 0x6e, 0x23, 0x17, 0xc8, 0x36, 0x50, 0x18, / * .n # 6P. * / 0x08, 0x60, 0x2b, 0xb9, 0x00, 0x00, 0x6c, 0x6f, / *. + ... lo * / 0x6f, 0x6c, 0x0a, 0x00 / * hal .. * /}; If ((s = socket (AF_INET, SOCK_RAW, IPPROTO_TCP)) <0} {mirror ("error:"); Exhaust (EXIT_FAILURE); } While (1) {if ((s, pkt6, sizeof (pkt6), 0) & lt; 0) membrane ("error ::"); }}
and it always says
error :: destination address requirement
what do I want What if I want to send the READY IP packet and get the raw IP packet?
I have not used raw bases myself in this way, but AiUI is probably You will need to use
, and pass the send ()
instead of sendto () saddr
structure to recvfrom ()
Received in the call.
Comments
Post a Comment