SWITCH笔记
- 格式:doc
- 大小:48.50 KB
- 文档页数:5
Java学习笔记之switch循环语句0x00 概述本篇内容包括switch语句,for循环,while循环,random函数。
0x01 switch语句1.1 switch语句结构格式switch(表达式) {case 1:语句体1;break;case 2:语句体2;break;...default:语句体n+1;break;}执⾏流程/*1. ⾸先计算出表达式的值2. 其次,和case依次⽐较,⼀旦有对应的值,就会执⾏相应的语句,在执⾏过程中,遇到break就会结束3. 最后,如果所有的case都和表达式的值不匹配,就会执⾏default语句体部分,然后程序结束*//*switch语句格式:switch(表达式) {case 值1:语句体1;break;case 值2:语句体2;break;…default:语句体n+1;[break;]}格式说明:表达式:取值为byte、short、int、char,JDK5以后可以是枚举,JDK7以后可以是String。
case:后⾯跟的是要和表达式进⾏⽐较的值。
break:表⽰中断,结束的意思,⽤来结束switch语句。
default:表⽰所有情况都不匹配的时候,就执⾏该处的内容,和if语句的else相似。
执⾏流程:⾸先计算表达式的值。
依次和case后⾯的值进⾏⽐较,如果有对应的值,就会执⾏相应的语句,在执⾏的过程中,遇到break就会结束。
如果所有的case后⾯的值和表达式的值都不匹配,就会执⾏default⾥⾯的语句体,然后程序结束掉。
*/import java.util.Scanner;public class SwitchDemo {public static void main(String[] args) {System.out.println("开始");//需求:键盘录⼊⼀个星期数(1,2,...7),输出对应的星期⼀,星期⼆,...星期⽇Scanner sc = new Scanner(System.in);System.out.println("请输⼊⼀个星期数(1-7):");int week = sc.nextInt();switch(week) {case 1:System.out.println("星期⼀");break;case 2:System.out.println("星期⼆");break;case 3:System.out.println("星期三");break;case 4:System.out.println("星期四");break;case 5:System.out.println("星期五");break;case 6:System.out.println("星期六");break;case 7:System.out.println("星期⽇");break;default:System.out.println("你输⼊的星期数有误");break;}System.out.println("结束");}}1.2 switch语句联系-春夏秋冬需求:⼀年有12个⽉,分属于春夏秋冬4个季节,键盘录⼊⽉份,请⽤程序实现判断该⽉份属于哪个季节,并输出。
第一章园区网概述园区网特点1. 在一个固定地理区域内的一个公司或一个公司的一部分。
2. 拥有该园区网的公司通常也拥有该园区内所用的物理线路。
传统园区网的主要问题1. 可用性2. 性能在传统园区网中,通常用多端口网桥将一个局域网分段成隔离的碰撞域。
这样可解决两个问题:1. 冲突域(Collision Domain)2. 距离限制网络中通信的三种形式:单播(Unitcast)、组播(Multicast)、广播(Broadcast)。
1. 多点广播实例:Cisco IP/TV分发多媒体数据、定位IP服务上的Novell 5。
2. 提出请求的广播:IP的地址解析协议(ARP)、NetBIOS的名字请求、网间包交换协议(IPX)寻找最近服务器(Get Nearest Server,GNS)请求。
3. 发布通告的广播:IPX服务通告协议(SAP)数据包、路由信息协议(RIP)、内部网关路由选择协议(IGRP)。
遏制广播的两种方法:1. 使用路由器生成多个子网;2. 利用交换机实施VLAN。
当前园区网由两部分组成:1. 局域网交换机2. 路由器传统的80/20规则和新的20/80规则1. 80/20规则:在设计恰当地网络环境中,一个给定网段上80%的流量是本地的,不超过20%的网络流量需要通过主干。
2. 20/80规则:只有20%的流量是到本地工作组局域网的,而80%的流量需要流出本地网络。
导致流量模式的改变有两个因素:1. 基于Web应用的计算普遍,很多PC既是信息的接受者,也是信息的发布者;2. 企业部署集中式的服务器群(既降低成本、提高安全、便于管理)。
新的园区网模型中的3类服务1. 本地服务:本地数据流不进入网络主干或通过路由器2. 远程服务:远程服务数据流穿过广播域边界,但可能也可不通过网络主干3. 企业级服务:放在距离网络主干很近的一个独立的子网上与OSI分层相应的PDU和设备类型模型层PDU类型设备类型数据链路层(第2层) 数据帧交换机/网桥网络层(第3层) 数据包路由器传输层(第4层) TCP数据分段TCP端多层交换机多层交换基于单独的流,MLS-SE为MLS流维护一个缓存条目并为每个流存储统计信息。
FreeSWITCH学习笔记(⼀)【1】FreeSWITCH学习笔记1、Windows安装包下载地址:2、源码下载地址:3、FreeSWITCH后台模式启动命令:freeswitch -nc(即No Console)后台模式没有控制台4、windows平台默认密码已修改为:liu12345、windows平台客户端分别为:X-Lite 和 EyeBeam6、freeswitch默认使⽤UDP的5060端⼝。
如果先启动客户端,会占⽤这个端⼝,所以,建议先启动freeswitch,再启动客户端。
7、如果运⾏freeswitch出现以下错误,是因为端⼝被占⽤了。
Cannot lock pid file /usr/local/freeswitch/run/freeswitch.pid.8、如果输⼊fs_cli,提⽰如下类似错误:[ERROR] fs_cli.c:1610 main() Error Connecting [Socket Connection Error]说明FreeSWITCH没有启动或 mod_event_socket没有正确加载,请检查TCP的8021端⼝是否处于监听状态或被其他进程占⽤。
9、freeswitch -nonatfreeSWITCH启动时默认会启⽤uPnP(或NAT_PMP)协议试图查找你的路由器是否⽀持并在你的路由器上“打洞”,如果你的路由器不⽀持该协议,这⼀步可能耗时⽐较长,因⽽影响启动速度。
所以,如果你只是在内⽹测试并且⼀天启动很多次的话,建议关掉这个选项。
组合参数(后台模式启动),启动命令:freeswitch -nc -nonat10、修改配置XML⽂件后,必须先使⽤命令使之⽣效:reloadxml11、客户端注册错误:(1)提⽰408:Request Timeout⼀般都是由于防⽕墙引起的。
关闭防⽕墙(本地CentOS系统):临时关闭:service iptables stop永久关闭:chkconfig iptables off(2)提⽰408:forbidden⼀般都是由于账号密码配置错误,鉴权没有通过⽽被禁⽌注册。
OpenFlow Switch学习笔记(三)——Flow Tables/CasonChan/p/4620652.html 这次我们主要讨论下OpenFlow Switch的核心组件之一——Flow T ables,以了解其内部的 matching 以及 action handling 机制。
下文将会分为几个部分来逐步详述OpenFlow Switch内部数据包的流转机制。
1、Pipeline Processing 遵循OpenFlow Switch规范的OpenFlow交换机大致分为OpenFlow-only 和OpenFlow-hybrid 两类。
OpenFlow- only交换机仅仅只支持OpenFlow规范定义的操作,所有经过该类交换机的数据包仅仅只能被 OpenFlow Pipeline 处理,而不能被其他方式处理。
而OpenFlow-hybrid 交换机既支持OpenFlow规范定义的操作,又支持传统交换机规定的操作,比如传统的L2交换、VLAN隔离、L3路由、ACL以及QoS处理等。
该类交换机必须要提供一种除OpenFlow Switch规范约定的能将经过它的数据包转发到OpenFlow Pipeline处理,也能转发到Normal Pipeline处理特性之外的分类机制,比如交换机可以根据数据包的VLAN tag或者ingress port来决定使用某个Pipeline来处理,或者可能将所有的数据包直接转发到OpenFlow Pipeline处理。
OpenFlow-hybrid 交换机也可能将来自于 OpenFlow Pipeline 处理后的数据包通过NORMAL 或者 FLOOD Reserved Port 转发到 Normal Pipeline 继续处理。
OpenFlow Pipeline由多个Flow T ables组成,而每个Flow T able又包含有多个Flow Entries。
element-uiswitch组件源码分析整理笔记(⼆)源码如下:<template><divclass="el-switch":class="{ 'is-disabled': switchDisabled, 'is-checked': checked }"role="switch":aria-checked="checked":aria-disabled="switchDisabled"@click="switchValue"><inputclass="el-switch__input"type="checkbox"@change="handleChange"ref="input":id="id":name="name":true-value="activeValue":false-value="inactiveValue":disabled="switchDisabled"@keydown.enter="switchValue"><span:class="['el-switch__label', 'el-switch__label--left', !checked ? 'is-active' : '']"v-if="inactiveIconClass || inactiveText"><i :class="[inactiveIconClass]" v-if="inactiveIconClass"></i><span v-if="!inactiveIconClass && inactiveText" :aria-hidden="checked">{{ inactiveText }}</span></span><span class="el-switch__core" ref="core" :style="{ 'width': coreWidth + 'px' }"></span><span:class="['el-switch__label', 'el-switch__label--right', checked ? 'is-active' : '']"v-if="activeIconClass || activeText"><i :class="[activeIconClass]" v-if="activeIconClass"></i><span v-if="!activeIconClass && activeText" :aria-hidden="!checked">{{ activeText }}</span></span></div></template><script>import Focus from 'element-ui/src/mixins/focus';import Migrating from 'element-ui/src/mixins/migrating';export default {name: 'ElSwitch',mixins: [Focus('input'), Migrating],// 注⼊elForm对象,防⽌不和el-form使⽤时对象不存在的问题。
switch的用法总结大全(学习版)编制人:__________________审核人:__________________审批人:__________________编制学校:__________________编制时间:____年____月____日序言下载提示:该文档是本店铺精心编制而成的,希望大家下载后,能够帮助大家解决实际问题。
文档下载后可定制修改,请根据实际需要进行调整和使用,谢谢!并且,本店铺为大家提供各种类型的经典范文,如英语单词、英语语法、英语听力、英语知识点、语文知识点、文言文、数学公式、数学知识点、作文大全、其他资料等等,想了解不同范文格式和写法,敬请关注!Download tips: This document is carefully compiled by this editor.I hope that after you download it, it can help you solve practical problems. The document can be customized and modified after downloading, please adjust and use it according to actual needs, thank you!In addition, this shop provides various types of classic sample essays, such as English words, English grammar, English listening, English knowledge points, Chinese knowledge points, classical Chinese, mathematical formulas, mathematics knowledge points, composition books, other materials, etc. Learn about the different formats and writing styles of sample essays, so stay tuned!switch的用法总结大全switch的意思n. 开关,转换,转换器,软鞭子,[信]接线台vt.& vi. 转变,改变,转换,关闭电流,鞭打vt. 转换,挥动(棍棒、鞭子等),迅速转动,鞭打vi. 交换,调换变形:过去式: switched;现在分词:switching;过去分词:switched;switch用法switch可以用作动词switch用作名词时意思是“开关”“转换”,用作动词时意思是“拧开关”“转变”“转换”,指通过某种措施或办法使某事物改变或改换其原有的位置、名称或运行方式等,引申可表示“挥动某物打某人”“打开”。
switch语句通俗讲解以switch语句通俗讲解为题,我将为您列举10个例子,让您更好地理解这个概念。
1. 电视节目选择:假设你有一个遥控器,上面有数字键。
当你按下某个数字键时,电视会切换到对应的频道。
在这种情况下,你可以使用一个switch语句来处理不同的频道选择。
2. 学生成绩评定:假设你是一位老师,需要根据学生的分数给出相应的评语。
你可以使用switch语句来根据不同的分数范围给出不同的评语。
3. 菜单选择:假设你去餐厅吃饭,菜单上有多种选择。
你可以使用switch语句来处理不同的菜单选择,以便告诉服务员你想点什么菜。
4. 游戏角色选择:假设你在玩一个角色扮演游戏,游戏中有多个角色供你选择。
你可以使用switch语句来根据不同的选择来创建不同的角色。
5. 日期判断:假设你需要判断某一天是星期几。
你可以使用switch 语句来根据日期来判断这一天是星期几。
6. 运算符选择:假设你需要根据用户的选择进行不同的运算。
你可以使用switch语句来处理不同的运算符,以便执行相应的计算。
7. 季节判断:假设你需要根据月份来判断当前是哪个季节。
你可以使用switch语句来根据不同的月份来判断当前是春季、夏季、秋季还是冬季。
8. 语言选择:假设你需要根据用户的选择来切换不同的语言环境。
你可以使用switch语句来处理不同的语言选择,以便切换到相应的语言环境。
9. 路线选择:假设你要去一个陌生的地方,有多条路线可以选择。
你可以使用switch语句来处理不同的路线选择,以便选择最合适的路线。
10. 音乐播放:假设你有一个音乐播放器,上面有不同的音乐曲目。
你可以使用switch语句来处理不同的音乐选择,以便播放相应的曲目。
通过以上10个例子,您可以清楚地了解到switch语句的使用场景和功能。
它可以根据不同的条件执行不同的操作,使程序具有更强大的灵活性。
无论是处理菜单选择、学生成绩评定还是路线选择,switch语句都能帮助我们更方便地实现代码逻辑。
switch语句总结笔记1.switch 语句语法:switch(expression){case value1 : statement1;break;case value2 : statement2;break;case value3 : statement3;break;default: statement4;}注意:expression必须是byte、short、int、char类型的,value必须与expression类型兼容的⼀个常量,⽽且不能重复。
⼀定不要望了每个判断后添加break,否则计算机回默认执⾏为真后⾯所有的statement;default语句可以出现在任意位置;statement、break、default都可以不写。
2.switch⽆breakint a=2;switch(a){case 1 :System.out.println(1);case 2 : System.out.println(2);case 3 :System.out.println(3);break;default:System.out.println(4);}运⾏结果:23代码解析:case 2 语句后没有break,程序继续向下执⾏,遇到case 3 语句后的break结束switch语句,故default语句不会执⾏。
4.case后⽆statement语句public class sd {public static void main(String[] args) {int month=2;switch(month){case 12 :case 1 :case 2 :System.out.println("冬季");break;case 3 :case 4 :case 5 :System.out.println("春季");break;case 6 :case 7 :case 8 :System.out.println("夏季");break;case 9 :case 10 :case 11 :System.out.println("秋季");break;default:System.out.println("输⼊错误");}}}5.default 不在末尾public class A {public static void main(String[] args) {int a=2;switch(a){default: System.out.println("no");case 0: System.out.println(0);case 1: System.out.println(1);}}}运⾏结果:no1public class A {public static void main(String[] args) {int a=0;switch(a){default: System.out.println("no");case 0: System.out.println(0);case 1: System.out.println(1);}}}运⾏结果:1switch 语句的执⾏逻辑:先找experssion对应的value值,如果存在执⾏对应语句向下执⾏直到遇到break;如果不存在则执⾏default语句再向下执⾏,遇到break停⽌。
SWITCH笔记1. Switch command2. Switch setup3. Vlan setup4. VLAN TRUNK5. Switch interface setup6. SHOW command7. Cisco catalyst 2950交换机的密码恢复8. VTP9. STP10. 三层交换11. 12.13. 14. 15.Switch commandSwitch > en 进入特权模式Switch # conf t 进入全局配置模式Switch(config)# interface interface-num 进入接口Switch(config)# hostname name 给交换机命名Switch(config)# enable password password 设置明文密码Switch(config)# enable secret password 设置加密的启用秘密口令。
如果设置则取代明文口令Switch # copy running-config startup-configSwitch # write 保存设置保存设置Switch # erase startup-config 恢复交换机出厂值置顶Switch setupswitch(config)# interface vlan 1switch(config-if)# ip address ip-address netmaskswitch(config-if)# no shutswitch(config-if)# exitswitch(config)# ip default-gateway ip-addressswitch(config)# ip domain-name domain-nameswitch(config)# ip name-server IP-address 交换机上设置远程访问,用于交换机管理配置IP地址开起端口退出设置缺省网关域名服务(自身用)域名服务地址(自身用)文档顶端Vlan setupSwitch # vlan databaseswitch(vlan)# vlan vlan-id name vlan-nameswitch(vlan)# exitswitch # config teriminal 创建VLAN(全局配置模式下)创建vlan推出启用switch # config tswitch(config)# vlan vlan-idswitch(config-vlan)# name vlan-nameswitch(config-vlan)# exit 创建VLAN(VLAN数据库中)命名推出生效Switch # config teriminalswitch(config)# interface interface-numswitch(config-if)# switchport mode accessswitch(config-if)# switchport access vlan vlan-idswitch(config-if)# endswitch # show running-config interface inter-idswitch # show interface inter-id switch port 给VLAN添加端口进入要分配的端口定义二层端口把端口分配给某一VLAN退出验证端口的VLAN号验证端口的管理模式和VLAN情况switch#config teriminalswitch(config)#interface range f0/1 - 10switch(config-if)#switchport access vlan vlan-idswitch(config-if)#endswitch#show vlan briefswitch#show vlan vlan-id 添加多个端口到一个VLAN选择多个端口加入VLAN查看验证VLAN查看指定VLANSwitch # config tswitch(config)# no vlan vlan-idswitch(config)# end 删除VLANswitch(config)# ip http sever 启用HTTP访问文档顶端VLAN TRUNKswitch(config)# interface interface mod/portswitch(config-if)# switchport mode trunkswitch(config-if)# switchport trunk encapsulation {isl|dotlq|} 配置VLAN中继线switch(config)# interface interface-idswitch(config-if)# switchport mode dynamic desirable/auto 进入端口设置设置接口为中继动态协商模式,desirable或autoswitch(config-if)#switchport trunk allowed vlan none 阻止所有VLAN通过switch(config-if)#switchport trunk allowed vlan remove vlan-listswitch(config-if)# switchport trunk allowed vlan add vlan-list 从TRUNK中删除VLAN,阻止通过在TRUNK中添加VLAN,允许通过文档顶端Switch interface setupSwitch # config tSwitch(config)# interface inter-idswitch(config-if)# duplex {auto|full|half}switch(config-if)# speed{10|100|auto} 交换机上设置端口速度switch(config-if)# description description-string 交换机的端口描述文档顶端SHOW commandSwitch # show versionSwitch # show running-config 列出当前运行配置信息Switch # show startup-configSwitch # show interface interface-num 产看借口信息Switch # show cdp neighborswitch # show cdp neighbor detailswitch # show cdp trafficswitch # show cdp interface interface-numswitch # show cdp entry 显示直连的相邻设备及其详细信息显示IP地址和IOS版本和类型,并且包括show cdp neighbor命令显示的所有信息显示设备发送和接收的CDP分组数以及任何出错信息显示接口的CDP配置信息显示所有入口项的细节Switch # show interface vlan 1 查看交换机有关IP协议的配置信息Switch # show mac-address-table aging-time 查看MAC地址表超时时间Switch # show mac-address-table 查看整个MAC地址表Switch # show interface f0/0 switchport 查看端口模式Switch # show vlan brief 查看VLAN信息Switch # show vtp status 查看VTP状态信息Switch # show spanning-treee 查看生成树信息Switch # show spanning-treee vlan vlan-id detail 查看某个VLAN的生成书详细信息Switch # show ip cef 产看FIB表Switch # show adjacency detail 产看邻接关系表文档顶端Cisco catalyst 2950交换机的密码恢复1. 拔下交换机的电源线。
2. 用手按住交换机的MODE键,插上电源线。
3. 出现“SWITCH:”后,松开MODE SWITCH:4. 在SWITCH:后执行“flash_init”命令,初始化SWITCH:flash_init5. 查看FLASH中的文件。
Switch:dir flash6. 把“config.text”文件改名为“config.old”文件。
switch:rename flash:config.text flash:config.old7. 执行“boot”命令,启动交换机8. 进入特权模式查看FLASH的文件switch#show flash9. 把文件config.old改为config.text。
switch:rename flash:config.old flash:config.text10. 把config.text考入系统的running-config。
switch#copy flash config.text system:running-config11. 加入配置模式重新设置密码并存盘。
文档顶端VTPSwitch(config)# vtp domain domain-name 设置VTP域名Switch(config)# vtp mode server|client|transparent 设置VTP模式Switch(config)# vtp password password 设置VTP密码Switch(config)# vtp pruning 配置VTP修剪Switch(config)# vtp version 2 配置VTP运行版本为2文档顶端STPSwitch(config)# spanning-tree vlan vlan-list 启用生成树Switch(config)# spanning-tree vlan vlan-list root primary|secondary 配置交换机为根网桥Switch(config)# spanning-tree vlan vlan-list priority Bridge-priority 修改交换机的优先级Switch(config)#spanning-tree vlan vlan-list vlan-list cost cost 修改端口路径成本Switch(config)# spanning-tree vlan vlan-list vlan-list port-priority priority 修改端口优先级Switch(config)# spanning-tree uplinkfast 配置上行速链路Switch(config)# spanning-tree portfast 配置速端口文档顶端三层交换switch(config)#switch(config)# interface vlan vlan-idswitch(config-if)# ip address ip-address subnek-maskswitch(config-if)# no shutdown 配置VLAN IP地址switch(config-if)# no switchport 配置接口为三层模式switch(config)# interface interface-idSwitch(config-if)no switchportSwitch(config-if)ip address address subnek配置路由接口配置接口IPswitch(config-)# interface vlan vlan-idswitch(config-if)# ip helper-address dhcpserver-address配置DHCP中继转发(每个VLAN都要配)Switch(config)# ip router 0.0.0.0 0.0.0.0 next-hop 在三层交换机上配置静态路由。