(I know this is mostly-Linux unrelated, but some people here 
who use Alcatel moedm as a router, with Linux, can find it useful)

While doing a routine telnet to my modem, I've discovered that
you can get a remarkable amount of information regarding the 
activity of your modem, on the fly.

This is important especially for those of us who need to 
update their dynamic IP on a dynamic DNS host server 
every time it is changed. 

I've proviously written a script that pulls the IP from the 
modem by running telnet, and let it run every 5 minutes (BTW, 
I also solved the problem with identd). But now, after discovering 
the logging information, I can write a daemon that waits for the 
modem to report the IP change.

The logging is activated by connecting using TCP/IP to 
the modem (usually 10.0.0.138), and sending the 0x11 byte:

#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
#include <arpa/inet.h>

int main()
{
    int sock, rc;
    struct sockaddr_in sin = {0,};
    char buf;
    
    sock = socket(AF_INET, SOCK_STREAM, 0);
    if (sock == -1) {
        perror("sock");
        return -1;
    }    
    
    sin.sin_family = AF_INET;
    sin.sin_port = htons(23);
    sin.sin_addr.s_addr = inet_addr("10.0.0.138");
    
    rc = connect(sock, (struct sockaddr *)&sin, sizeof(sin));
    if (rc != 0) {
        perror("connect");
        return -1;
    }

    sleep(1);
    recv(sock, buf, sizeof(buf), 0);
    
    buf = 0x11;
    send(sock, &buf, 1, 0);
    
    dup2(sock, 0);        
    execl("/bin/cat", "/bin/cat", NULL);
    return 0;
}


Running this while connecting to my ISP, I get on my side:

----------------------------------------------------------------------- 
Bit Swap Report (for line 0) 

  CarrierNr     Bi Old          Bi New          GiOld           GiNew 
  =========     ======          ======          =====           ===== 
  38            2               0               -14.5           -12.5 
  57            2               3               -14.5           -14.5 

  Results of bitswap algorithm : 
  ============================== 
  Minimum noise margin    : 17.1 dB (on carrier 56) 
  Maximum noise margin    : 25.8 dB (on carrier 78) 
  Total gain power        : 10.4
  Nominal Gi              : -12.0 dB 
  Boost Gi                : -12.0 dB 
----------------------------------------------------------------------- 
RX BITSWAP REQUEST ... 
PILOT_ERASE  ON 
PILOT_ERASE      OFF 
done at sync 7 and symb 0 
[0] E - : PPP_SET_ROUTE
<enter attach atm 0
[0] E - : PPP_LINK_OPEN
[0] E - : PPP_LINK_UP
[0] E - : Link Started
[0] E - : PPP_SET_DETCB
[Remote message: Welcome to NetVision, hana aloni
]
[0] E - : local  IP address 199.203.153.213
[0] E - : remote IP address 199.203.153.1


Unfortunately this doesn't slove the problem of what if the
IP changed while my computer was down (although it's down only
0.001% of the time).

-- 
Dan Aloni
[EMAIL PROTECTED]

=================================================================
To unsubscribe, send mail to [EMAIL PROTECTED] with
the word "unsubscribe" in the message body, e.g., run the command
echo unsubscribe | mail [EMAIL PROTECTED]

Reply via email to