libsmbclient.so speed

Alistair Hopkins alistair at berthengron.co.uk
Wed May 14 09:32:32 GMT 2003


Hi, sorry about the delay but...

Here's a tcpdump of what happens during a request - it looks as though it
takes three attempts for libsmbclient to get through, with a different local
port in each case (10:14:05 and 10:14:25).  I have done this a number of
times and it is always three ports to get  result, with the long (10s +) gap
between the different tries.  When I compare with using smbclient, it also
uses three ports but doesn't have the the ten second + gap between them - I
guessthere's a single config line I can write to tell libsmbclient.so how
long to wait between retries (or whatever they are!) but I can't find any
reference!

Below that is a slightly clipped version of the code (auth_fn removed).  It
uses the fact that a piece of software on these boxes should write to log
more than every fifteen minutes and when frozen, don't do that.  This is a
cheap way of monitoring the software until we get something a little more
net-friendly...   It initialises smbclient, opens a log directory, then
iterates through the entries cat'ing those with names that match the log
file and getting the most recently written one  (the logs rotate) then
deciding if it's too old.

Any suggestions welcome!

Alistair



10:13:34.681112 192.168.1.5.3794 > 10.1.1.12.netbios-ssn: S
3060113901:3060113901(0) win 64512 <mss 1406,nop,nop,sackOK> (DF)
10:13:45.272951 192.168.1.3.32772 > 192.168.1.5.netbios-ssn: P
2085402939:2085403043(104) ack 2626344319 win 11152 <nop,nop,timestamp
1647272 5756415>NBT Packet (DF)
10:13:45.274936 192.168.1.5.netbios-ssn > 192.168.1.3.32772: P 1:87(86) ack
104 win 63438 <nop,nop,timestamp 5758603 1647272>NBT Packet (DF)
10:13:45.275016 192.168.1.3.32772 > 192.168.1.5.netbios-ssn: . ack 87 win
11152 <nop,nop,timestamp 1647273 5758603> (DF)
10:13:45.275090 192.168.1.3.32772 > 192.168.1.5.netbios-ssn: P 104:172(68)
ack 87 win 11152 <nop,nop,timestamp 1647273 5758603>NBT Packet (DF)
10:13:45.275994 192.168.1.5.netbios-ssn > 192.168.1.3.32772: P 87:140(53)
ack 172 win 63370 <nop,nop,timestamp 5758603 1647273>NBT Packet (DF)
10:13:45.315018 192.168.1.3.32772 > 192.168.1.5.netbios-ssn: . ack 140 win
11152 <nop,nop,timestamp 1647294 5758603> (DF)
10:14:05.461631 192.168.1.3.32797 > 192.168.1.5.netbios-ssn: S
3932903551:3932903551(0) win 5840 <mss 1460,sackOK,timestamp 1657609
0,nop,wscale 0> (DF)
10:14:05.462150 192.168.1.5.netbios-ssn > 192.168.1.3.32797: S
3070080661:3070080661(0) ack 3932903552 win 64512 <mss 1406,nop,wscale
0,nop,nop,timestamp 0 0,nop,nop,sackOK> (DF)
10:14:05.462200 192.168.1.3.32797 > 192.168.1.5.netbios-ssn: . ack 1 win
5840 <nop,nop,timestamp 1657609 0> (DF)
10:14:05.713635 192.168.1.3.32797 > 192.168.1.5.netbios-ssn: P 1:73(72) ack
1 win 5840 <nop,nop,timestamp 1657738 0>NBT Packet (DF)
10:14:05.714075 192.168.1.5.netbios-ssn > 192.168.1.3.32797: FP 1:6(5) ack
73 win 64440 <nop,nop,timestamp 5758807 1657738>NBT Packet (DF)
10:14:05.714242 192.168.1.3.32797 > 192.168.1.5.netbios-ssn: F 73:73(0) ack
7 win 5840 <nop,nop,timestamp 1657738 5758807> (DF)
10:14:05.714551 192.168.1.5.netbios-ssn > 192.168.1.3.32797: . ack 74 win
64440 <nop,nop,timestamp 5758807 1657738> (DF)
10:14:25.869842 192.168.1.3.32799 > 192.168.1.5.netbios-ssn: S
3955105097:3955105097(0) win 5840 <mss 1460,sackOK,timestamp 1668058
0,nop,wscale 0> (DF)
10:14:25.870357 192.168.1.5.netbios-ssn > 192.168.1.3.32799: S
3075301498:3075301498(0) ack 3955105098 win 64512 <mss 1406,nop,wscale
0,nop,nop,timestamp 0 0,nop,nop,sackOK> (DF)
10:14:25.870409 192.168.1.3.32799 > 192.168.1.5.netbios-ssn: . ack 1 win
5840 <nop,nop,timestamp 1668058 0> (DF)
10:14:26.121807 192.168.1.3.32799 > 192.168.1.5.netbios-ssn: P 1:73(72) ack
1 win 5840 <nop,nop,timestamp 1668187 0>NBT Packet (DF)
10:14:26.122376 192.168.1.5.netbios-ssn > 192.168.1.3.32799: P 1:5(4) ack 73
win 64440 <nop,nop,timestamp 5759011 1668187>NBT Packet (DF)
10:14:26.122424 192.168.1.3.32799 > 192.168.1.5.netbios-ssn: . ack 5 win
5840 <nop,nop,timestamp 1668187 5759011> (DF)
10:14:26.122559 192.168.1.3.32799 > 192.168.1.5.netbios-ssn: P 73:241(168)
ack 5 win 5840 <nop,nop,timestamp 1668187 5759011>NBT Packet (DF)
10:14:26.123154 192.168.1.5.netbios-ssn > 192.168.1.3.32799: P 5:116(111)
ack 241 win 64272 <nop,nop,timestamp 5759011 1668187>NBT Packet (DF)
10:14:26.124575 192.168.1.3.32799 > 192.168.1.5.netbios-ssn: P 241:411(170)
ack 116 win 5840 <nop,nop,timestamp 1668188 5759011>NBT Packet (DF)
10:14:26.127015 192.168.1.5.netbios-ssn > 192.168.1.3.32799: P 116:251(135)
ack 411 win 64102 <nop,nop,timestamp 5759011 1668188>NBT Packet (DF)
10:14:26.127101 192.168.1.3.32799 > 192.168.1.5.netbios-ssn: P 411:499(88)
ack 251 win 5840 <nop,nop,timestamp 1668189 5759011>NBT Packet (DF)
10:14:26.127804 192.168.1.5.netbios-ssn > 192.168.1.3.32799: P 251:309(58)
ack 499 win 64014 <nop,nop,timestamp 5759011 1668189>NBT Packet (DF)
10:14:26.127922 192.168.1.3.32799 > 192.168.1.5.netbios-ssn: P 499:627(128)
ack 309 win 5840 <nop,nop,timestamp 1668190 5759011>NBT Packet (DF)
10:14:26.130869 192.168.1.5.netbios-ssn > 192.168.1.3.32799: .
309:1703(1394) ack 627 win 63886 <nop,nop,timestamp 5759011 1668190>NBT
Packet (DF)
10:14:26.132064 192.168.1.5.netbios-ssn > 192.168.1.3.32799: .
1703:3097(1394) ack 627 win 63886 <nop,nop,timestamp 5759011 1668190>NBT
Packet (DF)
10:14:26.132114 192.168.1.3.32799 > 192.168.1.5.netbios-ssn: . ack 3097 win
11152 <nop,nop,timestamp 1668192 5759011> (DF)
10:14:26.133258 192.168.1.5.netbios-ssn > 192.168.1.3.32799: .
3097:4491(1394) ack 627 win 63886 <nop,nop,timestamp 5759011 1668190>NBT
Packet (DF)
10:14:26.133554 192.168.1.5.netbios-ssn > 192.168.1.3.32799: P
4491:4633(142) ack 627 win 63886 <nop,nop,timestamp 5759011 1668190>NBT
Packet (DF)
10:14:26.133590 192.168.1.3.32799 > 192.168.1.5.netbios-ssn: . ack 4633 win
11152 <nop,nop,timestamp 1668193 5759011> (DF)
10:14:26.133903 192.168.1.3.32799 > 192.168.1.5.netbios-ssn: P 627:713(86)
ack 4633 win 11152 <nop,nop,timestamp 1668193 5759011>NBT Packet (DF)
10:14:26.135220 192.168.1.5.netbios-ssn > 192.168.1.3.32799: P
4633:5513(880) ack 713 win 63800 <nop,nop,timestamp 5759011 1668193>NBT
Packet (DF)
10:14:26.135515 192.168.1.3.32799 > 192.168.1.5.netbios-ssn: P 713:871(158)
ack 5513 win 11152 <nop,nop,timestamp 1668194 5759011>NBT Packet (DF)
10:14:26.136407 192.168.1.5.netbios-ssn > 192.168.1.3.32799: P
5513:5771(258) ack 871 win 63642 <nop,nop,timestamp 5759011 1668194>NBT
Packet (DF)
10:14:26.136507 192.168.1.3.32799 > 192.168.1.5.netbios-ssn: P 871:1043(172)
ack 5771 win 11152 <nop,nop,timestamp 1668194 5759011>NBT Packet (DF)
10:14:26.137384 192.168.1.5.netbios-ssn > 192.168.1.3.32799: P
5771:6043(272) ack 1043 win 63470 <nop,nop,timestamp 5759011 1668194>NBT
Packet (DF)
10:14:26.144171 192.168.1.3.32799 > 192.168.1.5.netbios-ssn: P
1043:1215(172) ack 6043 win 11152 <nop,nop,timestamp 1668198 5759011>NBT
Packet (DF)
10:14:26.145800 192.168.1.5.netbios-ssn > 192.168.1.3.32799: P
6043:6315(272) ack 1215 win 63298 <nop,nop,timestamp 5759011 1668198>NBT
Packet (DF)
10:14:26.145927 192.168.1.3.32799 > 192.168.1.5.netbios-ssn: P
1215:1387(172) ack 6315 win 11152 <nop,nop,timestamp 1668199 5759011>NBT
Packet (DF)
10:14:26.160004 192.168.1.5.netbios-ssn > 192.168.1.3.32799: P
6315:6587(272) ack 1387 win 63126 <nop,nop,timestamp 5759011 1668199>NBT
Packet (DF)
10:14:26.160400 192.168.1.3.32772 > 192.168.1.5.netbios-ssn: P 172:225(53)
ack 140 win 11152 <nop,nop,timestamp 1668206 5758603>NBT Packet (DF)
10:14:26.197825 192.168.1.3.32799 > 192.168.1.5.netbios-ssn: . ack 6587 win
11152 <nop,nop,timestamp 1668226 5759011> (DF)
10:14:26.252560 192.168.1.5.netbios-ssn > 192.168.1.3.32772: P 140:179(39)
ack 225 win 63317 <nop,nop,timestamp 5759012 1668206>NBT Packet (DF)
10:14:26.252725 192.168.1.3.32772 > 192.168.1.5.netbios-ssn: . ack 179 win
11152 <nop,nop,timestamp 1668254 5759012> (DF)
10:14:26.252782 192.168.1.3.32772 > 192.168.1.5.netbios-ssn: P 225:270(45)
ack 179 win 11152 <nop,nop,timestamp 1668254 5759012>NBT Packet (DF)
10:14:26.253350 192.168.1.5.netbios-ssn > 192.168.1.3.32772: P 179:218(39)
ack 270 win 63272 <nop,nop,timestamp 5759012 1668254>NBT Packet (DF)
10:14:26.253661 192.168.1.3.32799 > 192.168.1.5.netbios-ssn: F 1387:1387(0)
ack 6587 win 11152 <nop,nop,timestamp 1668254 5759011> (DF)
10:14:26.254019 192.168.1.5.netbios-ssn > 192.168.1.3.32799: F 6587:6587(0)
ack 1388 win 63126 <nop,nop,timestamp 5759012 1668254> (DF)
10:14:26.254047 192.168.1.3.32799 > 192.168.1.5.netbios-ssn: . ack 6588 win
11152 <nop,nop,timestamp 1668254 5759012> (DF)
10:14:26.291576 192.168.1.3.32772 > 192.168.1.5.netbios-ssn: . ack 218 win
11152 <nop,nop,timestamp 1668274 5759012> (DF)



int main(int argc, char **argv){

int dh, err, dsize, dirc;

int debug;

char file[100];

char logdir[500];

struct smbc_dirent *dirent;

long maxtime = 0;

long now;

int hours;

int minutes;

struct stat st;

struct SMBCCTX *ctx;

if (argc < 2) {

printf("You must call with the IP address to check. Add a d after for
debugging info\n");

exit (WARNING);

}

debug = (argc > 2 ? (int)argv[2] : 0);

/* Initialize lib */

if ((err = smbc_init(get_auth_data, 0)) < 0) {

fprintf(stderr, "Error initializing the smbclient library: check file exists
~/.smb/smb.conf: %u, %s\n", errno, strerror(errno));

exit (WARNING);

}

if( debug > 0 ) printf("smbc_init OK\n");

strcpy(logdir, LOGDIR1);

strcat(logdir, argv[1]);

strcat(logdir, LOGDIR2);

strcat(logdir, "\0");

/* Open directory */

if ((dh = smbc_opendir(logdir)) < 0) {

fprintf(stderr, "Could not open directory: %u, %s\n", errno,
strerror(errno));

exit(ERROR);

}

if(debug > 0) fprintf(stdout, "Dir %s opened\n", logdir);

time(&now);

if(debug > 0) fprintf(stdout, "Local time is %d\n", now);

while((dirent = smbc_readdir(dh)) != NULL){

/* sort out which files we want */

if ((dirent->smbc_type == 8) && !strncmp("File_",dirent->name,8)) {


/* Build the SMB URL for each file */

strcpy(file, logdir);

strcat(file,dirent->name);

/*stat the files*/

err = smbc_stat(file, &st);

if (err != 0) {

fprintf(stderr, "Stat failed: %s: %u %s\n", dirent->name, err,
strerror(errno));

} else {

if(debug > 1) fprintf(stdout, "File: %s. Size: %d time: %d\n", dirent->name,
(int)st.st_size, (long)st.st_mtime);

if(maxtime < (long)st.st_mtime)

maxtime = (long)st.st_mtime;

}

}

}

smbc_closedir(dh);

if(debug > 0) fprintf(stdout, "Youngest file is: %d %d minutes
old\n",maxtime, (now - maxtime)/60);

if((now - maxtime) > (ERR_AGE * 60)){

hours = (now - maxtime)/3600;

minutes = (now - maxtime)/60 - hours * 60;

fprintf(stdout,"ERROR: Last file is %d hours %d minutes old\n",hours,
minutes);

exit(ERROR);

}

printf("File is OK\n");

exit(OK);

}

-------------- next part --------------
HTML attachment scrubbed and removed


More information about the smb-clients mailing list