Pages

Sunday, January 15, 2012

Interview_stuffs

Standard vs Extended Access list

In networking, access control lists (ACLs) are used to control the traffic that is allowed or denied through a network device, such as a router or a switch. There are two main types of access control lists: standard access lists and extended access lists. Here are the key differences between them:

### Standard Access List:

1. **Matching Criteria:**
   - Standard access lists filter traffic based only on the source IP address of the packets.

2. **Positioning:**
   - Standard access lists are typically placed near the destination because they cannot filter based on specific protocols or destination addresses.

3. **Syntax:**
   - Standard access lists are identified by numbers ranging from 1 to 99 or 1300 to 1999 in Cisco devices. For example:
     ```
     access-list 1 permit 192.168.1.0 0.0.0.255
     ```

4. **Configuration Example:**
   - The following example permits traffic from the source IP address range 192.168.1.0 to 192.168.1.255:
     ```
     access-list 1 permit 192.168.1.0 0.0.0.255
     ```

### Extended Access List:

1. **Matching Criteria:**
   - Extended access lists filter traffic based on a variety of criteria, including source and destination IP addresses, protocols, source and destination ports, and more.

2. **Positioning:**
   - Extended access lists are usually placed as close to the source as possible to filter traffic early in the network. This allows for more granular control based on different parameters.

3. **Syntax:**
   - Extended access lists are identified by numbers ranging from 100 to 199 or 2000 to 2699 in Cisco devices. For example:
     ```
     access-list 101 permit tcp 192.168.1.0 0.0.0.255 host 10.0.0.1 eq 80
     ```

4. **Configuration Example:**
   - The following example permits TCP traffic from the source IP range 192.168.1.0 to 192.168.1.255 to the destination IP address 10.0.0.1 on port 80:
     ```
     access-list 101 permit tcp 192.168.1.0 0.0.0.255 host 10.0.0.1 eq 80
     ```

### Summary:

- Standard access lists filter based on source IP addresses only, whereas extended access lists provide more granularity by allowing filtering based on various parameters such as source and destination IP addresses, protocols, and port numbers.
  
- Standard access lists are simpler but less flexible, while extended access lists offer more control over the types of traffic that can be filtered.

The choice between standard and extended access lists depends on the specific requirements of the network and the desired level of control over the traffic.

NAT(Network Address Translation) hides the private ip address and communicate with public ip address
Thousand of PCs can share single public ip address ie through NAT
Auto-configuration range : 169.254.X.X this is used when a device is not configured any ip address or when ip is not assigned through dhcp. This ip can communicate only in local network
Router stops broadcast.
Every router represent a multiple n/ws ie every interface of a router is a single n/w

HSRP provides redundancy and provides multiple gateways.

Tcl will run on 3600 and 2600 series router
Dns key components
Domain name spaces: has the hierarchical structure. Root domain lies at the top
Zones : for admin purposes, domains can be divided into zones.
Nameserver : holds the database of the zones
Forward look up query is to map a name to an ip address
Root .
Top level com edu org
Microsoft.com
Sales.microsoft.com
These will have host ie computer1.sales.microsoft.com. called as FQDN.
Host—subdomain—2nd level—top level --root

Switch uses full duplex communication ..that is advantage over hub ie different host that are connected to switch can communicate at same time.

switches are significantly faster than bridges because switches mainly use hardware for switching, while bridges require software to perform switching
A switch can have a lot of ports. A bridge can have 2 or 4 ports only.

Switches vs Bridges
In networking, the terms "switch" and "bridge" are often used interchangeably, and modern network switches are considered an evolution of traditional bridges. Both switches and bridges operate at the data link layer (Layer 2) of the OSI model and are designed to forward frames based on MAC addresses.

Historically, bridges were used to connect different segments of a network, and they made filtering decisions based on MAC addresses. Switches, which are more advanced devices, inherited the basic functionality of bridges but with additional features and improved performance.

Here are some key points to consider:

1. **Performance:**
   - In general, modern network switches are faster than traditional bridges. Switches are designed to operate at higher speeds, support full-duplex communication, and have higher port densities. They use specialized hardware to make forwarding decisions quickly and efficiently.

2. **Granularity of Forwarding:**
   - Switches provide more granular forwarding decisions compared to bridges. While both devices make forwarding decisions based on MAC addresses, switches often have larger MAC address tables and can make decisions on a per-port basis.

3. **Collision Domains:**
   - Bridges were historically used to segment collision domains in Ethernet networks to reduce the likelihood of collisions. Switches, by providing full-duplex communication on each port, effectively eliminate collision domains for devices connected to individual ports.

4. **Broadcast Handling:**
   - Both switches and bridges handle broadcast frames, but switches are typically more efficient in managing broadcast traffic. Switches use MAC address tables to make forwarding decisions, reducing the need for unnecessary broadcast flooding.

5. **Topology Changes:**
   - Switches can adapt to changes in the network topology more quickly than traditional bridges. Modern switches use protocols like the Rapid Spanning Tree Protocol (RSTP) to converge rapidly in response to topology changes.

In summary, while the terms "switch" and "bridge" are often used interchangeably, switches are generally considered faster and more feature-rich than traditional bridges. The evolution from bridges to switches has brought improvements in terms of performance, granularity of forwarding decisions, and support for higher-speed networks. In contemporary networks, the term "switch" is commonly used to refer to devices that perform the functions of both traditional bridges and switches.

Bridge are of two types
Software bridge : your computer is acting as a bridge. U need to install a s/w for that.
Hardware bridge: like syslink .already s/w is embedded


Access vs Trunk 

In networking, especially in the context of Ethernet and VLANs (Virtual Local Area Networks), the terms "access link" and "trunk" are used to describe different types of connections between network devices. Let's explore the differences between an access link and a trunk:

### Access Link:

1. **Purpose:**
   - An access link is used to connect an end device, such as a computer, printer, or IP phone, to a switch port.

2. **VLAN Assignment:**
   - An access link typically belongs to a single VLAN. The switch port to which an access link is connected is configured to operate in access mode, and the device connected to the port is unaware of VLAN information.

3. **VLAN Tagging:**
   - Frames leaving an access link do not carry VLAN tags. The switch removes the VLAN tag when sending frames to an end device and adds the VLAN tag when receiving frames from the device.

4. **Configuration:**
   - Configuration on the switch port is minimal. It involves assigning the port to a specific VLAN.

### Trunk:

1. **Purpose:**
   - A trunk is used to interconnect switches, allowing the exchange of traffic for multiple VLANs between them.

2. **VLAN Assignment:**
   - A trunk can carry traffic for multiple VLANs simultaneously. It allows multiple VLANs to traverse a single link, facilitating communication between devices on different VLANs.

3. **VLAN Tagging:**
   - Frames on a trunk link are often tagged with VLAN information. Each frame includes a VLAN tag that identifies the VLAN to which the frame belongs. This tagging enables switches to distinguish between different VLANs on the same link.

4. **Configuration:**
   - Configuration on the trunk link involves setting it to operate in trunk mode. Additionally, trunk links often use protocols such as 802.1Q (dot1q) to carry VLAN information in the frame header.

### Summary:

- **Access Link:** Connects an end device to a switch port, typically belongs to a single VLAN, and frames leaving the link are untagged.

- **Trunk:** Connects switches to allow the exchange of traffic for multiple VLANs, can carry traffic for multiple VLANs simultaneously, and frames on the trunk are often tagged with VLAN information.

In practice, access links and trunks are components of VLAN implementations. Access links connect end devices to the network within a specific VLAN, while trunks facilitate inter-switch communication for multiple VLANs. The choice between access links and trunks depends on the network design and the need for VLAN segmentation.


Access link carries one vlan
Trunk link carries multiple vlan
Vlan membership
Static : by administrator . assigned port to particular vlan
Dynamic : done by vlan membership policy server ie vmps . here mac address are mapped to vlan no

Trunk is related to frame tagging
2 types isl and 802.1q . used to know from which vlan frame is coming and where it is going
802.1q is also associate native vlan which is by default vlan 1 which includes no tag at all when frames is send between switches.
Vlan is a broadcast domain and a logical subnet .

Switches deletes the CAM entries from the table that are not in used for certain time ie aging timer
Switch offers duplex transmission.
Switch can be symmetric or asymmetric ie all ports can operate at the same speed or there will be diff speed for uplink and downlink.
Broadcast nature of Ethernet causes switching loops which are called broadcast storm.
Stp is a method to disable redundant link in a switched network stp = 802.1d . stp blocks certain ports to prevent a loop . forces interfaces into standby or blocked state
Rapid stp ie rstp is 50 times faster than stp 802.1w

Link state routing protocols maintains 3 tables
Topology
Neighbor table/adjacency
Routing table.
Each router will reply to the multicast address. Each router will know each other and has knowledge about their adjacent router and further they all will share their topology and gets updated in the routing table.

Troubleshooting commands
Sh controllers
Sh ip int br
Sh int s0
Sh ip protocols autosummary /network

Tcp(Transmission control protocol) header is much larger than UDP(user datagram protocol) header hence we use UDP over TCP . It reduces the overhead.
Seq no= no assigned to the 1st byte of data in the message.
Ack no= next seq no or byte of data that rx expect to receive.
Offset = specifies the size of the Tcp header in 32 bit word and indicates where data actually begins.
Reserved field is set to 0 and can be used for further purpose.
Window : this sets the size of the rx window apart from seq no. This comes under flow control.
Padding is used to confirm that TCP header end with 32 bits .
Option is used for synchronization purpose.

To know the size of the data we should know the size of the header length in IP header
Minimum size of ip header is 20 bytes and maximum is 60 bytes
4 bits is used for ip header length.
So if header bits are 0101 means 5 *4 = 20 bytes
So always bits value is multiplied with 4 and header length is calculated .
Lets we have HL = 5base16 =5 *4 = 20bytes
TL =0028base16=40bytes ie 40-20 = 20 bytes is a data
TL=HL + data
So tL can be 20 bytes to 65,335bytes

How Checksum is calculated ?
HL fields in source side are are segmented/divided into 16 nbits. Initially Checksum is set to 0. All these n sets of 16 bits are added up together .say total bits value is Nbits .Do 1’s Complement of this. Say we get Ncbits .Update checksum with this value .send this value to destination.
Now we do same process in destination . but here we will add all 16 bits value with checksum value received from sender . Do 1’s complement of it and result should be zero. Otherwise data is corrupted.

In case of proc in tcl if we use return command it will return all the variables if return command is not mentioned it will return the last command.

Three way hand shake any host can initiate the connection
Client -------------------------server
Seq x ----------------------- received seq x
Seq y <------------ Ack x+1
Ack y+1 --------received Ack y+1

Routing Loop Avoidance Techniques
Split Horizon: Updates received in an interface can’t be sent out the same interface.
Split Horizon with Poison Reverse: Updates sent back with infinite metric (hop count 16) for every update received in an interface
Count to Infinity: To avoid continuous looping of a (bad) routing update. RIP sets the count to infinity with a hop count of 16.
Triggered Updates: supported with RIP version 2. Also known as the flash updates. If a metric is changed it is immediately advertised to neighbors without waiting for the regular scheduled update timer

BGP attributes, RR, and confederations

The BGP specifications dictate (for loop-prevention purposes) that a BGP speaker must not advertise prefixes heard from another IBGP speaker to a third IBGP speaker. Because of this convention, you must configure a full-mesh between all IBGP speakers within an AS. Obviously, this approach does not scale. Fortunately, BGPv4 provides two ways to approach this problem—route reflectors and confederation—in various possible setups and combinations:
• Single route reflector (not recommended, single point of failure)
• Clustered route reflectors
• Redundant route reflectors
• Confederation ("EIBGP")
• Hybrid architectures (route reflector cluster and confederation)

Route Reflection
• A route reflector setup consists of at least one route reflector and one or several route reflector clients that can also be assigned to a logical cluster via a 4-octet cluster ID. When only one route reflector exists, the implicit cluster ID is the loopback address of the router. The basic idea of the designers was that no changes are necessary on the client.
• A connection to a single route reflector does suffice to receive and advertise prefixes. For the purpose of redundancy, it is common practice to connect route reflector clients to at least two redundant route reflectors. In addition, large architectures introduce clustering to create multiple logical groups (BGP CLUSTER-LIST attribute).
• The cluster ID has to be consistent throughout a cluster. Of course, all route reflectors require full IBGP connectivity among themselves. Figure 10-6 (part a) demonstrates a single-cluster architecture featuring three fully meshed IBGP route reflectors. In this example, two route reflector clients are connected to multiple route reflectors for redundancy. Figure 10-6 (part b) presents a similar topology featuring multiple clusters.

Designated router - A Designated Router (DR) is elected whenever OSPF routers are connected to the same multi-access network. Cisco likes to call these “broadcast” networks, but really, they are networks that have multiple recipients. Try not to confuse multi-access with multipoint, which can be easy to do sometimes. A prime example is an Ethernet LAN. To minimize the number of adjacencies formed, a DR is chosen (elected) to disseminate/receive routing information to/from the remaining routers on the broadcast network or link. This ensures that their topology tables are synchronized. All routers on the shared network will establish adjacencies with the DR and backup designated router (BDR). The election is won by the router with the highest priority, and the Router ID is used as a tiebreaker if the priority of more than one router turns out to be the same.

Tcl map question
Classification Tools
IP Precedence and DiffServ Code Points
IPv4: three most significant bits of ToS byte are called IP
Precedence (IPP)—other bits unused
DiffServ: six most significant bits of ToS byte are called DiffServ
Code Point (DSCP)—remaining two bits used for flow control
DSCP is backward-compatible with IP precedence

DiffServ Extensions
• IP Type of Service Byte—As Layer 2 media often changes as packets traverse from source to
destination, a more ubiquitous classification would occur at Layer 3. The second byte in an IPv4 packet
is the Type of Service (ToS) byte. The first three bits of the ToS byte alone are referred to as the IP
Precedence (IPP) bits. These same three bits, in conjunction with the next three bits, are known
collectively as the DSCP bits.
The IP Precedence bits, like 802.1p CoS bits, allow for only 8 values of marking (0-7).
IPP values 6 and 7 are generally reserved for network control traffic (such as routing).
IPP value 5 is recommended for voice.
IPP value 4 is shared by video conferencing and streaming video.
IPP value 3 is for voice-control.
IPP values 1 and 2 can be used for data applications.
IPP value 0 is the default marking value.
Many enterprises find IPP marking to be overly restrictive and limiting, favoring instead the 6-Bit/64-
value DSCP marking model.

In tcl, variables, arrays, and namespaces are mutable
TCL lists are mutable
ARP packet

Router packet 4 in ospf has 7 lsa types
Lsa 1 produced by every router , describes the state and cost of router link to area.
Lsa2 only DR router originates this Lsa
Lsa 3 originated by an ABR
Lsa4 These LSAs are injected into the backbone by the ABR of an area which contains an ASBR. This is to ensure all other routers in the OSPF domain can reach the ASBR
 Lsa5 Originated by ASBR
 Lsa6 NSSA External LSA (Type 7)
 Same as Type 5
 Originated by ASBR
 Flooded Within NSSA area

The first word is the name of a command, which is not built into the language, but which is in the library. The following words are arguments. So we have:
commandName argument1 argument2 ... argumentN

In tcl everything can be dynamically redefined in?
A)Overridden ans
B)Static
C)both A and B
D) All

Everything can be dynamically redefined and overridden.

Regular expression can be used with regular substitution for?
A)Variable substitution
B)Command substitution
C)Perform substitution
D)regular match substitution expression. ans

4.Libraries allow you to load code in c as well as validate into your?
A)Compiler
B)Modules
C)Interperter
D)All

6.Tclsh will exit when it reaches the end of?
A) File ans
B)Script file
C) Command file
D) All

9.Tcl provides several commands for dealing with process and allows to create a new process through ,..
A) Env
B) Exec  ans
C) Both A and B
D) None

12.Tcl did not originally support object oriented syntax being a?
A) Complex language
B)Functional language
C)Simple language
D)None.

String map { 1 0 ab 2 a 3 abc 1} 1abcaababcabababc
a)02c322c212322c
b)02c322c222c ans
c)01321221
d)none

16. Out put for the following code?
set i 0
incr i
#this is equivalent to
a) incr cannot be used with set command
b)set i [expr{$i+1}] ans
c)set i [expr{{$i+1}}]
d)none


17.. Out put for the following code?
set a 2.2
set b 3.2
set c expr($a+$b*8
put $c

A)55.6
B)56.9
C)wrong argument ans
D)set value

WHAT IS A NAMESPACE?
A namespace is a collection of commands and variables. It encapsulates the commands and variables to ensure that they won't interfere with the commands and variables of other namespaces. Tcl has always had one such collection, which we refer to as the global namespace. The global namespace holds all global variables and commands. The namespace eval command lets you create new namespaces. For example,
namespace eval Counter {
namespace export bump
variable num 0

proc bump {} {
variable num
incr num
}
}
creates a new namespace containing the variable num and the procedure bump. The commands and variables in this namespace are separate from other commands and variables in the same program. If there is a command named bump in the global namespace, for example, it will be different from the command bump in the Counter namespace.
Namespace variables resemble global variables in Tcl. They exist outside of the procedures in a namespace but can be accessed in a procedure via the variable command, as shown in the example above.

Namespaces are dynamic. You can add and delete commands and variables at any time, so you can build up the contents of a namespace over time using a series of namespace eval commands. For example, the following series of commands has the same effect as the namespace definition shown above:

namespace eval Counter {
variable num 0
proc bump {} {
variable num
return [incr num]
}
}
namespace eval Counter {
proc test {args} {
return $args
}
}
namespace eval Counter {
rename test ""
}
Note that the test procedure is added to the Counter namespace, and later removed via the rename command.
Namespaces can have other namespaces within them, so they nest hierarchically. A nested namespace is encapsulated inside its parent namespace and can not interfere with other namespaces.

Keyed lists
Keyed lists provide a structured data type built upon standard Tcl lists. This provides a functionality similar to structs in the C programming language.

A keyed list is a list in which each element contains a key and value pair. These element pairs are stored as lists themselves, where the key is the first element of the list, and the value is the second. The key-value pairs are referred to as fields. This is an example of a keyed list:

{{NAME {Frank Zappa}} {JOB {musician and composer}}}
If the variable person contained the above list, then keylget person NAME would return {Frank Zappa}. Executing the command:

keylset person ID 106
would make person contain:

{{ID 106} {NAME {Frank Zappa}} {JOB {musician and composer}}
Fields may contain subfields; ``.'' is the separator character. Subfields are actually fields where the value is another keyed list. Thus, the following list has the top level fields ID and NAME, and subfields NAME.FIRST and NAME.LAST:
{ID 106} {NAME {{FIRST Frank} {LAST Zappa}}}
There is no limit to the recursive depth of subfields, allowing you to build complex data structures.
Keyed lists are constructed and accessed by a number of commands. All keyed list management commands take the name of the variable containing the keyed list as an argument (that is, passed by reference), rather than passing the list directly.

Available commands are:
keyldel(TCL)
deletes a key and value from a keyed list

keylget(TCL)
returns the value associated with a key from a keyed list

keylkeys(TCL)
returns the list of keys in the keyed list

keylset(TCL)
sets the value of a key in a keyed list

Proxy ARP
Proxy ARP (Address Resolution Protocol) is a technique by which a device on a given network answers the ARP queries for a network address that is not on that network. The ARP Proxy is aware of the location of the traffic's destination, and offers its own MAC address in reply, effectively saying, "send it to me, and I'll get it to where it needs to go." Serving as an ARP Proxy for another host effectively directs LAN traffic to the Proxy. The "captured" traffic is then typically routed by the Proxy to the intended destination via another interface or via a tunnel.
The process which results in the node responding with its own MAC address to an ARP request for a different IP address for proxying purposes is sometimes referred to as 'publishing'.A Proxy ARP Simulation visualizes how a router responds to ARP request on behalf of the target host at different networks. See ARP cache updates at host, router, remote host.

What is a tagged VLAN [Virtual Local Area Network]?
The IEEE 802.1Q standard allows defining an ethernet interface for multiple logical locations (as opposed to specific physical locations). One port can belong to several 802.1Q tagged VLANs. Thus, many host servers may be connected to the same ethernet LAN switch without being in the same collision or broadcast domain inherent in ethernet technology.

What is an untagged VLAN?
Untagged VLANs are the way we physically separate host servers into different broadcast and collision domains. A port (assigned to each PC connected to the LAN) can only belong to one untagged VLAN. Think of these LANs as the physical LAN connections within the logical or virtual LAN.
this is all based on the IEEE 802.1Q standard...

Basic rules:
1) a port can be untagged in at most 1 vlan at a time
2) a port can be tagged in as many vlans as are in the switch config

an untagged port is what you normally connect an endpoint device (computer, printer, server, camera, badege reader, sometimes a VoIP phone, etc)...

a tagged port is used "mostly" to interconnect switches that carry multiple vlans on that link...

a tagged frame has an extra 4 bytes in the middle, which has the vlan id, qos settings, and a few other bits of data...

"normal" endpoint devices are not configured to speak tagged...altho there can be exceptions to this rule given very specific configuration/operation requirements (servers, VoIP phones, AP's)...but generally a user computer speaks untagged...

Why iTest Personal
Today's high-tech equipment developers must conduct rigorous unit and feature testing to ensure they deliver quality code to QA teams. Similarly, test engineers must be able to perform a wide array of tests-from feature testing to system testing-while under intense deadline pressure. iTest Personal provides the functionality that developers and test engineers need to work more efficiently and contribute to automation efforts. With iTest Personal, they can:

Create test cases for products or applications requiring CLI, SNMP, Web, Web Services, Java Swing, Flash (Flex), Serial Port, or Tcl
Configure and orchestrate system testing with numerous devices and traffic generators to create an automated system testing solution
Connect to devices; start setup, configuration, or tear down; or launch commonly used sets of actions with a single mouse click
Automatically generate comprehensive documentation for every run, providing proof of testing and clear information for bug reports and issue resolution
Create basic test cases from captured steps and/or use shared procedure libraries
Annotate test cases with messages that will automatically be added to test reports
Add looping constructs to help automate repetitive tasks
The beginning of the automation assembly line

iTest Personal is typically used at the beginning of an automation assembly line, creating the base test case, replacing manual testing, and providing a repeatable test case at the conclusion. Users seeking to assign pass/fail criteria for automation should look to the next phase of the assembly line, where that task is performed using iTest Team and iTest Enterprise.

Tcl - global, upvar and uplevel.
In Tcl, variables are "scoped" to the procedure in which they're used. That's a sensible default, since you want to be able to write main applications without the risk of interfering with variables within your procs.

A global command in a proc allows you to refer to a variable in the main code from within a proc. (No need to declare it global at the top level too)

An upvar command allows you to reference a variable in your calling code from within your proc, and is commonly used for "pass by name" requirements where you're writing a proc that must alter an incoming variable.

The uplevel command allows you to run a piece of code as if it was in the namespace of your calling code and not in your proc - and you can even specify a number of levels of code up or an absolute level number.

Suggestion. Use upvar whenever you need to call by name. Use global sparingly. And think very carefully before you ever use uplevel!

Example:
proc demo {what where} {
global counter
upvar $where hereitis
uplevel incr dc
append hereitis ", UK"
incr counter
puts "Demo run"
return "$what $hereitis"
}
#
set dc 0
set counter 0
set place Melksham
set rz [demo "eat in" place]
puts "function returns: $rz"
puts "place will have UK on the end: $place"
puts "counter is number of calls to demo: $counter"
puts "variable dc has become: $dc"

BGP (Border Gateway Protocol) is a protocol for exchanging routing information between gateway hosts (each with its own router) in a network of autonomous systems. BGP is often the protocol used between gateway hosts on the Internet. The routing table contains a list of known routers, the addresses they can reach, and a cost metric associated with the path to each router so that the best available route is chosen.

Hosts using BGP communicate using the Transmission Control Protocol (TCP) and send updated router table information only when one host has detected a change. Only the affected part of the routing table is sent. BGP-4, the latest version, lets adminstrators configure cost metrics based on policy statements. (BGP-4 is sometimes called BGP4, without the hyphen.)

BGP communicates with autonomous (local) networks using Internal BGP (IBGP) since it doesn't work well with IGP. The routers inside the autonomous network thus maintain two routing tables: one for the interior gateway protocol and one for IBGP.

BGP-4 makes it easy to use Classless Inter-Domain Routing (CIDR), which is a way to have more addresses within the network than with the current IP address assignment scheme.

BGP is a more recent protocol than the Exterior Gateway Protocol (EGP).

HA
High availability is a system design approach and associated service implementation that ensures a prearranged level of operational performance will be met during a contractual measurement period.
Users want their systems, for example wrist watches, hospitals, airplanes or computers, to be ready to serve them at all times. Availability refers to the ability of the user community to access the system, whether to submit new work, update or alter existing work, or collect the results of previous work. If a user cannot access the system, it is said to be unavailable.[1] Generally, the term downtime is used to refer to periods when a system is unavailable.

Expect:
When the matching string is finally typed, expect returns. But before returning, expect stores the matched characters in a variable called expect_out(0,string) . All of the matched characters plus the characters that came earlier but did not match are stored in a variable called expect_out(buffer) . expect does this every time it matches characters. The names of these variables may seem odd, but they will make more sense later on.

What Happens When Input Does Not Match

Once expect has matched data to a pattern, it moves the data to the expect_out variable as I showed earlier. The matched data is no longer eligible to be matched. Additional matches can only take place with new data.

Consider the following fragment:
expect "hi"
send "$expect_out(0,string) $expect_out(buffer)"
If I execute these two commands, Expect waits for me to enter hi . If I enter philosophic followed by a return, Expect finds the hi and prints:
hi phi

If I execute the two commands again, Expect prints:
hi losophi

Even though there were two occurrences of hi, the first time expect matched the first one, moving it into expect_out. The next expect started from where the previous one had left off.




No comments:

Post a Comment