Winsock / Socket Created / Packet not send

Winsock / Socket Created / Packet not send

Post by monoch.. » Fri, 29 Nov 2002 22:07:04



Hi out there !

I hope someone can help me in this.

I am new to Winsock Programming, but now I have written an Applicatian
that should send an UDP packet. It is compiled without errors.

When I stat the Programm it outputs:

Winsock startet !
UDP Socket createt !
11 Bytes Data send  !

Than the Firewall Allerts:

Outbound Connection
Port xxx
Remote IP: < IP adress provided by my Providert>

of Course, I allow this Connection...

Now there should be an Inbound connection Alert, but It isn't. I have
tried to grab the UDP PAcket - but there is simply no UDP PAcket to
Sniff. I have tried to send the packet to a friend - the same result -
nothing is reaching it's Destination.

sorry for my Bad English :-)
Help would be really Great !

Greetz,
Ole

Here's the code I have written:

#include <windows.h>
#include <winsock2.h>
#include <stdio.h>

int ini_Winsock(void);
int startWinsock(void);
int open_socket(int);
int send_data(void);

long rc;
SOCKET sock_1;
SOCKADDR_IN addr;
SOCKADDR_IN remoteAddr;
int remoteAddrLen;
char buf[256];

void main(void){
  open_socket(1);
  closesocket(sock_1);
  WSACleanup();

  }

int startWinsock()
{
 rc=ini_Winsock();
 if(rc!=0)
 {
  printf("Fehler: startWinsock, error code: %d\n",rc);
  return 1;
 }else{
     printf("Winsock startet!\n");
     }

  return 0;
 }

int ini_Winsock()
{
 WSADATA wsa;
 return WSAStartup(MAKEWORD(1,2),&wsa);

Quote:}

int open_socket(int option){
  startWinsock();
  if (option == 1){
     printf("einz ist der Fall");
     sock_1=socket(AF_INET,SOCK_DGRAM,0);
     if(sock_1==INVALID_SOCKET){
     printf("Error the UDP Socket couldn't be Created \n");
     }else {printf("UDP SOCKET Createt \n");}
     }else if (option == 2){
            printf("zwei ist der Fall");
            }else if (option == 3){
                  printf("drei ist der Fall");
                  }

 printf("%d", option);
 send_data();
 getch();
 return 0;}

int send_data(){

    addr.sin_family=AF_INET;
    addr.sin_port=htons(2172);
    addr.sin_addr.s_addr=inet_addr("212.6.79.173");

    strcpy(buf,"Hallo Welt!");

rc=sendto(sock_1,buf,strlen(buf),0,(SOCKADDR*)&addr,sizeof(SOCKADDR_IN));
    if(rc==SOCKET_ERROR)
    {
    printf("Error: sendto, Errorr code: %d\n",WSAGetLastError());
    return 1;
    }else{
    printf("%d Bytes gesendet!\n", rc);
    printf("%d\n", WSAGetLastError());
    }
    return 0;}

 
 
 

Winsock / Socket Created / Packet not send

Post by arkady » Sat, 30 Nov 2002 01:08:57


What the result of sendto ?
Arkady

Quote:> Hi out there !

> I hope someone can help me in this.

> I am new to Winsock Programming, but now I have written an Applicatian
> that should send an UDP packet. It is compiled without errors.

> When I stat the Programm it outputs:

> Winsock startet !
> UDP Socket createt !
> 11 Bytes Data send  !

> Than the Firewall Allerts:

> Outbound Connection
> Port xxx
> Remote IP: < IP adress provided by my Providert>

> of Course, I allow this Connection...

> Now there should be an Inbound connection Alert, but It isn't. I have
> tried to grab the UDP PAcket - but there is simply no UDP PAcket to
> Sniff. I have tried to send the packet to a friend - the same result -
> nothing is reaching it's Destination.

> sorry for my Bad English :-)
> Help would be really Great !

> Greetz,
> Ole

> Here's the code I have written:

> #include <windows.h>
> #include <winsock2.h>
> #include <stdio.h>

> int ini_Winsock(void);
> int startWinsock(void);
> int open_socket(int);
> int send_data(void);

> long rc;
> SOCKET sock_1;
> SOCKADDR_IN addr;
> SOCKADDR_IN remoteAddr;
> int remoteAddrLen;
> char buf[256];

> void main(void){
>   open_socket(1);
>   closesocket(sock_1);
>   WSACleanup();

>   }

> int startWinsock()
> {
>  rc=ini_Winsock();
>  if(rc!=0)
>  {
>   printf("Fehler: startWinsock, error code: %d\n",rc);
>   return 1;
>  }else{
>      printf("Winsock startet!\n");
>      }

>   return 0;
>  }

> int ini_Winsock()
> {
>  WSADATA wsa;
>  return WSAStartup(MAKEWORD(1,2),&wsa);
> }

> int open_socket(int option){
>   startWinsock();
>   if (option == 1){
>      printf("einz ist der Fall");
>      sock_1=socket(AF_INET,SOCK_DGRAM,0);
>      if(sock_1==INVALID_SOCKET){
>      printf("Error the UDP Socket couldn't be Created \n");
>      }else {printf("UDP SOCKET Createt \n");}
>      }else if (option == 2){
>             printf("zwei ist der Fall");
>             }else if (option == 3){
>                   printf("drei ist der Fall");
>                   }

>  printf("%d", option);
>  send_data();
>  getch();
>  return 0;}

> int send_data(){

>     addr.sin_family=AF_INET;
>     addr.sin_port=htons(2172);
>     addr.sin_addr.s_addr=inet_addr("212.6.79.173");

>     strcpy(buf,"Hallo Welt!");

> rc=sendto(sock_1,buf,strlen(buf),0,(SOCKADDR*)&addr,sizeof(SOCKADDR_IN));
>     if(rc==SOCKET_ERROR)
>     {
>     printf("Error: sendto, Errorr code: %d\n",WSAGetLastError());
>     return 1;
>     }else{
>     printf("%d Bytes gesendet!\n", rc);
>     printf("%d\n", WSAGetLastError());
>     }
>     return 0;}


 
 
 

Winsock / Socket Created / Packet not send

Post by monoch.. » Sat, 30 Nov 2002 10:44:22




Quote:>What the result of sendto ?
>Arkady

I have added the following to the code in send_data :

rc=sendto(sock_1,buf,strlen(buf),0,(SOCKADDR*)&addr,sizeof(SOCKADDR_IN));
// (the  line  above is not new ! )
                // new :
printf("Send to returns (deci): %d ",rc);
printf("Send to returns (string): %s ",rc);

it prints:

Send to returns (deci): 11

Then a Windows Error Message pops up : (i will translate as Good as I
can...)

Diese Anwendung wird aufgrund eines ungltigen
Vorgans geschlossen.

(This Application will be terminated because of <Bad Instruction>/
illegal Instruction - something like that. ... now my computer is...
*ed up...) I will translate the Rest later... Shit, Winsock just
does harm to my system :-)
I Reboot...

The Error Message gives Info about some Stack and about some Register.

byby, maybe i will write more Info this Night.

greetz.  



>> Hi out there !

>> I hope someone can help me in this.

>> I am new to Winsock Programming, but now I have written an Applicatian
>> that should send an UDP packet. It is compiled without errors.

>> When I stat the Programm it outputs:

>> Winsock startet !
>> UDP Socket createt !
>> 11 Bytes Data send  !

>> Than the Firewall Allerts:

>> Outbound Connection
>> Port xxx
>> Remote IP: < IP adress provided by my Providert>

>> of Course, I allow this Connection...

>> Now there should be an Inbound connection Alert, but It isn't. I have
>> tried to grab the UDP PAcket - but there is simply no UDP PAcket to
>> Sniff. I have tried to send the packet to a friend - the same result -
>> nothing is reaching it's Destination.

>> sorry for my Bad English :-)
>> Help would be really Great !

>> Greetz,
>> Ole

>> Here's the code I have written:

>> #include <windows.h>
>> #include <winsock2.h>
>> #include <stdio.h>

>> int ini_Winsock(void);
>> int startWinsock(void);
>> int open_socket(int);
>> int send_data(void);

>> long rc;
>> SOCKET sock_1;
>> SOCKADDR_IN addr;
>> SOCKADDR_IN remoteAddr;
>> int remoteAddrLen;
>> char buf[256];

>> void main(void){
>>   open_socket(1);
>>   closesocket(sock_1);
>>   WSACleanup();

>>   }

>> int startWinsock()
>> {
>>  rc=ini_Winsock();
>>  if(rc!=0)
>>  {
>>   printf("Fehler: startWinsock, error code: %d\n",rc);
>>   return 1;
>>  }else{
>>      printf("Winsock startet!\n");
>>      }

>>   return 0;
>>  }

>> int ini_Winsock()
>> {
>>  WSADATA wsa;
>>  return WSAStartup(MAKEWORD(1,2),&wsa);
>> }

>> int open_socket(int option){
>>   startWinsock();
>>   if (option == 1){
>>      printf("einz ist der Fall");
>>      sock_1=socket(AF_INET,SOCK_DGRAM,0);
>>      if(sock_1==INVALID_SOCKET){
>>      printf("Error the UDP Socket couldn't be Created \n");
>>      }else {printf("UDP SOCKET Createt \n");}
>>      }else if (option == 2){
>>             printf("zwei ist der Fall");
>>             }else if (option == 3){
>>                   printf("drei ist der Fall");
>>                   }

>>  printf("%d", option);
>>  send_data();
>>  getch();
>>  return 0;}

>> int send_data(){

>>     addr.sin_family=AF_INET;
>>     addr.sin_port=htons(2172);
>>     addr.sin_addr.s_addr=inet_addr("212.6.79.173");

>>     strcpy(buf,"Hallo Welt!");

>> rc=sendto(sock_1,buf,strlen(buf),0,(SOCKADDR*)&addr,sizeof(SOCKADDR_IN));
>>     if(rc==SOCKET_ERROR)
>>     {
>>     printf("Error: sendto, Errorr code: %d\n",WSAGetLastError());
>>     return 1;
>>     }else{
>>     printf("%d Bytes gesendet!\n", rc);
>>     printf("%d\n", WSAGetLastError());
>>     }
>>     return 0;}

 
 
 

Winsock / Socket Created / Packet not send

Post by arkady » Mon, 02 Dec 2002 17:47:16


11 mean that you do send 11 bytes , so you have to see in sniffer ( try
NetMon if you are in W2K+ ) or windump to see that the data send to driver
Arkady




> >What the result of sendto ?
> >Arkady

> I have added the following to the code in send_data :

> rc=sendto(sock_1,buf,strlen(buf),0,(SOCKADDR*)&addr,sizeof(SOCKADDR_IN));
> // (the  line  above is not new ! )
> // new :
> printf("Send to returns (deci): %d ",rc);
> printf("Send to returns (string): %s ",rc);

> it prints:

> Send to returns (deci): 11

> Then a Windows Error Message pops up : (i will translate as Good as I
> can...)

> Diese Anwendung wird aufgrund eines ungltigen
> Vorgans geschlossen.

> (This Application will be terminated because of <Bad Instruction>/
> illegal Instruction - something like that. ... now my computer is...
> *ed up...) I will translate the Rest later... Shit, Winsock just
> does harm to my system :-)
> I Reboot...

> The Error Message gives Info about some Stack and about some Register.

> byby, maybe i will write more Info this Night.

> greetz.



> >> Hi out there !

> >> I hope someone can help me in this.

> >> I am new to Winsock Programming, but now I have written an Applicatian
> >> that should send an UDP packet. It is compiled without errors.

> >> When I stat the Programm it outputs:

> >> Winsock startet !
> >> UDP Socket createt !
> >> 11 Bytes Data send  !

> >> Than the Firewall Allerts:

> >> Outbound Connection
> >> Port xxx
> >> Remote IP: < IP adress provided by my Providert>

> >> of Course, I allow this Connection...

> >> Now there should be an Inbound connection Alert, but It isn't. I have
> >> tried to grab the UDP PAcket - but there is simply no UDP PAcket to
> >> Sniff. I have tried to send the packet to a friend - the same result -
> >> nothing is reaching it's Destination.

> >> sorry for my Bad English :-)
> >> Help would be really Great !

> >> Greetz,
> >> Ole

> >> Here's the code I have written:

> >> #include <windows.h>
> >> #include <winsock2.h>
> >> #include <stdio.h>

> >> int ini_Winsock(void);
> >> int startWinsock(void);
> >> int open_socket(int);
> >> int send_data(void);

> >> long rc;
> >> SOCKET sock_1;
> >> SOCKADDR_IN addr;
> >> SOCKADDR_IN remoteAddr;
> >> int remoteAddrLen;
> >> char buf[256];

> >> void main(void){
> >>   open_socket(1);
> >>   closesocket(sock_1);
> >>   WSACleanup();

> >>   }

> >> int startWinsock()
> >> {
> >>  rc=ini_Winsock();
> >>  if(rc!=0)
> >>  {
> >>   printf("Fehler: startWinsock, error code: %d\n",rc);
> >>   return 1;
> >>  }else{
> >>      printf("Winsock startet!\n");
> >>      }

> >>   return 0;
> >>  }

> >> int ini_Winsock()
> >> {
> >>  WSADATA wsa;
> >>  return WSAStartup(MAKEWORD(1,2),&wsa);
> >> }

> >> int open_socket(int option){
> >>   startWinsock();
> >>   if (option == 1){
> >>      printf("einz ist der Fall");
> >>      sock_1=socket(AF_INET,SOCK_DGRAM,0);
> >>      if(sock_1==INVALID_SOCKET){
> >>      printf("Error the UDP Socket couldn't be Created \n");
> >>      }else {printf("UDP SOCKET Createt \n");}
> >>      }else if (option == 2){
> >>             printf("zwei ist der Fall");
> >>             }else if (option == 3){
> >>                   printf("drei ist der Fall");
> >>                   }

> >>  printf("%d", option);
> >>  send_data();
> >>  getch();
> >>  return 0;}

> >> int send_data(){

> >>     addr.sin_family=AF_INET;
> >>     addr.sin_port=htons(2172);
> >>     addr.sin_addr.s_addr=inet_addr("212.6.79.173");

> >>     strcpy(buf,"Hallo Welt!");

rc=sendto(sock_1,buf,strlen(buf),0,(SOCKADDR*)&addr,sizeof(SOCKADDR_IN));

- Show quoted text -

Quote:> >>     if(rc==SOCKET_ERROR)
> >>     {
> >>     printf("Error: sendto, Errorr code: %d\n",WSAGetLastError());
> >>     return 1;
> >>     }else{
> >>     printf("%d Bytes gesendet!\n", rc);
> >>     printf("%d\n", WSAGetLastError());
> >>     }
> >>     return 0;}

 
 
 

Winsock / Socket Created / Packet not send

Post by monoch.. » Tue, 03 Dec 2002 01:01:44



comp.os.ms-windows.programmer.tools.winsock for further discussion, if
you want to.

greetz,
Ole



Quote:>11 mean that you do send 11 bytes , so you have to see in sniffer ( try
>NetMon if you are in W2K+ ) or windump to see that the data send to driver
>Arkady

 
 
 

Winsock / Socket Created / Packet not send

Post by Sandeep Prabhu [MS » Thu, 05 Dec 2002 08:45:48


Could you try to do more than 1 send and sniff to see if any of the other
packets make it on the wire? When you send UDP traffic, the stack needs to
figure out the MAC address of the next  hop to send this packet to. If an
Arp Cache Entry already exists, it uses that else it uses ARP protocol to
determine the MAC address. While ARP is in progress, only a limited number
of packets for this specific Arp Cache Entry get buffered. If you keep doing
sends and none of those packets make it on the wire, that would eliminate
this as the cause of problem.


Quote:> Hi out there !

> I hope someone can help me in this.

> I am new to Winsock Programming, but now I have written an Applicatian
> that should send an UDP packet. It is compiled without errors.

> When I stat the Programm it outputs:

> Winsock startet !
> UDP Socket createt !
> 11 Bytes Data send  !

> Than the Firewall Allerts:

> Outbound Connection
> Port xxx
> Remote IP: < IP adress provided by my Providert>

> of Course, I allow this Connection...

> Now there should be an Inbound connection Alert, but It isn't. I have
> tried to grab the UDP PAcket - but there is simply no UDP PAcket to
> Sniff. I have tried to send the packet to a friend - the same result -
> nothing is reaching it's Destination.

> sorry for my Bad English :-)
> Help would be really Great !

> Greetz,
> Ole

> Here's the code I have written:

> #include <windows.h>
> #include <winsock2.h>
> #include <stdio.h>

> int ini_Winsock(void);
> int startWinsock(void);
> int open_socket(int);
> int send_data(void);

> long rc;
> SOCKET sock_1;
> SOCKADDR_IN addr;
> SOCKADDR_IN remoteAddr;
> int remoteAddrLen;
> char buf[256];

> void main(void){
>   open_socket(1);
>   closesocket(sock_1);
>   WSACleanup();

>   }

> int startWinsock()
> {
>  rc=ini_Winsock();
>  if(rc!=0)
>  {
>   printf("Fehler: startWinsock, error code: %d\n",rc);
>   return 1;
>  }else{
>      printf("Winsock startet!\n");
>      }

>   return 0;
>  }

> int ini_Winsock()
> {
>  WSADATA wsa;
>  return WSAStartup(MAKEWORD(1,2),&wsa);
> }

> int open_socket(int option){
>   startWinsock();
>   if (option == 1){
>      printf("einz ist der Fall");
>      sock_1=socket(AF_INET,SOCK_DGRAM,0);
>      if(sock_1==INVALID_SOCKET){
>      printf("Error the UDP Socket couldn't be Created \n");
>      }else {printf("UDP SOCKET Createt \n");}
>      }else if (option == 2){
>             printf("zwei ist der Fall");
>             }else if (option == 3){
>                   printf("drei ist der Fall");
>                   }

>  printf("%d", option);
>  send_data();
>  getch();
>  return 0;}

> int send_data(){

>     addr.sin_family=AF_INET;
>     addr.sin_port=htons(2172);
>     addr.sin_addr.s_addr=inet_addr("212.6.79.173");

>     strcpy(buf,"Hallo Welt!");

> rc=sendto(sock_1,buf,strlen(buf),0,(SOCKADDR*)&addr,sizeof(SOCKADDR_IN));
>     if(rc==SOCKET_ERROR)
>     {
>     printf("Error: sendto, Errorr code: %d\n",WSAGetLastError());
>     return 1;
>     }else{
>     printf("%d Bytes gesendet!\n", rc);
>     printf("%d\n", WSAGetLastError());
>     }
>     return 0;}

 
 
 

Winsock / Socket Created / Packet not send

Post by arkady » Thu, 05 Dec 2002 15:19:04


Maybe try another sniffer , you really receive 11 bytes you send so now
everything is side of winsock and you can nothing to do. You can take simple
example of PSDK ( server and client which works in TCP or UDP modes ) and
check what happen . It's work without problems ( at least between 2
computers on my table :) )
Arkady



> comp.os.ms-windows.programmer.tools.winsock for further discussion, if
> you want to.

> greetz,
> Ole



> >11 mean that you do send 11 bytes , so you have to see in sniffer ( try
> >NetMon if you are in W2K+ ) or windump to see that the data send to
driver
> >Arkady

 
 
 

Winsock / Socket Created / Packet not send

Post by arkady » Thu, 05 Dec 2002 15:22:37


But sendto return 11 which is number of bytes sent so that mean that 11
bytes sent to line at least not ? Sniffer have to see it , not ?
Arkady



> Could you try to do more than 1 send and sniff to see if any of the other
> packets make it on the wire? When you send UDP traffic, the stack needs to
> figure out the MAC address of the next  hop to send this packet to. If an
> Arp Cache Entry already exists, it uses that else it uses ARP protocol to
> determine the MAC address. While ARP is in progress, only a limited number
> of packets for this specific Arp Cache Entry get buffered. If you keep
doing
> sends and none of those packets make it on the wire, that would eliminate
> this as the cause of problem.



> > Hi out there !

> > I hope someone can help me in this.

> > I am new to Winsock Programming, but now I have written an Applicatian
> > that should send an UDP packet. It is compiled without errors.

> > When I stat the Programm it outputs:

> > Winsock startet !
> > UDP Socket createt !
> > 11 Bytes Data send  !

> > Than the Firewall Allerts:

> > Outbound Connection
> > Port xxx
> > Remote IP: < IP adress provided by my Providert>

> > of Course, I allow this Connection...

> > Now there should be an Inbound connection Alert, but It isn't. I have
> > tried to grab the UDP PAcket - but there is simply no UDP PAcket to
> > Sniff. I have tried to send the packet to a friend - the same result -
> > nothing is reaching it's Destination.

> > sorry for my Bad English :-)
> > Help would be really Great !

> > Greetz,
> > Ole

> > Here's the code I have written:

> > #include <windows.h>
> > #include <winsock2.h>
> > #include <stdio.h>

> > int ini_Winsock(void);
> > int startWinsock(void);
> > int open_socket(int);
> > int send_data(void);

> > long rc;
> > SOCKET sock_1;
> > SOCKADDR_IN addr;
> > SOCKADDR_IN remoteAddr;
> > int remoteAddrLen;
> > char buf[256];

> > void main(void){
> >   open_socket(1);
> >   closesocket(sock_1);
> >   WSACleanup();

> >   }

> > int startWinsock()
> > {
> >  rc=ini_Winsock();
> >  if(rc!=0)
> >  {
> >   printf("Fehler: startWinsock, error code: %d\n",rc);
> >   return 1;
> >  }else{
> >      printf("Winsock startet!\n");
> >      }

> >   return 0;
> >  }

> > int ini_Winsock()
> > {
> >  WSADATA wsa;
> >  return WSAStartup(MAKEWORD(1,2),&wsa);
> > }

> > int open_socket(int option){
> >   startWinsock();
> >   if (option == 1){
> >      printf("einz ist der Fall");
> >      sock_1=socket(AF_INET,SOCK_DGRAM,0);
> >      if(sock_1==INVALID_SOCKET){
> >      printf("Error the UDP Socket couldn't be Created \n");
> >      }else {printf("UDP SOCKET Createt \n");}
> >      }else if (option == 2){
> >             printf("zwei ist der Fall");
> >             }else if (option == 3){
> >                   printf("drei ist der Fall");
> >                   }

> >  printf("%d", option);
> >  send_data();
> >  getch();
> >  return 0;}

> > int send_data(){

> >     addr.sin_family=AF_INET;
> >     addr.sin_port=htons(2172);
> >     addr.sin_addr.s_addr=inet_addr("212.6.79.173");

> >     strcpy(buf,"Hallo Welt!");

rc=sendto(sock_1,buf,strlen(buf),0,(SOCKADDR*)&addr,sizeof(SOCKADDR_IN));

- Show quoted text -

Quote:> >     if(rc==SOCKET_ERROR)
> >     {
> >     printf("Error: sendto, Errorr code: %d\n",WSAGetLastError());
> >     return 1;
> >     }else{
> >     printf("%d Bytes gesendet!\n", rc);
> >     printf("%d\n", WSAGetLastError());
> >     }
> >     return 0;}

 
 
 

Winsock / Socket Created / Packet not send

Post by monoch.. » Fri, 06 Dec 2002 12:52:54


ok, guys - after a few changing in the code, now everything works
fine, even if there is no remote receiveir. The sniffer had not
captured the packet, because the packet didn't get through the wire, i
think windows changed the dest. IP into the 127.0.0.1 because the
dest. IP was the IP of the local host.

Why didn't the sniffer captured a packet as i wanted to send a packet
to my friend ? i think at that time, the code was wrong, i have
pointed to the wrong ip in sendto().

thanx for the help,

Ole

>But sendto return 11 which is number of bytes sent so that mean that 11
>bytes sent to line at least not ? Sniffer have to see it , not ?
>Arkady



>> Could you try to do more than 1 send and sniff to see if any of the other
>> packets make it on the wire? When you send UDP traffic, the stack needs to
>> figure out the MAC address of the next  hop to send this packet to. If an
>> Arp Cache Entry already exists, it uses that else it uses ARP protocol to
>> determine the MAC address. While ARP is in progress, only a limited number
>> of packets for this specific Arp Cache Entry get buffered. If you keep
>doing
>> sends and none of those packets make it on the wire, that would eliminate
>> this as the cause of problem.



>> > Hi out there !

>> > I hope someone can help me in this.

>> > I am new to Winsock Programming, but now I have written an Applicatian
>> > that should send an UDP packet. It is compiled without errors.

>> > When I stat the Programm it outputs:

>> > Winsock startet !
>> > UDP Socket createt !
>> > 11 Bytes Data send  !

>> > Than the Firewall Allerts:

>> > Outbound Connection
>> > Port xxx
>> > Remote IP: < IP adress provided by my Providert>

>> > of Course, I allow this Connection...

>> > Now there should be an Inbound connection Alert, but It isn't. I have
>> > tried to grab the UDP PAcket - but there is simply no UDP PAcket to
>> > Sniff. I have tried to send the packet to a friend - the same result -
>> > nothing is reaching it's Destination.

>> > sorry for my Bad English :-)
>> > Help would be really Great !

>> > Greetz,
>> > Ole

>> > Here's the code I have written:

>> > #include <windows.h>
>> > #include <winsock2.h>
>> > #include <stdio.h>

>> > int ini_Winsock(void);
>> > int startWinsock(void);
>> > int open_socket(int);
>> > int send_data(void);

>> > long rc;
>> > SOCKET sock_1;
>> > SOCKADDR_IN addr;
>> > SOCKADDR_IN remoteAddr;
>> > int remoteAddrLen;
>> > char buf[256];

>> > void main(void){
>> >   open_socket(1);
>> >   closesocket(sock_1);
>> >   WSACleanup();

>> >   }

>> > int startWinsock()
>> > {
>> >  rc=ini_Winsock();
>> >  if(rc!=0)
>> >  {
>> >   printf("Fehler: startWinsock, error code: %d\n",rc);
>> >   return 1;
>> >  }else{
>> >      printf("Winsock startet!\n");
>> >      }

>> >   return 0;
>> >  }

>> > int ini_Winsock()
>> > {
>> >  WSADATA wsa;
>> >  return WSAStartup(MAKEWORD(1,2),&wsa);
>> > }

>> > int open_socket(int option){
>> >   startWinsock();
>> >   if (option == 1){
>> >      printf("einz ist der Fall");
>> >      sock_1=socket(AF_INET,SOCK_DGRAM,0);
>> >      if(sock_1==INVALID_SOCKET){
>> >      printf("Error the UDP Socket couldn't be Created \n");
>> >      }else {printf("UDP SOCKET Createt \n");}
>> >      }else if (option == 2){
>> >             printf("zwei ist der Fall");
>> >             }else if (option == 3){
>> >                   printf("drei ist der Fall");
>> >                   }

>> >  printf("%d", option);
>> >  send_data();
>> >  getch();
>> >  return 0;}

>> > int send_data(){

>> >     addr.sin_family=AF_INET;
>> >     addr.sin_port=htons(2172);
>> >     addr.sin_addr.s_addr=inet_addr("212.6.79.173");

>> >     strcpy(buf,"Hallo Welt!");

>rc=sendto(sock_1,buf,strlen(buf),0,(SOCKADDR*)&addr,sizeof(SOCKADDR_IN));
>> >     if(rc==SOCKET_ERROR)
>> >     {
>> >     printf("Error: sendto, Errorr code: %d\n",WSAGetLastError());
>> >     return 1;
>> >     }else{
>> >     printf("%d Bytes gesendet!\n", rc);
>> >     printf("%d\n", WSAGetLastError());
>> >     }
>> >     return 0;}

 
 
 

Winsock / Socket Created / Packet not send

Post by arkady » Fri, 06 Dec 2002 16:54:46


Oh , that know problem ! If you are in the same computer winsock
don't download packet to system level at all. So your sniffer is good enough
:) at least
Arkady


> ok, guys - after a few changing in the code, now everything works
> fine, even if there is no remote receiveir. The sniffer had not
> captured the packet, because the packet didn't get through the wire, i
> think windows changed the dest. IP into the 127.0.0.1 because the
> dest. IP was the IP of the local host.

> Why didn't the sniffer captured a packet as i wanted to send a packet
> to my friend ? i think at that time, the code was wrong, i have
> pointed to the wrong ip in sendto().

> thanx for the help,

> Ole

> >But sendto return 11 which is number of bytes sent so that mean that 11
> >bytes sent to line at least not ? Sniffer have to see it , not ?
> >Arkady



> >> Could you try to do more than 1 send and sniff to see if any of the
other
> >> packets make it on the wire? When you send UDP traffic, the stack needs
to
> >> figure out the MAC address of the next  hop to send this packet to. If
an
> >> Arp Cache Entry already exists, it uses that else it uses ARP protocol
to
> >> determine the MAC address. While ARP is in progress, only a limited
number
> >> of packets for this specific Arp Cache Entry get buffered. If you keep
> >doing
> >> sends and none of those packets make it on the wire, that would
eliminate
> >> this as the cause of problem.



> >> > Hi out there !

> >> > I hope someone can help me in this.

> >> > I am new to Winsock Programming, but now I have written an
Applicatian
> >> > that should send an UDP packet. It is compiled without errors.

> >> > When I stat the Programm it outputs:

> >> > Winsock startet !
> >> > UDP Socket createt !
> >> > 11 Bytes Data send  !

> >> > Than the Firewall Allerts:

> >> > Outbound Connection
> >> > Port xxx
> >> > Remote IP: < IP adress provided by my Providert>

> >> > of Course, I allow this Connection...

> >> > Now there should be an Inbound connection Alert, but It isn't. I have
> >> > tried to grab the UDP PAcket - but there is simply no UDP PAcket to
> >> > Sniff. I have tried to send the packet to a friend - the same
result -
> >> > nothing is reaching it's Destination.

> >> > sorry for my Bad English :-)
> >> > Help would be really Great !

> >> > Greetz,
> >> > Ole

> >> > Here's the code I have written:

> >> > #include <windows.h>
> >> > #include <winsock2.h>
> >> > #include <stdio.h>

> >> > int ini_Winsock(void);
> >> > int startWinsock(void);
> >> > int open_socket(int);
> >> > int send_data(void);

> >> > long rc;
> >> > SOCKET sock_1;
> >> > SOCKADDR_IN addr;
> >> > SOCKADDR_IN remoteAddr;
> >> > int remoteAddrLen;
> >> > char buf[256];

> >> > void main(void){
> >> >   open_socket(1);
> >> >   closesocket(sock_1);
> >> >   WSACleanup();

> >> >   }

> >> > int startWinsock()
> >> > {
> >> >  rc=ini_Winsock();
> >> >  if(rc!=0)
> >> >  {
> >> >   printf("Fehler: startWinsock, error code: %d\n",rc);
> >> >   return 1;
> >> >  }else{
> >> >      printf("Winsock startet!\n");
> >> >      }

> >> >   return 0;
> >> >  }

> >> > int ini_Winsock()
> >> > {
> >> >  WSADATA wsa;
> >> >  return WSAStartup(MAKEWORD(1,2),&wsa);
> >> > }

> >> > int open_socket(int option){
> >> >   startWinsock();
> >> >   if (option == 1){
> >> >      printf("einz ist der Fall");
> >> >      sock_1=socket(AF_INET,SOCK_DGRAM,0);
> >> >      if(sock_1==INVALID_SOCKET){
> >> >      printf("Error the UDP Socket couldn't be Created \n");
> >> >      }else {printf("UDP SOCKET Createt \n");}
> >> >      }else if (option == 2){
> >> >             printf("zwei ist der Fall");
> >> >             }else if (option == 3){
> >> >                   printf("drei ist der Fall");
> >> >                   }

> >> >  printf("%d", option);
> >> >  send_data();
> >> >  getch();
> >> >  return 0;}

> >> > int send_data(){

> >> >     addr.sin_family=AF_INET;
> >> >     addr.sin_port=htons(2172);
> >> >     addr.sin_addr.s_addr=inet_addr("212.6.79.173");

> >> >     strcpy(buf,"Hallo Welt!");

> >rc=sendto(sock_1,buf,strlen(buf),0,(SOCKADDR*)&addr,sizeof(SOCKADDR_IN));
> >> >     if(rc==SOCKET_ERROR)
> >> >     {
> >> >     printf("Error: sendto, Errorr code: %d\n",WSAGetLastError());
> >> >     return 1;
> >> >     }else{
> >> >     printf("%d Bytes gesendet!\n", rc);
> >> >     printf("%d\n", WSAGetLastError());
> >> >     }
> >> >     return 0;}

 
 
 

Winsock / Socket Created / Packet not send

Post by Sandeep Prabhu [MS » Fri, 13 Dec 2002 05:38:28


Yes if the packets get looped back at the IP layer, the sniffer won't be
able to see them.

To respond to your other question Arkadyf,
Even if the send returns 11 bytes sent, unfortunately it doesn't necessarily
guarantee the packet has actually made it to the wire.


> Oh , that know problem ! If you are in the same computer winsock
> don't download packet to system level at all. So your sniffer is good
enough
> :) at least
> Arkady



> > ok, guys - after a few changing in the code, now everything works
> > fine, even if there is no remote receiveir. The sniffer had not
> > captured the packet, because the packet didn't get through the wire, i
> > think windows changed the dest. IP into the 127.0.0.1 because the
> > dest. IP was the IP of the local host.

> > Why didn't the sniffer captured a packet as i wanted to send a packet
> > to my friend ? i think at that time, the code was wrong, i have
> > pointed to the wrong ip in sendto().

> > thanx for the help,

> > Ole

> > >But sendto return 11 which is number of bytes sent so that mean that 11
> > >bytes sent to line at least not ? Sniffer have to see it , not ?
> > >Arkady



> > >> Could you try to do more than 1 send and sniff to see if any of the
> other
> > >> packets make it on the wire? When you send UDP traffic, the stack
needs
> to
> > >> figure out the MAC address of the next  hop to send this packet to.
If
> an
> > >> Arp Cache Entry already exists, it uses that else it uses ARP
protocol
> to
> > >> determine the MAC address. While ARP is in progress, only a limited
> number
> > >> of packets for this specific Arp Cache Entry get buffered. If you
keep
> > >doing
> > >> sends and none of those packets make it on the wire, that would
> eliminate
> > >> this as the cause of problem.



> > >> > Hi out there !

> > >> > I hope someone can help me in this.

> > >> > I am new to Winsock Programming, but now I have written an
> Applicatian
> > >> > that should send an UDP packet. It is compiled without errors.

> > >> > When I stat the Programm it outputs:

> > >> > Winsock startet !
> > >> > UDP Socket createt !
> > >> > 11 Bytes Data send  !

> > >> > Than the Firewall Allerts:

> > >> > Outbound Connection
> > >> > Port xxx
> > >> > Remote IP: < IP adress provided by my Providert>

> > >> > of Course, I allow this Connection...

> > >> > Now there should be an Inbound connection Alert, but It isn't. I
have
> > >> > tried to grab the UDP PAcket - but there is simply no UDP PAcket to
> > >> > Sniff. I have tried to send the packet to a friend - the same
> result -
> > >> > nothing is reaching it's Destination.

> > >> > sorry for my Bad English :-)
> > >> > Help would be really Great !

> > >> > Greetz,
> > >> > Ole

> > >> > Here's the code I have written:

> > >> > #include <windows.h>
> > >> > #include <winsock2.h>
> > >> > #include <stdio.h>

> > >> > int ini_Winsock(void);
> > >> > int startWinsock(void);
> > >> > int open_socket(int);
> > >> > int send_data(void);

> > >> > long rc;
> > >> > SOCKET sock_1;
> > >> > SOCKADDR_IN addr;
> > >> > SOCKADDR_IN remoteAddr;
> > >> > int remoteAddrLen;
> > >> > char buf[256];

> > >> > void main(void){
> > >> >   open_socket(1);
> > >> >   closesocket(sock_1);
> > >> >   WSACleanup();

> > >> >   }

> > >> > int startWinsock()
> > >> > {
> > >> >  rc=ini_Winsock();
> > >> >  if(rc!=0)
> > >> >  {
> > >> >   printf("Fehler: startWinsock, error code: %d\n",rc);
> > >> >   return 1;
> > >> >  }else{
> > >> >      printf("Winsock startet!\n");
> > >> >      }

> > >> >   return 0;
> > >> >  }

> > >> > int ini_Winsock()
> > >> > {
> > >> >  WSADATA wsa;
> > >> >  return WSAStartup(MAKEWORD(1,2),&wsa);
> > >> > }

> > >> > int open_socket(int option){
> > >> >   startWinsock();
> > >> >   if (option == 1){
> > >> >      printf("einz ist der Fall");
> > >> >      sock_1=socket(AF_INET,SOCK_DGRAM,0);
> > >> >      if(sock_1==INVALID_SOCKET){
> > >> >      printf("Error the UDP Socket couldn't be Created \n");
> > >> >      }else {printf("UDP SOCKET Createt \n");}
> > >> >      }else if (option == 2){
> > >> >             printf("zwei ist der Fall");
> > >> >             }else if (option == 3){
> > >> >                   printf("drei ist der Fall");
> > >> >                   }

> > >> >  printf("%d", option);
> > >> >  send_data();
> > >> >  getch();
> > >> >  return 0;}

> > >> > int send_data(){

> > >> >     addr.sin_family=AF_INET;
> > >> >     addr.sin_port=htons(2172);
> > >> >     addr.sin_addr.s_addr=inet_addr("212.6.79.173");

> > >> >     strcpy(buf,"Hallo Welt!");

>rc=sendto(sock_1,buf,strlen(buf),0,(SOCKADDR*)&addr,sizeof(SOCKADDR_IN));
> > >> >     if(rc==SOCKET_ERROR)
> > >> >     {
> > >> >     printf("Error: sendto, Errorr code: %d\n",WSAGetLastError());
> > >> >     return 1;
> > >> >     }else{
> > >> >     printf("%d Bytes gesendet!\n", rc);
> > >> >     printf("%d\n", WSAGetLastError());
> > >> >     }
> > >> >     return 0;}