发布时间:2012-09-01 09:11:29
文章类别:TeX绘图
原文地址:http://blog.sina.com.cn/s/blog_5e16f1770102f31y.html

看图:

Network topology with three routers

选自:http://tex.stackexchange.com/questions/41533/is-there-a-tikz-library-for-network-symbols/43445#43445

思科图元下载参看:http://tex.stackexchange.com/questions/22837/cisco-icons-for-network-diagrams

\documentclass{article}
\usepackage[hmargin=2.5cm]{geometry}
\usepackage{tikz}
\usetikzlibrary{calc, shadings, shadows, shapes.arrows}

% Styles for interfaces and edge labels
\tikzset{%
  interface/.style={draw, rectangle, rounded corners, font=\LARGE\sffamily},
  ethernet/.style={interface, fill=yellow!50},% ethernet interface
  serial/.style={interface, fill=green!70},% serial interface
  speed/.style={sloped, anchor=south, font=\large\sffamily},% line speed at edge
  route/.style={draw, shape=single arrow, single arrow head extend=4mm,
    minimum height=1.7cm, minimum width=3mm, white, fill=blue!20,
    drop shadow={opacity=.8, fill=blue!50!black}, font=\tiny}% inroute / outroute arrows
}
\newcommand*{\shift}{1.3cm}% For placing the arrows later

% The router icon
\newcommand*{\router}[1]{
\begin{tikzpicture}   
  \coordinate (ll) at (-3,0.5);
  \coordinate (lr) at (3,0.5);
  \coordinate (ul) at (-3,2);
  \coordinate (ur) at (3,2);
  \shade [shading angle=90, left color=black!40!blue, right color=white] (ll)
    arc (-180:-60:3cm and .75cm) -- +(0,1.5) arc (-60:-180:3cm and .75cm)
    -- cycle;
  \shade [shading angle=270, right color=black!40!blue, left color=white!50] (lr)
    arc (0:-60:3cm and .75cm) -- +(0,1.5) arc (-60:0:3cm and .75cm) -- cycle;
  \draw [thick] (ll) arc (-180:0:3cm and .75cm) -- (ur) arc (0:-180:3cm and .75cm)
    -- cycle;
  \draw [thick, shade, upper left=blue!30!black, lower left=blue!80!white,
    upper right=blue!80!white, lower right=white] (ul)
    arc (-180:180:3cm and .75cm);
  \node at (0,0.5){\color{blue!60!black}\Huge #1};% The name of the router
  % The four arrows, symbols for incoming and outgoing routes:
  \begin{scope}[yshift=2cm, yscale=0.28, transform shape]
    \node[route, rotate=45, xshift=\shift] {\strut};
    \node[route, rotate=-45, xshift=-\shift] {\strut};
    \node[route, rotate=-135, xshift=\shift] {\strut};
    \node[route, rotate=135, xshift=-\shift] {\strut};
  \end{scope}
\end{tikzpicture}}

\begin{document}
\pagestyle{empty}
\centering
\begin{tikzpicture}[node distance=10cm]
  % Place three routers as nodes:
  \node (R1) {\router{R1}};
  \node [right of=R1] (R2) {\router{R2}};
  \node[yshift=6cm] at ($ (R1) !.5! (R2) $)  (R3) {\router{R3}};
  % Connect by lines and specify interfaces and speed:
  \draw[thick] (R1)
    -- node[ethernet,  at start]{eth0} node[ethernet, at end] {eth0} (R2)
      node[speed,midway] {100 Mbps}
    -- node[serial,  at start]{S0} node[serial, at end] {S1} (R3)
      node[speed,midway] {115200 bps}
    -- node[serial,  at start]{S0} node[serial, at end] {S0} (R1)
      node[speed,midway] {64000 bps};
\end{tikzpicture}
\end{document}

点赞(0)

评论列表 共有 0 条评论

暂无评论
立即
投稿

微信公众账号

微信扫一扫加关注

发表
评论
返回
顶部