Finding your Edimax SP-2101W devices from your PC

Finding the devices in your LAN is easy – but undocumented. Your android app will just send out a broadcast UDP packet to port 20560, which will be answered by every edimax device that receives it. Anyway, the following program can be used to enumerate your devices:

#include <sys/socket.h>
#include <netinet/in.h>
#include <stdio.h>
#include <stdlib.h>
#include <strings.h>
#include <signal.h>

#pragma pack(1)
struct reply {
    unsigned char macaddr[6];
    char     manufacturer[12];
    int      unknown;        // 0x 01 a1 fe 5e
    char     model[14];
    char     version[8];
    char     displayname[128];
    short     port;            // 0x10 27 == 10000 little endian
    unsigned char     ipaddr[4];
    long     unknown2;
    unsigned char     dstaddr[4];

int alarmed=0;
void gotalarm(int signo) {

int main(int argc, char**argv)
    int sockfd, n, len;
    int enable=1;
    struct sockaddr_in servaddr;
    struct reply reply;

    setsockopt(sockfd, SOL_SOCKET, SO_BROADCAST, &enable, sizeof enable);

    servaddr.sin_family = AF_INET;

    sendto(sockfd, "\xff\xff\xff\xff\xff\xff"        // 6
           "EDIMAX"                // 6
           "\x00\x00\x00\x00\x00\x00"        // 6
           "\x00\xA1\xFF\x5E",            // 4
        22, 0,
               (struct sockaddr *)&servaddr, sizeof(servaddr));

    signal(SIGALRM, gotalarm);
    while (!alarmed) {
        len=sizeof servaddr;
        n=recvfrom(sockfd, &reply, 1000, 0,
            (struct sockaddr *)&servaddr, &len);
        if (n>=186) {
            char ipbuf[16];
            char macbuf[20];
            snprintf(ipbuf, sizeof ipbuf, "%d.%d.%d.%d",
            snprintf(macbuf, sizeof macbuf, "%02X:%02X:%02X:%02X:%02X:%02X",
            printf("%-15s %5d %-20s %-12.12s %-14.14s %-8.8s %s\n",
                ipbuf, reply.port, macbuf, reply.manufacturer,
                reply.model, reply.version, reply.displayname);

The alarm(2) allows for 2 seconds until the response is received, adjust as needed.

One thought on “Finding your Edimax SP-2101W devices from your PC

Leave a Reply

Your email address will not be published. Required fields are marked *