ReadyGo!技术成就梦想 >> 网络应用 >> 组网维护 >> smtp压力测试工具:客户端程序smtp-client.c

smtp压力测试工具:客户端程序smtp-client.c

ReadyGo!技术成就梦想 网上整理 efish 2007-4-13 16:44:24


smtp压力测试工具:客户端程序smtp-client.c
/*++ /* name /* smtp-sink 8 /* summary /* multi-threaded smtp/lmtp test server /* synopsis /* smtp-sink :port backlog /* description /* \\\\fismtp-sink\\\\fr listens on the named host (or address) and port. /* it takes smtp messages from the network and throws them away. /* the purpose is to measure smtp client performance, not protocol /* compliance. /* this program is the complement of the \\\\fismtp-source\\\\fr program. /* .ip -c /* display a running counter that is updated whenever an smtp /* quit command is executed. /* .ip -l /* speak lmtp rather than smtp. /* .ip -p /* disable esmtp command pipelining. /* .ip -v /* show the smtp conversations. /* .ip \\\"-w delay\\\" /* wait \\\\fidelay\\\\fr seconds before responding to a data command. /* see also /* smtp-source, smtp/lmtp test message generator /* license /* .ad /* .fi /* the secure mailer license must be distributed with this software. /* author(s) /* wietse venema /* ibm t.j. watson research /* p.o. box 704 /* yorktown heights, ny 10598, usa /*--*/ /* system library. */ #include #include #include #include #include #include #include #ifdef strcasecmp_in_strings_h #include #endif /* utility library. */ #include #include #include #include #include #include #include #include #include #include /* global library. */ #include /* application-specific. */ typedef struct sink_state { vstream *stream; int data_state; int (*read) (struct sink_state *); int rcpts; } sink_state; #define st_any 0 #define st_cr 1 #define st_cr_lf 2 #define st_cr_lf_dot 3 #define st_cr_lf_dot_cr 4 #define st_cr_lf_dot_cr_lf 5 static int var_tmout; static int var_max_line_length; static char *var_myhostname; static vstring *buffer; static int command_read(sink_state *); static int data_read(sink_state *); static void disconnect(sink_state *); static int count; static int counter; static int disable_pipelining; static int fixed_delay; static int enable_lmtp; /* ehlo_response - respond to ehlo command */ static void ehlo_response(sink_state *state) { smtp_printf(state->stream, \\\"250-%s\\\", var_myhostname); if (!disable_pipelining) smtp_printf(state->stream, \\\"250-pipelining\\\"); smtp_printf(state->stream, \\\"250 8bitmime\\\"); } /* ok_response - send 250 ok */ static void ok_response(sink_state *state) { smtp_printf(state->stream, \\\"250 ok\\\"); } /* mail_response - reset recipient count, send 250 ok */ static void mail_response(sink_state *state) { state->rcpts = 0; ok_response(state); } /* rcpt_response - bump recipient count, send 250 ok */ static void rcpt_response(sink_state *state) { state->rcpts++; ok_response(state); } /* data_response - respond to data command */ static void data_response(sink_state *state) { state->data_state = st_cr_lf; smtp_printf(state->stream, \\\"354 end data with .\\\"); state->read = data_read; } /* data_event - delayed response to data command */ static void data_event(int unused_event, char *context) { sink_state *state = (sink_state *) context; data_response(state); } /* dot_response - response to . command */ static void dot_response(sink_state *state) { if (enable_lmtp) { while (state->rcpts-- > 0) /* xxx this could block */ ok_response(state); } else { ok_response(state); } } /* quit_response - respond to quit command */ static void quit_response(sink_state *state) { smtp_printf(state->stream, \\\"221 bye\\\"); if (count) { counter++; vstream_printf(\\\"%d\\\\r\\\", counter); vstream_fflush(vstream_out); } } /* data_read - read data from socket */ static int data_read(sink_state *state) { int ch; struct data_trans { int state; int want; int next_state; }; static struct data_trans data_trans.want) state->data_state = data_trans.next_state; else state->data_state = st_any; if (state->data_state == st_cr_lf_dot_cr_lf) { if (msg_verbose) msg_info(\\\".\\\"); dot_response(state); state->read = command_read; break; } } return (0); } /* * the table of all smtp commands that we can handle. */ typedef struct sink_command { char *name; void (*response) (sink_state *); } sink_command; static sink_command command_table :port backlog\\\", myname); } int main(int argc, char **argv) { int sock; int backlog; int ch; /* * initialize diagnostics. */ msg_vstream_init(argv, vstream_err); /* * parse jcl. */ while ((ch = getopt(argc, argv, \\\"clpvw:\\\")) > 0) { switch (ch) { case \\\@#c\\\@#: count++; break; case \\\@#l\\\@#: enable_lmtp = 1; break; case \\\@#p\\\@#: disable_pipelining = 1; break; case \\\@#v\\\@#: msg_verbose++; break; case \\\@#w\\\@#: if ((fixed_delay = atoi(optarg)) <= 0) usage(argv); break; default: usage(argv); } } if (argc - optind != 2) usage(argv); if ((backlog = atoi(argv)) <= 0) usage(argv); /* * initialize. */ buffer = vstring_alloc(1024); var_myhostname = \\\"smtp-sink\\\"; sock = inet_listen(argv, backlog, blocking); /* * start the event handler. */ event_enable_read(sock, connect_event, (char *) sock); for (;;) event_loop(-1); }
责任编辑: efish 参与评论 查找更多: ftp原因故障网络升级局域网服务器mail解决问题ftp原因故障网络升级局域网服务器mail解决问题ftp原因故障网络升级局域网服务器mail解决问题ftp原因故障网络升级局域网服务器mail解决问题ftp原因故障网络升级局域网服务器mail解决问题ftp原因故障网络升级局域网服务器mail解决问题ftp原因故障网络升级局域网服务器mail解决问题ftp原因故障网络升级局域网服务器mail解决问题ftp原因故障网络升级局域网服务器mail解决问题ftp原因故障网络升级局域网服务器mail解决问题ftp原因故障网络升级局域网服务器mail解决问题ftp原因故障网络升级局域网服务器mail解决问题ftp原因故障网络升级局域网服务器mail解决问题ftp原因故障网络升级局域网服务器mail解决问题ftp原因故障网络升级局域网服务器mail解决问题ftp原因故障网络升级局域网服务器mail解决问题ftp原因故障网络升级局域网服务器mail解决问题ftp原因故障网络升级局域网服务器mail解决问题ftp原因故障网络升级局域网服务器mail解决问题ftp原因故障网络升级局域网服务器mail解决问题ftp原因故障网络升级局域网服务器mail解决问题ftp原因故障网络升级局域网服务器mail解决问题ftp原因故障网络升级局域网服务器mail解决问题ftp原因故障网络升级局域网服务器mail解决问题
相关文章
安哥恶性病毒突袭局域网 金山毒霸反病毒实验室于11月27日在国内率先捕获一个恶性混合型病毒,命名为“安哥”(hack.agobot03.aw 别名..
安装win2003 server下的snort snort 是一个强大的轻量级的网络入侵检测系统。它具有实时数据流量分析和日志ip 网络数据包的能力,能够进行..
isa安装设置全集 随着因特网的使用继续扩展,安全和性能也同样面临挑战。在以前仅仅给我们提供了代理服务的软件渐渐的在我们..
网络端口及其详解 按端口号可分为3大类: (1)公认端口(well known ports):从0到1023,它们紧密绑定(binding)于一些服务..
漏洞公告:mail relaying漏洞转发.. 解决方法:  1.厂商补丁:  microsoft已经为此发布了一个安全公告(ms02-011)以及相应补丁:  ms02-0..
恶性蠕虫-诺维格(novarg/mydoom).. 病毒名称: worm.novarg.a中文名称: 诺维格威胁级别: 4a病毒别名:w32/mydoom@mm      worm_mimail.r  ..
2秒记住本站域名

玩过泡泡龙吗?Readygo?Go! 再加上.Com.Cn的后缀,那就是大名小顶的ReadyGo.com.cn

分类导航
ReadyGo!技术成就梦想