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.27 by pcg, Sat Mar 12 18:10:40 2005 UTC vs.
Revision 1.29 by pcg, Sun Mar 13 12:40:20 2005 UTC

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 2. // 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 40 // max. outstanding requests 60#define MAX_OUTSTANDING 100 // 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 240 // 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
66// every two request bytes less give room for one reply byte 66// every two request bytes less give room for one reply byte
67 67
68#define SEQNO_MASK 0x3fff 68#define SEQNO_MASK 0x3fff
69#define SEQNO_EQ(a,b) ( 0 == ( ((a) ^ (b)) & SEQNO_MASK) ) 69#define SEQNO_EQ(a,b) ( 0 == ( ((a) ^ (b)) & SEQNO_MASK) )
1238 } 1238 }
1239 else 1239 else
1240 NEXT (r->timeout); 1240 NEXT (r->timeout);
1241 } 1241 }
1242 1242
1243 if (send || (last_sent + send_interval <= NOW))
1244 {
1245 if (!send) 1243 if (!send)
1244 {
1245 // generate a new packet, if wise
1246
1247 if (!established)
1246 { 1248 {
1247 // generate a new packet, if wise 1249 if (vpn->dns_sndpq.empty ())
1248
1249 if (!established)
1250 { 1250 {
1251 if (vpn->dns_sndpq.empty ())
1252 {
1253 send = new dns_snd (this); 1251 send = new dns_snd (this);
1254 1252
1255 cfg.reset (THISNODE->id); 1253 cfg.reset (THISNODE->id);
1256 send->gen_syn_req (); 1254 send->gen_syn_req ();
1257 }
1258 } 1255 }
1256 }
1259 else if (vpn->dns_sndpq.size () < MAX_OUTSTANDING 1257 else if (vpn->dns_sndpq.size () < MAX_OUTSTANDING
1260 && !SEQNO_EQ (rcvseq, sndseq - (MAX_WINDOW - 1))) 1258 && !SEQNO_EQ (rcvseq, sndseq - (MAX_WINDOW - 1)))
1259 {
1260 if (last_sent + send_interval <= NOW)
1261 { 1261 {
1262 //printf ("sending data request etc.\n"); //D 1262 //printf ("sending data request etc.\n"); //D
1263 if (!snddq.empty () || last_received + 1. > NOW) 1263 if (!snddq.empty () || last_received + 1. > NOW)
1264 { 1264 {
1265 poll_interval = send_interval; 1265 poll_interval = send_interval;
1270 send->gen_stream_req (sndseq, snddq); 1270 send->gen_stream_req (sndseq, snddq);
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 else
1276 if (send && !send->retry) 1276 NEXT (last_sent + send_interval);
1277 vpn->dns_sndpq.push_back (send);
1278 } 1277 }
1279 1278
1280 if (send) 1279 if (send)
1281 { 1280 vpn->dns_sndpq.push_back (send);
1281 }
1282
1283 if (send)
1284 {
1282 last_sent = NOW; 1285 last_sent = NOW;
1283 sendto (vpn->dnsv4_fd, 1286 sendto (vpn->dnsv4_fd,
1284 send->pkt->at (0), send->pkt->len, 0, 1287 send->pkt->at (0), send->pkt->len, 0,
1285 vpn->dns_forwarder.sav4 (), vpn->dns_forwarder.salenv4 ()); 1288 vpn->dns_forwarder.sav4 (), vpn->dns_forwarder.salenv4 ());
1286 }
1287 } 1289 }
1288 else
1289 NEXT (last_sent + send_interval);
1290 1290
1291 slog (L_NOISE, "DNS: pi %f si %f N %f (%d:%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 rcvpq.size ());
1295 1295
1296 // 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
1297 if (next < NOW + 0.0001) 1297 if (next < NOW + 0.001)
1298 next = NOW + 0.1; 1298 next = NOW + 0.1;
1299 1299
1300 w.start (next); 1300 w.start (next);
1301} 1301}
1302 1302

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines