V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
通过以下 Referral 链接购买 DigitalOcean 主机,你将可以帮助 V2EX 持续发展
DigitalOcean - SSD Cloud Servers
redsonic
V2EX  ›  VPS

linode singapore 昨天改路由 联通延迟丢包突破天际

  •  
  •   redsonic · 2016-09-16 20:25:25 +08:00 · 390 次点击
    这是一个创建于 2799 天前的主题,其中的信息可能已经有所发展或是发生改变。
    官方的说法是为了网络优化,可现在魔都联通绕美国,延迟突破 400ms ,丢包 25%。 原来好端端的 PACNET HK 不走 改走阿三的 TATA US 。

    AS6453| AS6453 - TATA COMMUNICATIONS (AMERICA) INC, US if-ae-2-2.tcore2.SVW-Singapore.as6453.net
    ipinfo_no=0
    5. AS6453| AS6453 - TATA COMMUNICATIONS (AMERICA) INC, US if-ae-7-2.tcore2.LVW-Los-Angeles.as6453.net 34.0% 100 177.2 174.0 172.4 181.8 2.4
    ipinfo_no=0
    AS6453| AS6453 - TATA COMMUNICATIONS (AMERICA) INC, US if-ae-2-2.tcore2.SVW-Singapore.as6453.net
    ipinfo_no=0
    6. AS6453| AS6453 - TATA COMMUNICATIONS (AMERICA) INC, US if-ae-2-2.tcore1.LVW-Los-Angeles.as6453.net 6.0% 100 173.3 178.3 172.9 191.0 4.7
    ipinfo_no=0
    AS6453| AS6453 - TATA COMMUNICATIONS (AMERICA) INC, US if-ae-7-2.tcore2.LVW-Los-Angeles.as6453.net
    ipinfo_no=0
    7. AS6453| AS6453 - TATA COMMUNICATIONS (AMERICA) INC, US if-ae-2-2.tcore1.LVW-Los-Angeles.as6453.net 0.0% 100 187.6 179.7 171.6 191.5 4.2
    ipinfo_no=0
    AS4837| CHINA169-BACKBONE CNCGROUP China169 Backbone, CN 219.158.33.57
    ipinfo_no=0
    AS4837| CHINA169-BACKBONE CNCGROUP China169 Backbone, CN 219.158.40.189
    ipinfo_no=0
    AS6453| AS6453 - TATA COMMUNICATIONS (AMERICA) INC, US 66.110.59.118
    ipinfo_no=0
    8. AS4837| CHINA169-BACKBONE CNCGROUP China169 Backbone, CN 219.158.25.21 0.0% 100 390.2 284.7 172.1 418.0 109.6
    ipinfo_no=0
    AS6453| AS6453 - TATA COMMUNICATIONS (AMERICA) INC, US 66.110.59.118
    ipinfo_no=0
    AS4837| CHINA169-BACKBONE CNCGROUP China169 Backbone, CN 219.158.40.189
    ipinfo_no=0
    AS4837| CHINA169-BACKBONE CNCGROUP China169 Backbone, CN 219.158.33.57
    ipinfo_no=0
    9. AS4837| CHINA169-BACKBONE CNCGROUP China169 Backbone, CN 219.158.97.61 0.0% 100 387.8 394.8 377.3 450.8 11.4
    ipinfo_no=0
    AS4837| CHINA169-BACKBONE CNCGROUP China169 Backbone, CN 219.158.25.21
    ipinfo_no=0
    10. AS4837| CHINA169-BACKBONE CNCGROUP China169 Backbone, CN 219.158.3.205 2.0% 100 396.8 405.2 375.5 471.6 18.6
    ipinfo_no=0
    AS4837| CHINA169-BACKBONE CNCGROUP China169 Backbone, CN 219.158.97.61
    ipinfo_no=0
    11. AS4837| CHINA169-BACKBONE CNCGROUP China169 Backbone, CN 219.158.3.205 31.0% 100 399.7 412.7 386.8 468.1 13.2
    ipinfo_no=0
    AS17621| CNCGROUP-SH China Unicom Shanghai network, CN 139.226.225.142
    ipinfo_no=0
    12. AS17621| CNCGROUP-SH China Unicom Shanghai network, CN 139.226.225.142 54.0% 100 408.9 411.1 392.7 437.3 11.4
    ipinfo_no=0
    AS17621| CNCGROUP-SH China Unicom Shanghai network, CN 112.64.249.162
    ipinfo_no=0
    13. AS17621| CNCGROUP-SH China Unicom Shanghai network, CN 112.64.249.162 80.0% 100 410.4 420.8 400.2 442.8 9.4
    6 条回复    2016-09-18 02:33:34 +08:00
    seeley
        1
    seeley  
       2016-09-17 12:36:48 +08:00
    次奥 刚测了一下确实改了 经由美西去星国 太平洋一个来回
    幸好放弃得早
    yexm0
        2
    yexm0  
       2016-09-17 19:33:22 +08:00
    @redsonic MTR 咋吧后面那个" AS6453 - TATA COMMUNICATIONS (AMERICA) INC, US"调出来?
    redsonic
        3
    redsonic  
    OP
       2016-09-17 19:38:45 +08:00   ❤️ 1
    @yexm0 我自己随便改的代码
    redsonic
        4
    redsonic  
    OP
       2016-09-17 20:09:12 +08:00
    @yexm0
    修改 asn.c ,新增一个 get_asn_name 函数。 随手改的,自己用,没有测-y 非 0 的情况。基于 mtr-0.85_p20140126 版本,其他版本估计也能直接打这个补丁。原作者-y 0 参数的输出都是 hardcode 6 位 AS 输出,因为 asn name 不定长,所以这样改有可能后面的项会移位。如果原作者想真正加这个功能恐怕会改其他输出的代码。


    --- asn.c.bak 2016-09-02 11:25:32.733209580 +0800
    +++ asn.c 2016-09-17 19:59:55.710935263 +0800
    @@ -56,16 +56,18 @@
    int ipinfo_no = -1;
    int ipinfo_max = -1;
    int iihash = 0;
    -char fmtinfo[32];
    +char fmtinfo[96];
    +char fmtinfo2[96];
    extern int af; /* address family of remote target */

    -// items width: ASN, Route, Country, Registry, Allocated
    -int iiwidth[] = { 6, 19, 4, 8, 11}; // item len + space
    +// items width: ASN, Route, Country, Registry, Allocated
    +int iiwidth[] = {66, 19, 4, 8, 11}; // item len + space
    int iiwidth_len = sizeof(iiwidth)/sizeof((iiwidth)[0]);

    typedef char* items_t[ITEMSMAX + 1];
    items_t items_a; // without hash: items
    char txtrec[NAMELEN + 1]; // without hash: txtrec
    +char txtrec2[NAMELEN + 1];
    items_t* items = &items_a;


    @@ -129,7 +131,7 @@
    txtlen = NAMELEN;

    if (iihash) {
    - if (!(txt = malloc(txtlen + 1)))
    + if (!(txt = malloc(txtlen + 1 + 96)))
    return NULL;
    } else
    txt = (char*)txtrec;
    @@ -156,6 +158,76 @@
    return p;
    }

    +char * get_asn_name(char *asn) {
    + char lookup_key[NAMELEN];
    + char asn1[6];
    +
    + unsigned char answer[PACKETSZ], *pt;
    + char host[128];
    + int len, exp, size, txtlen, type;
    +
    + if (!asn)
    + return NULL;
    +
    + strcpy(asn1, asn);
    +
    + if (snprintf(lookup_key, NAMELEN, "AS%s.asn.cymru.com", asn) >= NAMELEN)
    + return NULL;
    +
    + if(res_init() < 0) {
    + fprintf(stderr,"@res_init failed\n");
    + return NULL;
    + }
    + memset(answer, 0, PACKETSZ);
    + if((len = res_query(lookup_key, C_IN, T_TXT, answer, PACKETSZ)) < 0) {
    + return UNKN;
    + }
    +
    + pt = answer + sizeof(HEADER);
    +
    + if((exp = dn_expand(answer, answer + len, pt, host, sizeof(host))) < 0) {
    + printf("@dn_expand failed\n"); return NULL;
    + }
    +
    + pt += exp;
    +
    + GETSHORT(type, pt);
    + if(type != T_TXT) {
    + printf("@Broken DNS reply.\n"); return NULL;
    + }
    +
    + pt += INT16SZ; /* class */
    +
    + if((exp = dn_expand(answer, answer + len, pt, host, sizeof(host))) < 0) {
    + printf("@second dn_expand failed\n"); return NULL;
    + }
    +
    + pt += exp;
    + GETSHORT(type, pt);
    + if(type != T_TXT) {
    + printf("@Not a TXT record\n"); return NULL;
    + }
    +
    + pt += INT16SZ; /* class */
    + pt += INT32SZ; /* ttl */
    + GETSHORT(size, pt);
    + txtlen = *pt;
    +
    +
    + if(txtlen >= size || !txtlen) {
    + printf("@Broken TXT record (txtlen = %d, size = %d)\n", txtlen, size); return NULL;
    + }
    +
    + if (txtlen > NAMELEN)
    + txtlen = NAMELEN;
    +
    + pt++;
    + strncpy(txtrec2, (char*) pt, txtlen);
    + txtrec2[txtlen] = 0;
    +
    + strcat(asn, strrchr(txtrec2, ITEMSEP));
    + return strrchr(txtrec2, ITEMSEP);
    +}
    // originX.asn.cymru.com txtrec: ASN | Route | Country | Registry | Allocated
    char* split_txtrec(char *txtrec) {
    if (!txtrec)
    @@ -187,6 +259,7 @@
    for (j = i; j <= ITEMSMAX; j++)
    (*items)[j] = NULL;

    + get_asn_name((*items)[0]);
    if (i > ipinfo_max)
    ipinfo_max = i;
    printf("ipinfo_no=%d\n", ipinfo_no);
    @@ -281,7 +354,7 @@
    char *ipinfo = get_ipinfo(addr);
    char fmt[8];
    snprintf(fmt, sizeof(fmt), "%s%%-%ds", ipinfo_no?"":"AS", get_iiwidth());
    - snprintf(fmtinfo, sizeof(fmtinfo), fmt, ipinfo?ipinfo:UNKN);
    + snprintf(fmtinfo, sizeof(fmtinfo2), fmt, ipinfo?ipinfo:UNKN);
    return fmtinfo;
    }
    yexm0
        5
    yexm0  
       2016-09-17 23:23:23 +08:00
    @redsonic 不知为啥它的 0.87 版本只能发 10 个包....奇葩
    redsonic
        6
    redsonic  
    OP
       2016-09-18 02:33:34 +08:00
    @yexm0 我的补丁的问题? 不打补丁也只能发 10 个包?
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   4801 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 10:03 · PVG 18:03 · LAX 03:03 · JFK 06:03
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.