Forum Discussion

Laurent_P_'s avatar
Laurent_P_
Icon for Employee rankEmployee
Feb 08, 2006

iRule for RTSP

Hi all,

 

 

I'm working on iRule which should do the following .

 

I have two Virtual Servers :

 

* One for RTSP traffic on which I setup persistence per source_addr.

 

* One for HTTP traffic which should connect the user to the same node that handling the RTSP connection.

 

In order to do so, I wrote the following iRule, expecting that I can query the persistence table and get the IP address of the node processing the RTSP connection. To get the IP of the client, it's only reading an HTTP header containing this value.

 

Am I right on my expectations ?

 

 

when HTTP_REQUEST {

 

client

 

set realip [HTTP::header "x-nokia-ip-address"]

 

set realnode [persist lookup uie $realip]

 

node $realnode

 

persist uie $realip

 

log "Node $realnode for client $realip"

 

}

 

 

Shall either lookup the session table ?

 

 

Thanks a lot for your answer.

 

Regards.

6 Replies

  • Guys,

     

     

    I thought about an onther solution in case the persist lookup doesn't give me the node handling a connection for the specified IP.

     

    I made up two iRules, one for the RSTP VIP and one for the HTTP vip. This gives :

     

     

    Attached to the HTTP VIP :

     

    when HTTP_REQUEST {

     

    set realip [HTTP::header "x-nokia-ip-address"]

     

    set realnode [session lookup tablesession $realip]

     

    node $realnode

     

    }

     

     

    Attached to the RSTP VIP :

     

    when LB_SELECTED {

     

    set nodeip [LB::server]

     

    session add tablesession [IP::remote_addr] $nodeip 1 1800

     

    }

     

     

    Is it correct ?

     

     

    Thanks a lot for your answer. I forgot to mention that I'm running v9.1.1.

     

    Regards.
  • Colin_Walker_12's avatar
    Colin_Walker_12
    Historic F5 Account
    In regards to using the information in the persistence table...you'll need to use the persist lookup command, like your rule alludes to. It looks like you need a little further clarification on the options of this command.

    In a great post unruley made a while back (which you can find by searching for persist lookup in the forums) here Click here

    He outlines the usage of the persist command. I believe the part you're interested in is the second part of the information that follows:

    The following instances of the persist command select persist:

    NOTE: items marked with are meant to be replaced with some sort of value or evaluated expression. Arguments bracketed by [] are used to note they are optional and should not be confused with Tcl command evaluation.

    
    persist simple [] []        
    persist source_addr [] []        
    persist sticky [] []        
    persist dest_addr [] []        
    persist ssl []        
    persist msrdp []        
    persist cookie [insert [] [] |        
                    rewrite [] [] |        
                    passive [] |        
                    hash  [{  [] } []] ]        
    persist uie  []        
    persist hash  []        

    The following instances of the persist command can be used to manipulate the persistence table directly:

    
    persist add   []        
    persist lookup   [all|node|port|pool]  
      "all" or no specification returns a list containing        
      the node, port and pool name.  Specifying any of the other        
      return types will return the specified item only.        
                  
    persist delete          
        = simple | source_addr | sticky | dest_addr | ssl | uie | hash        
        =  |        
             {  [any virtual|service|pool] [pool ] }        
      the latter key specification is used to create/access        
      persist entries across virtuals, services, or pools.        

    Hopefully this helps to clear things up. I'll also work on getting this info into the Wiki for future reference.

    -Colin
  • Colin_Walker_12's avatar
    Colin_Walker_12
    Historic F5 Account
    Oh, I also wanted to note that I'm not 100% sure you need an iRule here. I think if you enable universal persistence on the source address on these two virtuals, and enable the "across virtuals" option on both of them, then you might achieve what you're looking for without an iRule at all.

     

     

    -Colin
  • Currently,

     

     

     

     

    I have the following iRules in place,

     

     

    when LB_SELECTED {

     

     

    set nodeip [getfield [LB::server] " " 2]

     

     

    log "[IP::remote_addr] -> Noeud $nodeip"

     

     

    session add uie [IP::remote_addr] $nodeip 1800

     

     

    log "Dans la table [session lookup uie $nodeip]"

     

     

    log "Noeud traitant la connexion : $nodeip"

     

     

    }

     

     

    This one is attached to a VIP for RTSP traffic. Connections always arrive first on this VIP, so the session table should be populated.

     

     

     

     

    when HTTP_REQUEST {

     

     

    set realip [HTTP::header "x-nokia-ip-address"]

     

     

    set lll [list $realip any]

     

     

    set realnode [persist lookup universal $realip]

     

     

    log "lll -> $lll"

     

     

    set realnode [session lookup uie $lll]

     

     

    log "Lookup de $realip : [session lookup uie $lll] "

     

     

    log " Noeud switch $realnode"

     

     

    node $realnode

     

     

    pool ECDS-NIN-STREAMEZZO-RTSP member $realnode

     

     

    log "Choix du noeud $realnode pour client $realip"

     

     

    }

     

     

    This is rule is attached to a HTTP VIP where no persistence profile is attached as it’s not need. We only want to lookup the session table and find the matching IP extract from the HTTP header “x-nokia-ip-address”, and direct this http connection to the node handling the RTSP connection.

     

     

     

     

    It is clearer ?

     

     

  • Both VIPs have persistence profile attached :

     

    profile persist my_profile {

     

    defaults from universal

     

    mode universal

     

    across virtuals enable

     

    }

     

     

    My main proble is even when I'm issue a persist lookup or a session lookup right after adding an entry, the answer is still empty

     

     

    session add uie [IP::remote_addr] $nodeip 1800

     

    log "in the table [session lookup uie $nodeip]"

     

     

    This is my main issue, I guess.
  • Colin_Walker_12's avatar
    Colin_Walker_12
    Historic F5 Account
    Have you tried using the persist lookup command, instead of session lookup?

     

     

    -Colin