Member Avatar for Thew

Hello,
I am a beginner in Windows socket programming and I want to know, if there is some way how to create an UDP packet with no source IP address (or with some different on another network) so when it is forwarded to the destination, receiver will not be able to respond.
Thanks.

No source address? No -- even a broadcast address is an address. A different source address? Yes. That's packet-spoofing, something that's used to cause trouble (a 'smurf' packetstorm, for instance; google "Smurf Attack"). You can play with that over your own LAN, but *don't* let it out onto the Internet.

Member Avatar for Thew

I have finally found the solution how to do this. It's possible if you use the WinPcap. You can use this to generate signals on your NIC, "to send your own packets". With use of this headers:

/* 4 bytes IP address */
typedef struct ip_address{
    u_char byte1;
    u_char byte2;
    u_char byte3;
    u_char byte4;
}ip_address;

/* IPv4 header */
typedef struct ip_header{
    u_char  ver_ihl;        // Version (4 bits) + Internet header length (4 bits)
    u_char  tos;            // Type of service 
    u_short tlen;           // Total length 
    u_short identification; // Identification
    u_short flags_fo;       // Flags (3 bits) + Fragment offset (13 bits)
    u_char  ttl;            // Time to live
    u_char  proto;          // Protocol
    u_short crc;            // Header checksum
    ip_address  saddr;      // Source address
    ip_address  daddr;      // Destination address
//    u_int   op_pad;         // Option + Padding
}ip_header;

/* UDP header*/
typedef struct udp_header{
    u_short sport;          // Source port
    u_short dport;          // Destination port
    u_short len;            // Datagram length
    u_short crc;            // Checksum
}udp_header;

I can post whole source code how to create an UDP packet and send it.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.