ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/gvpe/src/vpn_dns.C
(Generate patch)

Comparing gvpe/src/vpn_dns.C (file contents):
Revision 1.26 by pcg, Tue Mar 8 17:25:27 2005 UTC vs.
Revision 1.27 by pcg, Sat Mar 12 18:10:40 2005 UTC

52 52
53#define INITIAL_TIMEOUT 0.1 // retry timeouts 53#define INITIAL_TIMEOUT 0.1 // retry timeouts
54#define INITIAL_SYN_TIMEOUT 10. // retry timeout for initial syn 54#define INITIAL_SYN_TIMEOUT 10. // retry timeout for initial syn
55 55
56#define MIN_SEND_INTERVAL 0.01 // wait at least this time between sending requests 56#define MIN_SEND_INTERVAL 0.01 // wait at least this time between sending requests
57#define MAX_SEND_INTERVAL 0.5 // optimistic? 57#define MAX_SEND_INTERVAL 2. // optimistic?
58 58
59#define LATENCY_FACTOR 0.5 // RTT * LATENCY_FACTOR == sending rate 59#define LATENCY_FACTOR 0.5 // RTT * LATENCY_FACTOR == sending rate
60#define MAX_OUTSTANDING 20 // max. outstanding requests 60#define MAX_OUTSTANDING 40 // max. outstanding requests
61#define MAX_WINDOW 1000 // max. for MAX_OUTSTANDING, and backlog 61#define MAX_WINDOW 1000 // max. for MAX_OUTSTANDING, and backlog
62#define MAX_BACKLOG (100*1024) // size of gvpe protocol backlog (bytes), must be > MAXSIZE 62#define MAX_BACKLOG (100*1024) // size of gvpe protocol backlog (bytes), must be > MAXSIZE
63 63
64#define MAX_DOMAIN_SIZE 200 // 255 is legal limit, but bind doesn't compress well 64#define MAX_DOMAIN_SIZE 200 // 255 is legal limit, but bind doesn't compress well
65// 240 leaves about 4 bytes of server reply data 65// 240 leaves about 4 bytes of server reply data
449 flags = 0; 449 flags = 0;
450 def_ttl = 0; 450 def_ttl = 0;
451 seq_cdc = 26; 451 seq_cdc = 26;
452 req_cdc = 62; 452 req_cdc = 62;
453 rep_cdc = 0; 453 rep_cdc = 0;
454 max_size = ntohs (MAX_PKT_SIZE); 454 max_size = htons (MAX_PKT_SIZE);
455 client = ntohs (clientid); 455 client = htons (clientid);
456 uid = next_uid++; 456 uid = next_uid++;
457 457
458 r2 = r3 = r4 = 0; 458 r2 = r3 = r4 = 0;
459 r4 = r5 = r6 = r7 = 0; 459 r4 = r5 = r6 = r7 = 0;
460} 460}
466 && id3 == 'P' 466 && id3 == 'P'
467 && id4 == 'E' 467 && id4 == 'E'
468 && seq_cdc == 26 468 && seq_cdc == 26
469 && req_cdc == 62 469 && req_cdc == 62
470 && rep_cdc == 0 470 && rep_cdc == 0
471 && version == 1 471 && version == 1;
472 && max_size == ntohs (MAX_PKT_SIZE);
473} 472}
474 473
475struct dns_packet : net_packet 474struct dns_packet : net_packet
476{ 475{
477 u16 id; 476 u16 id;
894 pkt [offs++] = 0; pkt [offs++] = 0; 893 pkt [offs++] = 0; pkt [offs++] = 0;
895 pkt [offs++] = 0; pkt [offs++] = dns ? dns->cfg.def_ttl : 0; // TTL 894 pkt [offs++] = 0; pkt [offs++] = dns ? dns->cfg.def_ttl : 0; // TTL
896 895
897 int rdlen_offs = offs += 2; 896 int rdlen_offs = offs += 2;
898 897
899 int dlen = (dns ? ntohs (dns->cfg.max_size) : MAX_PKT_SIZE) - offs;
900 // bind doesn't compress well, so reduce further by one label length
901 dlen -= qlen;
902
903 if (dns) 898 if (dns)
904 { 899 {
900 int dlen = ntohs (dns->cfg.max_size) - offs;
901
902 // bind doesn't compress well, so reduce further by one label length
903 dlen -= qlen;
904
905 // only put data into in-order sequence packets, if 905 // only put data into in-order sequence packets, if
906 // we receive out-of-order packets we generate empty 906 // we receive out-of-order packets we generate empty
907 // replies 907 // replies
908 while (dlen > 1 && !dns->snddq.empty () && in_seq) 908 while (dlen > 1 && !dns->snddq.empty () && in_seq)
909 { 909 {
1020 else 1020 else
1021 { 1021 {
1022#if 0 1022#if 0
1023 dns->send_interval *= 0.999; 1023 dns->send_interval *= 0.999;
1024#endif 1024#endif
1025 if (dns->send_interval < MIN_SEND_INTERVAL)
1026 dns->send_interval = MIN_SEND_INTERVAL;
1027
1028 // the latency surely puts an upper bound on 1025 // the latency surely puts an upper bound on
1029 // the minimum send interval 1026 // the minimum send interval
1030 double latency = NOW - (*i)->sent; 1027 double latency = NOW - (*i)->sent;
1031 1028
1032 if (latency < dns->min_latency) 1029 if (latency < dns->min_latency)
1033 dns->min_latency = latency; 1030 dns->min_latency = latency;
1034 1031
1035 if (dns->send_interval > dns->min_latency * LATENCY_FACTOR) 1032 if (dns->send_interval > dns->min_latency * LATENCY_FACTOR)
1036 dns->send_interval = dns->min_latency * LATENCY_FACTOR; 1033 dns->send_interval = dns->min_latency * LATENCY_FACTOR;
1034
1035 if (dns->send_interval < MIN_SEND_INTERVAL)
1036 dns->send_interval = MIN_SEND_INTERVAL;
1037 } 1037 }
1038 1038
1039 delete *i; 1039 delete *i;
1040 dns_sndpq.erase (i); 1040 dns_sndpq.erase (i);
1041 1041
1229 1229
1230 // the following code changes the query section a bit, forcing 1230 // the following code changes the query section a bit, forcing
1231 // the forwarder to generate a new request 1231 // the forwarder to generate a new request
1232 if (r->stdhdr) 1232 if (r->stdhdr)
1233 { 1233 {
1234 //printf ("reencoded header for ID %d retry %d:%d:%d\n", htons (r->pkt->id), THISNODE->id, r->seqno, r->retry);printf ("reencoded header for ID %d retry %d:%d:%d\n", htons (r->pkt->id), THISNODE->id, r->seqno, r->retry); 1234 //printf ("reencoded header for ID %d retry %d:%d:%d (%p)\n", htons (r->pkt->id), THISNODE->id, r->seqno, r->retry);
1235 //encode_header ((char *)r->pkt->at (6 * 2 + 1), THISNODE->id, r->seqno, r->retry); 1235 //encode_header ((char *)r->pkt->at (6 * 2 + 1), THISNODE->id, r->seqno, r->retry);
1236 } 1236 }
1237 } 1237 }
1238 } 1238 }
1239 else 1239 else
1240 NEXT (r->timeout); 1240 NEXT (r->timeout);
1241 } 1241 }
1242 1242
1243 if (last_sent + send_interval <= NOW) 1243 if (send || (last_sent + send_interval <= NOW))
1244 { 1244 {
1245 if (!send) 1245 if (!send)
1246 { 1246 {
1247 // generate a new packet, if wise 1247 // generate a new packet, if wise
1248 1248
1271 send->timeout = NOW + min_latency * 8.; 1271 send->timeout = NOW + min_latency * 8.;
1272 1272
1273 sndseq = (sndseq + 1) & SEQNO_MASK; 1273 sndseq = (sndseq + 1) & SEQNO_MASK;
1274 } 1274 }
1275 1275
1276 if (send) 1276 if (send && !send->retry)
1277 vpn->dns_sndpq.push_back (send); 1277 vpn->dns_sndpq.push_back (send);
1278 } 1278 }
1279 1279
1280 if (send) 1280 if (send)
1281 { 1281 {
1286 } 1286 }
1287 } 1287 }
1288 else 1288 else
1289 NEXT (last_sent + send_interval); 1289 NEXT (last_sent + send_interval);
1290 1290
1291 slog (L_NOISE, "DNS: pi %f si %f N %f (%d:%d)", 1291 slog (L_NOISE, "DNS: pi %f si %f N %f (%d:%d %d)",
1292 poll_interval, send_interval, next - NOW, 1292 poll_interval, send_interval, next - NOW,
1293 vpn->dns_sndpq.size (), snddq.size ()); 1293 vpn->dns_sndpq.size (), snddq.size (),
1294 rcvpq.size ());
1294 1295
1295 // TODO: no idea when this happens, but when next < NOW, we have a problem 1296 // TODO: no idea when this happens, but when next < NOW, we have a problem
1296 if (next < NOW + 0.0001) 1297 if (next < NOW + 0.0001)
1297 next = NOW + 0.1; 1298 next = NOW + 0.1;
1298 1299

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines